require( "scripts/style.lua" );


kMainMenuButtonSound="audio/sfx/menu_click.ogg";
kMainMenuRolloverButtonSound="audio/sfx/menu_rollover.ogg";
MainMenuStyle = {
	parent = DefaultStyle,
	sound = kMainMenuButtonSound,
	rolloversound = kMainMenuRolloverButtonSound
};

GameModeFont = {
	standardFont,
	24,
	MenuRedColor
};

OptionFont = {
	standardFont,
	16,
	MenuRedColor
};

MenuFont = {
	standardFont,
	48,
	MenuRedColor
};

CopyrightFont = {
  "fonts/arial.mvec",
  9,
  Color(255,255,255,255);
};

TrademarkFont = {
  "fonts/markerfeltthin.mvec",
  8,
  Color(0,0,0,255);
};

RegisteredFont = {
  "fonts/markerfeltthin.mvec",
  12,
  Color(0,0,0,255);
};


MenuButton1Graphics = {
	"buttons/main_menu_button1_a",
	"buttons/main_menu_button1_b",
	"buttons/main_menu_button1_c"
};

MenuButton2Graphics = {
	"buttons/main_menu_button2_a",
	"buttons/main_menu_button2_b",
	"buttons/main_menu_button2_c"
};

ChangePlayerButtonGraphics = {
	"buttons/change_player_button_a",
	"buttons/change_player_button_b",
	"buttons/change_player_button_c"
};


kRotationAmount = -14.8;

MenuButtonRotateStyle = {
	parent = DefaultStyle,
	x = 0, y = 0, 
	flags = kHAlignCenter + kVAlignCenter,
	rotation = kRotationAmount,
	rotationOriginX = kCenter,
	rotationOriginY = kCenter
};


MakeDialog
{
	x = 0,
	y = 0,
	w = 800,
	h = 600,
	
	Bitmap
	{
		image = "backgrounds/menubox",
		x = 0,
		y = 148,
	},
	
	
	Bitmap
	{ 
		name="backgroundimage",
		image="backgrounds/mainmenu",	
		mask="backgrounds/mainmenu_mask",
		
		
		
		Bitmap
		{
			image = "backgrounds/mainmenu_logo",
			x = 11,
			y = 4,	
		};
		
		MainMenu
		{
			name="mainmenuwindow",
			SetStyle(MainMenuStyle);
			x = 0,
			y = 0,
			w = 800,
			h = 600,
		
			
				
			Text
			{
				font = CopyrightFont,
				name="copyright",
				label="copyright",
				x=586,
				y=553,
				w=135,
				h=55,
				flags = kHAlignCenter + kVAlignCenter,
				padding = 0
			},

			
			SetStyle(MenuButtonRotateStyle);
			
			
			Text
			{
				font = MenuFont,
				x = 70,
				y = 227,
				w = 165,
				h = 59,
				name = "title",
				flags = kHAlignLeft + kVAlignCenter,
				label = "menutitle"
				
			};
				
			
			Button
			{
				x=50,
				y=265,
				font = GameModeFont,
				graphics = MenuButton1Graphics,
				name="gamemode1",
				type = kPush,
				mask = "buttons/main_menu_button1_mask",
				label="gamemode1",
				command=
					function()
						SetCurrentRestaurant(0);
						SetCurrentLevel(0);
						SetCurrentGameMode(0);
						if (GetNumUsers() == 0) then
							gEnterNameValue = "";
							name = DoModal("scripts/entername.lua");
							if (not(name == nil)) then
								CreateNewUser(name);
								SetWelcomeName();
								UnlockLevel(0,0);
								DoModal("scripts/comic_1_1.lua");
							end
						else
							if (GetNumUnlockedLevels() == 0) then
								UnlockLevel(0,0);
								DoModal("scripts/comic_1_1.lua");
							else
								DoModal("scripts/chooserestaurant.lua");
							end
						end
					end
			},
			
			Button
			{
				x=63,
				y=310,
				font = GameModeFont,
				graphics = MenuButton1Graphics,
				name="gamemode2",
				label="gamemode2",
				type = kPush,
				mask = "buttons/main_menu_button1_mask",
				command=
					function()
						SetCurrentLevel(0);
						SetCurrentGameMode(1);
						if (GetNumUsers() == 0) then
							gEnterNameValue = "";
							name = DoModal("scripts/entername.lua");
							if (not(name == nil)) then
								CreateNewUser(name);
								SetWelcomeName();
								DoModal("scripts/chooserestaurant.lua");
							end
						else
							DoModal("scripts/chooserestaurant.lua");
						end
					end
			},
			
			Button
			{
				x=60,
				y=395,
				font = OptionFont,
				graphics = MenuButton2Graphics,
				name="help",
				label="help",
				type = kPush,
				mask = "buttons/main_menu_button2_mask",
				command=
					function()
						DoModal("scripts/help1.lua");
					end
			},
			
			Button
			{
				x=185,
				y=363,
				font = OptionFont,
				graphics = MenuButton2Graphics,
				name="options",
				label="options",
				type = kPush,
				mask = "buttons/main_menu_button2_mask",
				command=
					function()
						DoModal("scripts/options.lua");
					end
			},
			
			Button
			{
				x=70,
				y=435,
				font = OptionFont,
				graphics = MenuButton2Graphics,
				name="highscores",
				label="highscores",
				type = kPush,
				mask = "buttons/main_menu_button2_mask",
				command=
					function()
						DoModal("scripts/hiscore.lua");
					end
			},
			

			
			Button
			{
				x=160,
				y=505,
				font = GameModeFont,
				graphics = MenuButton2Graphics,
				name="quit",
				label="quit",
				type = kPush,
				mask = "buttons/main_menu_button2_mask",
				command=
					function()
						result = DisplayDialog { 
							"scripts/yesno.lua", 
							body ="quitconfirm",
							title = "" 
						};
						if (result=='yes') then
							PostMessage( CreateNamedMessage( kQuitNow, "Quit" ) );
						end
					end
			},
			
			SetStyle(DefaultStyle);
			
			Bitmap
			{
				x=300,
				y=565,
				name = "welcomebox",
				image = "buttons/welcome_player"
			};
			Text
			{
				font = OptionFont,
				name = "welcome",
				x=320,y=570,w=370,h=20,
				flags = kHAlignLeft + kVAlignCenter,
				label = "welcome"
			};
			
			Button
			{
				x=398,
				y=490,
				font = OptionFont,
				graphics = ChangePlayerButtonGraphics,
				name="moregames",
				label="moregames",
				type = kPush,
				xoffset = 1,
				yoffset = 1,
				command=
					function()
						DoModal("xsell/xsell.lua");
					end
			},
			
			Button
			{
				x=398,
				y=525,
				font = OptionFont,
				graphics = ChangePlayerButtonGraphics,
				name="changeplayer",
				label="changeplayer",
				type = kPush,
				xoffset = 1,
				yoffset = 1,
				command=
					function()
						DoModal("scripts/chooseplayer.lua");
					end
			},
		}
	}
}

AllowQuitCofirm(true);