-
Notifications
You must be signed in to change notification settings - Fork 6
2) Basic Functions
Aaron C Robinson edited this page Aug 29, 2018
·
9 revisions
The bulk of settings helper is simply a wrapper for RimWorld's Listing_Standard
. Here we will describe those wrapper methods and give example of how to use them.
- First make sure you are using the appropriate namespace
SettingsHelper
- Label
- bool Value (by ref)
class SeasonalWeatherMod : Mod
{
...
public override void DoSettingsWindowContents(Rect inRect)
{
Listing_Standard listing_Standard = new Listing_Standard();
listing_Standard.Begin(inRect);
listing_Standard.AddLabeledCheckbox("EnableEarthquakesLabel".Translate() + ": ",
ref settings.enableEarthquakes);
listing_Standard.AddLabeledCheckbox("EnableWildfiresLabel".Translate() + ": ",
ref settings.enableWildfires);
listing_Standard.End();
settings.Write();
}
}
Example from: SeasonalWeather's ModSettings
- Label line
- Array or dictionary of labels
- Value being set
class MapRendererMod : Mod
{
public static MapRendererSettings settings;
public static string[] exportFormats = { "JPG", "PNG" };
...
public override void DoSettingsWindowContents(Rect inRect)
{
Listing_Standard listing_Standard = new Listing_Standard();
listing_Standard.Begin(inRect);
listing_Standard.AddLabeledCheckbox("MR_ShowWeatherLabel".Translate(),
ref settings.showWeather);
listing_Standard.AddHorizontalLine(3f);
listing_Standard.AddLabeledRadioList($"{"MR_AddExportFormatOptionsDescription".Translate()}:",
exportFormats, ref settings.exportFormat);
listing_Standard.AddHorizontalLine(3f);
listing_Standard.AddLabeledNumericalTextField<int>("MR_QualityLabel".Translate(),
ref settings.quality, minValue: 1f,
maxValue: 2000f);
listing_Standard.AddLabeledTextField("MR_PathLabel".Translate(), ref settings.path);
listing_Standard.End();
settings.Write();
}
}
Example from: MapRenderer's ModSettings
For the full details on this please refer to: SettingsHelper.cs