function GameScreen:RestoreScreen()
    ------------------------------------------------------------------------------------------------------------------------------ 
    --Первая загрузка екрана
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "state") == "") then
        local end_tip = function()
            DelayedExec(1.0, function()
                HUDScreen:ShowHintText({path = "graphics/screens/31_planets/location/Hint_31", x = 315, y = 1128, loop = true})
            end)
        end
        
        HUDScreen:ShowTips({path = "graphics/screens/31_planets/location/Text_31", x = 329, y = 1130, end_fun = end_tip})
        self:StartMG()
        self.active = true;
    elseif(GetState(CURRENT_SCREEN, "state") == "finish")then
        self:StartMG()
        clApplication:LoadLocation("032_fireflies")
    end
    
    
    
    for i = 1, 18 do
        if(GetState(CURRENT_SCREEN, self.part_table[i].name) == "1") then
            ItemRemove(self.name, self.part_table[i].name)
            CreateParticle(self, "31_planets", "gfx/stars.lua", ItemGetScrX(self.part_table[i].target) + ItemGetWidth(self.part_table[i].target) / 2, 
                        ItemGetScrY(self.part_table[i].target) + ItemGetHeight(self.part_table[i].target) / 2);
        end
    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()
   
    
    MusicPlay({"sound/ambient/01_04_31_ambient.ogg", "sound/music/spaceship.ogg"} , 31) 
    
    self:AddHiddenCrystal("crystal_31_part")
    HUDScreen:SetMiniGameMode() 
    
    self:RestoreScreen()
end
------------------------------------------------------------------------------------------------------
function GameScreen:StartMG()
    self.part_table = {}
    
    for i = 1, 18 do
        local part = {name = "projection_"..i, target = "face_"..i};
        table.insert(self.part_table, part)
    end
end
------------------------------------------------------------------------------------------------------
function GameScreen:get_part_by_name(item_name)
    for i = 1, 18 do
        if(item_name == self.part_table[i].name) then
            return self.part_table[i];
        end
    end
    
    return nil;
end
------------------------------------------------------------------------------------------------------
function GameScreen:onObjectClick(item_name)   
    if(not self.active) then return end    
    
    if(self.drag_item == nil) then
        local part = self:get_part_by_name(item_name)
        if(part) then
            SoundPlay("sound/planet_take.ogg")
            ItemSetType(part.name, OBJ_TYPE.NO_ACTIVE)
            SetVisibleCursor(false)
            DragObject.active = true;
            ItemAttachChild("drag_trigger_img", item_name)
            self.drag_item = {}
            self.drag_item.part = part;
            self.drag_item.start_x = ItemGetX(self.drag_item.part.name)
            self.drag_item.start_y = ItemGetY(self.drag_item.part.name)
        end
    else
        if(self.drag_item.part.target == item_name) then
            SoundPlay("sound/planet_insert.ogg")
            CreateParticle(self, "31_planets", "gfx/stars.lua", ItemGetScrX(self.drag_item.part.target) + ItemGetWidth(self.drag_item.part.target) / 2, 
                        ItemGetScrY(self.drag_item.part.target) + ItemGetHeight(self.drag_item.part.target) / 2);
            ItemRemove(self.name, self.drag_item.part.name, 0.3)
            SetState(CURRENT_SCREEN, self.drag_item.part.name, "1") 
            
            if(self:IsMinigameCompleted()) then
                DelayedExec(1.0, function()
                    self:OnFinish();
                end, 113)        
            end
        else
            SoundPlay("sound/interface/wrong.ogg")
            ItemSetType(self.drag_item.part.name, OBJ_TYPE.ACTIVE_ALL);
            ItemAttachChild(self.name, self.drag_item.part.name);
            ItemSetDepth(self.drag_item.part.name, LAYERS.FRONT_MOST);
            ItemMoveTo(self.drag_item.part.name, self.drag_item.start_x, self.drag_item.start_y, 0.3);
        end
        
        DragObject.active = false;
        SetVisibleCursor(true);
        self.drag_item = nil;
    end
