#include <GameOS\GameOS.hpp>
#include <GOSScript\GOSScriptHeaders.hpp>

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
HGOSVIDEO g_hVideo;
void _stdcall InitializeGameEngine()
{
	//
	//---------------------------
	// Start the Script Processor
	//---------------------------
	//
	gosScript_InitializeProcessor();

	gosScript_ExecuteScript("Assets\\Scripts\\MainMenu.script",0x1000,0);
	if (!g_hVideo)
		gosVideo_CreateResource(&g_hVideo, "d:\\@gameleap\\Training-k.avi");
	if (g_hVideo) {
		gosVideo_ResourceInfo gvi;
		gosVideo_GetResourceInfo(g_hVideo, &gvi);
		gosVideo_Command(g_hVideo, gosVideo_SetCoords, 0, 0);
		//gvi.dwWidth:640:=1.0:?
		//gvi.dwHeight:480=1.0:?
		gosVideo_Command(g_hVideo, gosVideo_SetScale, 640.0f/(float)gvi.dwWidth, 480.0f/(float)gvi.dwHeight);
		gosVideo_SetPlayMode(g_hVideo, gosVideo_Loop);
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void _stdcall DoGameLogic()
{
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void _stdcall UpdateDisplay()
{
	// let gosScript do it's thing, instead...
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void _stdcall TerminateGameEngine()
{
	//
	//--------------------------
	// Stop the Script Processor
	//--------------------------
	//
	gosVideo_DestroyResource(&g_hVideo);
	gosScript_ShutdownProcessor();

}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void _stdcall GetGameOSEnvironment(char* CommandLine)
{
	CommandLine = CommandLine;
	Environment.applicationName			= "Script Repository";
	Environment.screenWidth				= 640;
	Environment.screenHeight			= 480;
	Environment.fullScreen				= 0;
	Environment.bitDepth				= 16;
	Environment.debugLog				= "";
	Environment.spew					= "GameOS_Memory";
	Environment.memoryTraceLevel		= 5;
	Environment.TimeStampSpew			= 0;
	Environment.UpdateRenderers			= UpdateDisplay;
	Environment.DoGameLogic				= DoGameLogic;
	Environment.InitializeGameEngine	= InitializeGameEngine;
	Environment.TerminateGameEngine		= TerminateGameEngine;
	Environment.soundChannels			= 16;

	Environment.FullScreenDevice		= 0;
	Environment.fullScreen				= 0;
	Environment.AntiAlias				= 0;			// true/false - Enable full screen antialiasing
	Environment.Renderer				= 0;
																																				   
//
// Texture infomation
//

	Environment.Texture_S_256			= 1;
	Environment.Texture_S_128			= 1;
	Environment.Texture_S_64			= 1;
	Environment.Texture_S_32			= 1;
	Environment.Texture_S_16			= 1;

	Environment.Texture_K_256			= 1;
	Environment.Texture_K_128			= 1;
	Environment.Texture_K_64			= 1;
	Environment.Texture_K_32			= 1;
	Environment.Texture_K_16			= 1;

	Environment.Texture_A_256			= 1;
	Environment.Texture_A_128			= 1;
	Environment.Texture_A_64			= 1;
	Environment.Texture_A_32			= 1;
	Environment.Texture_A_16			= 1;
}

