local zoom_floor;

function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/24_Hold_Main.lua', 'quest')
    
    play_field:GetObject('area_crowbar_apply'):SetVisible(false);
    play_field:GetObject('area_floor_zoom'   ):SetVisible(false);
    play_field:GetObject('Nail_out'   ):SetOpacity(0);
    play_field:GetObject('layer_open' ):SetOpacity(0);
    play_field:GetObject('layer_open2'):SetOpacity(0);
    
    LinkScene( 'area_ho_steps',
               'CursorGlass',
               'data/Scenes/24_Hold_Steps_HO.lua',
               true);
    
    LinkScene( 'area_ho_floor',
               'CursorGlass',
               'data/Scenes/24_Hold_Floor_HO.lua',
               true);
    
    LinkScene( 'area_back',
               'CursorUpRight',
               'data/Scenes/23_Stateroom_Main.lua',
               false);
    
    zoom_floor = CreateZoomZone('area_floor_zoom',
                                'CloseZoomFloor',
                                'ZOOM_floor',   true,
                                'Layer_axe',    true);
    
    RegisterToolApplyInfo('24_combination_pliers', 'area_nail_in', nil, nil,    function(tool_name)
                                                                                    play_field:GetObject('area_nail_in'      ):SetVisible(false);
                                                                                    play_field:GetObject('area_crowbar_apply'):SetVisible(true);
                                                                                    
                                                                                    play_field:GetObject('Nail_in' ):ChangeOpacity(1, 0, 0.5);
                                                                                    play_field:GetObject('Nail_out'):ChangeOpacity(0, 1, 0.5);
                                                                                    
                                                                                    PlaySound('24_CombinationPliersApply');
                                                                                end,
                                                                                function(tool_name)
                                                                                    play_field:GetObject('area_nail_in'      ):SetVisible(false);
                                                                                    play_field:GetObject('area_crowbar_apply'):SetVisible(true);
                                                                                    
                                                                                    play_field:GetObject('Nail_in' ):SetOpacity(0);
                                                                                    play_field:GetObject('Nail_out'):SetOpacity(1);
                                                                                end,
                                                                                function(tool_name, target_name)
                                                                                    ShowMonolog('C_24_NAIL_HINT', 'C_24_NAIL_HINT');
                                                                                end);
                                                                                
    RegisterToolApplyInfo('24_crowbar', 'area_crowbar_apply', nil, nil,         function(tool_name)
                                                                                    local time = 0.5;
                                                                                    play_field:GetObject('area_crowbar_apply'):SetVisible(false);
                                                                                    play_field:GetObject('layer_open'):ChangeOpacity(0, 1, time);
                                                                                    
                                                                                    play_field:TimerDoString("play_field:GetObject('area_floor_zoom'):SetVisible(true);", time);
                                                                                    
                                                                                    PlaySound('24_CrowbarApply');
                                                                                end,
                                                                                function(tool_name)
                                                                                    play_field:GetObject('area_crowbar_apply'):SetVisible(false);
                                                                                    play_field:GetObject('area_floor_zoom'   ):SetVisible(true);
                                                                                    play_field:GetObject('layer_open'):SetOpacity(1);
                                                                                end,
                                                                                function(tool_name, target_name)
                                                                                    ShowMonolog('C_24_CROWBAR_APPLY_HINT', 'C_24_CROWBAR_APPLY_HINT');
                                                                                end);
    
    RegisterToolFindInfo('24_axe', 'Layer_axe',                                 function(tool_name)
                                                                                    zoom_floor.Disable();
                                                                                    
                                                                                    play_field:GetObject('layer_open'):SetOpacity(0);
                                                                                    play_field:GetObject('layer_open2'):SetOpacity(1);
                                                                                end,
                                                                                function(tool_name)
                                                                                    zoom_floor.Disable();
                                                                                    
                                                                                    play_field:GetObject('layer_open'):SetOpacity(0);
                                                                                    play_field:GetObject('layer_open2'):SetOpacity(1);
                                                                                end);
end

function OnSceneFree(screen)
    DefaultOnSceneFree()
    FreeData(screen)
end

function OnUpdate(dt)
    DefaultOnUpdate(dt)
end

function OnAllItemsFound()
    DefaultOnAllItemsFound()
end

function OnLose()
    DefaultOnLose()
end

function OnExit()
    DefaultOnExit()
end

function OnClose()
    DefaultOnClose()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnObjectMouseDown(object)
    local is_wrong_click = not DefaultOnObjectMouseDown(object)
    local obj_name = object:GetName()
    local pf = play_field

    DefaultOnObjectMouseDownProcessed(is_wrong_click);
end

function OnObjectMouseUp(object)
    DefaultOnObjectMouseUp(object)
end

function OnObjectFound(object)
    DefaultOnObjectFound(object)
end

function OnToolFound(tool)
    DefaultOnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnObjectReachPanel(object)
    DefaultOnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
    DefaultOnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
    DefaultOnSetTool(tool)
end

function LevelLoaded(level)
end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
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/Scenes/24_Hold/Zone_main/Layers/background.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('background',anim,512,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_ho_steps',anim,561,498,101,0,20,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_ho_floor',anim,219,533,101,0,20,20)
	local anim = CreateAnimation('data/Texture/Scenes/24_Hold/Zone_main/Layers/Nail_in.png',0,0,15,40,1,0)
	anim:SetHotSpot(7,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Nail_in',anim,387,640,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Hold/Zone_main/Layers/layer_open.jpg',0,0,130,99,1,0)
	anim:SetHotSpot(65,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_open',anim,375,629,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Hold/Zone_main/Layers/Nail_out.png',0,0,27,22,1,0)
	anim:SetHotSpot(13,11)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Nail_out',anim,333,653,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area_circle.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_nail_in',anim,390,638,104,0,0.5,0.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area_circle.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_crowbar_apply',anim,412,646,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,9)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim',anim,444,99,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,10)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim2',anim,903,109,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,8)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim3',anim,302,232,101,0,0.5,0.5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area_circle.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_floor_zoom',anim,392,640,105,0,0.8,0.8)
	local anim = CreateAnimation('data/Texture/Scenes/24_Hold/Zone_main/Zoom_floor/ZOOM_floor.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('ZOOM_floor',anim,512,384,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Hold/Zone_main/Zoom_floor/Layer_axe.jpg',0,0,215,197,1,0)
	anim:SetHotSpot(107,98)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Layer_axe',anim,501,404,151,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Hold/Zone_main/Layers/layer_open2.jpg',0,0,130,99,1,0)
	anim:SetHotSpot(65,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_open2',anim,375,629,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area_circle.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_back',anim,601,123,102,0,2.31,1.08)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
