public static void SetUpModConfigMenu(HorseConfig config, HorseOverhaul mod)
        {
            GenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("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 Bag", null, () => config.SaddleBag, (bool val) => config.SaddleBag = val);

            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, "Disable Stable Sprites", null, () => config.DisableStableSpriteChanges, (bool val) => config.DisableStableSpriteChanges = val);
            api.RegisterSimpleOption(manifest, "Pet Feeding", null, () => config.PetFeeding, (bool val) => config.PetFeeding = val);

            api.RegisterLabel(manifest, "(Menu Key Rebinding Only Available In Config File)", null);
        }
        public static void SetUpModConfigMenu(TreeOverhaulConfig config, TreeOverhaul mod)
        {
            GenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

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

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

            api.RegisterSimpleOption(manifest, "Stop Seed Growth In Shade", "Seeds don't sprout in the 8 surrounding tiles of a tree", () => config.StopShadeSaplingGrowth, (bool val) => config.StopShadeSaplingGrowth = val);
            api.RegisterSimpleOption(manifest, "Growth Ignores Stumps", "Trees can grow even if a small stump is next to them", () => config.GrowthIgnoresStumps, (bool val) => config.GrowthIgnoresStumps = val);
            api.RegisterChoiceOption(manifest, "Save Sprouts From Tools", "Normal and fruit trees can't be killed by the selected tools", () => GetElementFromConfig(SSChoices, config.SaveSprouts), (string val) => config.SaveSprouts = GetIndexFromArrayElement(SSChoices, val), SSChoices);

            api.RegisterLabel(manifest, "Winter Tweaks", null);

            api.RegisterSimpleOption(manifest, "Normal Trees Grow In Winter", null, () => config.NormalTreesGrowInWinter, (bool val) => config.NormalTreesGrowInWinter            = val);
            api.RegisterSimpleOption(manifest, "Mushroom Trees Grow In Winter", null, () => config.MushroomTreesGrowInWinter, (bool val) => config.MushroomTreesGrowInWinter      = val);
            api.RegisterSimpleOption(manifest, "Fruit Trees Don't Grow In Winter", null, () => config.FruitTreesDontGrowInWinter, (bool val) => config.FruitTreesDontGrowInWinter = val);

            api.RegisterLabel(manifest, "Buffs And Nerfs", null);

            api.RegisterSimpleOption(manifest, "Buff Mahogany Tree Growth", "20% unfertilized and 100% fertilized (from 15% and 60%)", () => config.BuffMahoganyTrees, (bool val) => config.BuffMahoganyTrees = val);
            api.RegisterClampedOption(manifest, "Seed Chance From Shaking", "Chance that a seed drops from shaking a tree (default: 5%, chance depends on host)", () => config.ShakingSeedChance, (int val) => config.ShakingSeedChance     = val, 0, 100);
            api.RegisterSimpleOption(manifest, "Faster Normal Tree Growth", "Normal trees try to grow twice every day, still random whether they succeed", () => config.FasterNormalTreeGrowth, (bool val) => config.FasterNormalTreeGrowth = val);
            api.RegisterChoiceOption(manifest, "Fruit Tree Growth Options", null, () => GetElementFromConfig(FTChoices, config.FruitTreeGrowth), (string val) => config.FruitTreeGrowth = GetIndexFromArrayElement(FTChoices, val), FTChoices);
        }
        public static void SetUpModConfigMenu(WateringGrantsXPConfig config, WateringGrantsXP mod)
        {
            GenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

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

            api.RegisterLabel(manifest, "Watering Grants XP", null);

            api.RegisterSimpleOption(manifest, "Amount Of Experience", null, () => config.WateringExperienceAmount, (int val) => config.WateringExperienceAmount = val);
            api.RegisterClampedOption(manifest, "Chance To Get XP", null, () => config.WateringChanceToGetXP, (int val) => config.WateringChanceToGetXP          = val, 0, 100);
            api.RegisterSimpleOption(manifest, "Forage Seed Watering\nGrants Foraging XP", null, () => config.ForageSeedWateringGrantsForagingXP, (bool val) => config.ForageSeedWateringGrantsForagingXP = val);

            // this is a spacer due to the line break above
            api.RegisterLabel(manifest, string.Empty, null);
            api.RegisterLabel(manifest, "Crops Die Without Water", null);

            api.RegisterSimpleOption(manifest, "Withering Feature Enabled", null, () => config.CropsCanDieWithoutWater, (bool val) => config.CropsCanDieWithoutWater = val);
            api.RegisterSimpleOption(manifest, "Days For Chance Of Withering", null, () => config.DaysWithoutWaterForChanceToDie, (int val) => config.DaysWithoutWaterForChanceToDie = val);
            api.RegisterClampedOption(manifest, "Chance For Withering", null, () => config.ChanceToDieWhenLeftForTooLong, (int val) => config.ChanceToDieWhenLeftForTooLong          = val, 0, 100);
        }
