GameScreen.textures_path = "graphics/screens/23_wine/location/"

GameScreen.hint_table = {
    {obj = {"bottles_hint", 1059, 225}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "mg") then return true end end},
}

function GameScreen:RestoreScreen()
    ------------------------------------------------------------------------------------------------------------------------------ 
    --Первая загрузка екрана
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "state") == "") then
        --стартовый диало
    
        local tip_end = function()
            SetState(CURRENT_SCREEN, "state", "ho")
            self:StartHO();
            DelayedExec(1.0, function()
                
            end, 113)
        end
        HUDScreen:ShowTips({path = self.textures_path.."Text_23", x = 390, y = 1130, end_fun = tip_end})
    end
    ------------------------------------------------------------------------------------------------------------------------------ 
    --ХО
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "state") == "ho") then
        self:StartHO();
    end
    
    if(GetState(CURRENT_SCREEN, "state") == "mg") then
        self:CreateLocationPortal("bottles_eye", "mg_023_bottles", "eye")
    end
    
    if(GetState(CURRENT_SCREEN, "state") == "mg_completed") then
        clApplication:LoadLocation("024_fish")
    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("bottles_bunch_08", "sound/bottles_bunch.ogg");
    self:SetItemSound("bottles_bunch_07", "sound/bottles_bunch.ogg");
    self:SetItemSound("bottles_bunch_06", "sound/bottles_bunch.ogg");
    self:SetItemSound("bottles_bunch_05", "sound/bottles_bunch_05.ogg");
    self:SetItemSound("bottles_bunch_04", "sound/bottles_bunch_04.ogg");
    self:SetItemSound("bottles_bunch_03", "sound/bottles_bunch_03.ogg");
    self:SetItemSound("bottles_bunch_02", "sound/bottles_bunch_02.ogg");
    self:SetItemSound("bottles_bunch_01", "sound/bottles_bunch_01.ogg");
    self:SetItemSound("barrel_wood_01", "sound/barrel_wood_01.ogg");
    self:SetItemSound("barrel_wood_02", "sound/barrel_wood_02.ogg");
    self:SetItemSound("barrel_wood_03", "sound/barrel_wood_03.ogg");
    
    MusicPlay({"sound/ambient/23_27_ambient.ogg", "sound/music/past.ogg"} , 23) 
    
    self:AddHiddenCrystal("crystal_23_part")
    
    self:RestoreScreen()
end

function GameScreen:StartHO()    
    self.item_list = {
        {obj = {"mouse_12", {x = 1175, y = 926}}},
        {obj = {"mouse_11", {x = 746, y = 723}}},
        {obj = {"mouse_10", {x = 68, y = 815}}, },
        {obj = {"mouse_09", {x = 44, y = 264}}, },
        {obj = {"mouse_08", {x = 980, y = 121}}, },
        {obj = {"mouse_07", {x = 1283, y = 540}}, },
        {obj = {"mouse_06", {x = 950, y = 1058}}, },
        {obj = {"mouse_05", {x = 1408, y = 902}}, },
        {obj = {"mouse_04", {x = 626, y = 939}}, }, 
        {obj = {"mouse_03", {x = 348, y = 598}}, },
        {obj = {"mouse_02", {x = 213, y = 835}}, },
        {obj = {"mouse_01", {x = 534, y = 33}}, },
     }
    
    local on_finish = function()
        SetState(CURRENT_SCREEN, "state", "mg");
        self:CreateLocationPortal("bottles_eye", "mg_023_bottles", "eye")
        self.mini_game = nil
    end       
              
    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, on_finish, true);
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:UnLoadScreen()
    StopSound(self.music_id)
	cpp_application_remove_window(self.name);
	self.win = false;
end
------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "23_wine", "graphics/screens/23_wine/location/23_wine", 0, 0);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_08", "graphics/screens/23_wine/location/bottles_bunch_08", 1296, 1063);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_07", "graphics/screens/23_wine/location/bottles_bunch_07", 1144, 1014);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_06", "graphics/screens/23_wine/location/bottles_bunch_06", 1071, 996);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_05", "graphics/screens/23_wine/location/bottles_bunch_05", 1443, 899);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_04", "graphics/screens/23_wine/location/bottles_bunch_04", 1313, 813);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_03", "graphics/screens/23_wine/location/bottles_bunch_03", 1183, 796);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_02", "graphics/screens/23_wine/location/bottles_bunch_02", 1080, 826);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_bunch_01", "graphics/screens/23_wine/location/bottles_bunch_01", 827, 625);
    self:CreateObj(OBJ_TYPE.TRIGGER, "barrel_wood_01", "graphics/screens/23_wine/location/barrel_wood_01", 0, 604);
    self:CreateObj(OBJ_TYPE.TRIGGER, "barrel_wood_02", "graphics/screens/23_wine/location/barrel_wood_02", 125, 880);
    self:CreateObj(OBJ_TYPE.TRIGGER, "barrel_wood_03", "graphics/screens/23_wine/location/barrel_wood_03", 743, 772);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottles_eye", "graphics/screens/23_wine/location/bottles_eye", 1112, 276);

    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_23_part", "graphics/screens/23_wine/location/crystal_23_part", 733, 1052);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_12", "graphics/screens/23_wine/location/mouse_12_part", 1212, 939);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_11", "graphics/screens/23_wine/location/mouse_11_part", 791, 747);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_10", "graphics/screens/23_wine/location/mouse_10_part", 90, 838);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_09_shadow", "graphics/screens/23_wine/location/mouse_09_shadow", 58, 276);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_09", "graphics/screens/23_wine/location/mouse_09_part", 137, 284);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_08", "graphics/screens/23_wine/location/mouse_08_part", 1031, 142);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_07", "graphics/screens/23_wine/location/mouse_07_part", 1345, 571);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_06", "graphics/screens/23_wine/location/mouse_06_part", 994, 1079);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_05", "graphics/screens/23_wine/location/mouse_05_part", 1457, 922);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_04", "graphics/screens/23_wine/location/mouse_04_part", 676, 966);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_03", "graphics/screens/23_wine/location/mouse_03_part", 451, 633);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_02", "graphics/screens/23_wine/location/mouse_02_part", 273, 859);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "mouse_01", "graphics/screens/23_wine/location/mouse_01_part", 578, 61);


    clScreenManager:add_screen("hud")        
end