Skip to content

Game.UI.Widgets.Bounds1Field

Assembly: Assembly-CSharp
Namespace: Game.UI.Widgets

Type: abstract class

Base: Field

Summary:
A reusable UI field widget that represents a 1-dimensional bounds value (Colossal.Mathematics.Bounds1). Exposes configuration for allowed range (min / max), display precision (fractionDigits), step increment used by UI controls, and whether inverted ranges (min > max) are permitted. The class serializes these configuration properties to a JSON writer so they can be emitted to the UI framework. Intended to be subclassed to provide concrete widget behavior or to be instantiated via a derived class in UIs that bind to Bounds1 values.


Fields

  • None
    This class does not declare explicit backing fields; it exposes configuration via public auto-properties.

Properties

  • public float min { get; set; }
    Minimum allowed value for the bounds. Default: float.MinValue. Used when serializing the widget configuration and by UI logic to clamp/validate input.

  • public float max { get; set; }
    Maximum allowed value for the bounds. Default: float.MaxValue. Used when serializing the widget configuration and by UI logic to clamp/validate input.

  • public int fractionDigits { get; set; }
    Number of fractional digits to show when formatting the numeric values. Default: 3. Affects displayed precision in the UI.

  • public float step { get; set; }
    Step/increment used by UI controls (e.g., spinner or arrow buttons). Default: 0.1f.

  • public bool allowMinGreaterMax { get; set; }
    Whether the field allows min to be greater than max (inverted range). Default: false. When false, UI or validation logic should prevent inverted ranges.

Constructors

  • public Bounds1Field()
    Default parameterless constructor (compiler-generated). The class is abstract — instantiate via a concrete subclass. Initializes properties to their default values as declared.

Methods

  • protected override void WriteProperties(IJsonWriter writer) : System.Void
    Serializes the widget configuration to the provided IJsonWriter. Calls base.WriteProperties(writer) and then writes the following properties in sequence: "min", "max", "fractionDigits", "step", and "allowMinGreaterMax". Used by the UI framework to produce the JSON description of the widget for front-end binding.

Usage Example

// Example: create a concrete subclass and configure it
public class MyBounds1Field : Bounds1Field
{
    // Provide widget-specific behavior/rendering if needed.
    // The base WriteProperties already emits the configuration
    // ("min","max","fractionDigits","step","allowMinGreaterMax").
}

var field = new MyBounds1Field {
    min = 0f,
    max = 10f,
    fractionDigits = 2,
    step = 0.5f,
    allowMinGreaterMax = false
};

// If you need to customize JSON output, you can override WriteProperties:
protected override void WriteProperties(IJsonWriter writer)
{
    base.WriteProperties(writer);
    // writer.PropertyName("custom"); writer.Write(customValue);
}