Testy Mod
this mod is for me and my friends to play with
Screenshots 5 screenshots
About this mod Author’s original text
LethalConfig
LethalConfig is a mod configuration menu that allows players to edit their configs from within the game. It also provides a simple API for developers to customize their mod and config entries.
Inspired by Rune580's RiskOfOptions
Summary
- Supported Types
- Usage
- Automatic generation
- Setting up
- Adding a ConfigItem
- ConfigItem restart requirement
- ConfigItem CanModifyCallback
- Disabling/Skipping Automatic Generation
- Listening to setting changes
- Generic buttons
- Overriding display properties of items
- Customizing mod's icon and description
- Building LethalConfig
- Issues and Suggestions
Supported Types
Currently, LethalConfig allows developers to add the following types of interfaces for ConfigEntry's:
| Component | Value Type | ConfigItem Type |
| --------- | ---------- | ---------- |
| Integer Slider | int | IntSliderConfigItem |
| Integer Input Field | int | IntInputFieldConfigItem |
| Float Slider | float | FloatSliderConfigItem |
| Float Step Slider | float | FloatStepSliderConfigItem |
| Float Input Field | float | FloatInputFieldConfigItem |
| Text Input Field | string | TextInputFieldConfigItem |
| Enum Dropdown | Enum | EnumDropDownConfigItem<> |
| Boolean Checkbox | Enum | BoolCheckBoxConfigItem |
| Generic Button | - | GenericButtonConfigItem
\
An example of the LethalConfig menu and its element types
Usage
Automatic generation
As of 1.1.0, LethalConfig automatically generates mod entries and detect all ConfigEntry's declared by said mods, and tries its best to generate the correct UI components.
It'll assign a default mod icon and will have a disclaimer in the mod's and config's descriptions about them being automatically generated and that they may require a restart, as there's no way for LethalConfig to tell if a setting will take effect immediately or not.
Unless you're a mod developer that wants to customize their mod icon and description, manually setup the UI components (e.g. use a slider instead of a number text field), or mark settings as non-restart required, you don't need to do anything else other than installing the mod.
Some types may not have a UI component developed for it yet. In these cases, LethalConfig will ignore the ConfigEntry. More types will be covered over time.
Setting up
To start using LethalConfig on your mod, add a reference on your project to the LethalConfig's dll file. You can get the dll by downloading the LethalConfig mod.
To access the API, simply use the LethalConfig namespace or import it on your source file:
using LethalConfig;
It is also recommended to add a BepInDependency attribute to your plugin to hint BepInEx that your mod has a dependency to it:
[BepInPlugin(PluginInfo.Guid, PluginInfo.Name, PluginInfo.Version)]
[BepInDependency("ainavt.lc.lethalconfig")]
public class MyVeryCoolPlugin: BaseUnityPlugin {...
}
Adding a ConfigItem
With everything setup, you should now have access to the main LethalConfigManager and are able to add any of the available components you want.
First, you create your ConfigEntry from BepInEx like you would normally:
var configEntry = Config.Bind("General", "Example", 0, "This is an example component!");
With your ConfigEntry in hand, you can now create and register a new item to the menu by using the following method:
var exampleSlider = new IntSliderConfigItem(configEntry, new IntSliderOptions
{
Min = 0,
Max = 100
});
LethalConfigManager.AddConfigItem(exampleSlider);
And that's it, you now have created your first component!
LethalConfig automatically picks up some of your mod info, and it automatically creates sections based on the section of the provided ConfigEntry, so you do not have to worry about any extra setup in terms of layout.
ConfigItem restart requirement
By default, all items will be set to require a restart if changed. This will give a warning to the player once they apply the settings.
If you want your items to not be flagged as restart required, simply
Install & use Install: BepInEx plugin
- The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
- Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
- Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
- Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.
Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.
Install these first, or the mod will not work: