コード例 #1
0
        private void AddGenericModConfigMenu()
        {
            IGenericModConfigMenuAPI modconfigAPI = this.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (modconfigAPI != null)
            {
                modconfigAPI.RegisterModConfig(
                    mod: this.ModManifest,
                    revertToDefault: () => ModEntry.Config = new Config(),
                    saveToFile: () => this.Helper.WriteConfig(ModEntry.Config));
                modconfigAPI.SetDefaultIngameOptinValue(
                    mod: this.ModManifest,
                    optedIn: true);
                System.Reflection.PropertyInfo[] properties = ModEntry.Config
                                                              .GetType()
                                                              .GetProperties()
                                                              .Where(p => p.PropertyType == typeof(bool))
                                                              .ToArray();
                foreach (System.Reflection.PropertyInfo property in properties)
                {
                    string key         = property.Name.ToLower();
                    string description = Translations.GetTranslation($"config.{key}.description", defaultToNull: true);
                    modconfigAPI.RegisterSimpleOption(
                        mod: this.ModManifest,
                        optionName: Translations.GetTranslation($"config.{key}.name"),
                        optionDesc: string.IsNullOrWhiteSpace(description) ? null : description,
                        optionGet: () => (bool)property.GetValue(ModEntry.Config),
                        optionSet: (bool value) => property.SetValue(ModEntry.Config, value: value));
                }
            }
        }
コード例 #2
0
        public static bool TryLoadModConfigMenu()
        {
            try
            {
                // Check to see if Generic Mod Config Menu is installed
                if (!Globals.Helper.ModRegistry.IsLoaded("spacechase0.GenericModConfigMenu"))
                {
                    Globals.Monitor.Log("GenericModConfigMenu not present - skipping mod menu setup");
                    return(false);
                }

                api = Globals.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");
                api.RegisterModConfig(Globals.Manifest,
                                      () => Globals.Config = new ModConfig(),
                                      () => Globals.Helper.WriteConfig(Globals.Config)
                                      );

                RegisterModOptions();
                return(true);
            }
            catch (Exception e)
            {
                Globals.Monitor.Log("Failed to register GMCM menu - skipping mod menu setup", StardewModdingAPI.LogLevel.Error);
                Globals.Monitor.Log(e.Message, StardewModdingAPI.LogLevel.Error);
                return(false);
            }
        }
コード例 #3
0
 private void StaminaConfigImplementation(IGenericModConfigMenuAPI api)
 {
     api.RegisterSimpleOption(this.ModManifest, "Enable Stamina Debuff", "Intead of vanilla regen, the farmer wakes up with an X% of missing stamina restored.",
                              () => this.Config.Stamina.Enabled, (bool val) => this.Config.Stamina.Enabled = val);
     api.RegisterSimpleOption(this.ModManifest, "Missing Stamina % Restored", "The percentage of missing stamina you regenerate each morning. A number between 0 - 100.",
                              () => this.Config.Stamina.StaminaRegenPercent, (int val) => this.Config.Stamina.StaminaRegenPercent = val);
     api.RegisterSimpleOption(this.ModManifest, "Stamina % After Pass Out (Coming Soon)", "The percentage of your max stamina you wake up with after passing out. A number between 1 - 100.",
                              () => this.Config.Stamina.StaminaAfterPassOutPercent, (int val) => this.Config.Stamina.StaminaAfterPassOutPercent = val);
 }
コード例 #4
0
 private void HealthConfigImplementation(IGenericModConfigMenuAPI api)
 {
     api.RegisterSimpleOption(this.ModManifest, "Enable Health Debuff", "Instead of vanilla regen, the farmer wakes up with an X% of missing health restored.",
                              () => this.Config.Health.Enabled, (bool val) => this.Config.Health.Enabled = val);
     api.RegisterSimpleOption(this.ModManifest, "Missing Health % Restored", "The percentage of missing health you regenerate each morning. A number between 0 - 100.",
                              () => this.Config.Health.HealthRegenPercent, (int val) => this.Config.Health.HealthRegenPercent = val);
     api.RegisterSimpleOption(this.ModManifest, "Health % After Pass Out (Coming Soon)", "The percentage of your max health you wake up with after falling to 0 HP. A number between 1 - 100.",
                              () => this.Config.Health.HealthAfterDeathPercent, (int val) => this.Config.Health.HealthAfterDeathPercent = val);
 }
