require "scripts/style";

SliderFont = {
  standardFont,
  20,
  BlackColor
};

--local bgk="backgrounds/dialog"
local bgk="ui/options_menu/ir_ui_options_bg"
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/ir_ui_options_sliderbar",
	railbot = "ui/options_menu/scrolls/top",
	sliderimage = "ui/options_menu/ir_ui_options_slider01",
	sliderrollimage = "ui/options_menu/ir_ui_options_slider00",

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

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

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

MakeDialog
{
	-- Name the modal dialog
	name="optionsmenu",
	Bitmap
	{
		image="backgrounds/dark",
		x=0,
		y=0,
		w= 1024,
		h= 768,
		alpha=true,
		
		OptionsWindow
		{
			Bitmap
			{
				image="ui/options_menu/ir_ui_options_bg",
				x = kCenter,
				y = kCenter,
				w=551,h=537,
				alpha=true
			};

			x = kCenter,
			y = kCenter,
			w=551,h=537,
				
			Text
			{
				font = SliderFont,
				name = "music",
				x=0,y=80,w=sw,h=50,
				flags = kHAlignCenter + kVAlignCenter,
				label = "musiclevel"
			};

			Text
			{
				font = SliderFont,
				name = "ambient",
				x=0,y=120,w=sw,h=50,
				flags = kHAlignCenter + kVAlignCenter,
				label = "ambientlevel"
			};

			Text
			{
				font = SliderFont,
				name = "sfx",
				x=0,y=160,w=sw,h=50,
				flags = kHAlignCenter + kVAlignCenter,
				label = "sfxlevel"
			};
			
			SetStyle(ButtonStyle),
			Button{
				name="credits",
				MenuButtonLabel3("credits",80,20),
				graphics={"buttons/ir_btn_univ01","buttons/ir_btn_univ03","buttons/ir_btn_univ02"},
				x=160,
				y=366,
				command=
				function()
					SetIsFromOptions(true)
					DoModal("scripts/credits.lua")
					--DoModal("scripts/ending.lua")
					--DoModal("scripts/generic_items.lua")
				end

			},
			
			Button
			{
				x = 130,
				y = 460,
				graphics={"buttons/ir_btn_univ_sm01","buttons/ir_btn_univ_sm03","buttons/ir_btn_univ_sm02"},
				name="ok",
				MenuButtonLabel3("ok",55,13),
				cancel=true,
				default=true,
				type = kPush,
				command =
					function()
						SaveVolumes();
						PopModal("optionsmenu");
					end
			},
			
			Button
			{
				x = 280,
				y = 460,
				graphics={"buttons/ir_btn_univ_sm01","buttons/ir_btn_univ_sm03","buttons/ir_btn_univ_sm02"},
				name="back",
				MenuButtonLabel3("back",47,13),
				sound = "audio/sfx/Menu_Click01.ogg",
				cancel=true,
				default=true,
				type = kPush,
				command =
					function()
						PopModal("optionsmenu");
					end
			},
			
			SetStyle(CheckboxButtonStyle),
			Button{
				name="timechkbx",
				label="timechkbx",
				x=280,
				y=230,
				w=180,
				command=
				function()
					ToggleTimedPlay();
				end
			},
			
			--Button{
			--	name="customcursor",
			--	label="customcursor",
			--	x=290,
			--	y=230,
			--	w=200,
			--	command=
			--	function()
			--		ToggleCustomCursor();
			--	end
			--},
			
			Button{
				name="showhint",
				label="showhint",
				x=80,
				y=300,
				w=200,
				--command=
				--function()
				--	ToggleShowTutorial();
				--end
			},
			
			Button{
				name="fullscreen",
				label= "fullscreen",
				--graphics={"ui/options_menu/buttons/fullscreen/fullscreen_in","ui/options_menu/buttons/fullscreen/fullscreen_ac","ui/options_menu/buttons/fullscreen/fullscreen_ac"},
				x=80,
				y=230,
				w=165,
				command=
				function()
					if (ToggleFullScreen() == false) then
						DisplayDialog {
							"scripts/ok.lua",
							body ="screenswitchfailed",
							title = "playground"
						};
					end
					UpdateFullscreen();
					
					--FullScreenChanged();
				end

			},
			
			Button{
				name="customcursor1",
				label= "#Custom Cursor",
				--graphics={"ui/options_menu/buttons/fullscreen/fullscreen_in","ui/options_menu/buttons/fullscreen/fullscreen_ac","ui/options_menu/buttons/fullscreen/fullscreen_ac"},
				x=280,
				y=300,
				w=190,
				command=
				function()
					ToggleCursor();					
				end

			},
			
			SetStyle(SliderStyle1),
			FeedbackSlider
			{
				name="musiclevelslider",
				x = sx + px,
				y = 80,
				w = sw,
			};
			SetStyle(SliderStyle2),
			FeedbackSlider
			{
				name="ambientlevelslider",
				x = sx + px,
				y = 120,
				w = sw,
			};
			SetStyle(SliderStyle3),
			FeedbackSlider
			{
				name="sfxlevelslider",
				x = sx + px,
				y = 160,
				w = sw,
			};			
		},
	},
}