require "scripts/style";

SliderFont = {
  standardFont,
  36,
  BlackColor
};

--local bgk="backgrounds/dialog"
local bgk="ui/options_menu/background"
if (gDialogTable.bgk) then
	--bgk = gDialogTable.bgk
end

local tx = 130
local ty = 160
local tdy = 130

local sx = 130
local sy = 210
local sdy = 130
local sw = 275

local px = 50

SliderStyle1 =
{
	parent=SliderStyle,
	railtop = "ui/options_menu/scrolls/top",
	railmid = "ui/options_menu/scrolls/music",
	railbot = "ui/options_menu/scrolls/top",
	sliderimage = "ui/options_menu/scrolls/dot",
	sliderrollimage = "ui/options_menu/scrolls/slider_ovr",

	yoffset = -1, -- scoot the slider down by one pixel to center it.
	soundgroup=1,
};

SliderStyle2 =
{
	parent=SliderStyle1,
	railmid = "ui/options_menu/scrolls/ambient",
	soundgroup=2,
};

SliderStyle3 =
{
	parent=SliderStyle1,
	railmid = "ui/options_menu/scrolls/sound",
	soundgroup=0,
};

MakeDialog
{
	-- Name the modal dialog
	name="optionsmenu",
	Bitmap
	{
		image=bgk,
		x = kCenter,
		y = kCenter,
		alpha=true,

		OptionsWindow
		{
			x=0,y=0,w=kMax,h=kMax,

			Text
			{
				font = SliderFont,
				name = "music",
				x=tx,y=ty+0*tdy,w=sw,h=50,
				flags = kHAlignCenter + kVAlignCenter,
				label = "musiclevel"
			};

			Text
			{
				font = SliderFont,
				name = "ambient",
				x=tx,y=ty+1*tdy,w=sw,h=50,
				flags = kHAlignCenter + kVAlignCenter,
				label = "ambientlevel"
			};

			Text
			{
				font = SliderFont,
				name = "sfx",
				x=tx,y=ty+2*tdy,w=sw,h=50,
				flags = kHAlignCenter + kVAlignCenter,
				label = "sfxlevel"
			};

			SetStyle(ButtonStyle),
			Button{
				name="fullscreen",
				label= IsFullScreen() and "fullscreen" or "windowmode",
				graphics={"ui/options_menu/buttons/fullscreen/fullscreen_in","ui/options_menu/buttons/fullscreen/fullscreen_ac","ui/options_menu/buttons/fullscreen/fullscreen_ac"},
				x=526,
				y=206,
				command=
				function()
					if (ToggleFullScreen() == false) then
						DisplayDialog {
							"scripts/ok.lua",
							body ="screenswitchfailed",
							title = "playground"
						};
					end
					UpdateFullscreen();
					
					--FullScreenChanged();
				end

			},

			Button{
				name="howtoplaybutton",
				label= "howtoplaybuttontext",
				graphics={"ui/options_menu/buttons/fullscreen/fullscreen_in","ui/options_menu/buttons/fullscreen/fullscreen_ac","ui/options_menu/buttons/fullscreen/fullscreen_ac"},
				x=526,
				y=286,
				command=
				function()
					DoModal("scripts/howtoplay.lua")
				end

			},

			Button{
				name="credits",
				label= "credits",
				graphics={"ui/options_menu/buttons/fullscreen/fullscreen_in","ui/options_menu/buttons/fullscreen/fullscreen_ac","ui/options_menu/buttons/fullscreen/fullscreen_ac"},
				x=526,
				y=366,
				command=
				function()
					DoModal("scripts/credits.lua")
				end

			},

			Button
			{
				x = 695,
				y = 555,
				graphics={"ui/options_menu/buttons/close/close_in","ui/options_menu/buttons/close/close_ac","ui/options_menu/buttons/close/close_ac"},
				name="back",
				label="back",
				cancel=true,
				default=true,
				type = kPush,
				command =
					function()
						SaveVolumes();
						PopModal("optionsmenu");
					end
			},

			--Button
			--{
			--	x = kCenter+80,
			--	y = kMax-50,
			--	name="credits",
			--	label="creditsbutton",
			--	type = kPush,
			--	command =
			--		function()
			--			DoModal("scripts/credits.lua");
			--		end
			--},

			SetStyle(SliderStyle1),
			FeedbackSlider
			{
				name="musiclevelslider",
				x = sx + px,
				y = sy+0*sdy,
				w = sw,
			};
			SetStyle(SliderStyle2),
			FeedbackSlider
			{
				name="ambientlevelslider",
				x = sx + px,
				y = sy+1*sdy,
				w = sw,
			};
			SetStyle(SliderStyle3),
			FeedbackSlider
			{
				name="sfxlevelslider",
				x = sx + px,
				y = sy+2*sdy,
				w = sw,
			};

--			SetStyle(CheckboxButtonStyle),
--			Button{
--				name="mutebox",
--				x=205,
--				y=175,
--				w=175,
--				label = "mutesound",
--				command =
--					function()
--						ToggleSoundMute();
--					end
--			};
			
		},
	},
}