GameScreen.textures_path = "graphics/screens/07_storeroom/location/"

GameScreen.hint_table = {
    {obj = {"basement_hint", 697, 153}, fun = function() if(GetState(CURRENT_SCREEN, "ho") == "completed") then return true end end},
}


function GameScreen:RestoreScene()
    if(GetState(CURRENT_SCREEN, "ho") == "") then
        SetState(CURRENT_SCREEN, "ho", "active")
        local tip_end = function()
        end
        self:StartHO();
        HUDScreen:ShowHintText({path = "graphics/screens/07_storeroom/location/hint_07", x = 427, y = 1128, end_fun = tip_end})
    elseif(GetState(CURRENT_SCREEN, "ho") == "active") then
        self:StartHO();
     elseif(GetState(CURRENT_SCREEN, "ho") == "completed") then   
        self:CreateObj(OBJ_TYPE.NO_ACTIVE, "locker_door_open", "graphics/screens/07_storeroom/location/locker_door_open", 241, 237);
        --self:ShowExit()
    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:CreateWallpaperPortal("note_07_part", "note_07_full",430, 178)
    self:SetItemCursor("note_07_part", "eye")
    self:AddHiddenCrystal("crystal_07_part")
    
    self:SetItemSound("bottles_02", "sound/bottles_bunch.ogg");
    self:SetItemSound("bottle_water", "sound/bottle_shake.ogg");
    self:SetItemSound("bottles_01", "sound/bottles_bunch_05.ogg");
    self:SetItemSound("paper_box", "sound/paper_box.ogg");
    self:SetItemSound("barrel", "sound/barrel_hit.ogg");
    self:SetItemSound("bottle_03", "sound/bottle_08.ogg");
    self:SetItemSound("bottle_02", "sound/bottle_06.ogg");
    self:SetItemSound("bottle_01", "sound/bottle_04.ogg");
    self:SetItemSound("soda_can_02", "sound/soda_can_open.ogg");
    self:SetItemSound("soda_can_01", "sound/soda_can_wobble.ogg");
    
    MusicPlay({"sound/ambient/07_09_ambient.ogg", "sound/music/basement.ogg"}, 7) 
    
    self:ShowExit()
end    
---------------------------------------------------------------------
function GameScreen:StartHO()
    local ho_end = function()  
        self.mini_game = nil;
        SetState(CURRENT_SCREEN, "ho", "completed") 
        SetState("screen_006_basement", "state", "store_room_finish") 
        --self:ShowExit()
        HUDScreen:ShowTips({path = "graphics/screens/07_storeroom/location/Text_07", x = 310, y = 1112})
    end

    local locker_click = function()
        if(GetState(CURRENT_SCREEN, "locker_door") == "") then
            SoundPlay("sound/small_metal_door.ogg")
            ItemRemove(self.name, "locker_door_eye")
            self:CreateObj(OBJ_TYPE.NO_ACTIVE, "locker_door_open", "graphics/screens/07_storeroom/location/locker_door_open", 241, 237);
            self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "pitchfork", "graphics/screens/07_storeroom/location/pitchfork_part", 250, 463);
            SetState(CURRENT_SCREEN, "locker_door", "open")
        end
    end
    self.item_list = {
        {obj = {"rake", {x = 381, y = 401}}, },
        {obj = {"sickle", {x = 1390, y = 882}}, },
        {obj = {"shovel", {x = 970, y = 136}}, },
        {obj = {"scythe", {x = 849, y = 406}}, },
        {obj = {"pitchfork", {x = 241, y = 443}},  intaractive = {"locker_door_eye", "locker_door_hint", 233, 234, locker_click}},
        {obj = {"pickaxe", {x = 786, y = 883}},},
        {obj = {"knife", {x = 605, y = 503}}, },
        {obj = {"hammer", {x = 354, y = 134}}, },
        {obj = {"crowbar", {x = 1474, y = 134}}, },
        {obj = {"cleaver", {x = 857, y = 807}}, },
        {obj = {"bat", {x = 509, y = 1009}}, },
        {obj = {"axe", {x = 25, y = 854}}, },
    }
    self:SetItemCursor("locker_door_eye", "eye")
    if(GetState(CURRENT_SCREEN, "locker_door") == "open") then
        ItemRemove(self.name, "locker_door_eye")
        self:CreateObj(OBJ_TYPE.NO_ACTIVE, "locker_door_open", "graphics/screens/07_storeroom/location/locker_door_open", 241, 237);
        self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "pitchfork", "graphics/screens/07_storeroom/location/pitchfork_part", 250, 463);
    end
    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, ho_end, true);
end

function GameScreen:ShowExit()
    self:CreateObj(OBJ_TYPE.TRIGGER, "basement_hand", "graphics/screens/07_storeroom/location/basement_hand", 711, 167);
    self:CreateLocationPortal("basement_hand", "006_basement", "hand")
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "07_background", "graphics/screens/07_storeroom/location/07_storeroom", 0, 0);
	
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_02", "graphics/screens/07_storeroom/location/bottles_02", 1195, 275);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_water", "graphics/screens/07_storeroom/location/bottle_water", 1164, 298);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_01", "graphics/screens/07_storeroom/location/bottles_01", 1135, 815);
    self:CreateObj(OBJ_TYPE.TRIGGER, "paper_box", "graphics/screens/07_storeroom/location/paper_box", 1146, 155);
    self:CreateObj(OBJ_TYPE.TRIGGER, "barrel", "graphics/screens/07_storeroom/location/barrel", 766, 649);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_03", "graphics/screens/07_storeroom/location/bottle_03", 1133, 310);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_02", "graphics/screens/07_storeroom/location/bottle_02", 849, 1071);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_01", "graphics/screens/07_storeroom/location/bottle_01", 276, 970);
    self:CreateObj(OBJ_TYPE.TRIGGER, "soda_can_02", "graphics/screens/07_storeroom/location/soda_can_02", 1323, 894);
    self:CreateObj(OBJ_TYPE.TRIGGER, "soda_can_01", "graphics/screens/07_storeroom/location/soda_can_01", 271, 1089);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "rake_shadow", "graphics/screens/07_storeroom/location/rake_shadow", 343, 420);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "rake", "graphics/screens/07_storeroom/location/rake_part", 360, 421);

    self:CreateObj(OBJ_TYPE.TRIGGER, "locker_door_eye", "graphics/screens/07_storeroom/location/locker_door_eye", 249, 246);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sickle", "graphics/screens/07_storeroom/location/sickle_part", 1407, 895);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "shovel", "graphics/screens/07_storeroom/location/shovel_part", 998, 175);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "scythe", "graphics/screens/07_storeroom/location/scythe_part", 859, 399);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "pickaxe", "graphics/screens/07_storeroom/location/pickaxe_part", 1011, 1004);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "knife", "graphics/screens/07_storeroom/location/knife_part", 697, 498);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "hammer", "graphics/screens/07_storeroom/location/hammer_part", 393, 164);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crowbar", "graphics/screens/07_storeroom/location/crowbar_part", 1492, 139);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "cleaver", "graphics/screens/07_storeroom/location/cleaver_part", 929, 750);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "bat", "graphics/screens/07_storeroom/location/bat_part", 620, 988);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "axe", "graphics/screens/07_storeroom/location/axe_part", 133, 746);

    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_07_part", "graphics/screens/07_storeroom/location/crystal_07_part", 1361, 907);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "note_07_part", "graphics/screens/07_storeroom/location/note_07_part", 547, 1047);
         
    
    clScreenManager:add_screen("hud") 
end