--
-- options menu page
--
function FormatName(szName)
	local c = strsub(szName, 1, 1);
	local szResult = strupper(c)..strsub(szName, 2);

	return szResult;
end


UI.PageCampaign=
{	
	GUI=
	{
		StartNewGameTab=
		{
			text = Localize("StartNewGame"),
			skin = UI.skins.TopMenuButton,
			
			greyedcolor = UI.szTabAdditiveColor,
			greyedblend = UIBLEND_ADDITIVE,
			
			tabstop = 1,
			
			OnCommand = function(Sender)
				UI.iStat = nil;
				UI:ActivateScreen("CampaignStart");

				UI.PageCampaignStart.GUI:OnActivate();
				
				UI.PageCampaign.GUI.StartNewGameTab.skin.OnLostFocus(UI.PageCampaign.GUI.StartNewGameTab);

			end
		},
					
		OnActivate= function(Sender)
			Sender.StartNewGameTab.OnCommand(Sender.StartNewGameTab);
		end,
	},
};


UI.PageCampaignStart=
{	
	GUI=
	{
	
		LevelLabel=
		{
			skin = UI.skins.MenuBorder,
			left = 250, top = 175,
			width = 480, height = 30,
			bordersides = "tlr",
			fontsize = 22,
			halign = UIALIGN_CENTER,
			text = "Introduction";
		},
		
		DiffInfo=
		{
			classname = "static",
			
			flags = UIFLAG_VISIBLE,
			greyedcolor = "0 0 0 0",
			bordersize = 1,
			bordercolor = UI.szBorderColor,
			color = "0 0 0 0",
			style = UISTYLE_WORDWRAP + UISTYLE_MULTILINE,
			
			left = 250, top = 200,
			width = 480, height = 250,
			halign = UIALIGN_JUSTIFY,
			valign = UIALIGN_TOP,
			text = "Introduction";
		},
		
		StartGame=
		{
			text=Localize("Start"),
			left = 600,
			skin = UI.skins.BottomMenuButton,
			
			tabstop = 17,
			
			OnCommand=function(Sender)
				System:ExecuteCommand("map Niveau1");
			end,
		},
		
		OnActivate = function(Sender)
			
			-- TEMPORARY
			-- TEMPORARY
			UI.PageCampaignStart.DefiantTable = {};

			if (tonumber(getglobal("ai_autobalance")) ~= 0) then
				UI.PageCampaignStart.GUI.AutoBalance:SetChecked(1);
			else
				UI.PageCampaignStart.GUI.AutoBalance:SetChecked(0);
			end
		end
	},
	
	StartGame = function()
		UI:TerminateGame();
		
		if (UI.PageCampaignStart.szLevelName) then
		
			local SaveList = Game:GetSaveGameList(getglobal("g_playerprofile"));
					
			if (SaveList and getn(SaveList) > 0) then
				UI.YesNoBox("@NewGameWarningTitle", "@StartNewGameWarning", UI.PageCampaignStart.StartGameReally);
			else
				UI.PageCampaignStart.StartGameReally();
			end
		end
	end,
	
	StartGameReally = function()
		
		if (UI.iStat) then setglobal("g_LevelStated", 1);
		else setglobal("g_LevelStated", 0);	end

		setglobal("g_GameType", "Default");
		
		if (strlower(UI.PageCampaignStart.szLevelName) == "training training") then
			UI:PlayCutScene("training_begin.bik", "StartLevel "..UI.PageCampaignStart.szLevelName);
		else
			Game:SendMessage("StartLevel "..UI.PageCampaignStart.szLevelName);
		end
		UI.PageCampaignStart.szLevelName = nil;
	end,
}

AddUISideMenu(UI.PageCampaign.GUI,
{
	{ "MainMenu", Localize("MainMenu"), "$MainScreen$", 0},
});

Language:LoadStringTable("summary.xml");

UI:CreateScreenFromTable("CampaignStart",UI.PageCampaignStart.GUI);
UI:CreateScreenFromTable("Campaign",UI.PageCampaign.GUI);