Table of Contents

Class SettingsXmlModel

Namespace
MCM.Abstractions.Xml
Assembly
MCMv5.dll

Settings declared in XML instead of code. The block can be the root of its own file or a child of <Module> in a mod's SubModule.xml, where MCM discovers it without the mod referencing MCM. The file is also the store: every property carries its Default, and the current value is written back as a Value attribute by MCM or by the mod itself (see SettingsXmlWriter).

<Settings>
  <Group Name="{=id}General">
    <Bool Id="Enabled" DisplayName="{=id}Enabled" HintText="{=id}..." Default="true" RequireRestart="false" />
  </Group>
  <Preset Id="off" DisplayName="Off"><Property Id="Enabled" Value="false" /></Preset>
</Settings>

Properties placed directly under <Settings> go to the default (Misc) group. In a SubModule.xml, Id defaults to the module id and DisplayName to the module name.

public class SettingsXmlModel
Inheritance
SettingsXmlModel
Inherited Members

Fields

ElementName

public const string ElementName = "Settings"

Field Value

string

ModuleElementName

public const string ModuleElementName = "Module"

Field Value

string

Properties

DisplayName

public string DisplayName { get; set; }

Property Value

string

FolderName

Not read from the XML. The values are stored in the declaring file, not in a settings folder.

public string FolderName { get; }

Property Value

string

FormatType

Not read from the XML. The values are stored in the declaring file, not in a settings format.

public string FormatType { get; set; }

Property Value

string

Groups

public List<PropertyGroupXmlModel> Groups { get; set; }

Property Value

List<PropertyGroupXmlModel>

Id

public string Id { get; set; }

Property Value

string

Presets

public List<PresetXmlModel> Presets { get; set; }

Property Value

List<PresetXmlModel>

Properties

Properties outside any group. They are shown in the default group.

public List<PropertyBaseXmlModel> Properties { get; set; }

Property Value

List<PropertyBaseXmlModel>

SubFolder

Not read from the XML. The values are stored in the declaring file, not in a settings folder.

public string SubFolder { get; }

Property Value

string

SubGroupDelimiter

The first character is used, / when empty.

public string SubGroupDelimiter { get; set; }

Property Value

string

UIVersion

public int UIVersion { get; set; }

Property Value

int

Methods

EnumerateDeclarations(XmlDocument)

Every <Settings> element of a document with the module id and name it can take its defaults from.

public static IEnumerable<(XmlElement Node, string ModuleId, string ModuleName)> EnumerateDeclarations(XmlDocument document)

Parameters

document XmlDocument

Returns

IEnumerable<(XmlElement Node, string ModuleId, string ModuleName)>

FromDocument(XmlDocument)

Reads every <Settings> block of a document: the root itself when the document is a standalone settings file (Id required), or the children of the <Module> root of a SubModule.xml, where Id defaults to the module id and DisplayName to the module name. Blocks resolving to an id already seen are skipped.

public static IEnumerable<SettingsXmlModel> FromDocument(XmlDocument document)

Parameters

document XmlDocument

Returns

IEnumerable<SettingsXmlModel>

FromXml(XmlNode, string, string)

Reads a <Settings> element. Returns null when no Id can be determined.

public static SettingsXmlModel? FromXml(XmlNode node, string moduleId = "", string moduleName = "")

Parameters

node XmlNode

The <Settings> element.

moduleId string

The id of the declaring module, used when Id is absent.

moduleName string

The name of the declaring module, used when DisplayName is absent.

Returns

SettingsXmlModel

GetAllProperties()

Every property of every group, including nested groups, plus the ungrouped ones.

public IEnumerable<PropertyBaseXmlModel> GetAllProperties()

Returns

IEnumerable<PropertyBaseXmlModel>

GetGroupedProperties()

Every property with the group it belongs to. Ungrouped properties belong to the default group and a nested group is flattened to Parent/Nested with the sub group delimiter, the way MCM names sub groups.

public IEnumerable<(IPropertyGroupDefinition Group, PropertyBaseXmlModel Property)> GetGroupedProperties()

Returns

IEnumerable<(IPropertyGroupDefinition Group, PropertyBaseXmlModel Property)>

This page was last modified at 10/17/2026 18:11:59 +03:00 (UTC).

Commit Message
Author:    Vitalii Mikhailov
Commit:    4c11f9b0c8db5363fd147c4f156b8d8151ad53b0
* Mods can declare their settings in their SubModule.xml, which MCM will render if installed.

* A warning is logged when two mods declare settings with the same id
* Updated to UIExtenderEx v3
* Fixed controller tab switching in the options screen landing on the wrong page next to Mod Options
* Fixed Cancel in the options screen undoing MCM changes before the game ask...