示例#1
0
        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();

            // Loading settings base
            BSMLParser.instance.Parse(SettingsBase, settingsContainer, model);

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