class 'InformScreen' (Node)
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
local TIME_SHOW = 0.3
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:__init(panel)
	Node.__init(self, panel:getMainEntity(), 'InformScreen', 5)

	self.main_entity.onDestroy:add( self.onEntityDestroy ) 
	self.game_scene = panel.game_scene

	self:LoadData()

	self.active = true

	self.inform_window 					= self:getEntityNamed('inform_window')
	self.inform_bttn 					= self:getEntityNamed('inform_button')
	self.inf_wind_show_opacity		 	= 1
	self.inf_wind_hide_opacity 			= 0
	self.inform_window_show_position	= {}
	self.inform_window_show_position.x	= 512
	self.inform_window_show_position.y	= 100
	
	self:getEntityNamed('inform_button').onFocusIn:add( function() self:focusIn() end )
	self:getEntityNamed('inform_button').onFocusOut:add( function() self:focusOut() end )
	self:getEntityNamed('inform_button').onPress:add( function() 
													  	self:present()
													  	current_scene:getPlayField():hideBlackBar()
													  end )
end
---------------------------------------------------------------------------------------------------

function InformScreen:focusIn()
	if self:isOnScreen() or not self.active then
		return
	end

	if self.present_timer then
		self.present_timer:kill()
		self.present_timer = nil
	end

	if not self.game_scene:getPlayField():getMouseBlocker():isHold() then
		self.inform_bttn:destroyEffectors()
		self.inform_bttn:ChangeOpacity(self.inf_wind_hide_opacity, self.inf_wind_show_opacity, TIME_SHOW)

		self.inform_window:destroyEffectors()
		self.inform_window:ChangeOpacity(self.inf_wind_hide_opacity, self.inf_wind_show_opacity, TIME_SHOW)
	end
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:focusOut(time)
	if self:isOnScreen() or not self.active then
		return
	end

	self:_focusOut(time)
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:_focusOut(time)	
	local time = time or TIME_SHOW

	if self.present_timer then
		self.present_timer:kill()
		self.present_timer = nil
	end

	self.inform_bttn:destroyEffectors()
	self.inform_bttn:ChangeOpacity(self.inf_wind_show_opacity, self.inf_wind_hide_opacity, time)

	self.inform_window:destroyEffectors()
	self.inform_window:ChangeOpacity(self.inf_wind_show_opacity, self.inf_wind_hide_opacity, time)
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:present(move_time)
	if self:isOnScreen() then	
		self:hideWindow(move_time)
	else	
		self:showWindow(move_time)
	end
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:hideWindow(move_time)
	local move_time = move_time or TIME_SHOW

	self:getEntityNamed('anchor_window'):destroyEffectors()
	self:getEntityNamed('anchor_window'):MoveTo(self.inform_window_show_position.x, -46, move_time, 0)

	self.is_on_screen = false

	self.game_scene:getPlayField().timer:add( function()
						self:getEntityNamed('inform_window'):ChangeOpacity(self.inf_wind_show_opacity, self.inf_wind_hide_opacity, move_time)
						self.inform_bttn:destroyEffectors()
						self.inform_bttn:ChangeOpacity(self.inf_wind_show_opacity, self.inf_wind_hide_opacity, move_time)
					end, move_time)
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:showWindow(move_time)
	local move_time = move_time or TIME_SHOW

	self:getEntityNamed('anchor_window'):destroyEffectors()
	self:getEntityNamed('anchor_window'):MoveTo(self.inform_window_show_position.x, self.inform_window_show_position.y, move_time, 0)

	--self.game_scene:getPlayField().timer:add( function()
						self:getEntityNamed('inform_window'):ChangeOpacity(self.inf_wind_hide_opacity, self.inf_wind_show_opacity, move_time)
						
						self.inform_bttn:destroyEffectors()
						self.inform_bttn:ChangeOpacity(self.inf_wind_hide_opacity, self.inf_wind_show_opacity, move_time)
					--end, move_time)

	self.is_on_screen = true
	
	if current_scene then
		-- local tutorial = current_scene:getPlayField():getGameScene():getTutorial()
		-- tutorial:showTip('ACHIEVMENT')
	end
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:LoadData()
	if self.CreateLoaderTable then
		local table_resource = self:CreateLoaderTable()
		LoadScene(self.main_entity, table_resource)
	end
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:getContentAnchor()
	return self:getEntityNamed('inform_anchor')
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function InformScreen:isOnScreen()
	return self.is_on_screen
end
---------------------------------------------------------------------------------------------------

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

function InformScreen:CreateLoaderTable()
	local objects =
	{
		{ name = 'anchor_window',  entityType = 'SpriteEntity',  x = 512,  y = -46,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 2,  height = 2,  },
		{ name = 'inform_window',  entityType = 'SpriteEntity',  parentName = 'anchor_window',  x = 0,  y = -54,  order = 0,  opacity = 0,  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 82, y = 74},  texturePath = 'Data/Textures/GUI/Inform/inform_window.png',  width = 163,  height = 220,  },
		{ name = 'inform_trigger_area',  entityType = 'SpriteEntity',  parentName = 'inform_window',  x = 0,  y = 0,  order = 100,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 80, y = 76},  width = 160,  height = 220,  },
		{ name = 'inform_anchor',  entityType = 'SpriteEntity',  parentName = 'inform_trigger_area',  x = 0,  y = 0,  order = 100,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 0.5, y = 0.5},  width = 1,  height = 1,  },
		{ name = 'inform_highlight',  entityType = 'SpriteEntity',  parentName = 'inform_anchor',  x = 18,  y = 14,  order = 0,  isVisible = false,  isRespondable = false,  scale = 2,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/Inform/inform_highlight.png',  width = 158,  height = 184,  fps = 12,  framesCount = 12,  },
		{ name = 'inform_title',  entityType = 'SpriteEntity',  parentName = 'inform_window',  x = 0,  y = -24,  order = 2,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Inform/inform_title.png',  width = 678,  height = 52,  },
		{ name = 'achievment_text',  entityType = 'TextEntity',  parentName = 'inform_title',  x = 0,  y = -12,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  localizationKey = 'CONGRATULATIONS',  font = 'Data/Fonts/Options.fnt',  height = 23,  boundsX = 563,  boundsY = 0,  },
		{ name = 'inform_button',  entityType = 'ButtonEntity',  parentName = 'anchor_window',  x = 0,  y = 70,  order = 20,  opacity = 0,  scale = 0.84,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Inform/bttn_inform.png',  text = '',  activeRectX = 210,  activeRectY = 78,  },
	}
	return objects
end
