LoadResource("fonts.xml")

LoadResource("ISpyLevelResource.xml")

LoadResource("ChipsAnim.xml")

LoadResource("GameResource.xml")
LoadResource("EditorRes.xml")
LoadResource("OutGameRes.xml")

LoadResource("MainMenuResource.xml")

LoadResource("Sound.xml")
LoadResource("ISpySound.xml")
LoadResource("Music.xml")
LoadResource("MultSound.xml")

LoadResource("HelpResource.xml")
LoadResource("PresentationResource.xml")

LoadResource("FishRes.xml")

LoadResource("Skeleton_Resource.xml")
LoadResource("Mult_Resource.xml")

LoadParticles("MultEffects.xml")
LoadEffects("MultEffects.xml")

LoadEffects("Flame.xml")
LoadEffects("FireEl.xml")
LoadEffects("DarkClouds.xml")
LoadEffects("Altar0809.xml")
LoadEffects("AirElement.xml")
--LoadEffects("Candle_last.xml")
LoadEffects("Lamp.xml")
LoadEffects("Earth.xml")
LoadEffects("Moloko.xml")

GUI:LoadText("text.xml")

LoadParticles("effects.xml")
LoadEffects("effects.xml")
LoadParticles("Bubbles.xml")
LoadEffects("Bubbles.xml")
LoadParticles("LockFlame.xml")
LoadEffects("LockFlame.xml")
LoadParticles("ChipFire.xml")
LoadEffects("ChipFire.xml")
LoadParticles("BookEffect.xml")
LoadEffects("BookEffect.xml")

LoadParticles("menuEffects.xml")
LoadEffects("menuEffects.xml")

LoadParticles("ISpyEffects.xml")
LoadEffects("ISpyEffects.xml")

LoadParticles("MG_Effects.xml")
LoadEffects("MG_Effects.xml")

LoadParticles("FaerieBonusEffLast.xml")
LoadEffects("FaerieBonusEffLast.xml")

LoadParticles("Candle.xml")
LoadEffects("Candle.xml")

LoadEffects("Iskra.xml")
LoadEffects("IskraLong.xml")

LoadEffects("CreditsFlame.xml")

LoadEffects("RecEff.xml")

LoadEffects("CreditsSun.xml")

LoadResource("RyushkiResource.xml")
LoadParticles("RyushkiEffects.xml")
LoadEffects("RyushkiEffects.xml")

LoadEffects("ShowMaybeMove.xml")

LoadEffects("LongChainBoom.xml")

LoadEffects("OneWildDot.xml")

LoadEffects("FaerieShow.xml")

LoadEffects("StartTextEff.xml")

LoadEffects("EnergyBegin.xml")

LoadEffects("TreeLeafs.xml")

LoadEffects("RecAir.xml")

LoadEffects("StatValue.xml")

LoadEffects("BonusComplete.xml")

LoadEffects("RecWaterFall.xml")

LoadEffects("BonusAccent.xml")

LoadEffects("ESourceAccent.xml")

LoadEffects("DiffFlame.xml")

GUI:LoadLayers("Presentation_GUI.xml")
GUI:LoadLayers("MultTest.xml")
GUI:LoadLayers("MenuInGame_GUI.xml")
GUI:LoadLayers("Options_GUI.xml")
GUI:LoadLayers("Menu_GUI.xml")
GUI:LoadLayers("Editor_GUI.xml")
GUI:LoadLayers("Game_GUI.xml")
GUI:LoadLayers("TestLayer.xml")
GUI:LoadLayers("BonusLevel_GUI.xml")
GUI:LoadLayers("Books_GUI.xml")
GUI:LoadLayers("MainMenu_GUI.xml")
GUI:LoadLayers("Hint_GUI.xml")
GUI:LoadLayers("ISpyLevel_GUI.xml")
--GUI:LoadLayers("editFileName.xml")
GUI:LoadLayers("Help_GUI.xml")

gameInfo:LoadHintMessages("Messages.xml")

StartInitFaerie()
LoadFaerieAnimations("Animations.xml")
LoadFaerieAnimations("Animations_js.xml")
LoadFaerieJobPresets("FaerieJobs.xml")
LoadFaerieJobPresets("FaerieJobs_js.xml")
EndInitFaerie()

local sndVolume = gameInfo:getSoundVolume()
local musVolume = gameInfo:getMusicVolume()

Sound:SetSoundVolume(sndVolume)
Sound:SetMusicVolume(musVolume)

--UploadResourceGroup("GameLayer")
--GUI:getLayer("GameLayer"):setUpdate(true)
--Screen:pushLayer( GUI:getLayer("GameLayer") )
--GUI:getLayer("GameLayer"):getWidget("GameField"):AcceptMessage(Message("StartLevel"))

SetCustomCursor( gameInfo:isCustomCursor() )

GUI:getLayer("BonusLevel"):getWidget("BonusLevel"):AcceptMessage(Message("Init"))
GUI:getLayer("BooksLayer"):getWidget("Books"):AcceptMessage(Message("Init"))
GUI:getLayer("MainMenu"):getWidget("zMenu"):AcceptMessage(Message("Init"))
GUI:getLayer("ISpyLevel"):getWidget("ISpyLevel"):AcceptMessage(Message("Init"))
GUI:getLayer("Help"):getWidget("zHelp"):AcceptMessage(Message("Init"))

GUI:getLayer("MainMenu"):getWidget("zMenu"):AcceptMessage(Message("ShowFaerie"))

--UploadResourceGroup("BooksAndBonus")
--GUI:getLayer("BonusLevel"):setUpdate(true)
--GUI:getLayer("BonusLevel"):getWidget("BonusLevel"):AcceptMessage(Message("Init"));
--GUI:getLayer("BonusLevel"):getWidget("BonusLevel"):AcceptMessage(Message("LoadCard", 0));
--Screen:pushLayer( GUI:getLayer("BonusLevel") )

--GUI:getLayer("BooksLayer"):setUpdate(true)
--Screen:pushLayer(GUI:getLayer("BooksLayer"))

GUI:getLayer("BooksLayer"):getWidget("Books"):AcceptMessage(Message("UpdateView"))
GUI:getLayer("MainMenu"):setUpdate(true)

--Sound:DelayPlayTrack("MainMenu", 0.25, 1.0, true)
--UploadResourceGroup("BooksAndBonus")

--Screen:pushLayer(GUI:getLayer("MainMenu"))

--Screen:pushLayer( GUI:getLayer("TestLayer") )
--Screen:pushLayer( GUI:getLayer("FileName") )

GUI:getLayer("MainMenu"):getWidget("zMenu"):AcceptMessage(Message("ShowingFaerie"))

Screen:pushLayer( GUI:getLayer("LoadScreen") )
GUI:getLayer("LoadScreen"):getWidget("LoadScreen"):AcceptMessage(Message("SetMode", "2"))
Sound:PlayTrack("MainMenu", true)

-- Инициализация игроков в меню Profiles и активного игрока
if not gameInfo:NoPlayers() then
	local namesWidget = GUI:getLayer("Profiles"):getWidget("Names")
	local numOfPlayers = gameInfo:getNumberOfPlayers()-1
	for i = 0, numOfPlayers do
		local playerName = gameInfo:getPlayerName(i)
		namesWidget:AcceptMessage(Message("Add", playerName))
	end
	namesWidget:AcceptMessage(Message("Set", gameInfo:getName()))
--	GUI:getLayer("MainMenu"):getWidget("profileButton"):AcceptMessage(Message("SetProfile", gameInfo:getName()))
end