class 'l_Raven' (BaseScreen)

function l_Raven:__init(name)
    BaseScreen.__init(self, name)  
    
    self.mouseBlocker			= MouseBlocker:new( self:getMainEntity() )
    self.mouseBlocker:push()
    
    self.element_select_actions = {['air'] = self.onAirSetClick, ['ground'] = self.onGroundSetClick, ['fire'] = self.onFireSetClick, ['water'] = self.onWaterSetClick}
    self.element_charge = {['air'] = self.onAirAddClick, ['ground'] = self.onGroundAddClick, ['fire'] = self.onFireAddClick, ['water'] = self.onWaterAddClick}
    self.element_focus_in = {['air'] = self.onBtnAirFocusIn, ['ground'] = self.onBtnGroundFocusIn, ['fire'] = self.onBtnFireFocusIn, ['water'] = self.onBtnWaterFocusIn}
    self.element_focus_out = {['air'] = self.onBtnAirFocusOut, ['ground'] = self.onBtnGroundFocusOut, ['fire'] = self.onBtnFireFocusOut, ['water'] = self.onBtnWaterFocusOut}
    self.fake_focus_in = {['air'] = self.onFakeAirFocusIn, ['ground'] = self.onFakeGroundFocusIn, ['fire'] = self.onFakeFireFocusIn, ['water'] = self.onFakeWaterFocusIn}
    self.fake_focus_out = {['air'] = self.onFakeAirFocusOut, ['ground'] = self.onFakeGroundFocusOut, ['fire'] = self.onFakeFireFocusOut, ['water'] = self.onFakeWaterFocusOut}
    
    local tutorial_not_show = true
    
    self.blackbar_panel = BlackBar(self)
    
    self:entityHide('bttn_air','bttn_fire','bttn_ground','bttn_water')

    
    local function setPercent(element)
        local percent = HasGameState('RAVEN_FEATURE_PERCENTAGE_BATTERY_' .. string.upper(element)) and GetGameState('RAVEN_FEATURE_PERCENTAGE_BATTERY_' .. string.upper(element)):get(0) or '0' 
        --self:getEntityNamed(element.. '_percent_text'):setText('+\n' .. percent .. '%')
        
        --[[if percent~='0' then
            self:getEntityNamed('area_click_'.. element).onPress:add(bind(self.element_select_actions[element], self))
            self:getEntityNamed(element.. '_percent_text'):setColor(0, 0.7, 0, 1)
        else
            self:getEntityNamed(element.. '_percent_text'):setColor(0.7, 0, 0, 1)
        end
        --if percent~='100' then
            self:getEntityNamed(element .. '_percent_text').onPress:add(bind(self.element_charge[element], self))
        --end--]]
        
        if percent == '0' then
            --self:getEntityNamed(element .. '_percent_text').onPress:add(bind(self.element_charge[element], self))
            self:getEntityNamed('bttn_black_'.. element).onPress:add(bind(self.element_charge[element], self))
            if HasGameState('RavenElementFound', string.upper(element)) then
                self:getEntityNamed(element.. '_percent_text'):setVisible(true)                  
                self:getEntityNamed(element.. '_percent_text'):setText(0 .. '%')
            end
        else
            if HasGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element)) then    
                local count = GetGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element)):get(0) or '0'     
                if count * 1 ~= 0 --[[and count * 1 < 5--]] then
                    self:getEntityNamed('bttn_' .. element).onPress:add(bind(self.element_charge[element], self))
                    self:getEntityNamed('bttn_' .. element).onFocusIn:add(bind(self.element_focus_in[element], self))
                    self:getEntityNamed('bttn_' .. element).onFocusOut:add(bind(self.element_focus_out[element], self))                   
                --[[elseif count * 1 >= 5 then
                    self:getEntityNamed('bttn_black_'.. element).onPress:add(bind(self.element_charge[element], self))
                    self:getEntityNamed('bttn_' .. element).onPress:add(bind(self.element_charge[element], self))    
                    self:getEntityNamed('bttn_' .. element).onFocusIn:add(bind(self.element_focus_in[element], self))
                    self:getEntityNamed('bttn_' .. element).onFocusOut:add(bind(self.element_focus_out[element], self)) --]] 
                else
                    self:getEntityNamed('bttn_' .. element):setRespondable(false)
                end
                if count * 1 >= 5 then
                    self:getEntityNamed('bttn_black_'.. element).onPress:add(bind(self.element_charge[element], self))
                else
                    self:getEntityNamed('bttn_black_'.. element).onPress:add(bind(self.element_select_actions[element], self))
                end
            else
                self:getEntityNamed('bttn_black_'.. element).onPress:add(bind(self.element_select_actions[element], self))
            end        
            
        end
            
        local element_upper = string.upper(element)
        if HasGameState('RavenscreenCreateFromRavenMg', 'true') then
            RemoveGameState('RavenscreenCreateFromRavenMg', 'true')
            tutorial_not_show = false
        elseif HasGameState(InteractiveHelp.States.SHOWING_HELP, 'true') and not HasGameState('CHARGE_RAVEN_TUTORIAL_SHOWED') and HasGameState('RavenElementFound', 'AIR') and not HasGameState('RAVEN_CHARGED_WITH_CHEAT')
        and (element == 'air') then            
            self.timer:add(function()
                AddUniqueGameState('CHARGE_RAVEN_TUTORIAL_SHOWED', 'true')
                InteractiveHelp.registeredTips['CHARGE_RAVEN'].Constructor('CHARGE_RAVEN')                    
                --InteractiveHelp.showTip('CHARGE_RAVEN', 0.5)
            end, 0.4)
        end
    end
    
    self:getEntityNamed('bttn_black_air').onFocusIn:add(bind(self.onFocusInAir, self))
	self:getEntityNamed('bttn_black_air').onFocusOut:add(bind(self.onFocusOutAir, self))
	self:getEntityNamed('bttn_black_ground').onFocusIn:add(bind(self.onFocusInGround, self))
	self:getEntityNamed('bttn_black_ground').onFocusOut:add(bind(self.onFocusOutGround, self))
	self:getEntityNamed('bttn_black_water').onFocusIn:add(bind(self.onFocusInWater, self))
	self:getEntityNamed('bttn_black_water').onFocusOut:add(bind(self.onFocusOutWater, self))
	self:getEntityNamed('bttn_black_fire').onFocusIn:add(bind(self.onFocusInFire, self))
	self:getEntityNamed('bttn_black_fire').onFocusOut:add(bind(self.onFocusOutFire, self))
	
	self.timer:add(function()
	    self:getMainEntity().onPress:add(bind(self.onOkButtonClick, self))
	end, 2)

    
    local function hideNotFoundElement(element)
        if not HasGameState('RavenElementFound', string.upper(element)) then
            --self:entityHide(element)
            self:entityHide('anim_'..element)
            self:entityShow(element .. '_fake')
            self:getEntityNamed(element .. '_fake'):setOpacity(0)
            self:getEntityNamed(element .. '_fake').onFocusIn:add(bind(self.fake_focus_in[element], self))
            self:getEntityNamed(element .. '_fake').onFocusOut:add(bind(self.fake_focus_out[element], self))
        else
            self:getEntityNamed('bttn_black_' .. element):setVisible(true)
            self.timer:add(function()                
                self:getEntityNamed('bttn_black_' .. element):setRespondable(true)
                self:getEntityNamed('bttn_black_' .. element):setActive(true)
            end, 0.2)
            self:entityHide(element .. '_fake')
        end        
    end
    
    local function createElement(element)        
        hideNotFoundElement(element)
        self:showElementCircle(element)
        setPercent(element)
    end
    
    createElement('air')
    createElement('ground')
    createElement('fire')
    createElement('water')
    
    self:showTriangles()

        
    self:getEntityNamed('bttn_close').onPress:add(bind(self.onOkButtonClick, self))
    self:getEntityNamed('bttn_help_mg').onPress:add(bind(self.onMgHelpBttnClick, self))
    
    local function create_candle(x, y)
		local candle = CreateSpriteEntity('Data/Textures/GUI/Zoom/candle.png')
	    candle:attachTo(self:getMainEntity())
	    candle:setName('candle_raven')
	    candle:setScale(0.7,0.7)
	    candle:setXY(x, y)
	    candle:setAnimationSize(69, 143)
	    candle:setFramesCount(3)
	    candle:setFPS(12)
	    candle:setOrder(4)
	    candle:setMode(4)
	    self.object_candle = candle	    
	end
	create_candle(580, 160)
	self.object_candle:play()
	
	--self:getEntityNamed('bttn_fire'):setRespondable(false)
	--self:getEntityNamed('bttn_water'):setRespondable(false)
	
	self.timer:add(function()
	    self.mouseBlocker:pop()
	end, 0.5)
