dofile('Data/Scripts/Screens/MoreGamesPage.lua')
dofile('Data/Scripts/Common/Screens/MoreGames/MoreGamesScreenBase.lua')

class 'MoreGamesScreen' (MoreGamesScreenBase)

function MoreGamesScreen:__init(name)
	MoreGamesScreenBase.__init(self, name)

	self.pageButtonSettings.deltaX			= 35
	self.pageButtonSettings.deltaY			= 65
	self.pageButtonSettings.deltaXprevnext	= 63

	self.pageButtonSettings.centerPos = Vector2f(512, 615)
end

-------------------------------------------------------------------------------
function MoreGamesScreen:initPageButtons()
	self.pagesCount = math.ceil(#self.games / self.iconsOnPage)

	local pagesRangeX = (self.pagesCount-1) * self.pageButtonSettings.deltaX
	local pos		  = Vector2f(self.pageButtonSettings.centerPos.x - pagesRangeX/2,
								 self.pageButtonSettings.centerPos.y - self.pageButtonSettings.deltaY)

	for i=1, self.pagesCount do
		local button = self:createPageButton(i)
		button:setPosition(pos)

		pos.x = pos.x + self.pageButtonSettings.deltaX
		table.insert(self.pageButtons, button)
	end

	self:createAdditionPageButtons()
end
-------------------------------------------------------------------------------

function MoreGamesScreen:createAdditionPageButtons()
	-- button prev
	do
		local firstButtonPos = self:getPageButton( 1 ):getPosition()

		local action = bind(self.showPrevPage, self)
		local pos	 = Vector2f(firstButtonPos.x - self.pageButtonSettings.deltaX - self.pageButtonSettings.deltaXprevnext,
								firstButtonPos.y)

		self.prevPageButton = self:createAdditionPageButton('<', pos, action)
	end

	-- button next
	do
		local lastButtonPos = self:getPageButton( self.pagesCount ):getPosition()

		local action = bind(self.showNextPage, self)
		local pos	 = Vector2f(lastButtonPos.x + self.pageButtonSettings.deltaX + self.pageButtonSettings.deltaXprevnext,
								lastButtonPos.y)

		self.nextPageButton = self:createAdditionPageButton('>', pos, action)
	end
end
-------------------------------------------------------------------------------


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

function MoreGamesScreen:CreateLoaderTable()
	local objects =
	{
		{ name = 'BG_transparent',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.01},  editingLocked = false,  treeItemIsExpanded = true,  width = 866,  height = 594,  },
		{ name = 'Layer_more_games_windows',  entityType = 'SpriteEntity',  parentName = 'BG_transparent',  x = 0,  y = 0,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/MoreGames/Layer_more_games_windows.png',  width = 866,  height = 594,  },
		{ name = 'bttn_close',  entityType = 'ButtonEntity',  parentName = 'BG_transparent',  x = 0,  y = 289,  order = 2,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/Buttons/bttn_quit.png',  text = '',  activeRectX = 207,  activeRectY = 50,  },
	}
	return objects
end