Beispiel #4
0
 protected override void InitializeApi(GenericModConfigMenuAPI api)
 {
     api.RegisterLabel(ModManifest, "Each night", "How soil decays every night");
     api.RegisterClampedOption(ModManifest, "Drying Rate", "Chance that tilled soil will disappear. Normally this is 0.1 (=10%).", () => (float)config.EachNight.DryingRate, (float val) => config.EachNight.DryingRate = val, 0.0f, 1.0f);
     api.RegisterClampedOption(ModManifest, "Delay", "Number of consecutive days that the patch must have been without water, before it can disappear during the night.", () => config.EachNight.Delay, (int val) => config.EachNight.Delay = val, 0, 4);
     api.RegisterLabel(ModManifest, "Each Season", "How soil decays on the farm (and maps that have the `ClearEmptyDirtOnNewMonth` property) during nights between seasons");
     api.RegisterClampedOption(ModManifest, "Drying Rate", "Chance that tilled soil will disappear. Normally this is 0.8 (=80%).", () => (float)config.EachSeason.DryingRate, (float val) => config.EachSeason.DryingRate = val, 0.0f, 1.0f);
     api.RegisterClampedOption(ModManifest, "Delay", "Number of consecutive days that the patch must have been without water, before it can disappear during the night.", () => config.EachSeason.Delay, (int val) => config.EachSeason.Delay = val, 0, 4);
     api.RegisterLabel(ModManifest, "Greenhouse", "How soil decays inside the greenhouse");
     api.RegisterClampedOption(ModManifest, "Drying Rate", "Chance that tilled soil will disappear. Normally this is 1.0 (=100%).", () => (float)config.Greenhouse.DryingRate, (float val) => config.Greenhouse.DryingRate = val, 0.0f, 1.0f);
     api.RegisterClampedOption(ModManifest, "Delay", "Number of consecutive days that the patch must have been without water, before it can disappear during the night.", () => config.Greenhouse.Delay, (int val) => config.Greenhouse.Delay = val, 0, 4);
     api.RegisterLabel(ModManifest, "Island", "How soil decays on Ginger Island");
     api.RegisterClampedOption(ModManifest, "Drying Rate", "Chance that tilled soil will disappear. Normally this is 0.1 (=10%).", () => (float)config.Island.DryingRate, (float val) => config.Island.DryingRate = val, 0.0f, 1.0f);
     api.RegisterClampedOption(ModManifest, "Delay", "Number of consecutive days that the patch must have been without water, before it can disappear during the night.", () => config.Island.Delay, (int val) => config.Island.Delay = val, 0, 4);
     api.RegisterLabel(ModManifest, "Non-farm", "How soil decays outside the farm");
     api.RegisterClampedOption(ModManifest, "Drying Rate", "Chance that tilled soil will disappear. Normally this is 1.0 (=100%).", () => (float)config.NonFarm.DryingRate, (float val) => config.NonFarm.DryingRate = val, 0.0f, 1.0f);
     api.RegisterClampedOption(ModManifest, "Delay", "Number of consecutive days that the patch must have been without water, before it can disappear during the night.", () => config.NonFarm.Delay, (int val) => config.NonFarm.Delay = val, 0, 4);
 }
        public static void SetUpModConfigMenu(ForageFantasyConfig config, ForageFantasy mod)
        {
            GenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

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

            api.RegisterLabel(manifest, "Quality Tweaks", null);

            api.RegisterSimpleOption(manifest, "Berry Bush Quality", "Salmonberries and blackberries have quality based\non forage level even without botanist perk.", () => config.BerryBushQuality, (bool val) => config.BerryBushQuality = val);
            api.RegisterSimpleOption(manifest, "Mushroom Box Quality", "Mushrooms have quality based on forage level and botanist perk.", () => config.MushroomBoxQuality, (bool val) => config.MushroomBoxQuality = val);
            api.RegisterChoiceOption(manifest, "Tapper Quality Options", null, () => GetElementFromConfig(TQChoices, config.TapperQualityOptions), (string val) => config.TapperQualityOptions = GetIndexFromArrayElement(TQChoices, val), TQChoices);
            api.RegisterSimpleOption(manifest, "Tapper Perk Is Required", null, () => config.TapperQualityRequiresTapperPerk, (bool val) => config.TapperQualityRequiresTapperPerk             = val);

            api.RegisterLabel(manifest, "XP Rewards", null);

            api.RegisterClampedOption(manifest, "Berry Bush Chance To Get XP", "Chance to get foraging experience when harvesting bushes.\nSet to 0 to disable feature.", () => config.BerryBushChanceToGetXP, (int val) => config.BerryBushChanceToGetXP = val, 0, 100);
            api.RegisterSimpleOption(manifest, "Berry Bush XP Amount", "Amount of XP gained per bush. For reference:\nChopping down a tree is 12XP, a foraging good is 7XP\nNegative values will be reset to 0.", () => config.BerryBushXPAmount, (int val) => config.BerryBushXPAmount = val);
            api.RegisterSimpleOption(manifest, "Mushroom Box XP Amount", "For reference:\nChopping down a tree is 12XP, a foraging good is 7XP\nNegative values will be reset to 0.", () => config.MushroomXPAmount, (int val) => config.MushroomXPAmount = val);
            api.RegisterSimpleOption(manifest, "Tapper XP Amount", "For reference:\nChopping down a tree is 12XP, a foraging good is 7XP\nNegative values will be reset to 0.", () => config.TapperXPAmount, (int val) => config.TapperXPAmount           = val);
            api.RegisterSimpleOption(manifest, "Automation Harvests Grant XP", "Whether automatic harvests with the Automate, Deluxe\nGrabber Redux or One Click Shed Reloader should grant XP.\nKeep in mind that some of those only affect the host.", () => config.AutomationHarvestsGrantXP, (bool val) => config.AutomationHarvestsGrantXP = val);

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

            api.RegisterSimpleOption(manifest, "Common Fiddlehead Fern¹", "Fiddlehead fern is available outside of the secret forest\nand added to the wild seeds pack and summer foraging bundle.", () => config.CommonFiddleheadFern, (bool val) => config.CommonFiddleheadFern = val);
            api.RegisterSimpleOption(manifest, "Forage Survival Burger¹", "Forage based early game crafting recipes\nand even more efficient cooking recipes.", () => config.ForageSurvivalBurger, (bool val) => config.ForageSurvivalBurger = val);

            // this is a spacer
            api.RegisterLabel(manifest, string.Empty, null);
            api.RegisterLabel(manifest, "1: Restart Needed For Changes To Take Effect", null);
        }
