-- animations -----------------------------------------------------------------
dofile('data/Scripts/scenes/06_garden/anim/06_garden_anim_bg.lua')
dofile('data/Scripts/scenes/06_garden/anim/06_garden_anim_z_ladder.lua')
dofile('data/Scripts/scenes/06_garden/anim/06_garden_anim_z_tree.lua')
dofile('data/Scripts/scenes/06_garden/anim/06_garden_anim_z_gate.lua')
--dofile('data/Scripts/scenes/06_garden/anim/06_garden_anim_butterfly.lua')

-- comics ---------------------------------------------------------------------
dofile('data/Scripts/scenes/06_garden/comics/06_garden_comics_mike.lua')
dofile('data/Scripts/scenes/06_garden/comics/06_garden_comics_dupin.lua')

class 'l_06_garden' (LevelEventHandler)

function l_06_garden:__init(name)
	LevelEventHandler.__init(self, name)
	
	-- animations ----------------------------------
	self.anim_bg = AnimationBundle(Loader_06_BG_Animations(Object('bg')))
	self.anim_bg:PlayAnimation('front')
	self.anim_bg:PlayAnimation('back')
	self.anim_bg:PlayAnimation('back_sky')
	
	-- link scenes ---------------------------------
	LinkScene('area_link_04', 'CursorDoorDown',   'l_04_guest_room')
	LinkScene('area_link_07', 'CursorDoorLeftUp', 'l_07_shed')
	LinkScene('area_link_08', 'CursorDoorUp',     'l_08_street')
	
	-- main logic ----------------------------------
	ObjectVisible('area_zoom_tree', false)
	ObjectVisible('area_zoom_bush', false)
	ObjectVisible('area_link_08',   false)
	-------------------------
	
	ObjectOpacity('layer_handle', 0)
	ObjectOpacity('layer_door_open', 0)
	ObjectOpacity('layer_ladder_on_tree', 0)
	ObjectOpacity('layer_gate_open', 0)
	ObjectOpacity('layer_ladder_2',     0)
	ObjectOpacity('layer_ladder_fixed', 0)
	-------------------------
	
	local function on_apply_ladder(e)
	    ObjectVisible(e.target, false)
	    
	    if e.save then
	        ObjectOpacity('layer_ladder_on_tree', 1)
	        ObjectVisible('area_zoom_tree', true)
	    else
	        local time = 0.5
	        ObjectOpacity('layer_ladder_on_tree', 1, time)
	        MakeSoundEntity('06_apply_ladder'):PlaySound(false)
	        
	        self.timer:Add( function()
	                            ObjectVisible('area_zoom_tree', true)
	                        end,
	                        time)
	    end
	end
	-------------------------
	
	CreateSmartZoomZone('bush')
	
	self:create_comics_mike()
	RegisterToolApplyInfo('06_ladder', 'area_apply_ladder', on_apply_ladder, 'BBT_06_NEED_APPLY_LADDER')
	-------------------------
	
	-- zoom zones ----------------------------------
	
	-- ZOOM DOOR
	do
	    CreateSmartZoomZone('door')
	    ---------------------
	    
	    ObjectOpacity('z_door_handle', 0)
	    ObjectOpacity('z_door_open',   0)
	    
	    ObjectVisible('area_link_07', false)
	    ObjectVisible('area_click_zd_handle', false)
	    ---------------------
	    
	    local function on_apply_ring_handle(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_door_handle', 1)
	            ObjectOpacity('layer_handle',  1)
	            ObjectVisible('area_click_zd_handle', true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_door_handle', 1, time)
	            ObjectOpacity('layer_handle',  1, time)
	            
	            MakeSoundEntity('06_apply_ring_handle'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_click_zd_handle', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_click_handle(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_door_open',     1)
	            ObjectOpacity('layer_door_open', 1)
                ObjectOpacity('layer_handle',    0)
	                                
	            self.zoom_door:CloseAndDisable()
	            ObjectsVisible('area_link_07', true)
	        else
	            local close_zoom_daley = 0.5
	            local time = 0.5
	            Object('z_door_handle'):Rotate(math.rad(15), time)
	            
	            self.mouseBlocker:Push()
	            self.timer:Add( function()
	                                local open_door_time = 0.5
	                                ObjectOpacity('z_door_open',     1, open_door_time)
	                                ObjectOpacity('layer_door_open', 1, open_door_time)
	                                ObjectOpacity('layer_handle',    0, open_door_time)
	                                
	                                MakeSoundEntity('06_open_door'):PlaySound(false)
	                                
	                                self.timer:Add( function()
                                                        self.mouseBlocker:Pop()
                                                        self.zoom_door:CloseAndDisable()
                                                        
                                                        ObjectsVisible('area_link_07', true)
                                                    end,
                                                    open_door_time + close_zoom_daley)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    RegisterToolApplyInfo('06_ring_handle', 'area_apply_zd_ring_handle', on_apply_ring_handle, 'BBT_06_NEED_APPLY_RING_HANDLE')
	    RegisterActiveObject('area_click_zd_handle', on_click_handle)
	end
	
	-- ZOOM LADDER
	do
	    CreateSmartZoomZone('ladder')
	    ---------------------
	    
	    self.anim_ladder = AnimationBundle(Loader_06_Zoom_Ladder_Animations(Object('z_ladder_bg')))
	    self.anim_ladder:PlayAnimation('front')
	    self.anim_ladder:PlayAnimation('back')
	    self.anim_ladder:PlayAnimation('grass')
	    ---------------------
	    
	    local x,y,w,h = self.zoom_ladder:GetClippingInfo()
	    local zoomRect = {x=x, y=y, w=w, h=h}
	    
	    self.anim_ladder:GetAnimation('front'):SetClippingRect(x,y,w,h)
	    self.anim_ladder:GetAnimation('back'):SetClippingRect(x,y,w,h)
	    self.anim_ladder:GetAnimation('grass'):SetClippingRect(x,y,w,h)
	    
	    Object('z_ladder_bar_1'):SetClippingRect(x,y,w,h)
	    Object('z_ladder_bar_2'):SetClippingRect(x,y,w,h)
	    
	    self.barsDropped = 0
	    ---------------------
	    
	    ObjectOpacity('z_ladder_step_1', 0)
	    ObjectOpacity('z_ladder_step_2', 0)
	    ObjectOpacity('z_ladder_rope',   0)
	    
	    ObjectVisible('area_apply_zl_rope',  false)
	    ObjectVisible('area_find_zl_ladder', false)
	    ---------------------
	    
	    local function on_get_bar(e)
	        local time = 0.1
	        local id   = string.sub(e.objName, -1)
	        
	        ObjectOpacity('z_ladder_shadow_'..id, 0, time)
	    end
	    ---------------------
	    
	    local function on_drop_bar(e)
	        local time = 0.1
	        local id   = string.sub(e.objName, -1)
	        
	        self.timer:Add( function()
	                            ObjectOpacity('z_ladder_shadow_'..id, 1, time)
	                        end,
	                        math.max(0, e.time - time))
	    end
	    ---------------------
	    
	    local function on_drop_target_bar(e)
	        local id = string.sub(e.objName, -1)
	        
	        if e.save then
	            ObjectOpacity('z_ladder_step_'..id,   1)
	            ObjectOpacity('z_ladder_shadow_'..id, 0)
	            ObjectOpacity(e.objName,              0)
	            
	            self.barsDropped = self.barsDropped + 1
	            
	            if self.barsDropped == 2 then
                    ObjectVisible('area_apply_zl_bars', false)
                    ObjectVisible('area_apply_zl_rope', true)
                    ObjectOpacity('layer_ladder',   0)
                    ObjectOpacity('layer_ladder_2', 1)
                else
                    play_field:DoNotIgnoreOnTestPoint('area_apply_zl_bars')
                end
	        else
	            local time = 0.5
	            
	            ObjectOpacity('z_ladder_step_'..id, 1, time)
	            ObjectOpacity(e.objName,            0, time)
	            
	            if not self.sound_drop_board then
	                self.sound_drop_board = MakeSoundEntity('06_drop_board')
	            end
	            
	            self.sound_drop_board:StopSound()
	            self.sound_drop_board:PlaySound(false)
	            
	            self.timer:Add( function()
	                                self.barsDropped = self.barsDropped + 1
	                                
	                                if self.barsDropped == 2 then
	                                    ObjectVisible('area_apply_zl_bars', false)
	                                    ObjectVisible('area_apply_zl_rope', true)
	                                    ObjectOpacity('layer_ladder',   0)
	                                    ObjectOpacity('layer_ladder_2', 1)
	                                else
	                                    play_field:DoNotIgnoreOnTestPoint('area_apply_zl_bars')
	                                end
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_apply_rope(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('layer_ladder_fixed', 1)
	            ObjectOpacity('layer_ladder_2',     0)
	            
	            ObjectOpacity('z_ladder_rope', 1)
	            ObjectVisible('area_find_zl_ladder', true)
	        else
	            local time = 0.5
	            
	            ObjectOpacity('layer_ladder_fixed', 1, time)
	            ObjectOpacity('layer_ladder_2',     0, time)
	            
	            ObjectOpacity('z_ladder_rope', 1, time)
	            MakeSoundEntity('06_apply_rope'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_find_zl_ladder', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_find_ladder(e)
	        ObjectOpacity('layer_ladder_fixed', 0)
	        
	        if e.save then
                self.anim_ladder:StopAnimation('front')
                self.anim_ladder:StopAnimation('back')
                self.anim_ladder:StopAnimation('grass')
            else
                self.timer:Add( function()
                                    self.anim_ladder:StopAnimation('front')
                                    self.anim_ladder:StopAnimation('back')
                                    self.anim_ladder:StopAnimation('grass')
                                end,
                                0.3)
            end
	    end
	    ---------------------
	    local info1
	    local info2
	    
	    info1 = RegisterDragObject('z_ladder_bar_1', nil, 'area_apply_zl_bars', on_get_bar, on_drop_bar, on_drop_target_bar, zoomRect)
	    info2 = RegisterDragObject('z_ladder_bar_2', nil, 'area_apply_zl_bars', on_get_bar, on_drop_bar, on_drop_target_bar, zoomRect)
	    info1.deltaZ = 30
	    info2.deltaZ = 30
	    
	    RegisterMonologObject('area_apply_zl_bars', 'BBT_06_NEED_DROP_BARS')
	    RegisterToolApplyInfo('07_rope',  'area_apply_zl_rope',  on_apply_rope, 'BBT_06_NEED_APPLY_ROPE')
	    RegisterToolFindInfo('06_ladder', 'area_find_zl_ladder', on_find_ladder)
	end
	
	-- ZOOM TREE
	do
	    CreateSmartZoomZone('tree')
	    ---------------------
	    
	    ObjectVisible('area_apply_zt_axe',        false)
	    ObjectVisible('area_drop_target_zt_leaf', false)
	    ObjectVisible('area_get_zt_leaf',         false)
	    
	    ObjectOpacity('z_tree_pencil', 0)
	    ObjectOpacity('z_tree_sail',   0)
	    ---------------------
	    
	    self.anim_tree = AnimationBundle(Loader_06_Zoom_Tree_Animations(Object('z_tree_bg')))
	    self.anim_tree:GetAnimation('action'):SetClippingRect(self.zoom_tree:GetClippingInfo())
	    self.anim_tree:PlayAnimation('action')
	    ---------------------
	    
	    --self.anim_butterfly = AnimationBundle(Loader_06_Butterfly_Animations(Object('z_tree_bg')))
	    --self.anim_butterfly:GetAnimation('action'):SetClippingRect(self.zoom_tree:GetClippingInfo())
	    
	    if not HasActionCompletedState('butterfly_out') then
	        --self.anim_butterfly:PlayAnimation('idle')
	    end
	    ---------------------
	    
	    local function on_apply_pencil(e)
	        ObjectVisible(e.target, false)
	        ObjectVisible('area_hint_zt_leaf', false)
	        
	        if e.save then
	            ObjectOpacity('z_tree_pencil', 1)
	            ObjectVisible('area_drop_target_zt_leaf', true)
	            ObjectVisible('area_get_zt_leaf',         true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_tree_pencil', 1, time)
	            MakeSoundEntity('06_apply_pencil'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_drop_target_zt_leaf', true)
	                                ObjectVisible('area_get_zt_leaf',         true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_get_leaf(e)
	        if not HasActionCompletedState('butterfly_out') then
	            AddActionCompletedState('butterfly_out')
	            
                --self.anim_butterfly:StopAnimation('idle')
                --self.anim_butterfly:PlayAnimation('action')
            end
	    end
	    ---------------------
	    
	    local function on_drop_leaf(e)
	    end
	    ---------------------
	    
	    local function on_drop_target_leaf(e)
	        ObjectVisible('area_drop_target_zt_leaf', false)
	        ObjectVisible('area_get_zt_leaf',         false)
	        
	        if e.save then
	            ObjectOpacity('z_tree_sail', 1)
	            ObjectOpacity('z_tree_leaf', 0)
	            ObjectVisible('area_apply_zt_axe', true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_tree_sail', 1, time)
	            ObjectOpacity('z_tree_leaf', 0, time)
	            
	            MakeSoundEntity('06_drop_target_leaf'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_apply_zt_axe', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_apply_axe(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            FindTool('06_ship')
	            self.zoom_tree:CloseAndDisable()
	        else
	            local time = 0.5
	            ReopenScene('l_06_garden_hp')
	            
	            self.timer:Add( function()
	                                FindTool('06_ship')
	                                self.zoom_tree:CloseAndDisable()
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    RegisterToolApplyInfo('04_pencil', 'area_apply_zt_pencil', on_apply_pencil, 'BBT_06_NEED_APPLY_PENCIL')
	    RegisterMonologObject('area_hint_zt_leaf', 'BBT_06_NEED_DROP_LEAF')
	    RegisterMonologObject('area_drop_target_zt_leaf', 'BBT_06_NEED_DROP_LEAF')
	    RegisterDragObject('z_tree_leaf', 'area_get_zt_leaf', 'area_drop_target_zt_leaf', on_get_leaf, on_drop_leaf, on_drop_target_leaf, nil, true)
	    RegisterToolApplyInfo('07_axe',    'area_apply_zt_axe',    on_apply_axe,    'BBT_06_NEED_APPLY_AXE')
	end
	
	-- ZOOM GATE
	do
	    CreateSmartZoomZone('gate')
	    ---------------------
	    
	    ObjectVisible('area_link_zg_08', false)
	    ---------------------
	    
	    LinkScene('area_link_mg',    'CursorGlass',  'l_06_Ship')
	    LinkScene('area_link_zg_08', 'CursorDoorUp', 'l_08_street')
	    ---------------------
	    
	    self.anim_gate = AnimationBundle(Loader_06_Zoom_Gate_Animations(Object('z_gate_bg')))
	    self.anim_gate:PlayAnimation('front')
	    self.anim_gate:PlayAnimation('sky')
	    
	    do
	        local x,y,w,h = self.zoom_gate:GetClippingInfo()
	        self.anim_gate:GetAnimation('front'):SetClippingRect(x,y,w,h)
	        self.anim_gate:GetAnimation('sky'  ):SetClippingRect(x,y,w,h)
	    end
	    ---------------------
	    
	    ObjectOpacity('z_gate_open', 0)
	    ---------------------
	    
	    self.zoom_gate.on_open = function()
	        AddUniqueGameState('SCENE_06_ZOOM_GATE_OPEN', 'true')
	        
	        if IsMiniGameCompleted('l_06_Ship') then
	            ObjectVisible('area_link_mg', false)
	            
	            if not HasActionCompletedState('gate_opened') then
                    local delay = 0.5
                    
                    self.mouseBlocker:Push()
                    self.timer:Add( function()
                                        local time = 0.5
                                        ObjectOpacity('z_gate_close',    0, time)
                                        ObjectOpacity('z_gate_open',     1, time)
                                        ObjectOpacity('layer_gate_open', 1, time)
                                        
                                        MakeSoundEntity('06_open_gate'):PlaySound(false)
                                        AddActionCompletedState('gate_opened')
                                        
                                        self.timer:Add( function()
                                                            self.mouseBlocker:Pop()
                                                            
                                                            if IsToolFound('07_rope') then
                                                                self.zoom_gate:Disable()
                                                                
                                                                ObjectVisible('area_zoom_gate', false)
                                                                ObjectVisible('area_link_08',   true)
                                                            end
                                                            
                                                            ObjectVisible('area_link_zg_08', true)
                                                        end,
                                                        time + delay)
                                    end,
                                    ZOOM_ZONE_APPEARING_TIME + delay)
                end
	        end
	    end
	    ---------------------
	    
	    self.zoom_gate.on_close = function()
	        if HasGameState('SCENE_06_ZOOM_GATE_OPEN', 'true') then
	            RemoveGameState('SCENE_06_ZOOM_GATE_OPEN', 'true')
	        end
	    end
	    ---------------------
	    
	    local function on_find_rope(e)
	        ObjectVisible(e.target, false)
	        ObjectOpacity('z_gate_rope', 0)
	        
	        if HasActionCompletedState('gate_opened') then
                self.zoom_gate:Disable()
                
                ObjectVisible('area_zoom_gate',  false)
                ObjectVisible('area_link_08',    true)
            end
	    end
	    ---------------------
	    
	    if HasActionCompletedState('gate_opened') then
	        ObjectOpacity('z_gate_close',    0)
            ObjectOpacity('z_gate_open',     1)
            ObjectOpacity('layer_gate_open', 1)
            
            ObjectVisible('area_link_zg_08', true)
	    end
	    
	    --if HasActionCompletedState('gate_opened') then
	    --    ObjectVisible('area_zoom_gate', false)
	    --   ObjectVisible('area_link_08',   true)
	    --    ObjectOpacity('layer_gate_open', 1)
	    --    self.zoom_gate:Disable()
	    --else
	    do
            if HasGameState('SCENE_06_ZOOM_GATE_OPEN', 'true') then
                self.zoom_gate:Open(0)
            end
        end
        
        RegisterToolFindInfo('07_rope', 'area_find_zg_rope', on_find_rope, false)
	end
	
	-- ZOOM BUSH
	do
	    CreateSmartZoomZone('bush')
	    ---------------------
	    
	    self.zoom_bush.on_open = function()
	        self:GetPanelLuaObject():SetDogIcoVisible(false)
	        
	        if not HasActionCompletedState('DogAnimInBushCompleted') then
	            AddActionCompletedState('DogAnimInBushCompleted')
	            
	            self.video_zoom_digging_dog = CreateVideoEntity('data/Video/Scenes/06_garden/06_zoom_digging_dog.ogg', '', false)
                self.video_zoom_digging_dog:AttachTo(Object('z_bush_bg'))
                self.video_zoom_digging_dog:SetZ(1)
                self.video_zoom_digging_dog:SetXY(0, 0)
                self.video_zoom_digging_dog:SetLoop(false)
                self.video_zoom_digging_dog:SetHideOnStop(true)
                self.video_zoom_digging_dog:PlayVideo()
                
                MakeSoundEntity('06_dog_digs'):PlaySound(false)
	            
	            self.mouseBlocker:Push()
	            self.timer:Add( function()
	                                self.mouseBlocker:Pop()
	                                
                                    ObjectVisible('area_find_zb_bronze_bug', true)
	                            end,
	                            self.video_zoom_digging_dog:GetDuration())
            else
                ObjectVisible('area_find_zb_bronze_bug', true)
            end
        end
	    ---------------------
	    
	    self.zoom_bush.on_close = function()
	        self:GetPanelLuaObject():SetDogIcoVisible(true)
	        
	        self.timer:Add( function()
                                if not IsToolFound('06_bronze_bug') then
                                    InteractiveHelp.ShowTip('HO')
                                end
                            end,
                            0)
	    end
	    ---------------------
	    
	    local function on_find_bronze_bug(e)
	        ObjectVisible(e.target, false)
	        NotebookPushNote('note_06_bronze_bug')
	    end
	    ---------------------
	    
	    RegisterToolFindInfo('06_bronze_bug', 'area_find_zb_bronze_bug', on_find_bronze_bug)
	end
end

function l_06_garden:create_comics_mike()
    local comics_name = '06_comics_mike'
    local delay = 1
    
    local comics_finish = function(save)
        LinkScene('area_link_hp', 'CursorGlass', 'l_06_garden_hp', nil, nil, true)
        
        NotebookPushNote('note_06_mike')
        ObjectOpacity('layer_mike', 0)
        
        --if IsToolFound('06_ring_handle') then
        if HasGameState(TOOL_INFO_SHOWN, '06_ring_handle') then
            if IsToolFound('05_piece_of_cloth') then
                self:create_comics_dupin()
            end
        else
            FindTool('06_ring_handle')
        end
        
        self:registerPieceOfClothApply()
    end
    
    if IsComicsShown(comics_name) then
        ObjectVisible('area_comics_mike', false)
        comics_finish(true)
    else
        local comics_mike = l_06_garden_comics_mike()
		comics_mike:LoadData(play_field)
		
        local c = Comics(comics_name,
                            CreateComicsVideoFrame('Mike',  'C_06_MIKE_01', nil, {path      = 'data/Video/Scenes/06_garden/C_06_MIKE_01.ogg',
                                                                                  path_idle = 'data/Video/Scenes/06_garden/C_06_MIKE_01_idle.ogg', x=653, y=392}, 'comics_mike_bg')
                            )
                                      
        c.on_finish = function()
            comics_finish(false)
        end
        
        local function on_click_mike(e)
            ObjectVisible(e.target, false)
            
            SetForcedObject(nil)
            c:Start()
        end
        
        SetForcedObject('area_comics_mike')
        RegisterActiveObject('area_comics_mike', on_click_mike, nil, 'CursorGlass')
    end
end

function l_06_garden:create_comics_dupin()
    local comics_name = '06_comics_dupin'
    
    local comics_finish = function(save)
        if not InteractiveHelp.IsTipShown('USE_DOG') then
            InteractiveHelp.ShowTip('USE_DOG', nil, true)
        else
            if save then
                if IsToolApplied('05_piece_of_cloth') and not HasActionCompletedState('DogAnimInBushCompleted') then
                else
                    if not InteractiveHelp.IsTipShown('HO') then
                        self.mouseBlocker:Push()
                        self.timer:Add( function()
                                            self.mouseBlocker:Pop()
                                            InteractiveHelp.ShowTip('HO')
                                        end,
                                        0.5)
                    end
                end
            else
                InteractiveHelp.ShowTip('HO')
            end
        end
    end
    
    if IsComicsShown(comics_name) then
        comics_finish(true)
    else
        local comics = l_06_garden_comics_dupin()
		comics:LoadData(play_field)
		
        local c = Comics(comics_name,
                            CreateComicsVideoFrame('Dupin', 'C_06_DUPIN_01', nil, {path='data/Video/Scenes/06_garden/C_06_DUPIN_01.ogg', isAlpha=true, x=600, scale=1.4}, 'layer_comics_dupin_bg')
                            )
        
        Object('layer_comics_dupin_bg'):GetAnimation():SetColor('0x01FFFFFF')
        
        c.on_finish = function()
            comics_finish(false)
        end
        
        c:Start()
    end
end

function l_06_garden:registerPieceOfClothApply()
    local function on_apply_on_dog_piece_of_cloth(e)
	    ObjectVisible('area_zoom_bush', true)
	    
	    if e.save then
	        if not HasActionCompletedState('DogAnimInBushCompleted') then
	            
	            self.mouseBlocker:Push()
	            self.timer:Add( function()
	                                self.mouseBlocker:Pop()
	                                self.zoom_bush:Open()
	                            end,
	                            0.3)
	        end
	    else
	        self.zoom_bush:Open()
	    end
	end
	-------------------------
	
	RegisterToolApplyOnDogInfo('05_piece_of_cloth', on_apply_on_dog_piece_of_cloth, 'area_zoom_bush')
end

function l_06_garden:OnUpdate(dt)
end

function l_06_garden:OnAllItemsFound()
end

function l_06_garden:OnObjectMouseEnter(object)
end

function l_06_garden:OnObjectMouseLeave(object)
end

function l_06_garden:OnScreenObjectMouseDown(object, key)
end

function l_06_garden:OnObjectMouseDownProcessed(is_wrong_click)
end

function l_06_garden:OnMouseMove(previous_pos, current_pos)
end

function l_06_garden:OnObjectMouseUp(object)
end

function l_06_garden:OnObjectFound(object)
end

function l_06_garden:OnToolFound(tool)
end

function l_06_garden:OnToolApply(tool, object)
    if tool == '05_piece_of_cloth' and InteractiveHelp.IsTipShown('USE_DOG') then
        InteractiveHelp.ShowTip('HO')
    end
end

function l_06_garden:OnToolWindowClose(tool)
    if tool == '06_ring_handle' and not InteractiveHelp.IsTipShown('USE_DOG') then
        self.mouseBlocker:Push()
    end
    
    if tool == '06_bronze_bug' and not InteractiveHelp.IsTipShown('HO') then
        self.mouseBlocker:Push()
    end
end

function l_06_garden:OnToolAddToInventory(tool)
    if tool == '06_ring_handle' then
        if not InteractiveHelp.IsTipShown('USE_DOG') then
            self.mouseBlocker:Pop()
        end
        
        if IsToolFound('05_piece_of_cloth') then
            self:create_comics_dupin()
        end
    end
    
    if tool == '06_bronze_bug' then
        if not InteractiveHelp.IsTipShown('HO') then
            self.mouseBlocker:Pop()
        end
        
        InteractiveHelp.ShowTip('HO')
    end
end

function l_06_garden:OnObjectReachPanel(object)
end

function l_06_garden:OnButtonPress(title)
end

function l_06_garden:OnSetTool(tool)
end

function l_06_garden:OnLoaded()
end

function l_06_garden:OnDestroy()
end

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function l_06_garden:LoadData(screen)
	local anim
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/bg.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bg',anim,512,384,50,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_link_04',anim,512,700,100,0,128,17)
	
	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_link_07',anim,422,441,100,0,20,15)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_link_08',anim,698,304,100,0,1.2,1.2)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_tree',anim,82,202,100,0,1.2,0.8)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_ladder',anim,189,541,100,0,1.2,0.8)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_door',anim,408,439,100,0,0.8,0.8)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_gate',anim,698,304,100,0,1.2,1.2)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_apply_ladder',anim,89,268,100,0,1.2,2)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_comics_mike',anim,613,446,110,0,2,3)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_bush',anim,903,522,100,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_ladder.png',0,0,206,94,1,0)
	anim:SetHotSpot(103,47)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_ladder',anim,197,584,56,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_door_open.png',0,0,90,168,1,0)
	anim:SetHotSpot(45,84)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_door_open',anim,435,455,53,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_handle.png',0,0,16,10,1,0)
	anim:SetHotSpot(8,5)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_handle',anim,417,442,52,0,1,1)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_link_hp',anim,868,356,100,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_mike.png',0,0,256,372,1,0)
	anim:SetHotSpot(128,186)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_mike',anim,702,469,90,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_gate_open.png',0,0,125,110,1,0)
	anim:SetHotSpot(62,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_gate_open',anim,698,303,56,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_ladder_fixed.png',0,0,206,94,1,0)
	anim:SetHotSpot(103,47)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_ladder_fixed',anim,197,584,58,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_left_tree.png',0,0,290,560,1,0)
	anim:SetHotSpot(145,280)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_left_tree',anim,139,271,53,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_ladder_on_tree.png',0,0,136,488,1,0)
	anim:SetHotSpot(68,244)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_ladder_on_tree',anim,68,433,54,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_gnome.png',0,0,42,68,1,0)
	anim:SetHotSpot(21,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_gnome',anim,901,370,70,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/06_garden/main/layers/layer_ladder_2.png',0,0,206,94,1,0)
	anim:SetHotSpot(103,47)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_ladder_2',anim,197,584,57,0,1,1)
	
end
-- CLEAR_ON_SAVE_END
