class 'MoreInfoScreenBase' (BaseScreen)

local BUTTON_FORUM_FILE_PATH			= 'Data/Textures/Screens/MoreInfo/bttn_forums.png'
local BUTTON_STRATEGY_GUIDE_FILE_PATH	= 'Data/Textures/Screens/MoreInfo/bttn_strategy_guide.png'

function MoreInfoScreenBase:__init(name)
	BaseScreen.__init(self, name)

	self.buttons_y = {{-50}, {-110, 10}, {-140, -40, 60}}

	self:setupButtons()
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:__finalize()
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:setupButtons()
	local bttn_ok = self:getEntityNamed('bttn_ok')
	bttn_ok.onPress:add(bind(self.onOkButtonClick, self))
	bttn_ok:setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )

	local buttons = {}

	local obj_back = self:getMainEntity():getEntityNamed('MoreInfo')

	if isSurveyMode() == false and resourceExists(BUTTON_FORUM_FILE_PATH) then
	    local externalLinksEnabled = Application:getApplicationDescriptor().externalLinksEnabled
	    if externalLinksEnabled == nil or (externalLinksEnabled and externalLinksEnabled == true) then
            local bttn = CreateButtonEntity(BUTTON_FORUM_FILE_PATH)
            bttn:setName(BUTTON_FORUM_FILE_PATH)
            bttn:attachTo(obj_back)
            bttn.onPress:add(bind(self.onForumButtonClick, self))
            
            bttn:setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )

            table.insert(buttons, bttn)
		end
	end

	if self:hasEntityNamed('bttn_credits') then
		local bttn = self:getEntityNamed('bttn_credits')
		bttn.onPress:add(bind(self.onCreditsButtonClick, self))
		bttn:setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
		
		table.insert(buttons, bttn)
	end

	if isSurveyMode() == false and resourceExists(BUTTON_STRATEGY_GUIDE_FILE_PATH) then
	    local externalLinksEnabled = Application:getApplicationDescriptor().externalLinksEnabled
	    if externalLinksEnabled == nil or (externalLinksEnabled and externalLinksEnabled == true) then
            local bttn = CreateButtonEntity(BUTTON_STRATEGY_GUIDE_FILE_PATH)
            bttn:setName(BUTTON_STRATEGY_GUIDE_FILE_PATH)
            bttn:attachTo(obj_back)
            bttn.onPress:add(bind(self.onStrategyGuideButtonClick, self))

            bttn:setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
            
            table.insert(buttons, bttn)
		end
	end

	for i, v in pairs(buttons) do
		v:setY(self.buttons_y[#buttons][i])
	end
	
	self.buttons = buttons
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:onForumButtonClick()
	openURL('Data/Links/ForumURL.txt')
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:onStrategyGuideButtonClick()
	if isCollectorsEdition() then
		createStrategyGuideScreen()
	else
	    openURL('Data/Links/StrategyGuideURL.txt')
	end
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:onCreditsButtonClick()
	self:onScreenDestroy()
	createCreditsScreen()
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:onOkButtonClick()
	self:onScreenDestroy()
end
-------------------------------------------------------------------------------

function MoreInfoScreenBase:onScreenDestroy()
	PopUpScreensMgr:pop()
end
-------------------------------------------------------------------------------