コード例 #5
0
        private void RegisterGenericModConfigMenuPage()
        {
            IGenericModConfigMenuAPI api = Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            api.RegisterModConfig(ModManifest,
                                  revertToDefault: () => Config = new Config(),
                                  saveToFile: () =>
            {
                // Apply changes to config
                Helper.WriteConfig(Config);

                // Reload list of buildings to affect
                this.UpdateEnabledOptions();
            });

            // Populate config with all (assumed boolean) config values
            List <string> menu = Config.GetType().GetProperties().Select(p => p.Name).ToList();

            // Add labels between options manually
            menu.Insert(4, "SpecificBuildingsOptions");
            menu.Insert(3, "OtherBuildingsOptions");
            menu.Insert(0, "GreenhouseOptions");
            foreach (string entry in menu)
            {
                string       key = entry.ToLower();
                Translation  name, description;
                PropertyInfo property = Config.GetType().GetProperty(entry);
                if (property != null)
                {
                    // Real properties
                    name        = i18n.Get("config." + key + ".name");
                    description = i18n.Get("config." + key + ".description");
                    api.RegisterSimpleOption(ModManifest,
                                             optionName: name.HasValue() ? name : property.Name,
                                             optionDesc: description.HasValue() ? description : null,
                                             optionGet: () => (bool)property.GetValue(Config),
                                             optionSet: (bool value) => property.SetValue(Config, value));
                }
                else
                {
                    // Labels
                    name = i18n.Get("config." + key + ".label");
                    api.RegisterLabel(ModManifest,
                                      labelName: name,
                                      labelDesc: null);
                }
            }
        }
コード例 #6
0
 internal ModConfigMenu()
 {
     this.Api = Mod.Registry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");
     if (this.Api is null)
     {
         Log.Trace("GMCM not available, skipping Mod Config Menu");
         return;
     }
     this.Helper      = Mod.Instance.Helper;
     this.ModManifest = Mod.Instance.ModManifest;
     RegisterMenu();
 }
コード例 #7
0
        public static bool HookIntoGMCM(IModHelper helper)
        {
            genericModConfigMenuApi = helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (genericModConfigMenuApi is null)
            {
                monitor.Log("Failed to hook into spacechase0.GenericModConfigMenu.", LogLevel.Error);
                return(false);
            }

            monitor.Log("Successfully hooked into spacechase0.GenericModConfigMenu.", LogLevel.Debug);
            return(true);
        }
コード例 #8
0
        /// <summary>Construct an instance.</summary>
        /// <param name="modRegistry">API for fetching metadata about loaded mods.</param>
        /// <param name="monitor">Encapsulates monitoring and logging.</param>
        /// <param name="consumerManifest">The manifest for the mod consuming the API.</param>
        /// <param name="getConfig">Get the current config model.</param>
        /// <param name="reset">Reset the config model to the default values.</param>
        /// <param name="saveAndApply">Save and apply the current config model.</param>
        public GenericModConfigMenuIntegration(IModRegistry modRegistry, IMonitor monitor, IManifest consumerManifest, Func <TConfig> getConfig, Action reset, Action saveAndApply)
            : base("Generic Mod Config Menu", "spacechase0.GenericModConfigMenu", "1.1.0", modRegistry, monitor)
        {
            // init
            ConsumerManifest = consumerManifest;
            GetConfig        = getConfig;
            Reset            = reset;
            SaveAndApply     = saveAndApply;

            // get mod API
            if (IsLoaded)
            {
                ModApi   = GetValidatedApi <IGenericModConfigMenuAPI>();
                IsLoaded = ModApi != null;
            }
        }
コード例 #9
0
 private void HealthConfigImplementation(IGenericModConfigMenuAPI api)
 {
     api.RegisterSimpleOption(this.ModManifest, "Enable Health Regeneration", "Allows your health to be modified by HealthPerRegenRate",
                              () => this.Config.Health.Enabled, (bool val) => this.Config.Health.Enabled = val);
     api.RegisterSimpleOption(this.ModManifest, "Health Per Regen Rate", "The amount of health you get every <Regen Rate> amount of seconds. Must not contain any decimal values",
                              () => this.Config.Health.HealthPerRegenRate, (int val) => this.Config.Health.HealthPerRegenRate = val);
     api.RegisterSimpleOption(this.ModManifest, "Health Regen Rate", "The seconds in between regeneration. Number must be greater than 0 and must not contain decimal values",
                              () => this.Config.Health.RegenRateInSeconds, (int val) => this.Config.Health.RegenRateInSeconds = val);
     api.RegisterSimpleOption(this.ModManifest, "Seconds Until Health Regen After Taking Damage",
                              "the cooldown for regen to start again after taking damage, set it to 0 if you don't want a regen cooldown",
                              () => this.Config.Health.SecondsUntilRegenWhenTakenDamage, (int val) => this.Config.Health.SecondsUntilRegenWhenTakenDamage = val);
     api.RegisterSimpleOption(this.ModManifest, "Don't Check Health Regen Conditions",
                              "Keep regenerating regardless if it goes past max health, ignores SecondsUntilRegen... etc. " +
                              "\n(eg. this allows you to be able to create some sort of hunger mod where you have a negative number set for Health Per Regen Rate; " +
                              "therefore forces you to eat or you may die)",
                              () => this.Config.Health.DontCheckConditions, (bool val) => this.Config.Health.DontCheckConditions = val);
 }
