function PanelOnSceneLoad(screen)
    game_state = {}

    LoadData(screen)

    custom_cursors = {}
    locked_objects = {}
    game_state.locker = ReferenceCounter()
    game_state.active_zone = nil
    game_state.locked_objects = {}
    game_state.active_objects = {}
	
	panel = screen
	local menu_bttn = create_button(screen, 'menu_bttn_panel_up', 'menu_bttn_panel_over', 'menu_bttn_panel_down', 'ExitPanel', 65, 736, 2)
	menu_bttn:SetHotKey(HGEK_ESCAPE)
	create_button(screen, 'help_bttn_panel_up', 'help_bttn_panel_over', 'help_bttn_panel_down', 'HelpPanel', 137, 736, 2)
	bttn_note = create_button(screen, 'button_note_up', 'button_note_over', 'button_note_down', 'NotePanel', 129, 622, 100)
	bttn_note:SetRect(-96, -76, 170, 160)
	
	screen:GetObject('open_note'):GetAnimation():Stop()
end

function OnSceneFree()
    FreeData()
end

function PanelOnScreenShown()
end

function PanelOnUpdate(dt)
    if not HasGameState("HintDelayValue") then
        AddGameState("HintDelayValue", "0")
    end
    SetGameState("HintDelayValue", tostring(play_field:GetLevelScreen():GetPhone():GetHintDelayValue()))
end

function PanelOnLose()
end

function PanelOnExit()
end

function PanelOnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function PanelOnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function PanelOnObjectMouseDown(object)
    obj_name = object:GetName()
    local pf = play_field
    local is_wrong_click = true

    is_wrong_click = DefaultOnObjectMouseDown(object)
    
    return is_wrong_click
end

function PanelOnObjectMouseUp(object)
end

function PanelOnObjectRightMouseDown(object)
end

function PanelOnObjectRightMouseUp(object)
end

function PanelOnObjectFound(object)
end

function PanelOnToolFound(tool)
end

function OnButtonMouseEnter(title)
end

function OnButtonMouseLeave(title)	
end

function PanelOnButtonPress(title)
    DefaultOnButtonPress(title)
    
    if title == 'ExitPanel' then
        CreateInGameMenu()
        
        return
    end
    
    if title == 'HelpPanel' then
        panel:SetAllowInput(false)
        
        local screen = load_screen('data/Lua/Screens/DialogHelp.lua')
        screen:SetLayer(LAYER_HELP)
        
        play_field:Stop()
        play_field:GetLevelScreen():Stop()
        return
    end
    
    if title == 'NotePanel' then
        panel:SetAllowInput(false)
        
        bttn_note:SetOpacity(0)
        panel:GetObject('open_note'):GetAnimation():SetMode(HGEANIM_FWD + HGEANIM_NOLOOP)
        panel:GetObject('open_note'):GetAnimation():Play()
        local length_anim = GetAnimationLength( panel:GetObject('open_note'):GetAnimation() )
        TimerDo(play_field:GetTimer(), length_anim - 0.1, function()
                                                        local screen = load_screen('data/Lua/Screens/DialogNotes.lua')
                                                        screen:SetLayer(LAYER_NOTES)
                                                        
                                                        play_field:Stop()
                                                        play_field:GetLevelScreen():Stop()
                                                    end)
        return
    end    
end

function PanelOnMouseMove(previous_pos, current_pos)
end

function PanelOnSetTool(tool)
end

function PanelOnMinigameCompleted()
end

function PanelOnLostFocus()
end

function PanelOnGainFocus()
end

-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/GUI/Panel/bg_panel.png',0,0,218,768,1,0)
	anim:SetHotSpot(109,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bg_panel',anim,109,384,1,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/help_bttn_panel.png',0,0,52,47,1,0)
	anim:SetHotSpot(26,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('help_bttn_panel_up',anim,970,498,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/help_bttn_panel.png',0,47,52,47,1,0)
	anim:SetHotSpot(26,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('help_bttn_panel_over',anim,970,408,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/help_bttn_panel.png',0,94,52,47,1,0)
	anim:SetHotSpot(26,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('help_bttn_panel_down',anim,969,453,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/menu_bttn_panel.png',0,0,88,40,1,0)
	anim:SetHotSpot(44,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('menu_bttn_panel_up',anim,65,736,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/menu_bttn_panel.png',0,40,88,40,1,0)
	anim:SetHotSpot(44,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('menu_bttn_panel_over',anim,915,254,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/menu_bttn_panel.png',0,80,88,40,1,0)
	anim:SetHotSpot(44,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('menu_bttn_panel_down',anim,916,291,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Button/button_note.png',0,0,113,44,1,0)
	anim:SetHotSpot(56,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('button_note_up',anim,129,622,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Button/button_note.png',0,44,113,44,1,0)
	anim:SetHotSpot(56,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('button_note_over',anim,740,367,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Button/button_note.png',0,88,113,44,1,0)
	anim:SetHotSpot(56,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('button_note_down',anim,741,415,100,0,1,1)
	local anim = CreateAnimation('data/Texture/GUI/Panel/open_note.png',0,0,210,227,9,10)
	anim:SetHotSpot(105,113)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('open_note',anim,105,626,20,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
