GameScreen.textures_path = "graphics/screens/19_house/location/"

GameScreen.hint_table = {
    {obj = {"wood_hint", 447, 358}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "wood1") then return true end end, tool = "key_020"},
    {obj = {"wood_hint", 447, 358}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "wood2") then return true end end},
    {obj = {"wizard_hint", 1327, 376}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "wizard") then return true end end}, 
    {obj = {"wizard_hint", 1327, 376}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "wizard2") then return true end end}, 
}


function GameScreen:RestoreScene()
    if(GetState(CURRENT_SCREEN, "state") == "") then
        SetState(CURRENT_SCREEN, "state", "wizard")
    elseif(GetState(CURRENT_SCREEN, "state") == "wizard") then    
    elseif(GetState(CURRENT_SCREEN, "state") == "wood2") then
        self:CreateLocationPortal("wood_hand", "021_wood", "hand")
    elseif(GetState(CURRENT_SCREEN, "state") == "wizard2") then   
        ItemRemove(self.name, "wood_hand")   
    end
    
    for found_item in string.gmatch(GetState(CURRENT_SCREEN, "found_obj"), "[_%a%d]+") do
		ItemRemove(self.name, found_item)
		ItemRemove(self.name, found_item.."_shadow")
    end 
end


function GameScreen:InitScreen()
    self:LoadScreen()       
         
    self:RestoreScene();

    self:SetItemSound("bottle_07", "sound/bottle_07.ogg");
    self:SetItemSound("bottle_08", "sound/bottle_08.ogg");
    self:SetItemSound("wood_creak_01", "sound/wood_creak_01.ogg");
    self:SetItemSound("big_black_pot", "sound/big_black_pot.ogg");
    self:SetItemSound("barrel_wood_03", "sound/barrel_wood_03.ogg");
    
    self:AddHiddenCrystal("crystal_19a")

    local key_apply = function()
        Inventory:ActiveToolApply()
        PlaySfx("sound/security_key.ogg")
        SetState(CURRENT_SCREEN, "wood_door", "open")
        SetState(CURRENT_SCREEN, "state", "wood2")
        self:CreateLocationPortal("wood_hand", "021_wood", "hand")      
    end
    self:AddToolApplyZone("wood_hand", "key_020", key_apply, true);


    self:CreateLocationPortal("attic_hand", "019_attic", "hand")      
    self:CreateLocationPortal("wizard_eye", "020_wizard", "eye")
    
    self:SetItemCursor("wood_hand", "hand")
    
    MusicPlay({"sound/ambient/19_ambient.ogg", "sound/music/past.ogg"} , 19) 
end

function GameScreen:onObjectClick(item_name)
    if(item_name == "wood_hand") then
        if(GetState(CURRENT_SCREEN, "wood_door") ~= "open")then
            SoundPlay("sound/security_door.ogg")
            HUDScreen:ShowTips({path = "graphics/screens/19_house/location/Text_19h", x = 698, y = 1130})
        else
            SoundPlay("sound/chief_door_open_02.ogg")
        end
    end
end    
    
function GameScreen:OnFinish()
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "19_house", "graphics/screens/19_house/location/19_house",0, 0);

    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_07", "graphics/screens/19_house/location/bottle_07",322, 826);
self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_08", "graphics/screens/19_house/location/bottle_08",899, 882);
self:CreateObj(OBJ_TYPE.TRIGGER, "wood_creak_01", "graphics/screens/19_house/location/wood_creak_01",52, 181);
self:CreateObj(OBJ_TYPE.TRIGGER, "big_black_pot", "graphics/screens/19_house/location/big_black_pot",973, 780);
self:CreateObj(OBJ_TYPE.TRIGGER, "barrel_wood_03", "graphics/screens/19_house/location/barrel_wood_03",108, 683);

    self:CreateObj(OBJ_TYPE.TRIGGER, "attic_hand", "graphics/screens/19_house/location/attic_hand",45, 16);
    self:CreateObj(OBJ_TYPE.TRIGGER, "wood_hand", "graphics/screens/19_house/location/wood_hand",461, 372);
    self:CreateObj(OBJ_TYPE.TRIGGER, "wizard_eye", "graphics/screens/19_house/location/wizard_eye",1342, 390);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_19a", "graphics/screens/19_house/location/crystal_19a_part",12, 978);
 
    clScreenManager:add_screen("hud") 
end
