InLobbyConfig
Adds an ability to edit configs for mods (that support this) inside a lobby
截圖 共 4 張
模組介紹 作者原文
Description
This library adds an ability to edit configs for mods (that support this) inside a lobby.
For developers
Dependency attribute [BepInDependency("com.KingEnderBrine.InLobbyConfig")]
TL;DR
Easiest (but limited) way to add config based on BepInEx config is to use helper method
var configEntry = InLobbyConfig.Fields.ConfigFieldUtilities.CreateFromBepInExConfigFile(Config, "Display name");
InLobbyConfig.ModConfigCatalog.Add(configEntry);
There is a special field. If your config has a bool field called Enabled (ignored case) it will be shown next to the mod name like so:
This behavior can be disabled if you add false to parameters for CreateFromBepInExConfigFile.
Or you can create InLobbyConfig.ModConfigEntry and add fields and section manually
var configEntry = new InLobbyConfig.ModConfigEntry();
configEntry.DisplayName = "Display name";
//configEntry.EnableField = new BooleanConfigField(...);
configEntry.SectionFields.Add("Section name", new List
{
new InLobbyConfig.Fields.BooleanConfigField("display name", () => ConfigField.Value, (newValue) => ConfigField.Value = newValue),
InLobbyConfig.Fields.ConfigFieldUtilities.CreateFromBepInExConfigEntry(ConfigField)
});
InLobbyConfig.ModConfigCatalog.Add(configEntry);
Documentation
Supported field types
|Type|Field class|
|----|---|
|bool|BooleanConfigField|
|enum|EnumConfigField|
|int|IntConfigField|
|float|FloatConfigField|
|string|StringConfigField|
|UnityEngine.Color|ColorConfigField|
|Collection|SelectListField|
Or you can create your own ConfigField with your own prefab, for example:
Field constructor parameters description
BaseConfigField (BooleanConfigField, EnumConfigField)
- displayName - name of a field
- tooltip - text to display when hover over field name.
- valueAccessor - a function which will be used to retrieve actual value of config.
- onValueChanged - a function which will be called when the value of a field is changed. Value in config doesn't automatically change, this is up to you what you want to do with the changed value.
SelectConfigField
Same as BaseConfigField +
- optionsAccessor - a function which will be used to retrieve available values for selection.
BaseInputConfigField (ColorConfigField, StringConfgiField)
Same as BaseConfigField +
- onEndEdit - a function which will be called when a user ended changing field. Unlike onValueChange which called with every change. Value in config doesn't automatically change, this is up to you what you want to do with the changed value.
BaseNumberInputConfigField (IntConfigField, FloatConfigField)
Same as BaseInputConfigField +
- minimum - minimum for a field value.
- maximum - maximum for a filed value.
SelectListField
Same as BaseConfigField +
- OnItemAddedCallback - a function which will be called when a new item added to a collection.
- OnItemRemovedCallback - a function which will be called when an item removed from a collection.
- OptionsAccessor - a function which will be used to retrieve options for selection.
Custom config field
Mandatory things that you need to create a custom config field:
- Create a class that implements InLobbyConfig.Fields.IConfigField (or inherits form InLobbyConfig.Fields.BaseConfigField)
- Create a class that inherites InLobbyConfig.FieldControllers.ConfigFieldController
- Create a prefab that has your ConfigFieldController in a root object
From this point, you can do whatever you want. For examples of how I set up fields, you can go to InLobbyConfig GitHub or ArtifactsRandomizer GitHub.
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: