-- Main game loop
function Main()

	ShowAnyCursor(false);
	DisplaySplash("assets/splash/playfirst_animated_logo.swf", "splash/playfirst_logo",4000);
	DisplaySplash("", "splash/distributor_logo",4000);
	ShowAnyCursor(true);
	while (true) do
		-- Push the game selection screen
		DoModal("scripts/mainmenu.lua");
		-- The game select screen will spawn its own replacement modal window. When that modal window
		-- returns, it will be time to execute this one again--hence the while/do loop.
	end

end


gSSSGSetupMode = 0;
function HandleSSSG()
	if (SSSGEnabled() == false) then
		return;
	end
	
	if (ShowSSSGTip()) then
		gSSSGSetupMode = 1;
		DoModal("scripts/sssgtip.lua");
		gSSSGSetupMode = 0;
	elseif (DoSaveOrLoad()) then
		DoModal("scripts/sssgsave.lua");
	end
end

function HandleSSSGLoad()
    if (GetNumUsers() == 0) then
		return;
    end
    
	if (HasCheckedLoadGame() == false) then
		if (SSSGEnabled() == false) then
			return;
		end
		
		if (DoSaveOrLoad()) then
			DoModal("scripts/sssgload.lua");
		end
		
		CheckedLoadGame();
	end
end

-- Return a function to be executed in a thread
return Main
