Game.UI.Widgets.UIntField
Assembly:
Game
Namespace:
Game.UI.Widgets
Type:
class
Base:
Field
Summary:
A UI field control for unsigned integer values used by the game's UI system. Exposes range and stepping configuration (min, max, step, stepMultiplier) and serializes those properties to a JSON writer via an overridden WriteProperties method. Useful when creating or configuring numeric input fields in modded UI panels or options.
Fields
- No explicit private fields declared in this class.
Compiler-generated backing fields exist for the auto-implemented properties (min, max, step, stepMultiplier).
Properties
-
public uint min { get; set; }
Minimum allowed value for the field. No explicit default set in code (defaults to 0). -
public uint max { get; set; } = uint.MaxValue;
Maximum allowed value for the field. Defaults to uint.MaxValue. -
public uint step { get; set; } = 1u;
Step/increment used for the field (e.g., when using spinner controls). Defaults to 1. -
public uint stepMultiplier { get; set; } = 10u;
Multiplier applied to step for faster increments (e.g., when a modifier key is held). Defaults to 10.
Constructors
public UIntField()
No explicit constructor is defined in the source file; the class uses the default parameterless constructor. Initialization of defaults for auto-properties is performed inline (see property defaults).
Methods
protected override void WriteProperties(IJsonWriter writer) : System.Void
Writes the field's properties into a JSON writer. The implementation calls base.WriteProperties(writer) and then writes the following JSON properties in order: "min", "max", "step", "stepMultiplier".
Note: The provided source contains a bug — the last written value mistakenly uses step again instead of stepMultiplier:
Original (buggy) line: writer.PropertyName("stepMultiplier"); writer.Write(step);
Corrected implementation should be:
protected override void WriteProperties(IJsonWriter writer) { base.WriteProperties(writer); writer.PropertyName("min"); writer.Write(min); writer.PropertyName("max"); writer.Write(max); writer.PropertyName("step"); writer.Write(step); writer.PropertyName("stepMultiplier"); writer.Write(stepMultiplier); // <-- corrected }
This ensures the stepMultiplier value is serialized properly.
Usage Example
// Create and configure a UIntField instance
var uintField = new Game.UI.Widgets.UIntField {
min = 0u,
max = 100u,
step = 5u,
stepMultiplier = 20u
};
// When the UI system serializes this control, WriteProperties will emit:
// "min": 0
// "max": 100
// "step": 5
// "stepMultiplier": 20
// If you need to patch the source, make sure the WriteProperties method
// writes stepMultiplier (not step) for the "stepMultiplier" property:
// writer.PropertyName("stepMultiplier");
// writer.Write(stepMultiplier);
Notes and recommendations: - Because the class uses auto-properties, no additional state management is required here. - Fix the serialization bug if you rely on stepMultiplier being present in generated JSON (it will otherwise duplicate step).