ModSettingsAPI
An API to create settings windows for mods.
模組介紹 作者原文
ModSettings API
About
ModSettings API allows other mods, to create a simple setting windows in the game "My Dream Setup".
Features
ModSettings API can be used by creating a new TabModel instance, and giving it the API with: ModdedSettingsApi.AddMod(TabModel modSettings)
There are currently the following components available:
ButtonSetting, TextBoxSetting, ComboBoxSetting, ToggleButtonSetting
These can be used by creating an instance of ButtonVariant, TextBoxVariant, ComboBoxVariant, ToggleButtonVariant, which require all data, to visualize the wanted setting, those variant wrappers are readonly and don't support changes mid game.
Use case
The API call to add the settings page for any mod, should be done very early, since the api only creates the entire view the first time and does not react to changes from the Variant or TabModel instances anymore.
This mod was mainly to get familiar with the ui components in MDS, and such is most likely not that useful, a settings window can be created like this:
public static void Init()
{
var lst = new List();
lst.Add(new ModSettingsApi.Models.Variants.ToggleButtonVariant("DebugToggle", ToggleChangedDebug, true));
var combo = new ModSettingsApi.Models.Variants.ComboBoxVariant("DebugCombo", ComboValueChanged, new List()
{
new ModSettingsApi.Models.Variants.ComboBoxOptionData("Debug_1"),
new ModSettingsApi.Models.Variants.ComboBoxOptionData("Debug_2"),
new ModSettingsApi.Models.Variants.ComboBoxOptionData("Debug_3"),
new ModSettingsApi.Models.Variants.ComboBoxOptionData("Debug_4")
});
lst.Add(combo);
lst.Add(new ModSettingsApi.Models.Variants.ButtonVariant("ButtonDebugOption", "BtnText", ButtonPressed));
//lst.Add(new SliderVariant("SliderOption"));
lst.Add(new ModSettingsApi.Models.Variants.TextBoxVariant("TextBoxDebugOption", "GreyText", TextBoxHasChanged, "TextBoxDefaultValue"));
var settingsData = new ModSettingsApi.Models.TabModel("DebugData Mod", lst);
ModSettingsApi.Api.ModdedSettingsApi.AddMod(settingsData);
}
public static void ButtonPressed(ButtonVariant sender)
{
LogManager.Message($"DebugDataManager: Button pressed, sender: {sender.SettingsText}");
}
private static void ToggleChangedDebug(bool newValue)
{
LogManager.Message($"DebugDataManager: Toggle changed, new Value: {newValue}");
}
private static void ComboValueChanged(IComboBoxData data)
{
LogManager.Message($"DebugDataManager: Combo value changed, new Value: {data.Text}");
}
private static void TextBoxHasChanged(string newValue)
{
LogManager.Message($"DebugDataManager: TextBox value changed, new Value: {newValue}");
}
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: