-------------------------------------------------------------------------------
class 'AboutMatch3' (Node)
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
local INFO_SHOWN = 'Match3_help_info_shown'
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:__init(match3)   
    Node.__init(self, match3.zoom:getMainEntity(), 'AboutMatch3', 1000)  
    self.screen 	= match3.zoom
    self.field 		= match3.field
    self.panel 		= match3.panel

    self:loadData(self)  

    self:init()  
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:init()
	self.close_window = false
	self.field.bActive = false
	self.panel.bActive = false

	self.main_entity:setXY(-512, -420)

    self.checkBoxCloseWindow = self:createCheckBox(Vector2f(98, 614), false, bind(self.setWindowClosed, self) )
    self:getEntityNamed('bttn_ok').onPress:add(bind(self.onOkButtonClick, self))    
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:onOkButtonClick()
	self:hideScreen()

	if self.close_window then
		SetGameState(INFO_SHOWN, 'true')
	end
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:isNeeded()
	return not HasGameState(INFO_SHOWN)
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:setWindowClosed()
	self.close_window = self.checkBoxCloseWindow:isChecked()
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:hideScreen()
	self.field.bActive = true
	self.panel.bActive = true
	self.main_entity:hide()
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
function AboutMatch3:showScreen()
	self.field.bActive = false
	self.panel.bActive = false
	if self.isNeeded() then
		self.main_entity:show()
	end
end
-------------------------------------------------------------------------------

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

-------------------------------------------------------------------------------
function AboutMatch3:createCheckBox(pos, startChecked, functionChange)
	spriteCheck = CreateSpriteEntity('Data/Textures/Screens/Options/CheckboxTick.png')
	
	local checkBox = createCheckBoxEntity(nil, spriteCheck)
	checkBox:attachTo( self:getMainEntity() )
	checkBox:setXY(pos.x, pos.y)
	checkBox:setOrder(20)
	checkBox:setChecked(startChecked)
	checkBox:setActiveRectSize(45, 45)
	checkBox.onCheck:add(functionChange)
	
	return checkBox
end
-------------------------------------------------------------------------------

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

function AboutMatch3:CreateLoaderTable()
	local objects =
	{
		{ name = 'window_border',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Match3/Helps/window_border.png',  width = 916,  height = 608,  },
		{ name = 'match3_title',  entityType = 'SpriteEntity',  parentName = 'window_border',  x = 0,  y = -267,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Match3/Helps/match3_title.png',  width = 150,  height = 18,  },
		{ name = 'bttn_ok',  entityType = 'ButtonEntity',  parentName = 'window_border',  x = 0,  y = 296,  order = 20,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Buttons/bttn_ok.png',  text = '',  },
		{ name = 'text_help_close',  entityType = 'TextEntity',  parentName = 'window_border',  x = -244,  y = 234,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'MATCH3_HELP_CLOSE',  height = 23,  },
		{ name = 'Match3HelpTile_1',  entityType = 'SpriteEntity',  parentName = 'window_border',  x = 290,  y = -118,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Match3/Helps/Match3HelpTile_3.jpg',  width = 200,  height = 200,  },
		{ name = 'Match3HelpTile_2',  entityType = 'SpriteEntity',  parentName = 'window_border',  x = -2,  y = -118,  order = 2,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Match3/Helps/Match3HelpTile_2.jpg',  width = 200,  height = 200,  },
		{ name = 'Match3HelpTile_3',  entityType = 'SpriteEntity',  parentName = 'window_border',  x = -288,  y = -118,  order = 3,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Match3/Helps/Match3HelpTile_1.jpg',  width = 200,  height = 200,  },
		{ name = 'text_info1',  entityType = 'TextEntity',  parentName = 'window_border',  x = -415,  y = 10,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'MATCH3_INFO1',  height = 23,  boundsX = 250,  boundsY = 0,  alignment = TextEntity.ETextHorizontalAlignmentLeft,  hotSpotType = TextEntity.ETextHotSpotTypeLeftTop,  },
		{ name = 'text_info2',  entityType = 'TextEntity',  parentName = 'window_border',  x = -125,  y = 10,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'MATCH3_INFO2',  height = 23,  boundsX = 250,  boundsY = 0,  alignment = TextEntity.ETextHorizontalAlignmentLeft,  hotSpotType = TextEntity.ETextHotSpotTypeLeftTop,  },
		{ name = 'text_info3',  entityType = 'TextEntity',  parentName = 'window_border',  x = 170,  y = 10,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  localizationKey = 'MATCH3_INFO3',  height = 23,  boundsX = 250,  boundsY = 0,  alignment = TextEntity.ETextHorizontalAlignmentLeft,  hotSpotType = TextEntity.ETextHotSpotTypeLeftTop,  },
	}
	return objects
end
