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)); } } }
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); } }
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); } } }
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(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); }
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"); }
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); }
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); }
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); }
/// <summary>Register the mod config.</summary> public GenericModConfigMenuIntegration <TConfig> RegisterConfig() { AssertLoaded(); ModApi.RegisterModConfig(ConsumerManifest, Reset, SaveAndApply); return(this); }
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); } } }