protected void AddCustomCounter(CustomCounter customCounter, Type counterType)
        {
            ConfigModel settings;

            if ((settings = Container.TryResolveId <ConfigModel>(customCounter.Name)) != null)
            {
                HUDCanvas canvasSettings = GrabCanvasForCounter(settings);

                if (!settings.Enabled || (!canvasSettings.IgnoreNoTextAndHUDOption && dataModel.playerData.playerSpecificSettings.noTextsAndHuds))
                {
                    return;
                }

                Plugin.Logger.Debug($"Loading counter {customCounter.Name}...");

                if (counterType.BaseType == typeof(MonoBehaviour))
                {
                    Container.BindInterfacesAndSelfTo(counterType).FromNewComponentOnRoot().AsSingle().NonLazy();
                }
                else
                {
                    Container.BindInterfacesAndSelfTo(counterType).AsSingle().NonLazy();
                }
            }
        }
        internal void ApplySettings(ConfigModel model)
        {
            ClearScreen();

            if (editingConfigModel != null)
            {
                mainConfig.OnConfigChanged -= MainConfig_OnConfigChanged;
            }

            settingsHeader.text         = $"{model.DisplayName} Settings";
            mainConfig.OnConfigChanged += MainConfig_OnConfigChanged;
            editingConfigModel          = model;
            mockCounter.HighlightCounter(editingConfigModel);

            // Setup helper functions for the config model to hook off of.
            model.GetCanvasFromID = (v) => canvasUtility.GetCanvasSettingsFromID(v);
            model.GetCanvasIDFromCanvasSettings = (v) => mainConfig.HUDConfig.OtherCanvasSettings.IndexOf(v);
            model.GetAllCanvases = () => GetAllCanvases();

            if (cachedSettings.TryGetValue(model, out var cache))
            {
                if (model is CustomConfigModel customConfig)
                {
                    CustomCounter customCounter = customConfig.AttachedCustomCounter;
                    settingsHeader.text = $"{customCounter.Name} Settings";
                }
                foreach (GameObject obj in cache)
                {
                    obj.SetActive(true);
                }
            }
            else
            {
                // Loading settings base
                var settingsBaseParams = BSMLParser.instance.Parse(SettingsBase, settingsContainer, model);
                var multiplayerWarning = settingsBaseParams.GetObjectsWithTag("multiplayer-warning")[0];

                // Only show multiplayer warning if this is a Custom Counter that is not enabled in multiplayer

                // Loading counter-specific settings
                if (model is not CustomConfigModel customConfig)
                {
                    string resourceLocation = $"CountersPlus.UI.BSML.Config.{model.DisplayName}.bsml";
                    string resourceContent  = Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), resourceLocation);
                    BSMLParser.instance.Parse(resourceContent, settingsContainer, model);

                    // All base Counters+ counters are (or should be) multiplayer ready.
                    multiplayerWarning.SetActive(false);
                }
示例#3
0
        private void AddCustomCounter()
        {
            Logger.log.Info("Creating Custom Counter");

            CustomCounter counter = new CustomCounter
            {
                SectionName       = "fpsCounter",
                Name              = PluginName,
                BSIPAMod          = _metadata,
                Counter           = PluginName,
                Icon_ResourceName = "FPS_Counter.Resources.icon.png"
            };

            CustomCounterCreator.Create(counter);
        }
示例#4
0
        private void AddPPCounter()
        {
            CustomCounter counter = new CustomCounter
            {
                SectionName            = "PPHelper Counter",
                Name                   = "PP",
                BSIPAMod               = PluginManager.EnabledPlugins.First(x => x.Name == Name),
                Counter                = "PP Counter",
                Description            = "Shows how much pp your current accuracy is worth on a ranked map",
                Icon_ResourceName      = "PP_Helper.Assets.pp.png",
                CustomSettingsResource = "PP_Helper.Counters_.settings.bsml",
                CustomSettingsHandler  = typeof(PPSettingsHandler)
            };

            CustomCounterCreator.Create(counter);
        }
示例#5
0
        private void AddCustomCounter()
        {
            Logger.Log("Creating Custom Counter");
            CustomCounter counter = new CustomCounter
            {
                SectionName = "deviationCounter",
                Name        = "Deviation Counter",
                BSIPAMod    = this,
                Counter     = "Deviation Counter",
            };

            CustomConfigModel defaults = new CustomConfigModel(counter.Name)
            {
                Enabled  = true,
                Position = CountersPlus.Config.ICounterPositions.BelowCombo,
                Distance = 1
            };

            CustomCounterCreator.Create(counter, defaults);
        }
示例#6
0
        void AddCustomCounter()
        {
            Log("Creating Custom Counter");
            CustomCounter counter = new CustomCounter
            {
                SectionName = "notesLeftCounter",     //Name in config system. Also used as an identifier. Don't plan on changing this.
                Name        = "Notes Left",           //Display name that will appear in the SettingsUI.
                Mod         = (IPA.Old.IPlugin) this, //IPA Plugin. Will show up in Credits in the SettingsUI.
                Counter     = "NotesLeftCounter",     //Name of the GameObject that holds your Counter component. Used to hook into the Counters+ system.
            };

            CustomConfigModel defaults = new CustomConfigModel(counter.Name)
            {
                Enabled  = true,
                Position = CountersPlus.Config.ICounterPositions.AboveHighway,
                Index    = 0,
            };

            CustomCounterCreator.Create(counter, defaults); //Using no ICounterPositions for params defaults to it being able to use all 6.
        }
示例#7
0
 void Awake()
 {
     counter = gameObject.GetComponent <CustomCounter>();
 }
示例#8
0
 // Is this too much? Probably.
 private void BindCustomCounter(CustomCounter counter, CustomConfigModel settings)
 {
     Container.Bind <ConfigModel>().WithId(counter.Name).To <CustomConfigModel>().FromInstance(settings).AsCached();
     Container.Bind <ConfigModel>().To <CustomConfigModel>().FromInstance(settings).AsCached();
     Container.BindInterfacesAndSelfTo <CustomConfigModel>().FromInstance(settings).WhenInjectedInto(counter.CounterType);
 }