end
------------------------------------------------------------------------------------------------------
function GameScreen:IsMinigameCompleted()
    for i = 1, 18 do
        if(GetState(CURRENT_SCREEN, self.part_table[i].name) ~= "1") then
            return false;
        end
    end
    
    return true;
end
------------------------------------------------------------------------------------------------------
function GameScreen:OnSkip()
    for i = 1, 18 do
        SetState(CURRENT_SCREEN, self.part_table[i].name, "1")
        ItemRemove(self.name, self.part_table[i].name)
    end
    HUDScreen:SetInvntoryOnlyMode()
    
    DelayedExec(1.0, function()
        self:OnFinish();
    end, 113)
end    
------------------------------------------------------------------------------------------------------
function GameScreen:OnFinish()
    self.active = false;
    SetState(CURRENT_SCREEN, "state", "finish");
    
    DelayedExec(1.0, function()
        clApplication:LoadLocation("032_fireflies")
    end, 113)
end
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:Update()
    if(self.drag_item) then
        ItemSetPosition(self.drag_item.part.name, messenger_table.mouse_X - ItemGetWidth(self.drag_item.part.name) / 2,
                                                   messenger_table.mouse_Y - ItemGetHeight(self.drag_item.part.name) / 2);
    end 
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "31_planets", "graphics/screens/31_planets/location/31_planets", 0, 0);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_31_part", "graphics/screens/31_planets/location/crystal_31_part", 84, 1072);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_18", "graphics/screens/31_planets/location/face_18", 877, 198);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_17", "graphics/screens/31_planets/location/face_17", 878, 504);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_16", "graphics/screens/31_planets/location/face_16", 1019, 200);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_15", "graphics/screens/31_planets/location/face_15", 1194, 503);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_14", "graphics/screens/31_planets/location/face_14", 1194, 806);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_13", "graphics/screens/31_planets/location/face_13", 1196, 458);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_12", "graphics/screens/31_planets/location/face_12", 878, 763);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_11", "graphics/screens/31_planets/location/face_11", 1336, 199);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_10", "graphics/screens/31_planets/location/face_10", 880, 459);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_9", "graphics/screens/31_planets/location/face_09", 877, 808);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_8", "graphics/screens/31_planets/location/face_08", 1196, 154);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_7", "graphics/screens/31_planets/location/face_07", 1335, 807);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_6", "graphics/screens/31_planets/location/face_06", 1194, 199);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_5", "graphics/screens/31_planets/location/face_05", 1020, 503);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_4", "graphics/screens/31_planets/location/face_04", 878, 155);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_3", "graphics/screens/31_planets/location/face_03", 1021, 809);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_2", "graphics/screens/31_planets/location/face_02", 1335, 503);
    self:CreateObj(OBJ_TYPE.TRIGGER, "face_1", "graphics/screens/31_planets/location/face_01", 1195, 762);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_18", "graphics/screens/31_planets/location/projection_18", 688, 903);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_17", "graphics/screens/31_planets/location/projection_17", 416, 903);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_16", "graphics/screens/31_planets/location/projection_16", 144, 903);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_15", "graphics/screens/31_planets/location/projection_15", 687, 752);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_14", "graphics/screens/31_planets/location/projection_14", 416, 752);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_13", "graphics/screens/31_planets/location/projection_13", 143, 752);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_12", "graphics/screens/31_planets/location/projection_12", 687, 600);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_11", "graphics/screens/31_planets/location/projection_11", 416, 600);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_10", "graphics/screens/31_planets/location/projection_10", 143, 601);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_9", "graphics/screens/31_planets/location/projection_09", 688, 449);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_8", "graphics/screens/31_planets/location/projection_08", 416, 450);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_7", "graphics/screens/31_planets/location/projection_07", 143, 449);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_6", "graphics/screens/31_planets/location/projection_06", 688, 298);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_5", "graphics/screens/31_planets/location/projection_05", 415, 298);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_4", "graphics/screens/31_planets/location/projection_04", 143, 298);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_3", "graphics/screens/31_planets/location/projection_03", 687, 147);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_2", "graphics/screens/31_planets/location/projection_02", 416, 147);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "projection_1", "graphics/screens/31_planets/location/projection_01", 143, 147);

    clScreenManager:add_screen("hud") 
end