Testy Modpack
this mod is for me and my friends to play with
截圖 共 5 張
模組介紹 作者原文
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
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: