Game.UI.Widgets.EnumMember
Assembly:
Assembly-CSharp
Namespace:
Game.UI.Widgets
Type:
class
Base:
System.Object, Colossal.UI.Binding.IJsonWritable
Summary:
Represents a single enum entry used by UI widgets. Carries the numeric value, a localized display name, and a disabled flag. Implements IJsonWritable to control JSON serialization (writes type header and three properties: "value", "displayName", and "disabled").
Fields
- This type declares no private fields.
The data is exposed via public auto-properties.
Properties
-
public ulong value { get; set; }
Holds the numeric value of the enum member. Serialized using ULongWriter.WriteAsArray when writing JSON. -
public LocalizedString displayName { get; set; }
The localized text shown to the user for this enum member. Serialized via the IJsonWriter.Write overload for LocalizedString. -
public bool disabled { get; set; }
If true, the enum option is considered disabled (e.g., shown but not selectable). Serialized as a boolean.
Constructors
public EnumMember(ulong value, LocalizedString displayName, bool disabled = false)
Initializes a new EnumMember with the provided numeric value, localized display name, and optional disabled state (defaults to false).
Methods
public void Write(IJsonWriter writer)
Implements IJsonWritable.Write. Serialization steps performed:- Calls writer.TypeBegin(GetType().FullName) to start the typed object.
- Writes the property name "value" and serializes the ulong via ULongWriter.WriteAsArray(writer, value).
- Writes the property name "displayName" and writes the LocalizedString via writer.Write(displayName).
- Writes the property name "disabled" and writes the boolean via writer.Write(disabled).
- Calls writer.TypeEnd() to finish the typed object.
Notes: - The "value" is written specifically with ULongWriter.WriteAsArray; this may produce an array-form representation compatible with the project's JSON conventions for unsigned long values. - The serialized output includes type metadata (full type name) because TypeBegin/TypeEnd are used.
Usage Example
using Colossal.UI.Binding;
using Game.UI.Localization;
using Game.UI.Widgets;
// create an enum member (example LocalizedString construction depends on the project's localization API)
var member = new EnumMember(1UL, new LocalizedString("enum.display.name"), disabled: false);
// write to an IJsonWriter (writer must be provided by the environment)
member.Write(writer);
// Example of the JSON-like structure produced (conceptual):
// {
// "$type": "Game.UI.Widgets.EnumMember, Assembly-CSharp",
// "value": [1], // produced by ULongWriter.WriteAsArray
// "displayName": { ... }, // representation produced by writer.Write(LocalizedString)
// "disabled": false
// }