GameScreen.textures_path = "graphics/screens/12_fresco/location/"

GameScreen.hint_table = {
    {obj = {"fresco_door_hint", 511, 354}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "mg" or GetState(CURRENT_SCREEN, "state") == "after_mg" or GetState(CURRENT_SCREEN, "state") == "finish") then return true end end},
}

function GameScreen:RestoreScene()
    if(GetState(CURRENT_SCREEN, "state") == "") then
        SetState(CURRENT_SCREEN, "state", "ho")
        local tip_end = function()
        end
        self:StartHO();
        HUDScreen:ShowTips({path = "graphics/screens/12_fresco/location/text_12", x = 315, y = 1112, end_fun = tip_end})
    elseif(GetState(CURRENT_SCREEN, "state") == "ho") then
        self:StartHO();
    elseif(GetState(CURRENT_SCREEN, "state") == "mg") then 
        self:CreateLocationPortal("fresco_door_empty", "mg_012_signs", "eye"); 
    elseif(GetState(CURRENT_SCREEN, "state") == "after_mg") then 
        SetState(CURRENT_SCREEN, "state", "finish") 
        ItemSetOpacity("fresco_door_empty", 0.0) 
        SoundPlay("sound/12_door.ogg", false)
        ItemMoveTo("fresco_door_open", 826, 369, 2.0)
        DelayedExec(1.5, function()
            self:CreateObj(OBJ_TYPE.TRIGGER, "lasers_eye", "graphics/screens/12_fresco/location/lasers_eye", 564, 411);
            self:CreateLocationPortal("lasers_eye", "013_lasers", "eye"); 
        end, 113)
    elseif(GetState(CURRENT_SCREEN, "state") == "finish") then 
        ItemSetPosition("fresco_door_open", 826, 369)
        ItemSetOpacity("fresco_door_empty", 0.0) 
        self:CreateObj(OBJ_TYPE.TRIGGER, "lasers_eye", "graphics/screens/12_fresco/location/lasers_eye", 564, 411);
        self:CreateLocationPortal("lasers_eye", "013_lasers", "eye"); 
    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_12_part")
    
    self:SetItemSound("creature", "sound/12_creature.ogg");
    self:SetItemSound("12_water", "sound/creek_splash.ogg");
    
    MusicPlay({"sound/ambient/12_ambient.ogg", "sound/ambient/04_ambient.ogg"}, 12) 
end    
------------------------------------------------------------------------------------------------------
function GameScreen:onObjectClick(item_name)
 
end

function GameScreen:StartHO()
    local ho_end = function()  
        SetState(CURRENT_SCREEN, "state", "mg") 
        self:CreateLocationPortal("fresco_door_empty", "mg_012_signs", "eye"); 
    end


    self.item_list = {
        {obj = {"sign_01", {x = 149, y = 317}}, },
        {obj = {"sign_02", {x = 220, y = 754}}, },
        {obj = {"sign_03", {x = 148, y = 862}}, },
        {obj = {"sign_04", {x = 321, y = 946}}, },
        {obj = {"sign_05", {x = 482, y = 742}}, },
        {obj = {"sign_06", {x = 681, y = 757}}, },
        {obj = {"sign_07", {x = 683, y = 883}}, },
        {obj = {"sign_08", {x = 1030, y = 739}}, },
        {obj = {"sign_09", {x = 1217, y = 907}}, },
        {obj = {"sign_10", {x = 1239, y = 691}}, },
        {obj = {"sign_11", {x = 1243, y = 274}}, },
        {obj = {"sign_12", {x = 447, y = 68}}, },
    }
    
    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, ho_end, true);
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "12_fresco", "graphics/screens/12_fresco/location/12_fresco", 0, 0);
	
	self:CreateObj(OBJ_TYPE.TRIGGER, "12_water", "graphics/screens/12_fresco/location/12_water", 242, 894);
	self:CreateObj(OBJ_TYPE.TRIGGER, "creature", "graphics/screens/12_fresco/location/creature", 557, 889);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_12_part", "graphics/screens/12_fresco/location/crystal_12_part", 1146, 1056);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "fresco_door_open", "graphics/screens/12_fresco/location/fresco_door_open", 526, 368);
	
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "fresco_door_empty", "graphics/screens/12_fresco/location/fresco_door_empty", 526, 369);
	self:CreateObj(OBJ_TYPE.NO_ACTIVE, "columns", "graphics/screens/12_fresco/location/columns", 595, 324);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_12", "graphics/screens/12_fresco/location/sign_12_part", 507, 103);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_11", "graphics/screens/12_fresco/location/sign_11_part", 1306, 320);
	
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_10", "graphics/screens/12_fresco/location/sign_10_part", 1296, 733);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_09", "graphics/screens/12_fresco/location/sign_09_part", 1284, 966);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_08", "graphics/screens/12_fresco/location/sign_08_part", 1092, 785);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_07", "graphics/screens/12_fresco/location/sign_07_part", 750, 944);
	
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_06", "graphics/screens/12_fresco/location/sign_06_part", 754, 814);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_05", "graphics/screens/12_fresco/location/sign_05_part", 551, 787);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_04", "graphics/screens/12_fresco/location/sign_04_part", 382, 1006);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_03", "graphics/screens/12_fresco/location/sign_03_part", 210, 917);
	
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_02", "graphics/screens/12_fresco/location/sign_02_part", 296, 820);
	self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "sign_01", "graphics/screens/12_fresco/location/sign_01_part", 216, 354);
	
	clScreenManager:add_screen("hud") 
end