GameScreen.textures_path = "graphics/screens/14_upside/location/"


function GameScreen:RestoreScene()
    if(GetState(CURRENT_SCREEN, "state") == "") then
        StopMusic();
        local _id = PlayMusic("sound/ambient/14_intro.ogg", false) 
        DelayedExec(GetMusicLenght(_id), function()
            MusicPlay({"sound/music/surreal.ogg"}, 14)  
        end, 113)
        
        SetState(CURRENT_SCREEN, "state", "ho")
    else
        MusicPlay({"sound/music/surreal.ogg"}, 14) 
    end
    
    if(GetState(CURRENT_SCREEN, "state") == "ho") then
        self:StartHO();
    elseif(GetState(CURRENT_SCREEN, "state") == "finish") then
        clApplication:LoadLocation("015_white")
    end
    
    if(GetState(CURRENT_SCREEN, "sideboard_door_opened") == "true")then
        self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "accordion_shadow", "graphics/screens/14_upside/location/accordion_shadow", 341, 545);
        self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "accordion", "graphics/screens/14_upside/location/accordion_part", 350, 649);
        ItemRemove(self.name, "sideboard_door_open", 0.4)
        ItemRemove(self.name, "sideboard_door_eye")
    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()

    self:RestoreScene();
    
    self:AddHiddenCrystal("crystal_14_part")

    self:SetItemSound("grammophone", "sound/grammophone.ogg");
    self:SetItemSound("dish", "sound/ceramic_pot.ogg");
    self:SetItemSound("clock", "sound/clock_chimes.ogg");
    self:SetItemSound("vase", "sound/ceramic_pot_01.ogg");
    self:SetItemSound("trumpet", "sound/trumpet.ogg");
    self:SetItemSound("pot", "sound/pot_hit.ogg");
    self:SetItemSound("bottle_01", "sound/bottle_01.ogg");
    self:SetItemSound("bottle_02", "sound/bottle_02.ogg");
    self:SetItemSound("bottle_03", "sound/bottle_03.ogg");
    self:SetItemSound("bottle_04", "sound/bottle_04.ogg");
    self:SetItemSound("glass", "sound/glass_tap.ogg");
    self:SetItemSound("contrabass", "sound/contrabass.ogg");
end
------------------------------------------------------------------------------------------------------
function GameScreen:StartHO()
    local bookcase_click = function()
        SetState(CURRENT_SCREEN, "sideboard_door_opened", "true")
        self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "accordion_shadow", "graphics/screens/14_upside/location/accordion_shadow", 341, 545);
        self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "accordion", "graphics/screens/14_upside/location/accordion_part", 350, 649);
        ItemSetOpacity("accordion_shadow", 0.0)
        ItemSetOpacity("accordion", 0.0)
        ItemSetOpacity("sideboard_door_open", 0.0)
        ItemChangeOpacity("accordion_shadow", 1.0, 0.4)
        ItemChangeOpacity("accordion", 1.0, 0.4)
        ItemChangeOpacity("sideboard_door_open", 1.0, 0.4)
        ItemRemove(self.name, "sideboard_door_eye")
        ItemRemove(self.name, "sideboard_door_open", 0.4)
        SoundPlay("sound/bookcase_door.ogg")
    end
    
    self.item_list = {
        {obj = {"guitar", {x = 714, y = 178}}, },
        {obj = {"vinyl", {x = 1250, y = 252}}, },
        {obj = {"microphone", {x = 1212, y = 920}}, },
        {obj = {"headphones", {x = 475, y = 7}}, },
        {obj = {"synthesizer", {x = 0, y = 178}}, },
        {obj = {"castanet", {x = 966, y = 430}}, },
        {obj = {"drum", {x = 1046, y = 875}}, },
        {obj = {"piano", {x = 532, y = 662}}, },
        
        {obj = {"flute", {x = 1391, y = 178}}, },
        {obj = {"harp", {x = 1376, y = 581}}, },
        {obj = {"accordion", {x = 290, y = 598}, true}, intaractive = {"sideboard_door_eye", "accordion_hint", 290, 598, bookcase_click}},
        {obj = {"cymbal", {x = 689, y = 388}}, },
    }
    
    local end_fun = function() 
        SetState(CURRENT_SCREEN, "state", "finish")
        DelayedExec(2.0, function()
            clApplication:LoadLocation("015_white")
        end, 113)
    end
    
    self:SetItemCursor("sideboard_door_eye", "eye")
    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, end_fun);
