BepInEx 插件/Mod管理 + GUI 漢化版(Plugin / mod configuration manager)
一個簡單的工具,無需自己製作,直接你的插件/Mod 配置一個GUI,用戶可以更改你公開的任何設置,包括鍵盤快捷鍵; 默認按F1打開管理界面,這個按鍵可以根據自己的習慣修改;
截圖 共 1 張
模組介紹 作者原文
一個簡單的工具,無需自己製作,直接你的插件/Mod 配置一個GUI,用戶可以更改你公開的任何設置,包括鍵盤快捷鍵; 默認按F1打開管理界面,這個按鍵可以根據自己的習慣修改;
作者:BepInEx
漢化:小莫
源碼:
一個簡單的工具,無需自己製作,直接你的插件/Mod 配置一個GUI,用戶可以更改你公開的任何設置,包括鍵盤快捷鍵;
默認按F1打開管理界面,這個按鍵可以根據自己的習慣修改;
安裝方法:
- 安裝BepInEx:
- 將“ConfigurationManager.dll”和“ConfigurationManager.xml”放入“\BepInEx\plugins”目錄
- 如果沒有“plugins”就自己新建一個
- 進遊戲按F1打開菜單
爲你的Mod製作GUI:
ConfigurationManager 會自動將插件的配置內容顯示出來;
ConfigurationManager 將使用所有元素(例如:說明,範圍)向用戶展示;
在大多數情況下,您不必引用ConfigurationManager.dll或對其進行特殊的數據處理;
只需確保添加儘可能多的參數(這樣可以幫助玩家更好的進行修改)。別忘了添加描述、鍵名、值範圍。
爲你的Mod添加範圍滑塊:
創建時,請指定 AcceptableValueRange,如果範圍是0f-1f,或0-100,則滑塊將顯示百分比%。
```csharp
CaptureWidth = Config.Bind(“Section”, “Key”, 1, new ConfigDescription(“Description”, new AcceptableValueRange(0, 100)));
```
爲你的Mod添加下拉選項:
創建時,請指定 AcceptableValueList,如果使用枚舉,則無需指定 AcceptableValueList,將會顯示所有的枚舉值。
注意:你可以將 System.ComponentModel.DescriptionAttribute 添加到枚舉項目中,以覆蓋其顯示的名稱,如:
```csharp
public enum MyEnum
{
// Entry1 將在下拉框中 顯示 Entry1
Entry1,
[Description(“Entry2 將在下拉框中顯示該字符串”)]
Entry2
}
```
爲你的Mod添加自定義按鍵:
創建類型爲 KeyboardShortcut,可以使用Update()函數 + IsDown 來監聽用戶是否按下;
KeyboardShortcut 支持Shift、Ctrl、Alt的修飾鍵,並且這些按鍵也得到了合適的處理,避免了一些常見的問題;
例如 K+Shift+Ctrl 時會觸發 K+Shift 的問題。(這個問題不會出現了)
```csharp
private ConfigEntry ShowCounter { get; set; }
public Constructor()
{
ShowCounter = Config.Bind(“Hotkeys”, “Show FPS counter”, new KeyboardShortcut(KeyCode.U, KeyCode.LeftShift));
}
private void Update()
{
if (ShowCounter.Value.IsDown())
{
// 處理按鍵
}
}
```
覆蓋Configuration Manager的默認行爲:
You can change how a setting is shown inside the configuration manager window by passing an instance of a special class as a tag of the setting. The special class code can be downloaded here. Simply download the.cs file and drag it into your project.
You do not have to reference ConfigurationManager.dll for this to work.
The class will work as long as name of the class and declarations of its fields remain unchanged.
Avoid making the class public to prevent conflicts with other plugins. If you want to share it between your plugins either give each a copy, or move it to your custom namespace.
If the ConfigurationManager plugin is not installed in the game, this class will be safely ignored and your plugin will work as normal.
Here’s an example of overriding order of settings and marking one of the settings as advanced:
```csharp
// Override IsAdvanced and Order
Config.Bind(“X”, “1”, 1, new ConfigDescription(“”, null, new ConfigurationManagerAttributes { IsAdvanced = true, Order = 3 }));
// Override only Order, IsAdvanced stays as the default value assigned by ConfigManager
Config.Bind(“X”, “2”, 2, new ConfigDescription(“”, null, new ConfigurationManagerAttributes { Order = 1 }));
```
How to make a custom editor for my setting?
If you are using a setting type that is not supported by ConfigurationManager, you can add a drawer Action for it. The Action will be executed inside OnGUI, use GUILayout to draw your setting as shown in the example below.
To use a custom seting drawer for an individual setting, use the CustomDrawer field in the attribute class. See above for more info on the attribute class.
```csharp
void Start()
{
// Add the drawer as a tag to this setting.
Config.Bind(“Section”, “Key”, “Some value”
new ConfigDescription(“Desc”, null, new ConfigurationManagerAttributes{ CustomDrawer = MyDrawer });
static void MyDrawer(BepInEx.Configuration.ConfigEntryBase entry)
{
// Make sure to use GUILayout.ExpandWidth(true) to use all available space
GUILayout.Label(entry.BoxedValue, GUILayout.ExpandWidth(true));
Add a custom editor globally
You can specify a drawer for all settings of a setting type. Do this by using ConfigurationManager.RegisterCustomSettingDrawer(Type, Action).
}
```
Warning: This requires you to reference ConfigurationManager.dll in your project and is not recommended unless you are sure all users will have it installed. It’s usually better to use the above method to add the custom d …
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 這類遊戲沒有通用的模組管理器:有的模組直接替換遊戲檔案、有的放進遊戲專屬的 Mods 資料夾、有的要先裝遊戲對應的社群載入器或工具,以包內說明為準。
- 嚴格按說明放置檔案;標註「前置依賴」的模組需要把依賴一併裝好。
- 啟動遊戲確認載入成功;部分遊戲需要在設定或模組選單裡手動啟用。
不同遊戲、不同模組的安裝位置差異很大,包內說明是最可靠的依據。