Esempio n. 1
0
        public MusicMenu(MusicChoice choice)
        {
            this.choice = choice;
            files       = PathMod.GetModFiles(GraphicsManager.MUSIC_PATH);

            List <MenuChoice> flatChoices = new List <MenuChoice>();

            flatChoices.Add(new MenuTextChoice("---", () => { choose(""); }));
            foreach (string song in files)
            {
                if (!DataManager.IsNonTrivialFile(song))
                {
                    continue;
                }

                flatChoices.Add(new MenuTextChoice(Path.GetFileNameWithoutExtension(song), () => { choose(Path.GetFileName(song)); }));
            }
            List <MenuChoice[]> choices = SortIntoPages(flatChoices, SLOTS_PER_PAGE);


            summaryMenu = new SongSummary(Rect.FromPoints(new Loc(8, GraphicsManager.ScreenHeight - 8 - 5 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 8, GraphicsManager.ScreenHeight - 8)));

            Initialize(new Loc(8, 16), 304, Text.FormatKey("MENU_MUSIC_TITLE"), choices.ToArray(), 0, 0, SLOTS_PER_PAGE);
        }
Esempio n. 2
0
        internal static void Postfix(ZEventListener __instance)
        {
            if (!__instance.eventName_.StartsWith(CustomDataInfo.GetPrefix <MusicChoice>()))
            {
                return;
            }

            Mod.Instance.Variables.CachedMusicChoice.GetOrCreate(__instance, () => MusicChoice.FromObject(__instance));
        }
Esempio n. 3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != null && instance != this)
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
        private void AddOrRemove(ReferenceMap.Handle <GameObject> beforeHandle, ref ReferenceMap.Handle <GameObject> afterHandle, bool add)
        {
            LevelEditor editor     = G.Sys.LevelEditor_;
            GameObject  gameObject = beforeHandle.Get();

            ZEventListener comp = (!add) ? addedComponentHandle.Get() : ((ZEventListener)((object)null));

            if (!gameObject.HasComponent <LevelSettings>())
            {
                editor.RemoveGameObjectSilent(gameObject);
            }

            if (add)
            {
                comp = gameObject.AddComponent <ZEventListener>();

                var choice = new MusicChoice();

                if (gameObject.HasComponent <LevelSettings>())
                {
                    choice.Choices.Add("Level", new MusicChoiceEntry(""));
                }

                if (gameObject.HasComponent <MusicTrigger>())
                {
                    choice.Choices.Add("Trigger", new MusicChoiceEntry(""));
                }

                if (gameObject.HasComponent <MusicZone>())
                {
                    choice.Choices.Add("Zone", new MusicChoiceEntry(""));
                }

                choice.WriteObject(comp);

                if (componentBytes != null)
                {
                    Serializers.BinaryDeserializer.LoadComponentContentsFromBytes(comp, null, componentBytes);
                }

                comp.enabled = false;
            }
            else if (comp)
            {
                comp.Destroy();
            }

            if (gameObject.HasComponent <LevelSettings>())
            {
                Mod.Instance.LevelEditor.NeedsRefresh = true;
            }

            if (!gameObject.HasComponent <LevelSettings>())
            {
                editor.AddGameObjectSilent(ref afterHandle, gameObject, editor.WorkingLevel_.GetLayerOfObject(gameObject));
            }

            addedComponentHandle = (!add) ? default : editor.ReferenceMap_.GetHandleOrNull(comp);
                                   gameObject.ForEachILevelEditorListenerInChildren(listener => listener.OnLevelEditorToolFinish());

                                   ObjectHadComponentAddedOrRemoved.Broadcast(new ObjectHadComponentAddedOrRemoved.Data(gameObject));

                                   if (!gameObject.HasComponent <LevelSettings>())
                                   {
                                       editor.SelectObject(gameObject);
                                   }
        }
        public string GetMusicChoiceValue(GameObject obj, string key)
        {
            var listener = obj.GetComponent <ZEventListener>();

            if (listener?.eventName_.StartsWith(CustomDataInfo.GetPrefix <MusicChoice>()) != true)
            {
                return(null);
            }

            var choice = mod_.Variables.CachedMusicChoice.GetOrCreate(listener, () => MusicChoice.FromObject(listener));

            if (choice == null)
            {
                return(null);
            }

            choice.Choices.TryGetValue(key, out MusicChoiceEntry entry);

            if (entry == null)
            {
                return(null);
            }

            return(entry.Track);
        }