コード例 #10
0
 private void StaminaConfigImplementation(IGenericModConfigMenuAPI api)
 {
     api.RegisterSimpleOption(this.ModManifest, "Enable Stamina Regeneration", "Allows your stamina to be modified by StaminaPerRegenRate",
                              () => this.Config.Stamina.Enabled, (bool val) => this.Config.Stamina.Enabled = val);
     api.RegisterSimpleOption(this.ModManifest, "Stamina Per Regen Rate", "The amount of stamina you get every <Regen Rate> seconds. Decimal values accepted",
                              () => this.Config.Stamina.StaminaPerRegenRate, (float val) => this.Config.Stamina.StaminaPerRegenRate = val);
     api.RegisterSimpleOption(this.ModManifest, "Stamina Regen Rate", "The seconds in between regeneration. Number must be greater than 0 and must not contain decimal values",
                              () => this.Config.Stamina.RegenRateInSeconds, (int val) => this.Config.Stamina.RegenRateInSeconds = val);
     api.RegisterSimpleOption(this.ModManifest, "Seconds Until Stamina Regen After Using Stamina",
                              "the cooldown for regen to start again after using stamina, set it to 0 if you don't want a regen cooldown",
                              () => this.Config.Stamina.SecondsUntilRegenWhenUsedStamina, (int val) => this.Config.Stamina.SecondsUntilRegenWhenUsedStamina = val);
     api.RegisterSimpleOption(this.ModManifest, "Don't Check Stamina Regen Conditions",
                              "Keep regenerating regardless if it goes past max stamina, ignores SecondsUntilRegen... etc. " +
                              "\n(eg. this allows you to be able to create some sort of hunger mod where you have a negative number set for Stamina Per Regen Rate; " +
                              "therefore forces you to eat or you will run out of stamina and get over-exertion)",
                              () => this.Config.Stamina.DontCheckConditions, (bool val) => this.Config.Stamina.DontCheckConditions = val);
 }
コード例 #11
0
        public static void SetUpModConfigMenu(HorseConfig config, HorseOverhaul mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(
                manifest,
                () => config = new HorseConfig(),
                delegate
            {
                mod.Helper.WriteConfig(config);
                VerifyConfigValues(config, mod);
            });

            api.RegisterLabel(manifest, "General", null);

            api.RegisterSimpleOption(manifest, "Thin Horse", null, () => config.ThinHorse, (bool val) => config.ThinHorse  = val);
            api.RegisterSimpleOption(manifest, "Saddle Bags", null, () => config.SaddleBag, (bool val) => config.SaddleBag = val);
            api.RegisterChoiceOption(manifest, "Visible Saddle Bags", null, () => config.VisibleSaddleBags.ToString(), (string val) => config.VisibleSaddleBags = val, Enum.GetNames(typeof(SaddleBagOption)));

            api.RegisterLabel(manifest, "Friendship", null);

            api.RegisterSimpleOption(manifest, "Movement Speed (MS)", null, () => config.MovementSpeed, (bool val) => config.MovementSpeed = val);
            api.RegisterSimpleOption(manifest, "Maximum MS Bonus", null, () => config.MaxMovementSpeedBonus, (float val) => config.MaxMovementSpeedBonus = val);
            api.RegisterSimpleOption(manifest, "Petting", null, () => config.Petting, (bool val) => config.Petting = val);
            api.RegisterSimpleOption(manifest, "Water", null, () => config.Water, (bool val) => config.Water       = val);
            api.RegisterSimpleOption(manifest, "Feeding", null, () => config.Feeding, (bool val) => config.Feeding = val);

            api.RegisterLabel(manifest, "Other", null);

            api.RegisterSimpleOption(manifest, "Pet Feeding", null, () => config.PetFeeding, (bool val) => config.PetFeeding = val);
            api.RegisterSimpleOption(manifest, "Allow Multiple Feedings A Day", null, () => config.AllowMultipleFeedingsADay, (bool val) => config.AllowMultipleFeedingsADay   = val);
            api.RegisterSimpleOption(manifest, "Disable Stable Sprite Changes", null, () => config.DisableStableSpriteChanges, (bool val) => config.DisableStableSpriteChanges = val);

            // this is a spacer
            api.RegisterLabel(manifest, string.Empty, null);
            api.RegisterLabel(manifest, "(Menu Key Rebinding Only Available In Config File)", null);
        }
