Beispiel #1
0
        internal static void UpdateMockCounters()
        {
            foreach (KeyValuePair <MockCounterGroup, ConfigModel> kvp in MockCounter.loadedMockCounters)
            {
                Destroy(kvp.Key.CounterName);
                Destroy(kvp.Key.CounterData);
            }
            if (TextHelper.CounterCanvas != null)
            {
                Destroy(TextHelper.CounterCanvas.gameObject);
            }
            TextHelper.CounterCanvas = null;
            List <ConfigModel> loadedModels = TypesUtility.GetListOfType <ConfigModel>();

            loadedModels = loadedModels.Where(x => !(x is CustomConfigModel)).ToList();
            loadedModels.ForEach(x => x = ConfigLoader.DeserializeFromConfig(x, x.DisplayName) as ConfigModel);
            foreach (CustomCounter potential in CustomCounterCreator.LoadedCustomCounters)
            {
                loadedModels.Add(potential.ConfigModel);
            }
            loadedModels.RemoveAll(x => x is null);

            foreach (ConfigModel counter in loadedModels)
            {
                MockCounter.Update(counter);
            }
        }
Beispiel #2
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            try
            {
                if (firstActivation)
                {
                    Instance     = this;
                    cellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First((LevelListTableCell x) => x.name == "LevelListTableCell");
                    base.DidActivate(firstActivation, type);

                    foreach (var kvp in AdvancedCounterSettings.counterUIItems)
                    {
                        counterInfos.Add(CreateFromModel(kvp.Key));
                    }
                    FileIniDataParser parser = new FileIniDataParser();
                    IniData           data   = parser.ReadFile(Path.Combine(BeatSaber.UserDataPath, "CountersPlus.ini"));
                    foreach (SectionData section in data.Sections)
                    {
                        if (section.Keys.Any((KeyData x) => x.KeyName == "SectionName") &&
                            PluginUtility.IsPluginPresent(section.Keys["ModCreator"]))
                        {
                            CustomConfigModel potential = new CustomConfigModel(section.SectionName);
                            potential = ConfigLoader.DeserializeFromConfig(potential, section.SectionName) as CustomConfigModel;

                            counterInfos.Add(new SettingsInfo()
                            {
                                Name        = potential.DisplayName,
                                Description = $"A custom counter added by {potential.ModCreator}!",
                                Model       = potential,
                                IsCustom    = true,
                            });
                        }
                    }
                    _customListTableView.didSelectCellWithIdxEvent += OnCellSelect;
                    _customListTableView.ReloadData();
                    _customListTableView.SelectCellWithIdx(0, false);
                }
            }
            catch (Exception e) {
                Plugin.Log(e.Message + e.StackTrace, Plugin.LogInfo.Fatal, "Check dependencies. If issue persists, re-install Counters+. If issue still persists, create an issue on the Counters+ GitHub.");
            }
        }
        private void LoadData()
        {
            List <ConfigModel> loadedModels = TypesUtility.GetListOfType <ConfigModel>();

            loadedModels = loadedModels.Where(x => !(x is CustomConfigModel)).ToList();
            loadedModels.ForEach(x => x = ConfigLoader.DeserializeFromConfig(x, x.DisplayName) as ConfigModel);
            foreach (ConfigModel model in loadedModels)
            {
                counterInfos.Add(CreateFromModel(model));
            }
            foreach (CustomCounter potential in CustomCounterCreator.LoadedCustomCounters)
            {
                counterInfos.Add(new SettingsInfo()
                {
                    Name        = potential.Name,
                    Description = string.IsNullOrEmpty(potential.Description) ? $"A custom counter added by {potential.ModName}!" : potential.Description,
                    Model       = potential.ConfigModel,
                    IsCustom    = true,
                });
            }
            counterInfos.RemoveAll(x => x is null);
        }