require "scripts/style"
--------------------------------------
-- 					Init
--------------------------------------
local kBtnsXOffset = 80;
local kBtnsYOffset = 180;
local kGroupXOffset = kCenter - 90;
local kGroupYOffset = 100;
--------------------------------------
-- 			  	 Controls
--------------------------------------
txtSfx = 
	ColorShadowColorText(200,50,
							kCenter,
							40 + kGroupYOffset,
							34,
							"sfxlevel", 
							Color(65,72,116,255),	
							Color(247,248,249,255),
							"sfxlevel",2,
							kHAlignCenter + kVAlignCenter,
							defaultgameplayfont);	
	
txtMusic = 
	ColorShadowColorText(200,50,
							kCenter,
							120 + kGroupYOffset,
							34,
							"musiclevel", 
							Color(65,72,116,255),	
							Color(247,248,249,255),
							"musiclevel",2,
							kHAlignCenter + kVAlignCenter,
							defaultgameplayfont);
btnFullScreen = 
	Button
	{
		name = "fullscreen",
		x = kCenter + 60,
		y = kCenter - 100 + kGroupYOffset,
		w = 260,
		ColorShadowColorText(200,
								50,
								52,
								0,
								34,
								"fullscreen", 
								Color(65,72,116,255),	
								Color(247,248,249,255),
								"fullscreen",
								1,
								kHAlignLeft + kVAlignCenter,
								defaultgameplayfont),
		command =
		function()
			if (ToggleFullScreen() == false)
			then
				SetButtonToggleState("fullscreen",false);
				DisplayDialog 
				{
					"scripts/popups/popupok.lua",
					body ="screenswitchfailed",
					title = ""
				};
			end
		end
	};

btnMute = 
	Button
	{
		name = "mutebox",
		x = kCenter + 60,
		y = kCenter - 40 + kGroupYOffset,
		w = 260,
		ColorShadowColorText(200,
								50,
								52,
								0,
								34,
								"mutebox", 
								Color(65,72,116,255),	
								Color(247,248,249,255),
								"mutebox",
								1,
								kHAlignLeft + kVAlignCenter,
								defaultgameplayfont),
		command =
		function()
			ToggleSoundMute();
		end
	};


btnBack = 
	Button
	{
		name = "back",
		x = kCenter,
		y = kMax - kBtnsYOffset - 18,
		cancel = true,
		default = true,
		type = kPush,
		DefaultButtonLabel("back"),
		command =
			function()
				SaveVolumes();
				PopModal("optionsmenu");
			end
	};

btnCredits = 
	Button
	{
		name = "credits",
		x = kCenter,
		y = kMax - kBtnsYOffset - 98,
		type = kPush,
		DefaultButtonLabel("creditsbutton"),
		command =
			function()
				DoModal("scripts/dialogs/dialogcredits.lua");
			end
	};

slrSfxLevel = 
	CustomSlider
	{
		name = "sfxlevelslider",
		x = 90 + kGroupXOffset,
		y = 80 + kGroupYOffset,
		w = 270,
		
	};

slrMusicLevel = 
	CustomSlider
	{
		name = "musiclevelslider",
		x = 90 + kGroupXOffset,
		y = 160 + kGroupYOffset,
		w = 270,
	};
--------------------------------------
-- 				Main Dialog
--------------------------------------
MakeDialog
{
	-- Name the modal dialog
	name = "optionsmenu",
	Bitmap
	{
		name = "dialogshadow",
		image = "backgrounds/dialogs/backgroundalpha",
	},

	Bitmap
	{
		image = "backgrounds/popups/popupoptions",
		x = 0,
		y = 0,

		OptionsWindow
		{
			x = 0,
			y = 0,
			w = kMax,
			h = kMax,
			
			-- Sound texts
			txtSfx, 
			txtMusic,
			
			-- Option checkboxes
			SetStyle(CheckboxButtonStyle),
			btnFullScreen,
			btnMute,
			
			-- Back, Credits buttons
			SetStyle(ButtonStyle),
			btnBack,
			btnCredits,
			
			-- Sound sliders
			SetStyle(SliderStyle),
			slrSfxLevel,
			
			SetStyle(SliderStyle),
			slrMusicLevel,
		},
	},
}