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);
        }
Пример #3
0
        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);
        }
        /// <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, () => Utility.MConfig = new ModConfig(), () => Helper.WriteConfig(Utility.MConfig)); //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(ModManifest, "Enable console commands", "Uncheck this box to disable FTM's console commands, e.g. for mod compatibility.\nNOTE: This will not take effect until Stardew Valley is restarted.", () => Utility.MConfig.EnableConsoleCommands, (bool val) => Utility.MConfig.EnableConsoleCommands = val);
                api.RegisterSimpleOption(ModManifest, "Enable content packs", "Uncheck this box to disable all FTM content packs.\nOnly the \"personal\" files in FarmTypeManager/data will be used.", () => Utility.MConfig.EnableContentPacks, (bool val) => Utility.MConfig.EnableContentPacks = val);
                api.RegisterSimpleOption(ModManifest, "Enable trace log messages", "Uncheck this box to disable FTM's [TRACE] message type in SMAPI's log files.\nLogs will be smaller but provide less info.", () => Utility.MConfig.EnableTraceLogMessages, (bool val) => Utility.MConfig.EnableTraceLogMessages = val);
                api.RegisterSimpleOption(ModManifest, "Monster limit per location", "The maximum number of monsters FTM will spawn on a single map.\nEnter NULL for unlimited monsters.", () => MonsterLimitAsString, (string val) => MonsterLimitAsString = val);
            }
            catch (Exception ex)
            {
                Utility.Monitor.Log($"An error happened while loading FTM's GMCM options menu. That menu might be missing or fail to work. The auto-generated error message has been added to the log.", LogLevel.Warn);
                Utility.Monitor.Log($"----------", LogLevel.Trace);
                Utility.Monitor.Log($"{ex.ToString()}", LogLevel.Trace);
            }
        }
Пример #5
0
        public void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            try
            {
                JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
                this.Helper.Content.InvalidateCache("Data/mail");
            }
            catch (Exception ex)
            {
                Monitor.Log("Error loading JSON assets", LogLevel.Warn);
            }

            try
            {
                GenericModConfigMenuAPI api = this.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

                if (api == null)
                {
                    return;
                }

                api.RegisterModConfig(ModManifest, () => Config = new UmbrellaConfig(), () => Helper.WriteConfig(Config));

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Enable wetness",
                    "",
                    () => Config.enableWetness,
                    (bool val) => Config.enableWetness = val
                );

                api.RegisterParagraph(ModManifest, "If this box is checked, the farmer will get wet when standing outside in the rain without an umbrella. When the farmer is wet, stamina will be slowly drained. More information about the wetness system can be found on the mod page.");

                api.RegisterSimpleOption(
                    ModManifest,
                    "Stamina drain rate",
                    "",
                    () => Config.staminaDrainRate,
                    (float val) => Config.staminaDrainRate = val
                    );

                api.RegisterParagraph(ModManifest, "How much stamina to drain every 10 minutes (in game time) when the farmer is wet.");
            }
            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);
            }
        }
Пример #6
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

                //register an option for each of this mod's config settings
                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Enable cosmetic floating effect",
                    "Check this box to enable the cosmetic \"floating\" effect on items in water.\nDisabling this might improve performance on some systems.",
                    () => Config.EnableCosmeticFloatingEffect,
                    (bool val) =>
                {
                    if (val)                                                 //if this is being set to true
                    {
                        HarmonyPatch_FloatingItemVisualEffect.ApplyPatch();  //apply this patch if necessary
                    }
                    else                                                     //if this is being set to false
                    {
                        HarmonyPatch_FloatingItemVisualEffect.RemovePatch(); //remove this patch if necessary
                    }
                    Config.EnableCosmeticFloatingEffect = val;
                }
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    "Teleport floating items to player",
                    "Check this box to make items in water teleport to the nearest player whenever possible.\nEnabling this makes it easier to retrieve items.",
                    () => Config.TeleportItemsOutOfWater,
                    (bool val) => Config.TeleportItemsOutOfWater = 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);
            }
        }
        private void RegisterWithGmcm()
        {
            GenericModConfigMenuAPI configMenuApi =
                Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            configMenuApi.RegisterModConfig(ModManifest,
                                            () => _config = new ModConfig(),
                                            () => Helper.WriteConfig(_config));

            configMenuApi.RegisterSimpleOption(ModManifest, _helper.Translation.Get("bettercrystalariums.debug-setting-title"),
                                               _helper.Translation.Get("bettercrystalariums.debug-setting-description"),
                                               () => _config.DebugMode,
                                               (bool value) => _config.DebugMode = value);
        }
Пример #8
0
        private void RegisterWithGmcm()
        {
            GenericModConfigMenuAPI configMenuApi =
                Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            configMenuApi.RegisterModConfig(ModManifest,
                                            () => _config = new ModConfig(),
                                            () => Helper.WriteConfig(_config));

            configMenuApi.RegisterSimpleOption(ModManifest, "Toggle Tracking Target",
                                               "Whether or not you want the log to specify whether the player or cursor was the source of this co-ordinate.",
                                               () => _config.LogTrackingTarget,
                                               (bool value) => _config.LogTrackingTarget = value);
            configMenuApi.RegisterSimpleOption(ModManifest, "HUD Toggle",
                                               "The key used to toggle the co-ordinate HUD.",
                                               () => _config.CoordinateHUDToggle,
                                               (button) => _config.CoordinateHUDToggle = button);
            configMenuApi.RegisterSimpleOption(ModManifest, "Log Co-ordinates",
                                               "The key used to log the current co-ordinates to file.",
                                               () => _config.LogCoordinates,
                                               (button) => _config.LogCoordinates = button);
            configMenuApi.RegisterSimpleOption(ModManifest, "Toggle Tracking Target",
                                               "The key used to toggle between tracking the cursor and the player's co-ordinates.",
                                               () => _config.SwitchToCursorCoords,
                                               (button) => _config.SwitchToCursorCoords = button);
            configMenuApi.RegisterSimpleOption(ModManifest, "HUD X Co-ordinate:",
                                               "The X co-ordinate of the HUD",
                                               () => _config.HudXCoord,
                                               (int value) => _config.HudXCoord = value);
            configMenuApi.RegisterSimpleOption(ModManifest, "HUD Y Co-ordinate:",
                                               "The Y co-ordinate of the HUD",
                                               () => _config.HudYCoord,
                                               (int value) => _config.HudYCoord = value);

// Since I can't think of a way to log co-ordinates on Android, a toggle to make the HUD movable is
// also out of the question until I figure that out.
#if ANDROID
#else
            configMenuApi.RegisterSimpleOption(ModManifest, "Unlock HUD Position",
                                               "Press this key to toggle the HUD to be unlocked so you can move it around.",
                                               () => _config.HudUnlock,
                                               (button) => _config.HudUnlock = button);
#endif
        }
        public void EnableGMCM(object sender, GameLaunchedEventArgs e)
        {
            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, () => MConfig = new ModConfig(), () => Helper.WriteConfig(MConfig)); //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(ModManifest, "Enable trackers without profession", "If this box is checked, you won't need the Foraging skill's \"Tracker\" perk to see trackers.", () => MConfig.EnableTrackersWithoutProfession, (bool val) => MConfig.EnableTrackersWithoutProfession = val);
            api.RegisterSimpleOption(ModManifest, "Replace trackers with forage icons", "If this box is checked, trackers will display the objects they're pointing to.", () => MConfig.ReplaceTrackersWithForageIcons, (bool val) => MConfig.ReplaceTrackersWithForageIcons    = val);
            api.RegisterSimpleOption(ModManifest, "Draw trackers behind interface", "If this box is checked, trackers will be drawn behind the game's interface, making it easier to see the UI.", () => MConfig.DrawBehindInterface, (bool val) => MConfig.DrawBehindInterface = val);
            api.RegisterSimpleOption(ModManifest, "Tracker pixel scale", "The size of the tracker icon's pixels (default 4). Increase this to make trackers easier to see.", () => MConfig.TrackerPixelScale, (float val) => MConfig.TrackerPixelScale = val);

            api.RegisterSimpleOption(ModManifest, "Track default forage", "If this box is checked, the mod will track most types of forage spawned by the base game.", () => MConfig.TrackDefaultForage, (bool val) => MConfig.TrackDefaultForage = val);
            api.RegisterSimpleOption(ModManifest, "Track artifact spots", "If this box is checked, the mod will track buried artifact locations.", () => MConfig.TrackArtifactSpots, (bool val) => MConfig.TrackArtifactSpots               = val);
            api.RegisterSimpleOption(ModManifest, "Track panning spots", "If this box is checked, the mod will track ore panning locations in the water.", () => MConfig.TrackPanningSpots, (bool val) => MConfig.TrackPanningSpots         = val);
            api.RegisterSimpleOption(ModManifest, "Track spring onions", "If this box is checked, the mod will track harvestable spring onions.", () => MConfig.TrackSpringOnions, (bool val) => MConfig.TrackSpringOnions                  = val);
            api.RegisterSimpleOption(ModManifest, "Track berry bushes", "If this box is checked, the mod will track harvestable salmonberry and blackberry bushes.", () => MConfig.TrackBerryBushes, (bool val) => MConfig.TrackBerryBushes = val);
        }
        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);
        }
Пример #11
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);
            }
        }
Пример #12
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));
                    }
                }
            }
        }
Пример #13
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);
            }
        }
Пример #14
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
                }
            }
                );
        }
        // <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

                //register an option for each of this mod's config settings
                api.RegisterSimpleOption
                (
                    ModManifest,
                    Helper.Translation.Get("BuildOnAllTerrainFeatures.Name"),
                    Helper.Translation.Get("BuildOnAllTerrainFeatures.Description"),
                    () => Config.BuildOnAllTerrainFeatures,
                    (bool val) => Config.BuildOnAllTerrainFeatures = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    Helper.Translation.Get("BuildOnOtherBuildings.Name"),
                    Helper.Translation.Get("BuildOnOtherBuildings.Description"),
                    () => Config.BuildOnOtherBuildings,
                    (bool val) => Config.BuildOnOtherBuildings = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    Helper.Translation.Get("BuildOnWater.Name"),
                    Helper.Translation.Get("BuildOnWater.Description"),
                    () => Config.BuildOnWater,
                    (bool val) => Config.BuildOnWater = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    Helper.Translation.Get("BuildOnImpassableTiles.Name"),
                    Helper.Translation.Get("BuildOnImpassableTiles.Description"),
                    () => Config.BuildOnImpassableTiles,
                    (bool val) => Config.BuildOnImpassableTiles = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    Helper.Translation.Get("BuildOnNoFurnitureTiles.Name"),
                    Helper.Translation.Get("BuildOnNoFurnitureTiles.Description"),
                    () => Config.BuildOnNoFurnitureTiles,
                    (bool val) => Config.BuildOnNoFurnitureTiles = val
                );

                api.RegisterSimpleOption
                (
                    ModManifest,
                    Helper.Translation.Get("BuildOnCaveAndShippingZones.Name"),
                    Helper.Translation.Get("BuildOnCaveAndShippingZones.Description"),
                    () => Config.BuildOnCaveAndShippingZones,
                    (bool val) => Config.BuildOnCaveAndShippingZones = 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);
            }
        }