end

function l_Raven:showTriangles()
    local coords = { {{549, 470, 0.4}, {553, 467, 0.7}, {567, 488, 0.8}, {570, 491, 1}},
                     {{549, 354, 0.4}, {553, 323, 0.7}, {567, 296, 0.8}, {570, 273, 1}},
                     {{426, 350, 0.4}, {396, 318, 0.7}, {373, 295, 0.8}, {351, 278, 1}},
                     {{429, 469, 0.4}, {397, 467, 0.7}, {377, 481, 0.8}, {356, 484, 1}} }
    local elems = {'air', 'ground', 'water', 'fire'}
    local delta = {{1,1}, {1, -1}, {-1, -1}, {-1, 1}}
    for i = 1,4 do 
        if HasGameState('RAVEN_FEATURE_COUNT_' .. string.upper(elems[i])) then    
            local count = GetGameState('RAVEN_FEATURE_COUNT_' .. string.upper(elems[i])):get(0) or '0'     
            --[[if count * 1 > 4 then
                count = 4
            end--]]
            if count * 1 >= 5 then
                count = 5
            end
            if count ~= '0' then
                self:entityShow('tri_'..elems[i] .. '_' .. count)
                self:getEntityNamed('tri_'..elems[i] .. '_' .. count):setRespondable(false)
                if count * 1 < 5 then  
                    self:getEntityNamed('wildness_' .. elems[i]):setActive(true)              
                    self:getEntityNamed('wildness_' .. elems[i]):setVisible(true)
                    self:getEntityNamed('wildness_' .. elems[i]):setXY(coords[i][count * 1][1], coords[i][count * 1][2])
                    self:getEntityNamed('wildness_' .. elems[i]):setScale(coords[i][count * 1][3], coords[i][count * 1][3])
                end
            end
            self:getEntityNamed(elems[i].. '_percent_text'):setVisible(true)   
            self:getEntityNamed(elems[i].. '_percent_text'):setText((100 - 20*count) .. '%')
        end    
    end
end

function l_Raven:__finalize()
end

--[[function l_Raven:onShowLights(entity, state)
	 self:getEntityNamed('bg_lights'):setVisible(true)
end
function l_Raven:onHideLights(entity, state)
	self:getEntityNamed('bg_lights'):setVisible(false)
end--]]
function l_Raven:onFocusInAir()
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_air'):setVisible(true)
    self:getEntityNamed( 'air_element_glow'):setVisible(true)
    self:getEntityNamed( 'air_element_glow'):setActive(true)
    self:getEntityNamed( 'air_element_glow'):play()	
end
function l_Raven:onFocusOutAir()
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_air'):setVisible(false)
    self:getEntityNamed( 'air_element_glow'):setVisible(false)
    self:getEntityNamed( 'air_element_glow'):setActive(false)
    self:getEntityNamed( 'air_element_glow'):stop()	
end
function l_Raven:onFocusInGround()
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_ground'):setVisible(true)
    self:getEntityNamed( 'ground_element_glow'):setVisible(true)
    self:getEntityNamed( 'ground_element_glow'):setActive(true)
    self:getEntityNamed( 'ground_element_glow'):play()	
end
function l_Raven:onFocusOutGround()
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_ground'):setVisible(false)
    self:getEntityNamed( 'ground_element_glow'):setVisible(false)
    self:getEntityNamed( 'ground_element_glow'):setActive(false)
    self:getEntityNamed( 'ground_element_glow'):stop()	
end
function l_Raven:onFocusInWater()
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_water'):setVisible(true)
    self:getEntityNamed( 'water_element_glow'):setVisible(true)
    self:getEntityNamed( 'water_element_glow'):setActive(true)
    self:getEntityNamed( 'water_element_glow'):play()	
end
function l_Raven:onFocusOutWater()
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_water'):setVisible(false)
    self:getEntityNamed( 'water_element_glow'):setVisible(false)
    self:getEntityNamed( 'water_element_glow'):setActive(false)
    self:getEntityNamed( 'water_element_glow'):stop()	
end
function l_Raven:onFocusInFire()
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_fire'):setVisible(true)
    self:getEntityNamed( 'fire_element_glow'):setVisible(true)
    self:getEntityNamed( 'fire_element_glow'):setActive(true)
    self:getEntityNamed( 'fire_element_glow'):play()	
end
function l_Raven:onFocusOutFire()
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_fire'):setVisible(false)
    self:getEntityNamed( 'fire_element_glow'):setVisible(false)
    self:getEntityNamed( 'fire_element_glow'):setActive(false)
    self:getEntityNamed( 'fire_element_glow'):stop()
