Table of Contents

Class SettingsXmlWriter

Namespace
MCM.Abstractions.Xml
Assembly
MCMv5.dll

Writes current values back into the file a <Settings> block was declared in, as Value attributes on the property elements. Only those attributes change: the file is edited as text, not re-serialized, so comments, quotes, attribute layout, line endings, encoding and byte order mark stay as they are.

public static class SettingsXmlWriter
Inheritance
SettingsXmlWriter
Inherited Members

Methods

FindDeclaration(XmlDocument, string)

Finds the <Settings> block with the id, resolving a missing Id attribute to the module id the way FromDocument(XmlDocument) does.

public static XmlElement? FindDeclaration(XmlDocument document, string settingsId)

Parameters

document XmlDocument
settingsId string

Returns

XmlElement

GetPropertyElements(XmlElement)

The property elements of a declaration by property id, nested groups included.

public static Dictionary<string, XmlElement> GetPropertyElements(XmlElement declaration)

Parameters

declaration XmlElement

Returns

Dictionary<string, XmlElement>

Load(string)

Loads the file with its whitespace preserved.

public static XmlDocument Load(string filePath)

Parameters

filePath string

Returns

XmlDocument

SetValues(string, string, IEnumerable<KeyValuePair<string, string>>)

Sets the Value attribute of every listed property of the block in the file. Values are the text a Default attribute takes; a dropdown takes the option index. Ids without a matching property element are ignored. Returns false when the block is not in the file. The file is written in place, so links a mod manager deployed stay intact, and only when a value changed.

public static bool SetValues(string filePath, string settingsId, IEnumerable<KeyValuePair<string, string>> values)

Parameters

filePath string
settingsId string
values IEnumerable<KeyValuePair<string, string>>

Returns

bool

TrySetValues(string, string, IEnumerable<KeyValuePair<string, string>>, out string)

public static bool TrySetValues(string xml, string settingsId, IEnumerable<KeyValuePair<string, string>> values, out string result)

Parameters

xml string
settingsId string
values IEnumerable<KeyValuePair<string, string>>
result string

Returns

bool

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...