
require( "scripts/style.lua" );

kButtonSpacing = 45;
kButtonY = 200;--768-307 --293;
kButtonX = 0;

buttonStartX = 220;
buttonStartY = 535;
buttonSpacing = 70;

function CheckUsers()
	if (GetNumUsers() == 0) then
		gEnterNameValue = "";
		name = DoModal("scripts/entername.lua");
		if (not(name == nil)) then
			CreateNewUser(name);
			mode = DoModal("scripts/controlscheme.lua");
			PlayGame();
			return true ;
		end
		return false ;
	else
		return true;
	end
end

function QuitGame()
	CloseWindow();
end

MakeDialog
{
	-- Name the modal dialog
	name="mainmenu",
	MainMenu
	{
	
		x=0,
		y=0,
		w=1024,
		h=768,
			
		--fit=true;
		--Bitmap
		--{
			--name="backgroundimage",
			--image="ui/main/bg",
			--Text
			--{
			--	font = StandardButtonFont,
			--	name = "welcome",
			--	x=216,y=487,w=250,h=50,
			--	flags = kHAlignCenter + kVAlignCenter,
			--	label = "welcome"
			--};
			SetStyle( MenuButtonStyle ),
			MenuButton
			{
				x=kButtonX,
				y=kButtonY + (kButtonSpacing * 1),
				name="gamemode2",
				MenuButtonLabel("gamemode2"),
				type = kPush,
				command=
					function()
						-- Set up the number of rows and columns
						gRows=5; gColumns=5;
						if (CheckUsers()) then
							-- Tell TSettings what game mode we're entering
							SetCurrentGameMode(1);
							-- Switch to the appropriate screen
							SwapToModal("scripts/scene2d.lua");
							SetState( kGameMode, "samplegame" );
							DoModal("scripts/proto_objective.lua");
						end
					end
			},

			--SetStyle(CleoButtonStyle),
			--Button
			--{
			--	x=700,
			--	y=710,
			--	name="help",
			--	label="help",
			--	type = kPush,
			--	command=
			--		function()
			--			DoModal("scripts/help.lua");
			--		end
			--},
			--SetStyle(MainPlayButtonStyle),
			--Button
			--{
			--	x=220,
			--	y=210,
			--	name="play",
			--	label="",
			--	type = kPush,
			--	command=
			--		function()
						-- Set up the number of rows and columns
			--			gRows=5; gColumns=5;
			--			if (CheckUsers()) then
							-- Tell TSettings what game mode we're entering,

			--				SetCurrentGameMode(1);
							-- Switch to the appropriate screen
			--				SwapToModal("scripts/scene2d.lua");
			--				SetState( kGameMode, "samplegame" );
							-- DoModal("scripts/proto_objective.lua")
			--			end
			--		end
			--},


			--SetStyle(MainProfileButtonStyle),
			--Button
			--{
			--	x = buttonStartX,
			--	y = buttonStartY,
			--	name="main_profile",
			--	label="",
			--	type = kPush,
			--	command=
			--		function()
			--			DoModal("scripts/chooseplayer.lua");
			--		end
			--},

			--SetStyle(MainOptionButtonStyle),
			--Button
			--{
			--	x = buttonStartX,
			--	y = buttonStartY + buttonSpacing,
			--	name="main_options",
			--	label="",
			--	type = kPush,
			--	command=
			--		function()
			--			DoModal("scripts/options.lua");
			--		end
			--},

			--SetStyle(MainExitButtonStyle),
			--Button
			--{
			--	x = buttonStartX,
			--	y = buttonStartY + buttonSpacing*2,
			--	name="main_exit",
			--	label="",
			--	type = kPush,
			--	command=
			--		function()
			--			result = DisplayDialog {
			--				"scripts/yesno.lua",
			--				body ="quitconfirm",
			--				title = "quittitle"
			--			};
			--			if (result=='yes') then
			--				PostMessage( CreateNamedMessage( kQuitNow, "Quit" ) );
			--			end
			--		end
			--},
			
		--},
	}
}
EnableWindow("gamemode2",false);
