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,
	13,
	MenuRedColor
};

MenuFont = {
	standardFont,
	40,
	MenuRedColor
};

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

TrademarkFont = {
  "fonts/default.mvec",
  8,
  MenuRedColor
};

RegisteredFont = {
  "fonts/default.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"
};

MenuButton3Graphics = {
	"buttons/main_menu_button3_a",
	"buttons/main_menu_button3_b",
	"buttons/main_menu_button3_c"
};

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


kRotationAmount = 3.0;

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


kButtonTextShift = 4;

gGotoSSSGLogin = false;

MakeDialog
{
	x = 0,
	y = 0,
	w = 800,
	h = 600,
	
	Window
	{
		name="toplevelmainmenu",
		x = 0,
		y = 0,
		w = kMax,
		h = kMax,
		
		Bitmap
		{ 
			name="backgroundimage",
			image="backgrounds/mainmenu",	
			
		
			
			MainMenu
			{
				name="mainmenuwindow",
				SetStyle(MainMenuStyle);
				x = 0,
				y = 0,
				w = 800,
				h = 600,
			
				
					
				Text
				{
					font = CopyrightFont,
					name="copyright",
					label="copyright",
					x=585,
					y=540,
					w=214,
					h=60,
					flags = kHAlignLeft + kVAlignCenter,
					padding = 0
				},
				

				
				
				SetStyle(MenuButtonRotateStyle);
				
				
				Text
				{
					font = MenuFont,
					x = 584,
					y = 163,
					w = 165,
					h = 59,
					name = "title",
					flags = kHAlignLeft + kVAlignCenter,
					label = "menutitle"
					
				};
				
				
				
				
				
				
				Button
				{
					x=500,
					y=210,
					font = GameModeFont,
					graphics = MenuButton1Graphics,
					name="gamemode1",
					type = kPush,
					mask = "buttons/main_menu_button1_mask",
					label="gamemode1",
					command=
						function()
							SetCurrentRestaurant(0);
							SetCurrentLevel(0);
							SetCurrentGameMode(0);
							SetLevelMode(0);
							if (GetNumUsers() == 0) then
								gEnterNameValue = "";
								name = DoModal("scripts/entername.lua");
								if (not(name == nil)) then
									CreateNewUser(name);
									SetWelcomeName();							
									if (gGotoSSSGLogin == true) then
										DoModal("scripts/sssgsetup.lua");
									end
									if (GetNumUnlockedLevels() == 0) then
										UnlockLevel(0,0);
										DoModal("scripts/comic_1_1.lua");
									else
										DoModal("scripts/chooserestaurant.lua");
									end
								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=498,
					y=245,
					font = GameModeFont,
					graphics = MenuButton1Graphics,
					name="gamemode2",
					label="gamemode2",
					type = kPush,
					mask = "buttons/main_menu_button1_mask",
					command=
						function()
							SetCurrentLevel(0);
							SetCurrentGameMode(1);
							SetLevelMode(0);
							if (GetNumUsers() == 0) then
								gEnterNameValue = "";
								name = DoModal("scripts/entername.lua");
								if (not(name == nil)) then
									CreateNewUser(name);
									SetWelcomeName();
									if (gGotoSSSGLogin == true) then
										DoModal("scripts/sssgsetup.lua");
									end
									DoModal("scripts/chooserestaurant.lua");
								end
							else
								DoModal("scripts/chooserestaurant.lua");
							end
						end
				},
				
				Button
				{
					x=537,
					y=305,
					font = GameModeFont,
					graphics = MenuButton3Graphics,
					name="floscloset",
					mask = "buttons/main_menu_button3_mask",
					type = kPush,
					xoffset = 1,
					yoffset = 1,
					ty = 3,
					label='floscloset',
					command=
						function()
							if (GetNumUsers() == 0) then
								gEnterNameValue = "";
								name = DoModal("scripts/entername.lua");
								if (not(name == nil)) then
									CreateNewUser(name);
									SetWelcomeName();
									if (gGotoSSSGLogin == true) then
										DoModal("scripts/sssgsetup.lua");
									end
									DoModalWithTip("scripts/floscloset.lua", "flosclosettip", EnterFlosCloset());
								end
							else
								DoModalWithTip("scripts/floscloset.lua", "flosclosettip", EnterFlosCloset());
							end
							
						end
				},		
				
				Button
				{
					x=492,
					y=340,
					tw = kMax - kButtonTextShift,
					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=620,
					y=346,
					tw = kMax - kButtonTextShift,
					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=490,
					y=380,
					tw = kMax - kButtonTextShift,
					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=618,
					y=386,
					font = OptionFont,
					graphics = MenuButton2Graphics,
					name="floscorner",
					mask = "buttons/main_menu_button1_mask",
					type = kPush,
					Text
					{
						x = 25, y = 5, w=kMax-25 - kButtonTextShift, h = kMax,
						flags = kHAlignCenter + kVAlignCenter,
						label = "floscorner",
						name="label",
						font = OptionFont,
						padding =-3,
						
					};
					command=
						function()
							DoModal("scripts/floscorner1.lua");
						end
				},
				
				Button
				{
					x=555,
					y=460,
					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=5,
					y=564,
					font = OptionFont,
					graphics = ChangePlayerButtonGraphics,
					name="moregames",
					label="moregames",
					type = kPush,
					xoffset = 1,
					yoffset = 1,
					scale = 0.9,
					command=
						function()
							DoModal("xsell/xsell.lua");
						end
				},
				
				Button
				{
					x=150,
					y=564,
					scale = 0.9,
					font = OptionFont,
					graphics = ChangePlayerButtonGraphics,
					name="changeplayer",
					label="changeplayer",
					type = kPush,
					xoffset = 1,
					yoffset = 1,
					command=
						function()
							DoModal("scripts/chooseplayer.lua");
							HandleSSSGLoad();
						end
				},
				
					
				
				
				
				Button
				{
					x=670,
					y=530,
					font = OptionFont,
					graphics = SolidButtonGraphics,
					name="editors",
					label="le_editors",
					type = kPush,
					xoffset = 1,
					yoffset = 1,
					command=
						function()
							DoModal("scripts/leveleditor/editors.lua");
						end
				},
			}
		}
	}
}

AllowQuitCofirm(true);