dofile('Data/Scripts/Common/Screens/OptionsScreenBase.lua')

class 'OptionsScreen' (OptionsScreenBase)

function OptionsScreen:__init(name)
	self.test_voice_track_path = 'Data/Sounds/Common/ItemFound.ogg'
	OptionsScreenBase.__init(self, name)
end

function OptionsScreen:setupCheckBoxes()
	local window = Application:getPlatform():getWindow()
	
	self.checkBoxFullScreen = self:createCheckBox(Vector2f(714, 411), window:isFullscreen(), bind(self.fullScreenChange, self) )
	self:createCheckBox( Vector2f(714, 455), self.custom_cursor, bind(self.customCursorChange, self) )
	self.checkBoxWideScreen = self:createCheckBox( Vector2f(714, 498), window:isWidescreen(), bind(self.wideScreenChange, self) )

	if Application:getApplicationDescriptor().optionsFullScreenEnabled == false then
	    self:disableCheckBox(self.checkBoxFullScreen)
	end
	if Application:getApplicationDescriptor().optionsWideScreenEnabled == false or not Application:getPlatform():getWindow():isFullscreen() then
	    self:disableCheckBox(self.checkBoxWideScreen)
	end
	if Application:getApplicationDescriptor().optionsUseCustomCursorEnabled == false then
	    self:disableCheckBox(self.checkBoxCustomCurs)
	end
end

function OptionsScreen:setupButtons()
	self:getEntityNamed('bttn_change_play_mode').onPress:add(bind(self.onChangePlayModeButtonClick, self))
	self:getEntityNamed('bttn_ok').onPress:add(bind(self.onOkButtonClick, self))
	self:getEntityNamed('bttn_cancel').onPress:add(bind(self.onCancelButtonClick, self))
	
	self:getEntityNamed('bttn_change_play_mode'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
	self:getEntityNamed('bttn_ok'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
	self:getEntityNamed('bttn_cancel'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )

	-- Если режим игры не добавлялся, то прячем кнопку bttn_change_play_mode
	if HasGameState(PLAY_MODE) == false then
		local bttn = self:getMainEntity():getEntityNamed('bttn_change_play_mode')
		bttn:hide()
		self:getEntityNamed('bttn_change_play_mode'):hide()
	end

	if current_scene == nil then
		self:getMainEntity():getEntityNamed('bttn_change_play_mode'):hide()
		self:getEntityNamed('bttn_change_play_mode'):hide()
	end
end

function OptionsScreen:onScreenModeChange()
	if not Application:getPlatform():getWindow():isFullscreen() then
	    self:disableCheckBox(self.checkBoxWideScreen)
	else
	    self:enableCheckBox(self.checkBoxWideScreen)
	end
end

function OptionsScreen:disableCheckBox(checkbox)
    checkbox:setOpacity(0.1)
	checkbox:setRespondable(false)
end

function OptionsScreen:enableCheckBox(checkbox)
    checkbox:setOpacity(1)
	checkbox:setRespondable(true)
end

--------------------------------------------------------------------------------
--                      GENERATED CONTENT. DO NOT EDIT.                       --
--------------------------------------------------------------------------------

function OptionsScreen:CreateLoaderTable()
	local objects =
	{
		{ name = 'OptionsScreen',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 10,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 268, y = 221},  texturePath = 'Data/Textures/Screens/Options/OptionsScreen.png',  width = 530,  height = 450,  },
		{ name = 'options_txt',  entityType = 'SpriteEntity',  parentName = 'OptionsScreen',  x = 0,  y = -193,  order = 0,  isVisible = false,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Options/options_txt.png',  width = 74,  height = 16,  },
		{ name = 'voice_slider',  entityType = 'SpriteEntity',  x = 561,  y = 303,  order = 20,  color = {r = 1, g = 1, b = 1, a = 0},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'text_voice_volume',  entityType = 'TextEntity',  parentName = 'voice_slider',  x = -323,  y = -3,  order = 25,  isVisible = false,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'VOICE_VOLUME',  font = 'Data/Fonts/Options.fnt',  height = 32,  hotSpotType = TextEntity.ETextHotSpotTypeLeft,  },
		{ name = 'sound_slider',  entityType = 'SpriteEntity',  x = 561,  y = 258,  order = 20,  color = {r = 1, g = 1, b = 1, a = 0},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'text_sound_volume',  entityType = 'TextEntity',  parentName = 'sound_slider',  x = -323,  y = -3,  order = 25,  isVisible = false,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'SOUND_VOLUME',  font = 'Data/Fonts/Options.fnt',  height = 32,  hotSpotType = TextEntity.ETextHotSpotTypeLeft,  },
		{ name = 'music_slider',  entityType = 'SpriteEntity',  x = 561,  y = 348,  order = 20,  color = {r = 1, g = 1, b = 1, a = 0},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'text_music_volume',  entityType = 'TextEntity',  parentName = 'music_slider',  x = -323,  y = -3,  order = 25,  isVisible = false,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'MUSIC_VOLUME',  font = 'Data/Fonts/Options.fnt',  height = 32,  hotSpotType = TextEntity.ETextHotSpotTypeLeft,  },
		{ name = 'text_custom_color',  entityType = 'TextEntity',  x = 288,  y = 460,  order = 18,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'CUSTOM_CURSOR',  font = 'Data/Fonts/Options.fnt',  height = 32,  boundsX = 440,  boundsY = 0,  hotSpotType = TextEntity.ETextHotSpotTypeLeft,  },
		{ name = 'text_full_screen',  entityType = 'TextEntity',  x = 288,  y = 414,  order = 18,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'FULLSCREEN',  font = 'Data/Fonts/Options.fnt',  height = 32,  boundsX = 440,  boundsY = 0,  hotSpotType = TextEntity.ETextHotSpotTypeLeft,  },
		{ name = 'text_wide_screen',  entityType = 'TextEntity',  x = 288,  y = 504,  order = 18,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'WIDE_SCREEN',  font = 'Data/Fonts/Options.fnt',  height = 32,  boundsX = 440,  boundsY = 0,  hotSpotType = TextEntity.ETextHotSpotTypeLeft,  },
		{ name = 'bttn_ok',  entityType = 'ButtonEntity',  x = 448,  y = 609,  order = 20,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Buttons/bttn_ok.png',  text = '',  activeRectX = 110,  activeRectY = 40,  },
		{ name = 'bttn_change_play_mode',  entityType = 'ButtonEntity',  x = 506,  y = 565,  order = 25,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Buttons/bttn_mode.png',  text = '',  activeRectX = 228,  activeRectY = 44,  },
		{ name = 'bttn_cancel',  entityType = 'ButtonEntity',  x = 567,  y = 611,  order = 230,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Buttons/bttn_cancel.png',  text = '',  activeRectX = 110,  activeRectY = 40,  },
	}
	return objects
end
