/******************************************************************************/
/*                                                                            */
/* User Output Code                                                           */
/*                                                                            */
/******************************************************************************/


#include "standard.h"
#include "global.h"
#include "winmain.h"
#include "output.h"
#include "display.h"

#include "../game/camera.h"
#include "../game/inventry.h"



	int game_hires = 0;		//still need this for other bits of code...
	double screen_sizer=1.0, game_sizer=1.0;
	static	int	fade_value = 16<<16;
	static	int fade_limit = 16<<16;
	static	int	fade_adder = 32768;
	int mode_lock = 0;

/******************************************************************************
 *				Increase Size of Display Window
 *****************************************************************************/
void	IncreaseScreenSize( void )
{
	if (screen_sizer==1.0)
		return;

	screen_sizer += 0.08;
	if ( screen_sizer>1.0 )
		screen_sizer = 1.0;
	
	game_sizer = screen_sizer;

	setup_screen_size();
}


/******************************************************************************
 *				Decrease Size of Display Window
 *****************************************************************************/
void	DecreaseScreenSize( void )
{
	if (screen_sizer==0.44)
		return;

	screen_sizer -= 0.08;
	if ( screen_sizer<0.44 )
		screen_sizer = 0.44;
	
	game_sizer = screen_sizer;
	
	setup_screen_size();
}

/******************************************************************************
 *					Reinitialise View Window Size....
 *****************************************************************************/
void	setup_screen_size( void )
{

	int		xoff,yoff;
	int		wwidth,wheight;
//	int		size;

	wwidth = (int)(DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).w*screen_sizer);
	wheight = (int)(DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).h*screen_sizer);
	if (wwidth>DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).w)
		wwidth=DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).w;
	if (wheight>DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).h)
		wheight=DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).h;
	xoff = (DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).w-wwidth)/2;
	yoff = (DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).h-wheight)/2;

	phd_InitWindow( xoff,yoff,
					wwidth,wheight,
					20,DPQ_END,		// Dude: changed to 20 (avoids ooz overflow stress)
					GAME_FOV,
					DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).w,
					DXDisplayMode(App.DeviceInfoPtr,App.DXConfigPtr).h); // RF G_RenderInfo.nBufferWidth,G_RenderInfo.nBufferHeight);

	game_setup.dump_x = (short)xoff;
	game_setup.dump_y = (short)yoff;
	game_setup.dump_width = (short)wwidth;
	game_setup.dump_height = (short)wheight;
	GtFullScreenClearNeeded=true;
}

void TempVideoAdjust(int hires, double sizer)
	{
	mode_lock=1;
	if (sizer==screen_sizer)
		return;
	screen_sizer=sizer;
	setup_screen_size();
	}

void TempVideoRemove(void)
	{
	mode_lock=0;
	if (screen_sizer==game_sizer)
		return;
	screen_sizer=game_sizer;
	setup_screen_size();
	}

/***********************************************************************************
 *				Fade Inventry
 **********************************************************************************/
void S_NoFade()
{
	fade_limit = fade_value = 16<<16;
}


void	S_FadeInInventory( int fade )
{
	if (Inventory_Mode!=INV_TITLE_MODE)
		S_CopyScreenToBuffer();

	if (fade)
	{
		fade_value = 16<<16;  				// Initiate A Fade Out..
		fade_limit = 24<<16;
		fade_adder = 32768;
	}
}

void	S_FadeOutInventory( int fade )
{
	if (fade)
	{
		fade_value = 24<<16;				// Initiate A Fade In..
		fade_limit = 16<<16;
		fade_adder = -32768;
	}
}