Beispiel #6
0
        protected override void InitializeApi(GenericModConfigMenuAPI api)
        {
            api.RegisterSimpleOption(ModManifest, "Harvest With Sword", "Whether a sword can be used instead of a normal scythe.", () => config.HarvestWithSword, (bool val) => config.HarvestWithSword = val);

            string[] options      = { "Hand", "Scythe", "Both", "Gold" };
            string   options_desc =
                " · Hand: only pluckable;\n" +
                " · Scythe: only scythable;\n" +
                " · Both: both pluckable and scythable;\n" +
                " · Gold: like 'both', but requires the golden scythe.";

            api.RegisterLabel(ModManifest, "HarvestMode", null);
            api.RegisterParagraph(ModManifest, options_desc);
            api.RegisterChoiceOption(ModManifest, "PluckableCrops", "How crops that normally can only be harvested by hand can be harvested.", () => writeEnum(config.HarvestMode.PluckableCrops), (string val) => config.HarvestMode.PluckableCrops       = parseEnum(val), options);
            api.RegisterChoiceOption(ModManifest, "ScythableCrops", "How crops that normally can only be harvested with a scythe can be harvested.", () => writeEnum(config.HarvestMode.ScythableCrops), (string val) => config.HarvestMode.ScythableCrops = parseEnum(val), options);
            api.RegisterChoiceOption(ModManifest, "Flowers", "How flowers can be harvested.", () => writeEnum(config.HarvestMode.Flowers), (string val) => config.HarvestMode.Flowers = parseEnum(val), options);
            api.RegisterChoiceOption(ModManifest, "Forage", "How forage can be harvested.", () => writeEnum(config.HarvestMode.Forage), (string val) => config.HarvestMode.Forage     = parseEnum(val), options);
            api.RegisterChoiceOption(ModManifest, "SpringOnion", "How spring onions can be harvested.", () => writeEnum(config.HarvestMode.SpringOnion), (string val) => config.HarvestMode.SpringOnion = parseEnum(val), options);
        }
