/// <summary>Add a dropdown to the form.</summary> /// <param name="label">The label text.</param> /// <param name="description">A description shown on hover, if any.</param> /// <param name="get">Get the current value.</param> /// <param name="set">Set a new value.</param> /// <param name="choices">The choices to choose from.</param> /// <param name="enable">Whether the field is enabled.</param> public GenericModConfigMenuIntegration <TConfig> AddDropdown(string label, string description, Func <TConfig, string> get, Action <TConfig, string> set, string[] choices, bool enable = true) { AssertLoaded(); if (enable) { ModApi.RegisterChoiceOption( mod: ConsumerManifest, optionName: label, optionDesc: description, optionGet: () => get(GetConfig()), optionSet: val => set(GetConfig(), val), choices: choices ); } return(this); }
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); }
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); }
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); } } }
private static void AddDropdown(string name, string desc, Func <string> get, Action <string> set, string[] choices) { api.RegisterChoiceOption(Globals.Manifest, name, desc, get, set, choices); }