GameScreen.textures_path = "graphics/screens/17_city/location/"

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/17_city/location/Hint_17", x = 510, y = 1127, end_fun = tip_end, loop = true})
    elseif(GetState(CURRENT_SCREEN, "ho") == "active") then
        self:StartHO();
    elseif(GetState(CURRENT_SCREEN, "ho") == "completed") then   
        clApplication:LoadLocation("018_teenager")
    end
    
    for found_item in string.gmatch(GetState(CURRENT_SCREEN, "found_obj"), "[_%a%d]+") do
		ItemRemove(self.name, found_item)
    end 
end


function GameScreen:InitScreen()
    self:LoadScreen()       
         
    self:RestoreScene();
    
    self:AddHiddenCrystal("crystal_17_part")
    
    self:SetItemSound("windows", "sound/glass_tap.ogg");
    self:SetItemSound("van", "sound/van_engine.ogg");
    self:SetItemSound("car", {"sound/car_horn_01.ogg", "sound/car_horn_02.ogg", "sound/sedan_engine.ogg"});
    self:SetItemSound("conditioner_02", "sound/conditioner.ogg");
    self:SetItemSound("conditioner_01", "sound/conditioner.ogg");
    self:SetItemSound("reservoir", "sound/compressor.ogg");
    self:SetItemSound("sewer", "sound/sewer.ogg");
    self:SetItemSound("glass_entrance", "sound/glass_tap.ogg");
    
    MusicPlay({"sound/music/past_garden.ogg", "sound/ambient/17_ambient.ogg"} , 17) 
end

---------------------------------------------------------------------
function GameScreen:StartHO()
    local ho_end = function()  
        HintTest:RemoveLoop()
        Tip:RemoveLoop()
        self.mini_game = nil;
        SetState(CURRENT_SCREEN, "ho", "completed") 
        DelayedExec(2.0, function()
            clApplication:LoadLocation("018_teenager")
        end)
    end

    self.item_list = {
        {obj = {"traffic_light", {x = 1485, y = 922}}, },
        {obj = {"yacht", {x = 1174, y = 223}}, hint = {x = 1420, y = 362}},
        {obj = {"bicycle", {x = 765, y = 2}}, },
        {obj = {"microwave", {x = 1292, y = 340}}, },
        {obj = {"cup", {x = 1046, y = 246}}, },
        {obj = {"curtain", {x = 745, y = 230}}, },
        {obj = {"basket", {x = 659, y = 194}},},
        {obj = {"tree", {x = 712, y = 388}}, },
        {obj = {"welcome", {x = 765, y = 914}}, },
        {obj = {"rails", {x = 432, y = 605}}, },
        {obj = {"timer", {x = 481, y = 428}}, },
        {obj = {"iceman", {x = 461, y = 78}}, },
        {obj = {"funicular", {x = 178, y = 179}}, },
        {obj = {"balloon", {x = 225, y = 728}}, },
    }

    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, ho_end, true);
end

function GameScreen:OnFinish()
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "17_city", "graphics/screens/17_city/location/17_city", 0, 0);
    self:CreateObj(OBJ_TYPE.TRIGGER, "windows", "graphics/screens/17_city/location/windows", 1154, 249);
    self:CreateObj(OBJ_TYPE.TRIGGER, "van", "graphics/screens/17_city/location/van", 530, 1068);
    self:CreateObj(OBJ_TYPE.TRIGGER, "car", "graphics/screens/17_city/location/car", 1077, 765);
    self:CreateObj(OBJ_TYPE.TRIGGER, "conditioner_02", "graphics/screens/17_city/location/conditioner_02", 1179, 416);
    self:CreateObj(OBJ_TYPE.TRIGGER, "conditioner_01", "graphics/screens/17_city/location/conditioner_01", 851, 248);
    self:CreateObj(OBJ_TYPE.TRIGGER, "reservoir", "graphics/screens/17_city/location/reservoir", 278, 904);
    self:CreateObj(OBJ_TYPE.TRIGGER, "sewer", "graphics/screens/17_city/location/sewer", 496, 964);
    self:CreateObj(OBJ_TYPE.TRIGGER, "glass_entrance", "graphics/screens/17_city/location/glass_entrance", 396, 502);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_17_part", "graphics/screens/17_city/location/crystal_17_part", 182, 595);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "traffic_light", "graphics/screens/17_city/location/traffic_light_part", 1500, 936);
 
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "yacht_shadow", "graphics/screens/17_city/location/yacht_shadow", 1252, 660);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "yacht", "graphics/screens/17_city/location/yacht_part", 1433, 380);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "bicycle", "graphics/screens/17_city/location/bicycle_part", 812, 43);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "microwave", "graphics/screens/17_city/location/microwave_part", 1353, 384);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "cup", "graphics/screens/17_city/location/cup_part", 1070, 265);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "curtain", "graphics/screens/17_city/location/curtain_part", 905, 251);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "basket", "graphics/screens/17_city/location/basket_part", 718, 228);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "tree_shadow", "graphics/screens/17_city/location/tree_shadow", 591, 788);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "tree", "graphics/screens/17_city/location/tree_part", 755, 448);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "welcome", "graphics/screens/17_city/location/welcome_part", 822, 960);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "rails_shadow", "graphics/screens/17_city/location/rails_shadow", 454, 599);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "rails", "graphics/screens/17_city/location/rails_part", 454, 609);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "timer", "graphics/screens/17_city/location/timer", 509, 452);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "iceman", "graphics/screens/17_city/location/iceman_part", 489, 134);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "funicular", "graphics/screens/17_city/location/funicular_part", 190, 194);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "balloon_shadow", "graphics/screens/17_city/location/balloon_shadow", 252, 753);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "balloon", "graphics/screens/17_city/location/balloon_part", 288, 769);
    
    clScreenManager:add_screen("hud") 
end