コード例 #12
0
        public static void SetUpModConfigMenu(CookoutKitConfig config, PermanentCookoutKit mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new CookoutKitConfig(), delegate { mod.Helper.WriteConfig(config); VerifyConfigValues(config, mod); });

            api.RegisterLabel(manifest, "Cookout Kit Reignition Cost", null);

            api.RegisterSimpleOption(manifest, "Wood Needed", null, () => config.WoodNeeded, (int val) => config.WoodNeeded = val);
            api.RegisterSimpleOption(manifest, "Coal Needed", null, () => config.CoalNeeded, (int val) => config.CoalNeeded = val);
            api.RegisterSimpleOption(manifest, "Fiber/ Kindling Needed", null, () => config.FiberNeeded, (int val) => config.FiberNeeded = val);

            api.RegisterLabel(manifest, "Charcoal Kiln", null);

            api.RegisterSimpleOption(manifest, "Wood Needed", "Also works with driftwood and hardwood", () => config.CharcoalKilnWoodNeeded, (int val) => config.CharcoalKilnWoodNeeded = val);
            api.RegisterSimpleOption(manifest, "Time Needed", "The game only checks every 10 minutes", () => config.CharcoalKilnTimeNeeded, (int val) => config.CharcoalKilnTimeNeeded  = val);

            api.RegisterLabel(manifest, "Wood Multipliers", null);

            api.RegisterSimpleOption(manifest, "Driftwood Multiplier¹", null, () => config.DriftwoodMultiplier, (float val) => config.DriftwoodMultiplier = val);
            api.RegisterSimpleOption(manifest, "Hardwood Multiplier¹", null, () => config.HardwoodMultiplier, (float val) => config.HardwoodMultiplier    = val);

            api.RegisterLabel(manifest, "Kindling Multipliers", null);

            api.RegisterSimpleOption(manifest, "Newspaper Multiplier¹", null, () => config.NewspaperMultiplier, (float val) => config.NewspaperMultiplier = val);
            api.RegisterSimpleOption(manifest, "Wool Multiplier¹", null, () => config.WoolMultiplier, (float val) => config.WoolMultiplier    = val);
            api.RegisterSimpleOption(manifest, "Cloth Multiplier¹", null, () => config.ClothMultiplier, (float val) => config.ClothMultiplier = val);

            // this is a spacer
            api.RegisterLabel(manifest, string.Empty, null);
            api.RegisterLabel(manifest, "1: Set To 0 To Disallow Using It", null);
        }
コード例 #13
0
ファイル: ModEntry.cs プロジェクト: b-b-blueberry/GiftWrapper
        private void RegisterGenericModConfigMenuPage()
        {
            IGenericModConfigMenuAPI api = Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            api.RegisterModConfig(ModManifest,
                                  revertToDefault: () => Config = new Config(),
                                  saveToFile: () => Helper.WriteConfig(Config));
            api.RegisterSimpleOption(ModManifest,
                                     optionName: i18n.Get("config.availableallyear.name"),
                                     optionDesc: i18n.Get("config.availableallyear.description"),
                                     optionGet: () => Config.AvailableAllYear,
                                     optionSet: (bool value) => Config.AvailableAllYear = value);
            api.RegisterSimpleOption(ModManifest,
                                     optionName: i18n.Get("config.invertmousebuttons.name"),
                                     optionDesc: i18n.Get("config.invertmousebuttons.description"),
                                     optionGet: () => Config.InteractUsingToolButton,
                                     optionSet: (bool value) => Config.InteractUsingToolButton = value);
        }