Beispiel #7
0
        // <summary>A SMAPI GameLaunched event that enables GMCM support if that mod is available.</summary>
        public void EnableGMCM(object sender, GameLaunchedEventArgs e)
        {
            try
            {
                GenericModConfigMenuAPI api = Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu"); //attempt to get GMCM's API instance

                if (api == null)                                                                                                       //if the API is not available
                {
                    return;
                }

                api.RegisterModConfig(ModManifest, () => Config = new ModConfig(), () => Helper.WriteConfig(Config)); //register "revert to default" and "write" methods for this mod's config
                api.SetDefaultIngameOptinValue(ModManifest, true);                                                    //allow in-game setting changes (rather than just at the main menu)

                //register an option for each of this mod's config settings

                //buildings
                api.RegisterLabel
                (
                    ModManifest,
                    "Building settings",
                    "Transparency settings for player-constructed farm buildings.\nNote: These settings only affect buildings that can be constructed or moved by players."
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Enable",
                    "Check this box to enable custom settings for building transparency.\nUncheck this box to use Stardew's default transparency.",
                    () => Config.BuildingSettings.Enable,
                    (bool val) => Config.BuildingSettings.Enable = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Below player only",
                    "If this box is checked, buildings will only be transparent if they're vertically lower than your character.",
                    () => Config.BuildingSettings.BelowPlayerOnly,
                    (bool val) => Config.BuildingSettings.BelowPlayerOnly = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Tile distance",
                    "If the number of tiles between your character and a building is less than this setting, the building will be transparent.",
                    () => Config.BuildingSettings.TileDistance,
                    (int val) => Config.BuildingSettings.TileDistance = val
                );

                //bushes
                api.RegisterLabel
                (
                    ModManifest,
                    "Bush settings",
                    "Transparency settings for bushes.\nNote: These settings only affect bushes that players can interact with."
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Enable",
                    "Check this box to enable custom settings for bush transparency.\nUncheck this box to use Stardew's default transparency.",
                    () => Config.BushSettings.Enable,
                    (bool val) => Config.BushSettings.Enable = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Below player only",
                    "If this box is checked, bushes will only be transparent if they're vertically lower than your character.",
                    () => Config.BushSettings.BelowPlayerOnly,
                    (bool val) => Config.BushSettings.BelowPlayerOnly = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Tile distance",
                    "If the number of tiles between your character and a bush is less than this setting, the bush will be transparent.",
                    () => Config.BushSettings.TileDistance,
                    (int val) => Config.BushSettings.TileDistance = val
                );

                //trees
                api.RegisterLabel
                (
                    ModManifest,
                    "Tree settings",
                    "Transparency settings for trees.\nNote: These settings only affect trees that players can interact with."
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Enable",
                    "Check this box to enable custom settings for tree transparency.\nUncheck this box to use Stardew's default transparency.",
                    () => Config.TreeSettings.Enable,
                    (bool val) => Config.TreeSettings.Enable = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Below player only",
                    "If this box is checked, trees will only be transparent if they're vertically lower than your character.",
                    () => Config.TreeSettings.BelowPlayerOnly,
                    (bool val) => Config.TreeSettings.BelowPlayerOnly = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Tile distance",
                    "If the number of tiles between your character and a tree is less than this setting, the tree will be transparent.",
                    () => Config.TreeSettings.TileDistance,
                    (int val) => Config.TreeSettings.TileDistance = val
                );

                //keybinds
                api.RegisterLabel
                (
                    ModManifest,
                    "Key bindings",
                    "Keybind settings for this mod's optional toggle controls."
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Disable transparency",
                    "A list of keybinds that toggle between this mod's settings and normal Stardew transparency.\n\nSee the wiki for info about multi-key bindings: https://stardewvalleywiki.com/Modding:Player_Guide/Key_Bindings",
                    () => Config.KeyBindings.DisableTransparency,
                    (KeybindList val) => Config.KeyBindings.DisableTransparency = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Full transparency",
                    "A list of keybinds that toggle between this mod's settings and maximum transparency on all objects.\n\nSee the wiki for info about multi-key bindings: https://stardewvalleywiki.com/Modding:Player_Guide/Key_Bindings",
                    () => Config.KeyBindings.FullTransparency,
                    (KeybindList val) => Config.KeyBindings.FullTransparency = val
                );
            }
            catch (Exception ex)
            {
                Monitor.Log($"An error happened while loading this mod's GMCM options menu. Its menu might be missing or fail to work. The auto-generated error message has been added to the log.", LogLevel.Warn);
                Monitor.Log($"----------", LogLevel.Trace);
                Monitor.Log($"{ex.ToString()}", LogLevel.Trace);
            }
        }
