require( "scripts/style.lua" );

SliderFont = {
  standardFont,
  16,
  BlackColor
};

function F_fx_volume_change()
PlayVolumeSound( "fx" );
end

function F_music_volume_change()
PlayVolumeSound( "music" );
end

function F_sound_save()
SaveOptions();
end

MakeDialog
{
	-- Name the modal dialog
	name="optionsmenu",
	
	Options
	{
		x = 0,
		y = 0,
		w = kMax,
		h = kMax,
		
		Bitmap
		{
			image="backgrounds/options",
			x = kCenter,
			y = kCenter - 84,
			
      Text
			{
				font = BookAntiquaTitle36Font,
				name = "titleoptionsvideo",
				x=98,y=70,w=kMax,h=50,
				flags = kHAlignLeft + kVAlignCenter,
				label = "titleoptionsvideo"
			};
      
      Text
			{
				font = BookAntiquaTitle36Font,
				name = "titleoptionssound",
				x=531,y=70,w=kMax,h=50,
				flags = kHAlignLeft + kVAlignCenter,
				label = "titleoptionssound"
			};
      
			Text
			{
				font = BookAntiquaLegend24Font,
				name = "sfx",
				x=531,y=130,w=kMax,h=50,
				flags = kHAlignLeft + kVAlignCenter,
				label = "sfxlevel"
			};
		
			Text
			{
				font = BookAntiquaLegend24Font,
				name = "music",
				x=531,y=210,w=kMax,h=50,
				flags = kHAlignLeft + kVAlignCenter,
				label = "musiclevel"
			};
      
      Text
			{
				font = BookAntiquaLegend24Font,
				name = "displaymode",
				x=98,y=280,w=kMax,h=50,
				flags = kHAlignLeft + kVAlignCenter,
				label = "displaymode"
			};

			SetStyle(RuneButtonStyle),
			Button{
				name="fullscreen",
				x=283,
				y=136,
				command=
				function()
					if (ToggleFullScreen(true) == false) then
						DisplayDialog { 
							"scripts/ok.lua", 
							body ="screenswitchfailed_body",
							title = "screenswitchfailed_title" 
						};
					end
				end
				
			};
			Button{
				name="windowed",
				x=283,
				y=200,
				command=
				function()
					if (ToggleFullScreen(false) == false) then
						DisplayDialog { 
							"scripts/ok.lua", 
							body ="screenswitchfailed_body",
							title = "screenswitchfailed_title" 
						};
					end
				end
				
			};
      -- its label
      Text
		  {
				font = BookAntiquaLegend24Font,
				name = "fullscreenlabel",
				x=98,
				y=145,
				w=kMax,
				h=kMax,
				flags = kHAlignLeft + kVAlignTop,
				label="fullscreen",
			};
			
	  Text
		  {
				font = BookAntiquaLegend24Font,
				name = "windowedlabel",
				x=98,
				y=209,
				w=kMax,
				h=kMax,
				flags = kHAlignLeft + kVAlignTop,
				label="windowed",
			};

			Button{
				name="fourthird",
				x=283,
				y=330,
				w=150,
				command=
				function()
					ToggleResolution(0, true);
					-- if (ToggleFullScreen() == false) then
						-- DisplayDialog { 
							-- "scripts/ok.lua", 
							-- body ="screenswitchfailed",
							-- title = "playground" 
						-- };
					-- end
				end
			};
      -- its label
      Text
			{
				font = BookAntiquaLegend24Font,
				name = "fourthirdlabel",
				x=98,
				y=338,
				w=kMax,
				h=kMax,
				flags = kHAlignLeft + kVAlignTop,
				label="fourthird",
			};
			
			Button{
				name="sixteennineth",
				x=283,
				y=400,
				command=
				function()
					ToggleResolution(1, true);
					-- if (ToggleFullScreen() == false) then
						-- DisplayDialog { 
							-- "scripts/ok.lua", 
							-- body ="screenswitchfailed",
							-- title = "playground" 
						-- };
					-- end
				end
			};
      -- its label
      Text
			{
				font = BookAntiquaLegend24Font,
				name = "sixteenninethlabel",
				x=98,
				y=408,
				w=kMax,
				h=kMax,
				flags = kHAlignLeft + kVAlignTop,
				label="sixteennineth",
			};
			
			Button{
				name="mutebox",
				x=710,
				y=311,
				w=175,
				command =
					function()
						ToggleSoundMute();
					end
			};
			Text
			{
				font = BookAntiquaLegend24Font,
				name = "mutesoundlabel",
				x=531,
				y=316,
				w=kMax,
				h=kMax,
				flags = kHAlignLeft + kVAlignTop,
				label="mutesound",
			};
			
			Button{
				name="tutobox",
				x=710,
				y=361,
				w=175,
				command =
					function()
						ToggleTuto();
					end
			};
			Text
			{
				font = BookAntiquaLegend24Font,
				name = "tutotogglelabel",
				x=531,
				y=366,
				w=kMax,
				h=kMax,
				flags = kHAlignLeft + kVAlignTop,
				label="tutotoggle",
			};

			SetStyle(OptionsValidationButtonStyle),
			Button
			{
				x = 531,
				y = 439,
				name="OK",
				label="ok",
				type = kPush,
				close = true,
				-- command =
					-- function()
						-- SaveOptions();
					-- end
			},
			SetStyle(OptionsCancelButtonStyle),
			Button
			{
				x = 697,
				y = 439,
				name="cancel",
				label="cancel",
				type = kPush,
				close = true,
				command =
					function()
						CancelOptions();
					end
			},

			SetStyle( OptionsSliderStyle ),
			OurSlider
			{
				name="sfxlevelslider",
				x = 531,
				y = 170,
				w = 149,
				h = 25,
				hslider = true,
				onmouseup = "F_fx_volume_change",
				slider_change_callback = "F_sound_save",
			};
			
			OurSlider
			{
				name="musiclevelslider",
				x = 531,
				y = 250,
				w = 149,
				h = 25,
				hslider = true,
				onmouseup = "F_music_volume_change",
				slider_change_callback = "F_sound_save",
			};
		},
	},
}