Ejemplo n.º 1
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
                {
                    Monitor.Log($"Optional API not found: Generic Mod Config Menu (GMCM).", LogLevel.Trace);
                    return;
                }
                else //if the API is available
                {
                    Monitor.Log($"Optional API found: Generic Mod Config Menu (GMCM).", LogLevel.Trace);
                }

                api.RegisterModConfig(ModManifest, () => ResetConfigToDefault(), () => Helper.WriteConfig(Utility.MConfig)); //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, "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, "Enable EPU debug messages", "Check this box to enable Expanded Preconditions Utility (EPU) debug messages.\nThis can be helpful when testing preconditions.", () => EPUDebugMessages, (bool val) => EPUDebugMessages = 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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }