require( "scripts/styles/style.lua" );
--require("scripts/styles/uistyle.lua");
local function CreateAspectRatioButton()
	local t = {};
	if IsWin() then
		table.insert(t, SetStyle(Button3Style));
		table.insert(t, 
			BlgContainer{
				transformMatrix = {x = 476, y = 435},
				BlgText {
						name = "fixAspectRatio",
						label = "wnd_options_fixaspectratio",
						w = 200,
						h = 30,
						font = {
							standardFont,
							21,
							DefaultColor,
						},
						transformMatrix = {x = 20},
				},

				BlgCheckBox{
					name = "aspectCheckBoxBtn",

					selected = GetFixAspectRatio();

					selectedIcon = {
						image = "common/buttons/btn_check",
						transformMatrix = {x = -2, y = -2},
						center = {x = 0, y = 0}
					},
					upState = {
						bitmap = "common/buttons/btn_checkbox_default",
					},
					overState = {
						bitmap = "common/buttons/btn_checkbox_rollover",
					},
					downState = {
						bitmap = "common/buttons/btn_checkbox_pushed",
						sound = kDefaultButtonSound,
					},

					command = function()
						ToggleFixAspectRatio();
					end
				},
			}
		);
	end

	return Group(t);
end

MakeState{

	BlgBitmap{
		image = "common/backgrounds/alpha_black",
		name = "mainmenuBG",
		center = {x = 0, y = 0},
	},
		
	BlgMovieClip{
		transformMatrix = {x = 0, y = 0},
		
		SetStyle(WindowBGStyle),
		BlgMovieClip {
			name = "back",
			
			BlgMovieClip{
				repeatCount = 0,
				SetStyle(PalmTrunkStyle),
				BlgContainer{
					transformMatrix = {x = 700, y = 200},
					BlgBitmap {
						image="common/backgrounds/trunk",
						center = {x = 27, y = 122},
						transformMatrix = {x = 0, y = 0},
					},
					BlgBitmap {
						image = "common/backgrounds/hojas",
						center = {x = 90, y = 202},
						transformMatrix = {x = 0, y = 0},
					},
					
				},	
			},
			
			SetStyle(WindowBGStyle),
			BlgBitmap {
				image="common/backgrounds/box_mainmenu",
				center = {x = 0, y = 0},
				transformMatrix = {x = 307, y = 174},
			},

			SetStyle(Button2Style),
			BlgContainer{
				transformMatrix = {x = 476, y = 402},
				BlgText {
						name = "fullscreenText",
						label = "wnd_options_fullscreen",
						w = 200,
						h = 30,
						font = {
							standardFont,
							21,
							DefaultColor,
						},
						transformMatrix = {x = 20},
				},

				BlgFullScreenCheckBox{
					name = "checkBoxBtn",

					selected = IsFullScreen();

					selectedIcon = {
						image = "common/buttons/btn_check",
						transformMatrix = {x = -2, y = -2},
						center = {x = 0, y = 0}
					},
					font = {
						standardFont,
						21,
						DefaultColor,
					},
					upState = {
						bitmap = "common/buttons/btn_checkbox_default",
					},
					overState = {
						bitmap = "common/buttons/btn_checkbox_rollover",
					},
					downState = {
						bitmap = "common/buttons/btn_checkbox_pushed",
						sound = kDefaultButtonSound,
					},

					command = function()
						ToggleFullScreen();
					end
				},
			},
			
			CreateAspectRatioButton();

			SetStyle(Button4Style),
			BlgContainer{
				name = "bgmSlider1",
				transformMatrix =  {x = 491, y = 276},
				
				BlgBitmap{
					image = "common/backgrounds/slider_back",
					name = "slider_back",
					center = {x = 0, y = 0},
					transformMatrix = {x = -3, y = -24},
				},

				BlgText {
						name = "bgmText",
						label = "wnd_options_music",
						w = 200,
						h = 30,
						font = {
							standardFont,
							21,
							DefaultColor,
						},
				},

				BlgSlider {
					name = "bgmSld",
					value = GetMusicVolume(),
					railtop = "common/sliders/sld_top",
					railmid = "common/sliders/sld_middle",
					railbot = "common/sliders/sld_bottom",
					sliderimage = "common/sliders/sld_knob_default",
					sliderrollimage = "common/sliders/sld_knob_rollover",
					offset = 2, -- scoot the slider down by one pixel to center it.
					transformMatrix = {skewX = -90, skewY = -90},
					changeCommand = function()
						SetMusicVolume(BlgGetSliderValue("bgmSld"));
					end,
				},
			},

			SetStyle(Button5Style),
			BlgContainer{
				name = "bgmSlider2",
				transformMatrix =  {x =491, y =344},
				
				BlgBitmap{
					image = "common/backgrounds/slider_back",
					name = "slider_back",
					center = {x = 0, y = 0},
					transformMatrix = {x = -3, y = -24},
				},

				BlgText {
					name = "fxText",
					label = "wnd_options_sfx",
					w = 200,
					h = 30,
					font = {
						standardFont,
						21,
						DefaultColor,
					},
				},

				BlgSlider {
					name = "fxSld",
					value = GetSoundVolume(),
					railtop = "common/sliders/sld_top",
					railmid = "common/sliders/sld_middle",
					railbot = "common/sliders/sld_bottom",
					sliderimage = "common/sliders/sld_knob_default",
					sliderrollimage = "common/sliders/sld_knob_rollover",
					offset = 2, -- scoot the slider down by one pixel to center it.
					sound = "audio/FX/cp_account_new.ogg",
					transformMatrix = {skewX = -90, skewY = -90},
					changeCommand = function()
						SetSoundVolume(BlgGetSliderValue("fxSld"));
					end,
				},
			},
		},
		
		SetStyle(WindowLogoStyle),
		BlgBitmap{
			image = "common/backgrounds/logo_01_big",
			name = "mainmenuBG",
			center = {x = 0, y = 0},
			transformMatrix = {x = 236, y = 185},
		},

		SetStyle(Button1Style),
		BlgButton{
			name = "backBtn",
			transformMatrix = {x = 614, y = 473},
			label = "wnd_options_close",
			font = {
				standardFont,
				21,
				DefaultColor,
			},
			upState = {
				bitmap = "common/buttons/btn_default",
			},
			overState = {
				bitmap = "common/buttons/btn_rollover",
			},
			downState = {
				bitmap = "common/buttons/btn_pushed",
				sound = kDefaultButtonSound,
			},

			command =
				function()
					PopState();
				end
		},
	},

};