end  
------------------------------------------------------------------------------------------------------
function GameScreen:onObjectClick(item_name)
 
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "14_upside", "graphics/screens/14_upside/location/14_upside", 0, 0);

    self:CreateObj(OBJ_TYPE.TRIGGER, "grammophone", "graphics/screens/14_upside/location/grammophone", 219, 71);
    self:CreateObj(OBJ_TYPE.TRIGGER, "dish", "graphics/screens/14_upside/location/dish", 1019, 464);
    self:CreateObj(OBJ_TYPE.TRIGGER, "clock", "graphics/screens/14_upside/location/clock", 311, 431);
    self:CreateObj(OBJ_TYPE.TRIGGER, "vase", "graphics/screens/14_upside/location/vase", 1042, 0);
    self:CreateObj(OBJ_TYPE.TRIGGER, "trumpet", "graphics/screens/14_upside/location/trumpet", 1136, 586);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "pot", "graphics/screens/14_upside/location/pot", 1469, 399);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_01", "graphics/screens/14_upside/location/bottle_01", 898, 687);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_02", "graphics/screens/14_upside/location/bottle_02", 927, 683);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_03", "graphics/screens/14_upside/location/bottle_03", 959, 692);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_04", "graphics/screens/14_upside/location/bottle_04", 974, 703);
    self:CreateObj(OBJ_TYPE.TRIGGER, "glass", "graphics/screens/14_upside/location/glass", 477, 543);
    self:CreateObj(OBJ_TYPE.TRIGGER, "contrabass", "graphics/screens/14_upside/location/contrabass", 370, 970);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "guitar", "graphics/screens/14_upside/location/guitar_part", 776, 198);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "vinyl", "graphics/screens/14_upside/location/vinyl_record_part", 1304, 251);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "microphone", "graphics/screens/14_upside/location/microphone_part", 1245, 972);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "headphones", "graphics/screens/14_upside/location/headphones_part", 513, 43);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "synthesizer", "graphics/screens/14_upside/location/synthesizer_part", 39, 91);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "castanet", "graphics/screens/14_upside/location/castanet_part", 1027, 452);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "drum_shadow", "graphics/screens/14_upside/location/drum_shadow", 1040, 972);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "drum", "graphics/screens/14_upside/location/drum_part", 1096, 895);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "piano", "graphics/screens/14_upside/location/piano_part", 558, 710);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "flute", "graphics/screens/14_upside/location/flute_part", 1363, 216);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "harp_shadow", "graphics/screens/14_upside/location/harp_shadow", 1539, 778);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "harp", "graphics/screens/14_upside/location/harp_part", 1403, 620);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "cymbal_shadow", "graphics/screens/14_upside/location/cymbal_shadow", 690, 384);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "cymbal", "graphics/screens/14_upside/location/cymbal_part", 709, 420)
    self:CreateObj(OBJ_TYPE.TRIGGER, "sideboard_door_eye", "graphics/screens/14_upside/location/sideboard_door_eye", 316, 545);
    self:CreateObj(OBJ_TYPE.NO_ACTIVE, "sideboard_door_open", "graphics/screens/14_upside/location/sideboard_door_open", 239, 534);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_14_part", "graphics/screens/14_upside/location/crystal_14_part", 829, 957);
    
    clScreenManager:add_screen("hud") 
end