SettingsApi
Settings API for allowing mods to add settings.
模組介紹 作者原文
Muck Settings API
This is a helper mod made to allow easier addition of settings to mods that require configuration, all in the in-game settings menu.
An example of implementing this library can be found in the "MuckSettingsExample" subdirectory of this repository.
To add your own settings, first patch one of the 5 tabs in `MuckSettings.Settings: either Gameplay, Controls, Graphics, Video or Audio. Don't worry about the settings overflowing, all pages are scrollable. Next, make sure you take a MuckSettings.Settings.Page argument called page in your patch, and you can add settings to that page. To save your settings, you should be using BepInEx.Configuration;, and create a ConfigFile to store your config. Make sure to specify that config.SaveOnConfigSet = true;` or else your config willl not save when the user changes the settings!
Different settings
Boolean Setting
This one is fairly straightforward. It's a toggle that can be either on, or off.
- You should use `page.AddBoolSetting(string name, ConfigEntry configEntry) to create a setting that assigns the associated ConfigEntry` from your BepInEx config. The first parameter is the display name for the setting.
- You can use `page.AddBoolSetting(string name, bool defaultValue, Action update) to create a low-level setting where you control it. name is the name that displays for the option. defaultValue is the value to show when the page loads, and update` is the Action to call with the new value whenever the user changes the setting.
Scroll Setting
A scroll setting lets the user scroll through a list of predetermined options.
- You should use `page.AddScrollSetting(string name, ConfigEntry configEntry) where T: Enum to create a scroll setting from enum values with the given ConfigEntry`. For this to work correctly you need the values to be consecutive from 0 (i.e. just the names in the declaration, no values assigned).
- You can use `page.AddScrollSetting(string name, T defaultValue, Action update) where T: Enum to create a scroll setting from enum values, starting at the specified defaultValue and telling when it changes using the update` callback.
- You can use `page.AddScrollSetting(string name, int index, Action update) where T: Enum`. It works very similarly to the one above, but this one takes the value of the enums, and not the enum object straight up. You should probably only use this when you actually need the index values, such as when storing them and you cannot change that (i.e. the vanilla game's settings store, which is the only reason this overload exists).
- You can use `page.AddScrollSetting(string name, string values, int defaultIndex, Action update) to create a with name still being the name that displays, values is the array of options to show, defaultIndex the index you loaded to show by default, and update` is a callback giving you the index of the option whenever the user changes it.
Slider Setting
A slider setting is... a slider, that you use to select a number within a range. The sliders are only whole numbers, and you can use divison if you want fractional values, such as with the music slider in the base game, which actually ranges from 0-1 internally but is divided by 10 since the slider range is 0-10.
- You should use `page.AddSliderSetting(string name, ConfigEntry configEntry, int min, int max) to create a slider from the given ConfigEntry, ranging from min-max and with the display name name`.
- You can use `page.AddSliderSetting(string name, int defaultValue, int min, int max, Action update) to create a slider setting with the given name and defaultValue, ranging from min to max and telling you when it changes with update`.
Control Setting
A control setting allows the user to choose a button on their keyboard or mouse to bind a specific action to.
- You should use `page.AddControlSetting(string name, ConfigEntry configEntry) to create a control setting from the given ConfigEntry. name` is the display name in the settings page.
- You
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。