
--System.DoFile(Game.GetDataPath().."AchInGame.lua");
System.DoFile(Game.GetDataPath().."AchEndRound.lua");
System.DoFile(Game.GetDataPath().."AchEndTournament.lua");
System.DoFile(Game.GetDataPath().."AchEndGame.lua");
-- JJK: 2010-09-27 No longer need instore.lua
--System.DoFile(Game.GetDataPath().."AchInStore.lua");
System.DoFile(Game.GetDataPath().."AchWiFi.lua");

	
-----------------------------------------------------------------------------
-- CHECK FOR ITEM UNLOCKS
-----------------------------------------------------------------------------
function CheckItemUnlocks()
	System.OutputDebugString("Checking Item Unlocks\n");
	
	if(EntGame.CheckWeaponUnlocks() == true) then
		return(true);
		end;
		
	if(EntGame.CheckItemUnlocks() == true) then
		return(true);
		end;

	end;


-----------------------------------------------------------------------------

function ShowAchievements()
	
	-- JJK: 2010-09-27 swapped item unlock pop up's
	--      to show unlocks first so our unlock all achievements won't appear last
	
	-- Award item's here.
    while( CheckItemUnlocks() == true ) do
		-- display our menu
		EntGame.PushMenu("MenuUnlockNotice");

		EntGame.ClearFlag(GF_READYTOSTART);		
		
		-- wait until the we accepted the award
		while (EntGame.GetFlag(GF_READYTOSTART) == false) do
			Script.WaitFrame(1);
			end;
		end;
	
	while( IsNewAchievement() == true ) do
		--System.ConsoleBeep(440, 400);
		
		-- display our menu
		--System.ConsoleBeep(440, 400);
		EntGame.PushMenu("MenuAchieveNotice");

		EntGame.ClearFlag(GF_READYTOSTART);		
		
		-- wait until the we accepted the award
		while (EntGame.GetFlag(GF_READYTOSTART) == false) do
			Script.WaitFrame(1);
			end;
		
    	end;
    	
	
	-- Jump back to the main menu
	-- JJK: TODO: will need to go back to the tournament screen in single/multi mode
	menuRoot = Game.GetMenuEntity()
	
	
	System.OutputDebugString("Checking Tradeshow\n");
	if ( EntGame.IsTradeShow() ) then
		System.OutputDebugString("Launching Tradeshow\n");
		CreateAndNameEntity("MenuTradeShow", "MenuTradeShow", menuRoot);
	else
		CreateAndNameEntity("MenuFinalStage", "MenuFinalStage", menuRoot);
		end;
		
    EntGame.DestroyWorld();		
	
	end; -- end function


-----------------------------------------------------------------------------

function IsNewAchievement()
    
    System.OutputDebugString("Checking in-game achievements\n");
    
	--[[
    if (DoAchInGame()) then
		return(true);
		end;
    ]]--
	
    System.OutputDebugString("Checking End-of-Round achievements\n");
	
	if(DoAchEndRound()) then
		return(true);
		end;
    
    System.OutputDebugString("Checking End-of-Tournament achievements\n");
    
	if(DoAchEndTournament()) then
		return(true);
		end;
		
    System.OutputDebugString("Checking End-of-Game achievements\n");
	
	if(DoAchEndGame()) then
		return(true);
		end;
		
	--JJK: Moved in-store acheivements to end of round, no longer need this
    --System.OutputDebugString("Checking Store achievements\n");
	--if(DoAchInStore()) then
	--	return(true);
	--	end;
		
    System.OutputDebugString("Checking Wi-fi achievements\n");
    
	if(DoAchWiFi()) then
		return(true);
		end;
    
    return(false);
    	
	end; -- end function
	


-- just do it!
ShowAchievements();

