class 'ComicsPanelBase' (Node)

function ComicsPanelBase:__init(panel)
	Node.__init(self, panel:getMainEntity(), 'ComicsPanel', 3)
	self.game_scene = panel.game_scene
	
	if self.CreateLoaderTable then
        local table_resource = self:CreateLoaderTable()
        LoadScene(self.main_entity, table_resource)
    end

    do
		self:getEntityNamed('bttn_skip'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
		self:getEntityNamed('bttn_skip').onPress:add(bind(self.onSkipButtonPress, self))
	end

    self.showTextField = self:getEntityNamed('text_field_1')
    self.hideTextField = self:getEntityNamed('text_field_2')

    self.showTextField:setOpacity(0)
    self.hideTextField:setOpacity(0)
end

-------------------------------------------------------------------------------
function ComicsPanelBase:setText(textKey, time, ignoreGetString)
	local text = (ignoreGetString) and textKey or StringManager:getString(textKey)
	time = time or 0
    
    if self.showTextField:getOpacity() > 0 then
    	self.showTextField, self.hideTextField = self.hideTextField, self.showTextField
    end

    self.showTextField:setText(text)

    self.showTextField:destroyEffectors()
    self.hideTextField:destroyEffectors()

    self.showTextField:ChangeOpacity(0, 1, time)
    self.hideTextField:ChangeOpacity(1, 0, time)
end

-------------------------------------------------------------------------------
function ComicsPanelBase:showContinueText(delay)
	self:entityHide('text_continue')
	
	if (self.showTimer ~= nil) then
		self.showTimer:kill()
	end

	local playfield = self.game_scene:getPlayField()
	self.showTimer = playfield.timer:add(	function()
	    										self:getEntityNamed('text_continue'):setVisible(true)
	    									end, delay )
end

-------------------------------------------------------------------------------
function ComicsPanelBase:onSkipButtonPress()
	local playfield = self.game_scene:getPlayField()
	if playfield and playfield.active_comics then
		playfield.active_comics:skip()
	end
end

-------------------------------------------------------------------------------
function ComicsPanelBase:moveIn(time)
	self:getMainEntity():show()

	self.showTextField:setOpacity(0)
    self.hideTextField:setOpacity(0)
end

-------------------------------------------------------------------------------
function ComicsPanelBase:moveOut(time)
	self:getMainEntity():hide()
end