//--- OBJECT WRITE BEGIN ---
new GuiFadeinBitmapCtrl(StartupGui1) {
   profile = "GuiInputCtrlProfile";
   horizSizing = "center";//"right";
   vertSizing = "center";//"bottom";
   position = "0 0";
   extent = "800 600";
   minExtent = "8 8";
   visible = "1";
   helpTag = "0";
   bitmap = "scriptsAndAssets/data/ui/splash_screen";
   wrap = "0";
   fadeinTime = "150";
   waitTime   = "5000";
   fadeoutTime = "150";
};

%guiContent = new GuiBitmapCtrl(StartupGui1WBkgnd) {
   canSaveDynamicFields = "0";
   Enabled = "1";
   isContainer = "1";
   Profile = "GuiDefaultProfile";
   HorizSizing = "width";
   VertSizing = "height";
   Position = "0 0";
   Extent = "800 600";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   hovertime = "1000";
   bitmap = "scriptsAndAssets/data/ui/splash_screen_bkgnd";
   wrap = "0";
   fadeinTime = "150";
   waitTime   = "5000";
   fadeoutTime = "150";

   new GuiFadeinBitmapCtrl(StartupGui1W) {
      profile = "GuiInputCtrlProfile";
      horizSizing = "center";//"right";
      vertSizing = "center";//"bottom";
      position = "0 0";
      extent = "800 600";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      bitmap = "scriptsAndAssets/data/ui/splash_screen";
      wrap = "0";
      fadeinTime = "150";
      waitTime   = "5000";
      fadeoutTime = "150";
   };
};

new GuiFadeinBitmapCtrl(StartupGui2) {
   profile = "GuiInputCtrlProfile";
   horizSizing = "center";//"right";
   vertSizing = "center";//"bottom";
   position = "0 0";
   extent = "800 600";//"640 480";
   minExtent = "8 8";
   visible = "1";
   helpTag = "0";
   bitmap = "scriptsAndAssets/data/ui/splash_screen2";
   wrap = "0";
   fadeinTime = "150";
   waitTime   = "4000";
   fadeoutTime = "150";
};

%guiContent = new GuiBitmapCtrl(StartupGui2WBkgnd) {
   canSaveDynamicFields = "0";
   Enabled = "1";
   isContainer = "1";
   Profile = "GuiDefaultProfile";
   HorizSizing = "width";
   VertSizing = "height";
   Position = "0 0";
   Extent = "800 600";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   hovertime = "1000";
   bitmap = "scriptsAndAssets/data/ui/splash_screen_bkgnd";
   wrap = "0";

   new GuiFadeinBitmapCtrl(StartupGui2W) {
      profile = "GuiInputCtrlProfile";
      horizSizing = "center";//"right";
      vertSizing = "center";//"bottom";
      position = "0 0";
      extent = "800 600";//"640 480";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      bitmap = "scriptsAndAssets/data/ui/splash_screen2";
      wrap = "0";
      fadeinTime = "150";
      waitTime   = "4000";
      fadeoutTime = "150";
   };
};

new GuiFadeinBitmapCtrl(StartupGui3) {
   profile = "GuiInputCtrlProfile";
   horizSizing = "center";//"right";
   vertSizing = "center";//"bottom";
   position = "0 0";
   extent = "800 600";//"640 480";
   minExtent = "8 8";
   visible = "1";
   helpTag = "0";
   bitmap = "scriptsAndAssets/data/ui/wii_splash_480p_4.3";//"scriptsAndAssets/data/ui/splash_screen2";
   wrap = "0";
   fadeinTime = "150";
   waitTime   = "4000";
   fadeoutTime = "150";
};

%guiContent = new GuiBitmapCtrl(StartupGui3WBkgnd) {
   canSaveDynamicFields = "0";
   Enabled = "1";
   isContainer = "1";
   Profile = "GuiDefaultProfile";
   HorizSizing = "width";
   VertSizing = "height";
   Position = "0 0";
   Extent = "800 600";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   hovertime = "1000";
   bitmap = "scriptsAndAssets/data/ui/splash_screen_bkgnd";
   wrap = "0";

   new GuiFadeinBitmapCtrl(StartupGui3W) {
      profile = "GuiInputCtrlProfile";
      horizSizing = "center";//"right";
      vertSizing = "center";//"bottom";
      position = "0 0";
      extent = "800 600";//"640 480";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      bitmap = "scriptsAndAssets/data/ui/wii_splash_480p_4.3";//"scriptsAndAssets/data/ui/splash_screen2";
      wrap = "0";
      fadeinTime = "150";
      waitTime   = "4000";
      fadeoutTime = "150";
   };
};


//--- OBJECT WRITE END ---

function loadStartup()
{
   %deskRes    = getFullscreenResolution();      
   %deskResX   = getWord(%deskRes, $WORD::RES_X);
   %deskResY   = getWord(%deskRes, $WORD::RES_Y);
   %deskResBPP = getWord(%deskRes, 2);
   
   %aspectRatio = %deskResX / %deskResY;
   
   StartupGui1.aspectRatio = %aspectRatio;
   
   StartupGui1.done = false;
   LoadSplashScreenCanvas(1);
   schedule(100, 0, checkStartupDone1 );
}
   

//-------------------------------------
function StartupGui1::click()
{
	//DO NOT ALLOW to fastforward the torque splash screen.
	//LEGAL REASONS!
   //StartupGui1.done = true; 
}

//-------------------------------------
function StartupGui1W::click()
{
	//DO NOT ALLOW to fastforward the torque splash screen.
	//LEGAL REASONS!
   //StartupGui1W.done = true;
}

//-------------------------------------
function StartupGui2::click()
{
//   StartupGui2.done = true;
}

//-------------------------------------
function StartupGui2W::click()
{
//   StartupGui2W.done = true;
}

//-------------------------------------
function StartupGui3::click()
{
//   StartupGui3.done = true;
}

//-------------------------------------
function StartupGui3W::click()
{
//   StartupGui3W.done = true;
}

//-------------------------------------
function checkStartupDone1()
{
   if (StartupGui1.done || StartupGui1W.done)
   {
	   LoadSplashScreenCanvas(2);
	   schedule(100, 0, checkStartupDone2 );
   }
   else
   {
      schedule(100, 0, checkStartupDone1 );
   }
}

function checkStartupDone2()
{
   if (StartupGui2.done || StartupGui2W.done)
   {
	   LoadSplashScreenCanvas(3);
      sfxPlay(AudioStartup);	   
	   schedule(100, 0, checkStartupDone3 );
   }
   else
      schedule(100, 0, checkStartupDone2 );
}

function checkStartupDone3()
{
   if (StartupGui3.done || StartupGui3W.done)
      loadMainMenu();
   else
      schedule(100, 0, checkStartupDone3 );
}


function LoadSplashScreenCanvas(%canvasId)
{
   if(StartupGui1.aspectRatio > 4/3)
   {
      echo("Wide Screen");
      Canvas.schedule(150, "setContent", "StartupGui" @ %canvasId @ "WBkgnd" );
      Canvas.setWidescreen( "StartupGui" @ %canvasId @ "W", 100, false);
   }
   else   
   {
	  echo("4/3 Screen");
      Canvas.setContent( "StartupGui" @ %canvasId );
   }
}

