Adds a new page to the game options for mods. This allows mods to easily implement settings using native UI instead of UMM. This does not create a save dependency.
If you don't want to use ModFinder you can download the latest release and install normally using UMM.
File an issue on GitHub or reach out to me (@WittleWolfie) on Discord in #mod-dev-technical or #mod-user-general channel.
This does not support controllers. It's a lot of work to support, but let me know if you need this. If there is enough demand I will add it.
This is a non-exhaustive list, let me know if you want your mod added here!
The screenshot above was generated using TestSettings. That exercises every function supported. The API is documented and generally self-explanatory.
In your mod's Info.json
add ModMenu
as a requirement:
"Requirements": ["ModMenu"]
You should specify a minimum version:
"Requirements": ["ModMenu-1.1.0"]
It's safest to just specify the version you build against as the minimum version, but methods added after 1.0 do specify the version in their remarks.
Install ModMenu then in your mod's project add %WrathPath%/Mods/ModMenu/ModMenu.dll
as an assembly reference.
Create a setting:
ModMenu.AddSettings(
SettingsBuilder.New("mymod-settings, SettingsTitle)
.AddToggle(Toggle.New("mymod-settings-toggle", defaultValue: true, MyToggleTitle)
.OnValueChanged(OnToggle)));
private static void OnToggle(bool toggleValue) {
// The user just changed the toggle, toggleValue is the new setting.
// If you need to react to it changing then you can do that here.
// If you don't need to do something whenever the value changes, you can skip OnValueChanged()
}
Get the setting value:
ModMenu.GetSettingValue<bool>("mymod-settings-toggle");
The game handles the setting value for you. You do not need to save the setting, or set the setting to a specific value. You can set it if necessary but most of the time it isn't necessary. This includes saving settings that you flag as per-save using DependsOnSave()
.
For more examples see TestSettings.
LocalizedString
. I recommend adding settings before, during, or after BlueprintsCache.Init()
.IsModificationAllowed
to enable/disable a setting based on another setting. This is checked when the page is opened so it won't apply immediately.WithLongDescription()
. The game's setting boolean RequireReboot
does nothing.Define a "root" key unique to your mod to make sure there are no key conflicts:
private const string RootKey = "mymod-settings";
You can then prepend this to all of your settings keys:
// Results in a settings key "mymod-settings-key"
var toggle = Toggle.New(GetKey("toggle"), MyToggleTitle);
private static string GetKey(string key)
{
return $"{RootKey}-{key}";
}
Just make sure you always get the key the same way when getting a setting value.
DependsOnSave()
are associated with a save slot, but do not create save dependencies
OnValueChanged()
is called after the user clicks "Apply" and confirmsOnTempValueChanged()
is called immediately after the user changes the value, but before it is applied