class 'l_HelpScreen' (BaseScreen)
-------------------------------------------------------------------------------
local COUNT_PAGES = 6
-------------------------------------------------------------------------------

function l_HelpScreen:__init(name, screen)
	BaseScreen.__init(self, name, screen)
	
	self:CreateButtonByName('Ok', KEY_ENTER)
	self.bttn_left  = self:CreateButtonByName('Left',  KEY_LEFT)
	self.bttn_right = self:CreateButtonByName('Right', KEY_RIGHT)
	
	self.text_help = {}
	for i=1, COUNT_PAGES do
	    table.insert( self.text_help, self:CreateText(screen, 'HELP_TEXT_'..(i+1)) )
	end
	
	self.text_help[1]:SetOpacity(1)
	self.index_current = 1
	self.index_count   = COUNT_PAGES
	self:UpdateButtonClick()
	
	self.screen:SetXY(0, -50)
end
-------------------------------------------------------------------------------

function l_HelpScreen:CreateText(screen, text)
    local text = CreateTextEntity(MENU_FONT, text)
	text:AttachTo(screen)
	text:SetXY(512, 314)
	text:SetBorderSize(450, 100)
	text:SetTracking(-2)
	text:SetSpacing(0.8)
	text:SetTextAlignment(HGETEXT_CENTER + HGETEXT_MIDDLE)
	text:SetOpacity(0)
	text:SetScale(0.5)
	text:SetZ(250)
	
	return text
end
-------------------------------------------------------------------------------

function l_HelpScreen:ChangeText(textFadeIn, textFadeOut)
    local time = 0.25
    
    textFadeIn:ChangeOpacity(1, 0, time)
    textFadeOut:ChangeOpacity(0, 1, time)
    
    self.bttn_left:SetActive(false)
    self.bttn_right:SetActive(false)
    
    self.timer:Add(function()
                        self.bttn_left:SetActive(true)
                        self.bttn_right:SetActive(true)
                    end,
                    time)
end
-------------------------------------------------------------------------------

function l_HelpScreen:OnOkButtonClick()
    PopUpScreensMgr:Pop()
end
-------------------------------------------------------------------------------

function l_HelpScreen:OnLeftButtonClick()
    if self.index_current > 1 then
        local textFadeIn  = self.text_help[self.index_current]
        local textFadeOut = self.text_help[self.index_current - 1]
    
        self:ChangeText(textFadeIn, textFadeOut)
        self.index_current = self.index_current - 1
    end
    
    self:UpdateButtonClick()
end
-------------------------------------------------------------------------------

function l_HelpScreen:OnRightButtonClick()
    if self.index_current < self.index_count then
        local text_fade_in = self.text_help[self.index_current]
        local text_fade_out = self.text_help[self.index_current + 1]
    
        self:ChangeText(text_fade_in, text_fade_out)
        self.index_current = self.index_current + 1
    end
    
    self:UpdateButtonClick()
end
-------------------------------------------------------------------------------

function l_HelpScreen:UpdateButtonClick()
    local left_bttn_enabled  = self.bttn_left:IsEnabled()
    local right_bttn_enabled = self.bttn_right:IsEnabled()
    
    if self.index_current == 1 then
        if left_bttn_enabled then
            self.bttn_left:SetEnabled(false)
        end
    else
        if not left_bttn_enabled then
            self.bttn_left:SetEnabled(true)
        end
    end
    
    if self.index_current == self.index_count then
        if right_bttn_enabled then
            self.bttn_right:SetEnabled(false)
        end
    else
        if not right_bttn_enabled then
            self.bttn_right:SetEnabled(true)
        end
    end
end
-------------------------------------------------------------------------------

function CreateHelpScreen(hideActiveScreen)
    hideActiveScreen = (hideActiveScreen == nil) and true or hideActiveScreen
    
    local screen = CreateScriptedScreen('data/Scripts/screens/HelpScreen.lua', 'l_HelpScreen');
    PopUpScreensMgr:Push(screen, hideActiveScreen, nil);
end
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function l_HelpScreen:LoadData(screen)
	local anim
	anim = CreateAnimation('data/Texture/GUI/OK/WindowOK.png',0,0,580,450,1,0)
	anim:SetHotSpot(290,225)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('HelpBackground',anim,512,384,100,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_ok.png',0,0,162,104,3,0)
	anim:SetHotSpot(81,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_ok',anim,512,584,100,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_scroll_right.png',0,0,51,51,3,0)
	anim:SetHotSpot(25,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_right',anim,612,584,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_scroll_left.png',0,0,51,51,3,0)
	anim:SetHotSpot(25,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_left',anim,412,584,120,0,1,1)
end
-- CLEAR_ON_SAVE_END
