GameScreen.textures_path = "graphics/screens/27_dressmaker/location/"

function GameScreen:RestoreScreen()
    ------------------------------------------------------------------------------------------------------------------------------ 
    --Первая загрузка екрана
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "ho") == "") then
        --стартовый диалог
        clScreenManager:add_screen("hud")   
    
        local comics_finish = function()
            SetState(CURRENT_SCREEN, "ho", "active")
            ItemChangeOpacity(HUDScreen.name, 1.0, 0.5)
            DelayedExec(1.0, function()
                self:StartHO();
            end, 113)
        end
        local comics = clScreenManager:add_screen("027_dressmaker_dlg") 	
        comics.on_finish = comics_finish;
    end
    ------------------------------------------------------------------------------------------------------------------------------ 
    --ХО
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "ho") == "active") then
        self:StartHO();
    end
    ------------------------------------------------------------------------------------------------------------------------------ 
    --после ХО
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "ho") == "completed") then
        clApplication:LoadLocation("028_cloakroom")
    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()
   
    ------------------------------------------------------------------------------------------------------------------------------ 
    --OTHER       
    self:SetItemSound("goblet", "sound/metal_pot_24.ogg");
    self:SetItemSound("bottle_02", "sound/bottle_08.ogg");
    self:SetItemSound("bottle_01", "sound/bottle_01.ogg");
    
    MusicPlay({"sound/ambient/23_27_ambient.ogg", "sound/music/past.ogg"} , 27) 
    
    self:AddHiddenCrystal("crystal_27")
    
    self:RestoreScreen()
end

function GameScreen:StartHO()    
    self.item_list = {
        {obj = {"thimble", {x = 585, y = 872}}},
        {obj = {"comb", {x = 1464, y = 397}}},
        {obj = {"press_iron", {x = 408, y = 727}}, },
        {obj = {"pincushion", {x = 405, y = 914}}, },
        {obj = {"spool_of_thread", {x = 602, y = 721}}, },
        {obj = {"crochet_hook", {x = 998, y = 578}}, },
        {obj = {"chalk", {x = 786, y = 1084}}, },
        {obj = {"scissors", {x = 1310, y = 888}}, },
        {obj = {"basket", {x = 388, y = 487}}, }, 
        {obj = {"skein", {x = 557, y = 353}}, },
        {obj = {"needle", {x = 206, y = 304}}, },
        {obj = {"jewel", {x = 917, y = 506}},  zoom = {"027_dressmaker_zoom", "box_hint", 552, 1020}, inv = "jewel_027"},
     }
    
    local on_finish = function()
        HUDScreen:SetInvntoryOnlyMode()
        SetState(CURRENT_SCREEN, "ho", "completed");
        self.mini_game = nil;
        Inventory:save_tool("jewel_027", true)
        
        clApplication.curret_win = clScreenManager:add_screen("tool_found_screen") 
        clApplication.curret_win._resource = "graphics/screens/27_dressmaker/location/object_found_27"
        clApplication.curret_win.end_fun = function()
            Inventory:ToolFound("jewel_027", 800, 600)
            local tip_end = function()
                DelayedExec(1.0, function()
                   clApplication:LoadLocation("028_cloakroom")
                end, 113)
            end
            DelayedExec(1.0, function()
                HUDScreen:ShowTips({path = self.textures_path.."Text_27", x = 381, y = 1131, end_fun = tip_end})
            end, 113)
        end
    end       
    
    clScreenManager:add_screen("hud")                  
    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, on_finish);
    self:ZoomZoneLink("box_eye", "027_dressmaker_zoom");
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "27_dressmaker", "graphics/screens/27_dressmaker/location/27_dressmaker", 0, 0);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "goblet", "graphics/screens/27_dressmaker/location/goblet", 1035, 663);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_02", "graphics/screens/27_dressmaker/location/bottle_02", 1252, 525);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_01", "graphics/screens/27_dressmaker/location/bottle_01", 515, 526);
    
    self:CreateObj(OBJ_TYPE.NO_ACTIVE, "crystal_27_shadow", "graphics/screens/27_dressmaker/location/crystal_27_shadow", 1426, 676);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_27", "graphics/screens/27_dressmaker/location/crystal_27_part", 1446, 677);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "thimble", "graphics/screens/27_dressmaker/location/thimble_part", 602, 897);
    self:CreateObj(OBJ_TYPE.TRIGGER, "box_eye", "graphics/screens/27_dressmaker/location/box_eye", 567, 1035);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "comb", "graphics/screens/27_dressmaker/location/comb_part", 1558, 435);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "press_iron", "graphics/screens/27_dressmaker/location/press_iron_part", 464, 789);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "pincushion", "graphics/screens/27_dressmaker/location/pincushion_part", 424, 943);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "spool_of_thread", "graphics/screens/27_dressmaker/location/spool_of_thread_part", 623, 761);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crochet_hook", "graphics/screens/27_dressmaker/location/crochet_hook_part", 1010, 557);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "chalk", "graphics/screens/27_dressmaker/location/chalk_part", 799, 1137);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "scissors", "graphics/screens/27_dressmaker/location/scissors_part", 1321, 874);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "basket", "graphics/screens/27_dressmaker/location/basket_part", 408, 506);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "skein", "graphics/screens/27_dressmaker/location/skein_part", 592, 389);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "needle", "graphics/screens/27_dressmaker/location/needle_part", 213, 312);
    
    --clScreenManager:add_screen("hud") 
end