コード例 #14
0
        public static void SetUpModConfigMenu(ScytheConfig config, EnchantableScythes mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new ScytheConfig(), delegate { mod.Helper.WriteConfig(config); });

            api.RegisterLabel(manifest, "Enchanting", null);

            api.RegisterSimpleOption(manifest, "Enchantable Scythes", null, () => config.EnchantableScythes, (bool val) => config.EnchantableScythes = val);
            api.RegisterSimpleOption(manifest, "Scythes Can Only Get Haymaker", null, () => config.ScythesCanOnlyGetHaymaker, (bool val) => config.ScythesCanOnlyGetHaymaker = val);
            api.RegisterSimpleOption(manifest, "Other Weapons Cannot\nGet Haymaker Anymore", null, () => config.OtherWeaponsCannotGetHaymakerAnymore, (bool val) => config.OtherWeaponsCannotGetHaymakerAnymore = val);

            api.RegisterLabel(manifest, "Fixes", null);

            api.RegisterSimpleOption(manifest, "Golden Scythe Respawns", null, () => config.GoldenScytheRespawns, (bool val) => config.GoldenScytheRespawns = val);
        }
コード例 #15
0
        public static void SetUpModConfigMenu(Config config, DropItHotkey mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(
                manifest,
                () => config = new Config(),
                delegate
            {
                mod.Helper.WriteConfig(config);
            });

            api.SetTitleScreenOnlyForNextOptions(manifest, false);

            api.AddKeybindList(manifest, () => config.DropKey, (KeybindList keybindList) => config.DropKey = keybindList, () => "Drop Key");
        }
コード例 #16
0
        public static void SetUpModConfigMenu(HorseConfig config, HorseOverhaul mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(
                manifest,
                delegate
            {
                // if the world is ready, then we are not in the main menu, so reset should only reset the keybindings
                if (Context.IsWorldReady)
                {
                    config.HorseMenuKey = HorseMenuKeyDefault;
                    config.PetMenuKey   = PetMenuKeyDefault;
                    config.AlternateSaddleBagAndFeedKey   = AlternateSaddleBagAndFeedKeyDefault;
                    config.DisableMainSaddleBagAndFeedKey = false;
                }
                else
                {
                    config = new HorseConfig();
                }
            },
                delegate
            {
                mod.Helper.WriteConfig(config);
                VerifyConfigValues(config, mod);
            }
                );

            api.SetTitleScreenOnlyForNextOptions(manifest, true);

            api.RegisterLabel(manifest, "General", null);

            api.RegisterSimpleOption(manifest, "Thin Horse", null, () => config.ThinHorse, (bool val) => config.ThinHorse  = val);
            api.RegisterSimpleOption(manifest, "Saddle Bags", null, () => config.SaddleBag, (bool val) => config.SaddleBag = val);
            api.RegisterChoiceOption(manifest, "Visible Saddle Bags", null, () => config.VisibleSaddleBags.ToString(), (string val) => config.VisibleSaddleBags = val, Enum.GetNames(typeof(SaddleBagOption)));

            api.RegisterLabel(manifest, "Friendship", null);

            api.RegisterSimpleOption(manifest, "Movement Speed (MS)", null, () => config.MovementSpeed, (bool val) => config.MovementSpeed = val);
            api.RegisterSimpleOption(manifest, "Maximum MS Bonus", null, () => config.MaxMovementSpeedBonus, (float val) => config.MaxMovementSpeedBonus = val);
            api.RegisterSimpleOption(manifest, "Petting", null, () => config.Petting, (bool val) => config.Petting        = val);
            api.RegisterSimpleOption(manifest, "Water", null, () => config.Water, (bool val) => config.Water              = val);
            api.RegisterSimpleOption(manifest, "Feeding", null, () => config.Feeding, (bool val) => config.Feeding        = val);
            api.RegisterSimpleOption(manifest, "Heater", null, () => config.HorseHeater, (bool val) => config.HorseHeater = val);

            api.RegisterLabel(manifest, "Other", null);

            api.RegisterSimpleOption(manifest, "Horse Hoofstep Effects", null, () => config.HorseHoofstepEffects, (bool val) => config.HorseHoofstepEffects = val);
            api.RegisterSimpleOption(manifest, "Disable Horse Sounds", null, () => config.DisableHorseSounds, (bool val) => config.DisableHorseSounds       = val);
            api.RegisterSimpleOption(manifest, "New Food System", null, () => config.NewFoodSystem, (bool val) => config.NewFoodSystem = val);
            api.RegisterSimpleOption(manifest, "Pet Feeding", null, () => config.PetFeeding, (bool val) => config.PetFeeding           = val);
            api.RegisterSimpleOption(manifest, "Allow Multiple Feedings A Day", null, () => config.AllowMultipleFeedingsADay, (bool val) => config.AllowMultipleFeedingsADay   = val);
            api.RegisterSimpleOption(manifest, "Disable Stable Sprite Changes", null, () => config.DisableStableSpriteChanges, (bool val) => config.DisableStableSpriteChanges = val);

            api.SetTitleScreenOnlyForNextOptions(manifest, false);

            api.RegisterLabel(manifest, "Keybindings", null);

            api.AddKeybindList(manifest, () => config.HorseMenuKey, (KeybindList keybindList) => config.HorseMenuKey = keybindList, () => "Horse Menu Key");
            api.AddKeybindList(manifest, () => config.PetMenuKey, (KeybindList keybindList) => config.PetMenuKey     = keybindList, () => "Pet Menu Key");
            api.AddKeybindList(manifest, () => config.AlternateSaddleBagAndFeedKey, (KeybindList keybindList) => config.AlternateSaddleBagAndFeedKey = keybindList, () => "Alternate Saddle Bag\nAnd Feed Key");
            api.RegisterSimpleOption(manifest, "Disable Main Saddle Bag\nAnd Feed Key", null, () => config.DisableMainSaddleBagAndFeedKey, (bool val) => config.DisableMainSaddleBagAndFeedKey = val);
        }
コード例 #17
0
        private static void LoadModConfigMenuElements()
        {
            IGenericModConfigMenuAPI gmcm = Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (gmcm == null)
            {
                return;
            }

            gmcm.RegisterModConfig(ModEntry.Instance.ModManifest, () => ModEntry.Config = new Config(), () => Helper.WriteConfig(ModEntry.Config));
            gmcm.SubscribeToChange(ModManifest,
                                   changeHandler: (string key, bool value) =>
            {
                Log.D($"Config check: {key} => {value}",
                      ModEntry.Config.DebugMode);

                if (key == i18n.Get($"config.option.{"AddNewCropsAndStuff".ToLower()}_name") &&
                    Helper.ModRegistry.IsLoaded("blueberry.CommunityKitchen"))
                {
                    // Show warning when using
                    Log.W("Changes to Community Kitchen bundles won't be applied until you reopen the game.");
                }
            });

            string[] entries = new[]
            {
                "features",

                "AddCookingMenu",
                "AddCookingSkillAndRecipes",
                "AddCookingToolProgression",
                //"AddCookingQuestline",
                "AddNewCropsAndStuff",

                "changes",

                "PlayCookingAnimation",
                "AddRecipeRebalancing",
                "AddBuffReassigning",
                "HideFoodBuffsUntilEaten",
                "FoodHealingTakesTime",
                "FoodCanBurn",

                "others",

                "ShowFoodRegenBar",
                "RememberLastSearchFilter",
                "DefaultSearchFilter",
                "ResizeKoreanFonts",
            };
            foreach (string entry in entries)
            {
                BindingFlags flags    = BindingFlags.Public | BindingFlags.Instance;
                PropertyInfo property = typeof(Config).GetProperty(entry, flags);
                if (property != null)
                {
                    string i18nKey = $"config.option.{entry.ToLower()}_";
                    if (property.PropertyType == typeof(bool))
                    {
                        gmcm.RegisterSimpleOption(
                            ModManifest,
                            optionName: i18n.Get(i18nKey + "name"),
                            optionDesc: i18n.Get(i18nKey + "description"),
                            optionGet: () => (bool)property.GetValue(ModEntry.Config),
                            optionSet: (bool value) =>
                        {
                            Log.D($"Config edit: {property.Name} - {property.GetValue(ModEntry.Config)} => {value}",
                                  ModEntry.Config.DebugMode);
                            property.SetValue(ModEntry.Config, value);
                        });
                    }
                    else if (property.Name == "DefaultSearchFilter")
                    {
                        gmcm.RegisterChoiceOption(
                            ModManifest,
                            optionName: i18n.Get(i18nKey + "name"),
                            optionDesc: i18n.Get(i18nKey + "description"),
                            optionGet: () => (string)property.GetValue(ModEntry.Config),
                            optionSet: (string value) => property.SetValue(ModEntry.Config, value),
                            choices: Enum.GetNames(typeof(Objects.CookingMenu.Filter)));
                    }
                }
                else
                {
                    string i18nKey = $"config.{entry}_";
                    gmcm.RegisterLabel(
                        ModManifest,
                        labelName: i18n.Get(i18nKey + "label"),
                        labelDesc: null);
                }
            }
        }