Popup settings window - piotrulos/MSCModLoader GitHub Wiki
Popup Settings Window
In version 1.3+ there is new type of customizable window, called PopupSettings. It's designed in similar way to ModSettings but unlike ModSettings any values put there are not saved by default. It's designed to act as custom form that user can submit, and it's your job to parse the values and use them however your want.
Example
private void Mod_Settings()
{
Settings.AddButton("Create Popup Setting", () => { CreatePopupWindow(); });
}
private void CreatePopupWindow()
{
PopupSetting popupSetting = ModUI.CreatePopupSetting("Some Form", "Submit Form");
popupSetting.AddText("Print Below text to console");
popupSetting.AddTextBox("myText", "Some text", string.Empty, "Enter some text...");
popupSetting.AddSlider("manyTimes", "How many times", 1, 10, 1);
popupSetting.ShowPopup(MyResult);
}
private void MyResult(string response)
{
MyParsedResult myParsedResult = ModUI.ParsePopupResponse<MyParsedResult>(response);
for(int i = 0; i < myParsedResult.manyTimes; i++)
{
ModConsole.Warning(response);
}
}
class MyParsedResult
{
public string myText;
public int manyTimes;
}
Response in popup result comes as json string that uses format "settingID":"value", there is many more features for this, you can control visibility just like in settings, you can also specify for some fields to not return a value by calling DontReturnValue()
(like you have checkbox that only controls visibility of some elemets)