end
-------------------------------------------------------------------------
function l_Raven:onBtnAirFocusIn()
    self:entityShow('text_air')
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_air'):setVisible(true)
    self:getEntityNamed( 'air_glow'):setVisible(true)
    self:getEntityNamed( 'air_glow'):setActive(true)
    self:getEntityNamed( 'air_glow'):play()	
end
function l_Raven:onBtnAirFocusOut()
    self:entityHide('text_air')
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_air'):setVisible(false)
    self:getEntityNamed( 'air_glow'):setVisible(false)
    self:getEntityNamed( 'air_glow'):setActive(false)
    self:getEntityNamed( 'air_glow'):stop()
end
function l_Raven:onBtnGroundFocusIn()
    self:entityShow('text_ground')
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_ground'):setVisible(true)
    self:getEntityNamed( 'ground_glow'):setVisible(true)
    self:getEntityNamed( 'ground_glow'):setActive(true)
    self:getEntityNamed( 'ground_glow'):play()
end
function l_Raven:onBtnGroundFocusOut()
    self:entityHide('text_ground')
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_ground'):setVisible(false)
    self:getEntityNamed( 'ground_glow'):setVisible(false)
    self:getEntityNamed( 'ground_glow'):setActive(false)
    self:getEntityNamed( 'ground_glow'):stop()
end
function l_Raven:onBtnWaterFocusIn()
    self:entityShow('text_water')
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_water'):setVisible(true)
    self:getEntityNamed( 'water_glow'):setVisible(true)
    self:getEntityNamed( 'water_glow'):setActive(true)
    self:getEntityNamed( 'water_glow'):play()
end
function l_Raven:onBtnWaterFocusOut()
    self:entityHide('text_water')
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_water'):setVisible(false)
    self:getEntityNamed( 'water_glow'):setVisible(false)
    self:getEntityNamed( 'water_glow'):setActive(false)
    self:getEntityNamed( 'water_glow'):stop()
end
function l_Raven:onBtnFireFocusIn()
    self:entityShow('text_fire')
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_fire'):setVisible(true)
    self:getEntityNamed( 'fire_glow'):setVisible(true)
    self:getEntityNamed( 'fire_glow'):setActive(true)
    self:getEntityNamed( 'fire_glow'):play()
end
function l_Raven:onBtnFireFocusOut()
    self:entityHide('text_fire')
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_fire'):setVisible(false)
    self:getEntityNamed( 'fire_glow'):setVisible(false)
    self:getEntityNamed( 'fire_glow'):setActive(false)
    self:getEntityNamed( 'fire_glow'):stop()
end
-------------------------------------------------------------------------------------
function l_Raven:onFakeAirFocusIn()
    self:getEntityNamed('air_fake'):setOpacity(0.5)
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_air'):setVisible(true)
end
function l_Raven:onFakeAirFocusOut()
    self:getEntityNamed('air_fake'):setOpacity(0)
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_air'):setVisible(false)
end
function l_Raven:onFakeGroundFocusIn()
    self:getEntityNamed('ground_fake'):setOpacity(0.5)
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_ground'):setVisible(true)
end
function l_Raven:onFakeGroundFocusOut()
    self:getEntityNamed('ground_fake'):setOpacity(0)
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_ground'):setVisible(false)
end
function l_Raven:onFakeWaterFocusIn()
    self:getEntityNamed('water_fake'):setOpacity(0.5)
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_water'):setVisible(true)
end
function l_Raven:onFakeWaterFocusOut()
    self:getEntityNamed('water_fake'):setOpacity(0)
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_water'):setVisible(false)
end
function l_Raven:onFakeFireFocusIn()
    self:getEntityNamed('fire_fake'):setOpacity(0.5)
    self:getEntityNamed('bg_lights'):setVisible(false)
    self:getEntityNamed('bg_light_fire'):setVisible(true)
end
function l_Raven:onFakeFireFocusOut()
    self:getEntityNamed('fire_fake'):setOpacity(0)
    self:getEntityNamed('bg_lights'):setVisible(true)
    self:getEntityNamed('bg_light_fire'):setVisible(false)
end
-------------------------------------------------------------------------------------------
function l_Raven:onUpdate(dt)
end

function l_Raven:onAirAddClick()
    self:onScreenDestroy()
    createRavenAirMgScreen()
end

function l_Raven:showElementCircle(type)
    local percent = HasGameState('RAVEN_FEATURE_PERCENTAGE_BATTERY_' .. string.upper(type)) and GetGameState('RAVEN_FEATURE_PERCENTAGE_BATTERY_' .. string.upper(type)):get(0) or '0' 
    if percent == '100' then
        self:entityShow('bttn_'..type)
    elseif percent == '0' then
        self:getEntityNamed('anim_' .. type):stop()
    end
end

function l_Raven:setData(element, action, obj_name)
    self.element = element
    self.action = action
    self.obj_name = obj_name
    if self.element ~= nil and self.element == 'air' and not InteractiveHelp.isHelpCompleted('RAVEN_AIR_CLICK') and HasGameState('RAVEN_FEATURE_PERCENTAGE_BATTERY_AIR', '100') and 
    not IsLevelCollectorsEdition(current_scene:getPlayField().name) then
        InteractiveHelp.showTip('RAVEN_AIR_CLICK', 0.1)
    end
end

function l_Raven:onAirSetClick()
    if self.element == nil then
        --self:onScreenDestroy()
        self:showBlackBar('BBT_01_NEED_AREA_RAVEN')
    elseif self.element =='air' then        
        self:onScreenDestroy('air')
    else
        --self:onScreenDestroy()
        self:showBlackBar('BBT_WRONG_RAVEN_SELECTED')
    end
end

function l_Raven:onFireSetClick()
    if self.element == nil then
        --self:onScreenDestroy()
        self:showBlackBar('BBT_01_NEED_AREA_RAVEN')
    elseif self.element =='fire' then        
        self:onScreenDestroy('fire')
    else
        --self:onScreenDestroy()
        self:showBlackBar('BBT_WRONG_RAVEN_SELECTED')
    end
end

function l_Raven:onGroundSetClick()
    if self.element == nil then
        --self:onScreenDestroy()
        self:showBlackBar('BBT_01_NEED_AREA_RAVEN')
    elseif self.element =='ground' then
        self:onScreenDestroy('ground')
    else
        --self:onScreenDestroy()
        self:showBlackBar('BBT_WRONG_RAVEN_SELECTED')
    end
end

function l_Raven:onWaterSetClick()
    if self.element == nil then
        --self:onScreenDestroy()
        self:showBlackBar('BBT_01_NEED_AREA_RAVEN')
    elseif self.element =='water' then
        self:onScreenDestroy('water')
    else
        --self:onScreenDestroy()
        self:showBlackBar('BBT_WRONG_RAVEN_SELECTED')
    end
end

function l_Raven:onGroundAddClick()
    self:onScreenDestroy()
    createRavenGroundMgScreen()
end

function l_Raven:onWaterAddClick()
    self:onScreenDestroy()
    createRavenWaterMgScreen()   
end

function l_Raven:onFireAddClick()
    self:onScreenDestroy()
    createRavenFireMgScreen()    
end

-------------------------------------------------------------------------------
function l_Raven:showBlackBar(textKey, once, bTextAsIs)
	if not (once and self:isBlackBarShown(textKey)) then
		self.blackbar_panel:showText(textKey, bTextAsIs)
	end
end
-------------------------------------------------------------------------------
function l_Raven:hideBlackBar(bInstantly)
	self.blackbar_panel:hideText(bInstantly)
end
-------------------------------------------------------------------------------
function l_Raven:isBlackBarShown(textKey)
	return HasGameState(BLACK_BAR_SHOWN, textKey)
end

function l_Raven:onOkButtonClick()
    self:onScreenDestroy()
end

function l_Raven:onMgHelpBttnClick()
    createHelpRavenScreen()
end

function l_Raven:onExitToMainMenu()
    exitToMainMenu()
end

function l_Raven:onScreenDestroy(element)

    if element and (element==self.element) then
        local state_value = current_scene.name..'('..self.obj_name..')'
        AddGameState(RAVEN_APPLIED, state_value)
        current_scene:entityHide(self.obj_name)
        current_scene.playfield.hint:removeAdditionalHintObject(obj_name)
        if HasGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element)) then
            local count = GetGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element)):get(0) or '0' 
            RemoveGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element), count)
            count = string.upper(count * 1 + 1)
            AddGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element), count)
        else
            count = string.upper(1)
            AddGameState('RAVEN_FEATURE_COUNT_' .. string.upper(element), count)
        end
        
        if current_scene.playfield.active_objects[obj_name] and current_scene.playfield.active_objects[obj_name].connection then
            current_scene.active_objects[obj_name].connection:remove()
            current_scene.active_objects[obj_name].connection = nil
        end
        current_scene:getEntityNamed(self.obj_name):setCursorOverName('')
        self.action()
    end
    --[[if HasGameState('RAVEN_FEATURE_PERCENTAGE_BATTERY_AIR', '100') and not InteractiveHelp.isHelpCompleted('APPLY_RAVEN') and not HasGameState('RAVEN_CHARGED_WITH_CHEAT') then  --not show tutorial if used elementscharged command
	    InteractiveHelp.showTip('APPLY_RAVEN', 0)
	end--]]
    
    AudioManager:inGameResume()
    
    if HasGameState('05_Journalist_First_Show_Minigames') then
        RemoveGameState('05_Journalist_First_Show_Minigames')
        AddGameState('05_Journalist_Minigame_closed', 'true') 
    end
    if HasGameState('03_Worker_First_Show_Minigame') then
        RemoveGameState('03_Worker_First_Show_Minigame')
        AddGameState('03_Worker_Minigame_closed', 'true') 
    end
    if HasGameState('04_Witch_First_Show_Minigame') then
        RemoveGameState('04_Witch_First_Show_Minigame')
        AddGameState('04_Witch_Minigame_closed', 'true') 
    end
    
    PopUpScreensMgr:pop()
end

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

function l_Raven:CreateLoaderTable()
	local objects =
	{
		{ name = 'bg',  entityType = 'SpriteEntity',  x = 504,  y = 394,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/bg.png',  width = 420,  height = 470,  },
		{ name = 'bg_light_water',  entityType = 'SpriteEntity',  x = 508,  y = 435,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/power of Water.png',  width = 212,  height = 82,  },
		{ name = 'bg_light_ground',  entityType = 'SpriteEntity',  x = 504,  y = 429,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/power of Earth.png',  width = 204,  height = 72,  },
		{ name = 'bg_lights',  entityType = 'SpriteEntity',  x = 508,  y = 430,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/bg_lights.png',  width = 204,  height = 62,  },
		{ name = 'bg_light_air',  entityType = 'SpriteEntity',  x = 506,  y = 434,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/power of Air.png',  width = 174,  height = 62,  },
		{ name = 'bg_light_fire',  entityType = 'SpriteEntity',  x = 505,  y = 430,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/power of Fire.png',  width = 226,  height = 92,  },
		{ name = 'ground_fake',  entityType = 'SpriteEntity',  x = 622,  y = 318,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/ground_fake.png',  width = 172,  height = 174,  },
		{ name = 'fire_fake',  entityType = 'SpriteEntity',  x = 394,  y = 543,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/fire_fake.png',  width = 182,  height = 180,  },
		{ name = 'air_fake',  entityType = 'SpriteEntity',  x = 623,  y = 545,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/air_fake.png',  width = 178,  height = 178,  },
		{ name = 'water_fake',  entityType = 'SpriteEntity',  x = 394,  y = 318,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/water_fake.png',  width = 178,  height = 178,  },
		{ name = 'bttn_help_mg',  entityType = 'ButtonEntity',  x = 507,  y = 640,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/MG/bttn_help_mg.png.png',  activeRectX = 120,  activeRectY = 50,  },
		{ name = 'bttn_close',  entityType = 'ButtonEntity',  x = 576,  y = 179,  order = 5,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/Zoom/close.png',  activeRectX = 40,  activeRectY = 40,  },
		{ name = 'bttn_black_ground',  entityType = 'ButtonEntity',  x = 624,  y = 316,  order = 10,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/black_down.png',  activeRectX = 178,  activeRectY = 174,  },
		{ name = 'bttn_black_water',  entityType = 'ButtonEntity',  x = 393,  y = 317,  order = 10,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/black_down.png',  activeRectX = 178,  activeRectY = 174,  },
		{ name = 'bttn_black_fire',  entityType = 'ButtonEntity',  x = 393,  y = 543,  order = 10,  isVisible = false,  isRespondable = false,  isActive = false,  scale = -1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/black_down.png',  activeRectX = 178,  activeRectY = 174,  },
		{ name = 'bttn_black_air',  entityType = 'ButtonEntity',  x = 624,  y = 542,  order = 10,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/black_up.png',  activeRectX = 178,  activeRectY = 174,  },
		{ name = 'bttn_water',  entityType = 'ButtonEntity',  x = 356,  y = 278,  order = 12,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/bttn_water.png',  activeRectX = 98,  activeRectY = 54,  },
		{ name = 'text_water',  entityType = 'TextEntity',  parentName = 'bttn_water',  x = -5,  y = -42,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  text = '³äÄÜ',  font = 'Data/Fonts/inventory_item.fnt',  height = 25,  },
		{ name = 'bttn_ground',  entityType = 'ButtonEntity',  x = 662,  y = 276,  order = 12,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/bttn_ground.png',  activeRectX = 98,  activeRectY = 54,  },
		{ name = 'text_ground',  entityType = 'TextEntity',  parentName = 'bttn_ground',  x = 2,  y = -40,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  text = '³äÄÜ',  font = 'Data/Fonts/inventory_item.fnt',  height = 25,  },
		{ name = 'bttn_fire',  entityType = 'ButtonEntity',  x = 355,  y = 582,  order = 12,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/bttn_fire.png',  activeRectX = 98,  activeRectY = 54,  },
		{ name = 'text_fire',  entityType = 'TextEntity',  parentName = 'bttn_fire',  x = -6,  y = 37,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  text = '³äÄÜ',  font = 'Data/Fonts/inventory_item.fnt',  height = 25,  },
		{ name = 'bttn_air',  entityType = 'ButtonEntity',  x = 662,  y = 580,  order = 12,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/bttn_air.png',  activeRectX = 98,  activeRectY = 54,  },
		{ name = 'text_air',  entityType = 'TextEntity',  parentName = 'bttn_air',  x = 5,  y = 36,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  text = '³äÄÜ',  font = 'Data/Fonts/inventory_item.fnt',  height = 25,  },
		{ name = 'RavenAnim',  entityType = 'CompositionContainer',  x = 0,  y = 0,  order = 20,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Screens/Anim/RavenAnim.lua',  },
		{ name = 'anim_air',  entityType = 'CompositionSequence',  parentName = 'RavenAnim',  x = 0,  y = 0,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'anim_fire',  entityType = 'CompositionSequence',  parentName = 'RavenAnim',  x = 0,  y = 0,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'anim_ground',  entityType = 'CompositionSequence',  parentName = 'RavenAnim',  x = 0,  y = 0,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'anim_water',  entityType = 'CompositionSequence',  parentName = 'RavenAnim',  x = 0,  y = 0,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'water_percent_text',  entityType = 'TextEntity',  x = 412,  y = 341,  order = 22,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  text = '100',  font = 'Data/Fonts/puppy_name.fnt',  height = 30,  },
		{ name = 'tri_ground_5',  entityType = 'SpriteEntity',  x = 618,  y = 323,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 1.1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_down_5.png',  width = 141,  height = 148,  },
		{ name = 'tri_ground_4',  entityType = 'SpriteEntity',  x = 604,  y = 340,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 1.1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_down_4.png',  width = 117,  height = 119,  },
		{ name = 'tri_ground_3',  entityType = 'SpriteEntity',  x = 596,  y = 348,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 1.1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_down_3.png',  width = 102,  height = 104,  },
		{ name = 'tri_ground_2',  entityType = 'SpriteEntity',  x = 579,  y = 364,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_down_2.png',  width = 76,  height = 80,  },
		{ name = 'tri_ground_1',  entityType = 'SpriteEntity',  x = 565,  y = 377,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_down_1.png',  width = 51,  height = 54,  },
		{ name = 'tri_air_5',  entityType = 'SpriteEntity',  x = 619,  y = 537,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 1.1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_up_5.png',  width = 149,  height = 142,  },
		{ name = 'tri_air_4',  entityType = 'SpriteEntity',  x = 603,  y = 525,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 1.1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_up_4.png',  width = 120,  height = 118,  },
		{ name = 'tri_air_3',  entityType = 'SpriteEntity',  x = 596,  y = 517,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 1.1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_up_3.png',  width = 105,  height = 103,  },
		{ name = 'tri_air_2',  entityType = 'SpriteEntity',  x = 578,  y = 498,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_up_2.png',  width = 81,  height = 77,  },
		{ name = 'tri_air_1',  entityType = 'SpriteEntity',  x = 564,  y = 486,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_up_1.png',  width = 55,  height = 53,  },
		{ name = 'tri_water_5',  entityType = 'SpriteEntity',  x = 400,  y = 322,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1.1,  scaleY = 1.1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_down_5.png',  width = 141,  height = 148,  },
		{ name = 'tri_water_4',  entityType = 'SpriteEntity',  x = 418,  y = 343,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_down_4.png',  width = 117,  height = 119,  },
		{ name = 'tri_water_3',  entityType = 'SpriteEntity',  x = 425,  y = 350,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_down_3.png',  width = 102,  height = 104,  },
		{ name = 'tri_water_2',  entityType = 'SpriteEntity',  x = 439,  y = 364,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_down_2.png',  width = 76,  height = 80,  },
		{ name = 'tri_water_1',  entityType = 'SpriteEntity',  x = 451,  y = 377,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_down_1.png',  width = 51,  height = 54,  },
		{ name = 'tri_fire_5',  entityType = 'SpriteEntity',  x = 401,  y = 536,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1.1,  scaleY = 1.1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_up_5.png',  width = 149,  height = 142,  },
		{ name = 'tri_fire_4',  entityType = 'SpriteEntity',  x = 422,  y = 518,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_up_4.png',  width = 120,  height = 118,  },
		{ name = 'tri_fire_3',  entityType = 'SpriteEntity',  x = 429,  y = 510,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_up_3.png',  width = 105,  height = 103,  },
		{ name = 'tri_fire_2',  entityType = 'SpriteEntity',  x = 442,  y = 497,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/tri_up_2.png',  width = 81,  height = 77,  },
		{ name = 'tri_fire_1',  entityType = 'SpriteEntity',  x = 455,  y = 484,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Raven/tri_up_1.png',  width = 55,  height = 53,  },
		{ name = 'air_glow',  entityType = 'SpriteEntity',  x = 662,  y = 583,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 2,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/air_glow.png',  width = 72,  height = 72,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'water_glow',  entityType = 'SpriteEntity',  x = 354,  y = 280,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 2,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/ground_glow.png',  width = 72,  height = 72,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'air_element_glow',  entityType = 'SpriteEntity',  x = 611,  y = 538,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 4,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/air_element_glow.png',  width = 72,  height = 68,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'ground_element_glow',  entityType = 'SpriteEntity',  x = 606,  y = 351,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  angle = 30,  scale = 4,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/ground_element_glow.png',  width = 72,  height = 68,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'ground_glow',  entityType = 'SpriteEntity',  x = 662,  y = 278,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 2,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/ground_glow.png',  width = 72,  height = 72,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'fire_glow',  entityType = 'SpriteEntity',  x = 356,  y = 585,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scale = 2,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/ground_glow.png',  width = 72,  height = 72,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'fire_element_glow',  entityType = 'SpriteEntity',  x = 403,  y = 542,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  scaleX = -4,  scaleY = 4,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/air_element_glow.png',  width = 72,  height = 68,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'water_element_glow',  entityType = 'SpriteEntity',  x = 411,  y = 344,  order = 30,  isVisible = false,  isRespondable = false,  isActive = false,  angle = -30,  scaleX = -4,  scaleY = 4,  blend = RenderedObject.EBlendModeColorAdd,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Screens/Raven/ground_element_glow.png',  width = 72,  height = 68,  mode = 4,  fps = 12,  framesCount = 30,  },
		{ name = 'fire_percent_text',  entityType = 'TextEntity',  x = 410,  y = 531,  order = 31,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  text = '100',  font = 'Data/Fonts/puppy_name.fnt',  height = 30,  },
		{ name = 'air_percent_text',  entityType = 'TextEntity',  x = 606,  y = 529,  order = 31,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  text = '100',  font = 'Data/Fonts/puppy_name.fnt',  height = 30,  },
		{ name = 'ground_percent_text',  entityType = 'TextEntity',  x = 606,  y = 341,  order = 31,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  text = '100',  font = 'Data/Fonts/puppy_name.fnt',  height = 30,  },
		{ name = 'TrianglesAnim',  entityType = 'CompositionContainer',  x = 0,  y = 0,  order = 30,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Screens/Anim/TrianglesAnim.lua',  },
		{ name = 'wildness_ground',  entityType = 'CompositionSequence',  parentName = 'TrianglesAnim',  x = 549,  y = 354,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'wildness_water',  entityType = 'CompositionSequence',  parentName = 'TrianglesAnim',  x = 351,  y = 278,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'wildness_fire',  entityType = 'CompositionSequence',  parentName = 'TrianglesAnim',  x = 356,  y = 484,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'wildness_air',  entityType = 'CompositionSequence',  parentName = 'TrianglesAnim',  x = 567,  y = 488,  order = 0,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
	}
	return objects
end
