class 'Match3AbilityInfoScreen' (BaseScreen)

function Match3AbilityInfoScreen:__init(name, screen, abilityId)
	BaseScreen.__init(self, name, screen);
		
    self.level = GetCurrentLevel()
    self:GetObject('fade'):SetVisible(false)
    
    do
        local button = self:CreateButton('bttn_ok', 'Match3AbilityInfoScreen.OnOkButtonClick')
        button:SetActionSound("Menu_button_click")
        button:SetKeyEquivalent(KEY_ESCAPE)
    end
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:initContent(abilityId, bShowCheckBox)
    self.abilityId = abilityId
    
    local parent = self:GetObject('Match3HelpWindowSmall')
	local textScale = 0.6
	
	local targets        = {}
	targets['explosive'] = {'',       'no_eye', ''      }
    targets['knife']     = {'item6',  'item3',  'ice'   }
    targets['match']     = {'item8',  '',       'ice'   }
    targets['mirror']    = {'no_eye', '',       'no_ice'}
    targets['pick']      = {'item10', '',       'ice'   }
    targets['torch']     = {'item8',  '',       'ice'   }
	
	do
	    local anim = CreateAnimationByTextureName('data/Texture/GUI/Match3Help/big_ico/layer_big_'..self.abilityId..'.png')
        local obj  = self.screen:CreateObject('indicator',anim,-82,-68,1,0,1,1)
        obj:AttachTo(parent)
	end
	
	do
	    local anim = CreateAnimationByTextureName('data/Texture/GUI/Match3Help/LayerArrow.png')
        local obj  = self.screen:CreateObject('arrow',anim,0,-68,1,0,1,1)
        obj:AttachTo(parent)
	end
	
	do
	    local start_x =  82
	    local delta_y =  60
	    local start_y = -68 - delta_y
	    
        for i=1, 3 do
            local target = targets[abilityId][i]
            
            if target ~= '' then
                local y = start_y + delta_y * (i-1)
                
                local anim = CreateAnimationByTextureName('data/Texture/GUI/Match3Help/small_ico/layer_small_'..target..'.png')
                local obj  = self.screen:CreateObject('smallIndicator'..tostring(i),anim,start_x,y,1,0,1,1)
                obj:AttachTo(parent)
            end
        end
    end
	
	do
		local text = CreateTextEntity(HELP_FONT, 'MATCH3_ABILITY_INFO_TEXT_'..string.upper(self.abilityId))
		text:AttachTo(parent)
		text:SetX(0)
		text:SetY(60)
		text:SetZ(1)
		text:SetScale(textScale)
		text:SetSpacing(0.55)
		text:SetTracking(-10.5)
		text:SetTextAlignment(HGETEXT_CENTER + HGETEXT_TOP)
		text:SetBorderSize(300, 100)
	end
	
	if bShowCheckBox then
	    local tile = self.screen:GetObject('CheckboxTile')
	    local size = 25
	    
	    self.chBox = CreateCheckBox()
	    self.chBox:AttachTo(parent)
	    self.chBox:SetRect(tile:GetX() - size/2, tile:GetY() - size/2, size, size)
	    self.chBox:SetZ(2)
	    self.chBox:SetOnTexture("data/Texture/GUI/Match3Help/CheckboxTick.png")
	    self.chBox:SetState(0)
	    self.chBox:SetAction("OnChangeDontShowCheckBox", self)
	    
	    local text = CreateTextEntity(HELP_FONT, 'MATCH3_TUTORIAL_CHECKBOX')
		text:AttachTo(parent)
		text:SetX(-43)
		text:SetY(143)
		text:SetZ(1)
		text:SetScale(textScale)
		text:SetSpacing(0.55)
		text:SetTracking(-10.5)
		text:SetTextAlignment(HGETEXT_LEFT + HGETEXT_TOP)
		text:SetBorderSize(400, 0)
    else
        self:GetObject('CheckboxTile'):SetVisible(false)
	end
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:OnButtonPress(action)
	Helpers.CallFunctionByName(action, self)
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:OnOkButtonClick()
    self:Hide()
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:OnChangeDontShowCheckBox()
    local state = 'DONT_SHOW_STATE_ON_FIELD_ABILITY_'..string.upper(self.abilityId)
    
    if self.chBox:GetState() == 1 then
        if not HasGameState(state, 'true') then
            SetGameState(state, 'true')
        end
    else
        if HasGameState(state, 'true') then
            RemoveGameState(state, 'true')
        end
    end
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:OnUpdate(dt)
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:Show()
    local inventory = play_field:GetLevelScreen():GetInventory()
    self:GetTopLevelScreen():SetLayer( inventory:GetLayer() + 1 )

    SetCursor('CursorDefault')
    
	self.level.mouseBlocker:Push()
    PopUpScreensMgr:Push(self:GetTopLevelScreen())
end
-------------------------------------------------------------------------------

function Match3AbilityInfoScreen:Hide()
    self.level.mouseBlocker:Pop()
    PopUpScreensMgr:Pop()
end
-------------------------------------------------------------------------------

function CreateMatch3AbilityInfoScreen(abilityId, bShowCheckBox)
    local scr = CreateScriptedScreen('data/Scripts/screens/Match3AbilityInfoScreen.lua', 'Match3AbilityInfoScreen')
	local screen = scr:GetAssociatedLuaObject();
	
	screen:initContent(abilityId, bShowCheckBox)
	screen:Show()
	
	return screen
end
--------------------------------------------------------------------------------

function CanShowMatch3AbilityInfoScreen(abilityId)
    local state = 'DONT_SHOW_STATE_ON_FIELD_ABILITY_'..string.upper(abilityId)
    return not HasGameState(state, 'true')
end
--------------------------------------------------------------------------------



--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function Match3AbilityInfoScreen:LoadData(screen)
	local anim
	anim = CreateAnimation('data/Texture/GUI/Match3Help/Match3HelpWindowSmall.png',0,0,414,496,1,0)
	anim:SetHotSpot(207,248)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Match3HelpWindowSmall',anim,512,384,1000,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_ok.png',0,0,230,74,3,0)
	anim:SetHotSpot(115,37)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_ok',anim,512,570,1001,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Match3Help/CheckboxTile.png',0,0,30,30,1,0)
	anim:SetHotSpot(15,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('CheckboxTile',anim,445,520,1001,0,1,1)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_block',anim,512,31,99,0,20,5)
	
	anim = CreateAnimation('data/Texture/GUI/Match3Help/Match3HelpTitle.png',0,0,174,22,1,0)
	anim:SetHotSpot(87,11)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Match3HelpTitle',anim,513,173,1001,0,1,1)
	
end
-- CLEAR_ON_SAVE_END
