Text alignment and layout groups for settings - piotrulos/MSCModLoader GitHub Wiki

[!IMPORTANT] Below features were added in version 1.3.3 build 355

Groups and layouts

A new functions have been added to create custom settings group outside header, custom vertical group could be used to toggle visibility of multiple settings without making header, and you can also create custom horizontal group to for example put few elemets in horizontal layout.
Settings.CreateGroup(true/false); true - horizontal group / false - vertical (default) grup
Settings.EndGroup(); Closes custom group

Functions and limitations

Created group retunrs SettingsGroupLayout variable, it can be used to toggle visibility of the group.
Horizontal layout can be used to create for example 3 buttons side by side (Remember that horizontal space has fixed size)
Current limitation: Groups cannot be nested, you need to end previous group to create new one.

Example usage

private void Mod_Settings()
{
    Settings.AddHeader("Horizontal group example");
    Settings.AddText("Below is an example of 3 buttons in a horizontal group");
    Settings.CreateGroup(true); // true = horizontal, false = vertical
    Settings.AddButton("Button 1", () => ModConsole.Warning("Button 1 pressed"));
    Settings.AddButton("Button 2", () => ModConsole.Warning("Button 2 pressed"));
    Settings.AddButton("Button 3", () => ModConsole.Warning("Button 3 pressed"));
    Settings.EndGroup(); // End, closes the group and goes back to default layout.
}

horizontal group

Text alignment

AddText now supports TextAlignment

Example usage

private void Mod_Settings()
{
    Settings.AddHeader("Text alignment example");
    Settings.AddText("Left aligned text", TextAlignment.Left);
    Settings.AddText("Center aligned text", TextAlignment.Center);
    Settings.AddText("Right aligned text", TextAlignment.Right);
}

text