Beispiel #8
0
        public static void SetUpModConfigMenu(AnimalsDieConfig config, AnimalsDie mod, bool isWaterModInstalled)
        {
            GenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

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

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

            foreach (var prop in typeof(AnimalsDieConfig).GetProperties())
            {
                if (prop.PropertyType == typeof(bool))
                {
                    string betterName = Regex.Replace(prop.Name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");
                    if (prop.Name == nameof(config.DeathByDehydrationWithAnimalsNeedWaterMod))
                    {
                        if (!isWaterModInstalled)
                        {
                            continue;
                        }
                        else
                        {
                            betterName = Regex.Replace(prop.Name.Remove(prop.Name.Length - "WithAnimalsNeedWaterMod".Length), "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");
                        }
                    }

                    api.RegisterSimpleOption(manifest, betterName, null, () => (bool)prop.GetValue(config), (bool b) => prop.SetValue(config, b));
                }
                else
                {
                    if (prop.Name == nameof(config.DaysToDieDueToStarvation) || prop.Name == nameof(config.IllnessScoreToDie))
                    {
                        string betterName = Regex.Replace(prop.Name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");

                        api.RegisterSimpleOption(manifest, betterName, null, () => (int)prop.GetValue(config), (int b) => prop.SetValue(config, b));
                    }

                    if (prop.Name == nameof(config.DaysToDieDueToDehydrationWithAnimalsNeedWaterMod))
                    {
                        string betterName = string.Empty;

                        if (!isWaterModInstalled)
                        {
                            continue;
                        }
                        else
                        {
                            betterName = Regex.Replace(prop.Name.Remove(prop.Name.Length - "WithAnimalsNeedWaterMod".Length), "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");
                        }

                        api.RegisterSimpleOption(manifest, betterName, null, () => (int)prop.GetValue(config), (int b) => prop.SetValue(config, b));
                    }
                }
            }

            api.RegisterLabel(manifest, "Ages (in years)", null);

            foreach (var prop in typeof(AnimalsDieConfig).GetProperties())
            {
                if (prop.Name.StartsWith("Min"))
                {
                    if (prop.PropertyType == typeof(int))
                    {
                        string betterName = Regex.Replace(prop.Name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");

                        api.RegisterSimpleOption(manifest, betterName, "must at least 0 and smaller or equal to maximum age, otherwise it's reset", () => (int)prop.GetValue(config), (int i) => prop.SetValue(config, i));

                        var maxProp = typeof(AnimalsDieConfig).GetProperty("Max" + prop.Name.Substring(3));

                        betterName = Regex.Replace(maxProp.Name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");

                        api.RegisterSimpleOption(manifest, betterName, "must be larger or equal to the minimum age, otherwise it's reset", () => (int)maxProp.GetValue(config), (int i) => maxProp.SetValue(config, i));
                    }
                }
            }
        }
Beispiel #9
0
        /// <summary>A SMAPI GameLaunched event that enables GMCM support if that mod is available.</summary>
        public void EnableGMCM(object sender, GameLaunchedEventArgs e)
        {
            try
            {
                GenericModConfigMenuAPI api = Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu"); //attempt to get GMCM's API instance

                if (api == null)                                                                                                       //if the API is not available
                {
                    return;
                }

                api.RegisterModConfig(ModManifest, () => Config = new ModConfig(), () => Helper.WriteConfig(Config)); //register "revert to default" and "write" methods for this mod's config
                api.SetDefaultIngameOptinValue(ModManifest, true);                                                    //allow in-game setting changes (rather than just at the main menu)

                //register an option for each of this mod's config settings
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "When bushes regrow",
                    "The amount of time before destroyed bushes will regrow.\nType a number and then a unit of time (Days, Seasons, Years).\nLeave this blank to never respawn bushes.\nExamples: \"3 days\" \"1 season\" \"1 year\"",
                    () => Config.WhenBushesRegrow ?? "null", //return the string "null" if the setting is null
                    (string val) => Config.WhenBushesRegrow = val
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Destroyable bush locations",
                    "A list of locations where bushes should be destroyable.\nIf the list is empty, all locations will be allowed.\nSeparate each name with a comma.\nExample: \"Farm, BusStop, Forest, Woods\"",
                    () => GMCMLocationList,
                    (string val) => GMCMLocationList = val
                );

                api.RegisterLabel
                (
                    ModManifest,
                    "Destroyable bush types",
                    "The types of bush that are allowed to be destroyed."
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Small bushes",
                    "Check this box to make small bushes destroyable.",
                    () => Config.DestroyableBushTypes.SmallBushes,
                    (bool val) => Config.DestroyableBushTypes.SmallBushes = val
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Medium bushes",
                    "Check this box to make medium bushes destroyable. These are the type that can produce berries.",
                    () => Config.DestroyableBushTypes.MediumBushes,
                    (bool val) => Config.DestroyableBushTypes.MediumBushes = val
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Large bushes",
                    "Check this box to make large bushes destroyable.",
                    () => Config.DestroyableBushTypes.LargeBushes,
                    (bool val) => Config.DestroyableBushTypes.LargeBushes = val
                );

                api.RegisterLabel
                (
                    ModManifest,
                    "Amount of wood dropped",
                    "The number of wood pieces dropped when each type of bush is destroyed."
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Small bushes",
                    "The number of wood pieces dropped when a small bush is destroyed.",
                    () => Config.AmountOfWoodDropped.SmallBushes,
                    (int val) => Config.AmountOfWoodDropped.SmallBushes = val
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Medium bushes",
                    "The number of wood pieces dropped when a medium bush is destroyed.",
                    () => Config.AmountOfWoodDropped.MediumBushes,
                    (int val) => Config.AmountOfWoodDropped.MediumBushes = val
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Large bushes",
                    "The number of wood pieces dropped when a large bush is destroyed.",
                    () => Config.AmountOfWoodDropped.LargeBushes,
                    (int val) => Config.AmountOfWoodDropped.LargeBushes = val
                );
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Green tea bushes",
                    "The number of wood pieces dropped when a green tea bush is destroyed.",
                    () => Config.AmountOfWoodDropped.GreenTeaBushes,
                    (int val) => Config.AmountOfWoodDropped.GreenTeaBushes = val
                );
            }
            catch (Exception ex)
            {
                Monitor.Log($"An error happened while loading this mod's GMCM options menu. Its menu might be missing or fail to work. The auto-generated error message has been added to the log.", LogLevel.Warn);
                Monitor.Log($"----------", LogLevel.Trace);
                Monitor.Log($"{ex.ToString()}", LogLevel.Trace);
            }
        }
Beispiel #10
0
        public static void EnableGMCM(object sender, GameLaunchedEventArgs e)
        {
            IManifest manifest = ModEntry.Instance.ModManifest;                                                                                      //get this mod's manifest

            GenericModConfigMenuAPI api = ModEntry.Instance.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu"); //attempt to get GMCM's API instance

            if (api == null)                                                                                                                         //if the API is not available
            {
                return;
            }

            api.RegisterModConfig(manifest, () => ModEntry.ModConfig = new ModConfig(), () => ModEntry.Instance.Helper.WriteConfig(ModEntry.ModConfig)); //register "revert to default" and "write" methods for this mod's config

            //register an option for each of this mod's config settings
            api.RegisterSimpleOption(
                manifest,
                "Enable slow debuff",
                "If this box is checked, Pollen Sprites will apply a slow effect when they touch you.\nIn multiplayer, this option only affects you.",
                () => ModEntry.ModConfig.EnableSlowDebuff,
                (bool val) => ModEntry.ModConfig.EnableSlowDebuff = val
                );

            api.RegisterSimpleOption(
                manifest,
                "Enable energy drain",
                "If this box is checked, Pollen Sprites will slowly drain your energy when they touch you (but never below 10 points).\nIn multiplayer, this option only affects you.",
                () => ModEntry.ModConfig.EnableEnergyDrain,
                (bool val) => ModEntry.ModConfig.EnableEnergyDrain = val
                );

            api.RegisterLabel(
                manifest,
                "Seed drop chances",
                "When Pollen Sprites are defeated, these options decide how often they drop seeds.\nUse 0 for a 0% chance, 0.45 for 45%, 1 for 100%, etc."
                );

            api.RegisterSimpleOption(
                manifest,
                "Mixed seeds",
                "The chance that Pollen Sprites will drop mixed seeds.\nUse 0 for a 0% chance, 0.45 for 45%, 1 for 100%, etc.",
                () => ModEntry.ModConfig.SeedDropChances.MixedSeeds.ToString(), //read this setting as a string
                (string val) =>
            {
                if (double.TryParse(val, out double result))                //if the string can be parsed to a double
                {
                    ModEntry.ModConfig.SeedDropChances.MixedSeeds = result; //use the parsed value
                }
            }
                );

            api.RegisterSimpleOption(manifest,
                                     "Flower seeds",
                                     "The chance that Pollen Sprites will drop random flower seeds.\nUse 0 for a 0% chance, 0.45 for 45%, 1 for 100%, etc.",
                                     () => ModEntry.ModConfig.SeedDropChances.FlowerSeeds.ToString(), //read this setting as a string
                                     (string val) =>
            {
                if (double.TryParse(val, out double result))                 //if the string can be parsed to a double
                {
                    ModEntry.ModConfig.SeedDropChances.FlowerSeeds = result; //use the parsed value
                }
            }
                                     );

            api.RegisterSimpleOption(
                manifest,
                "All seeds",
                "The chance that Pollen Sprites will drop ANY random seeds, including from modded crops.\nUse 0 for a 0% chance, 0.45 for 45%, 1 for 100%, etc.",
                () => ModEntry.ModConfig.SeedDropChances.AllSeeds.ToString(), //read this setting as a string
                (string val) =>
            {
                if (double.TryParse(val, out double result))              //if the string can be parsed to a double
                {
                    ModEntry.ModConfig.SeedDropChances.AllSeeds = result; //use the parsed value
                }
            }
                );
        }