Skip to content

Game.UI.Widgets.Bounds2InputField

Assembly: Game
Namespace: Game.UI.Widgets

Type: class

Base: Colossal.UI.Binding.Field

Summary:
A UI input field widget for editing Colossal.Mathematics.Bounds2 values (typically a pair of min/max Vector2 or similar). This widget extends the generic Field binding infrastructure and exposes a configuration option allowMinGreaterMax which (when serialized to the UI) indicates whether the minimum component(s) are allowed to be greater than the maximum component(s). The actual validation/behavior is handled by the UI system that consumes the serialized property.


Fields

  • None
    This class declares no private or public fields of its own; it only adds a property and overrides a serialization method on top of Field.

Properties

  • public bool allowMinGreaterMax { get; set; }
    Controls whether the UI should allow the minimum value(s) to be greater than the maximum value(s). By default this is false (standard min <= max semantics) unless explicitly set. The property is serialized in WriteProperties so the UI/JSON consumer can apply the appropriate validation/behavior.

Constructors

  • public Bounds2InputField()
    The default parameterless constructor is implicit. No custom construction logic is defined in this class.

Methods

  • protected override void WriteProperties(IJsonWriter writer)
    Overrides the Field serialization hook to write the allowMinGreaterMax flag into the JSON representation consumed by the UI layer. Implementation behavior:
  • Calls base.WriteProperties(writer) to serialize standard field properties.
  • Writes a boolean property named "allowMinGreaterMax" with the current value of the property.

This method is used by the Colossal UI binding system when building the widget description that the UI renderer or editor consumes.

Usage Example

using Colossal.Mathematics;
using Colossal.UI.Binding;
using Game.UI.Widgets;

// create and configure the input field
var boundsField = new Bounds2InputField
{
    allowMinGreaterMax = true // allow inverted ranges if your use-case requires it
};

// typically you'd add the field to a UI form / binding container and set up binding
// Example (conceptual):
// someForm.AddField("myBounds", boundsField);
// binder.Bind("myBounds", () => myBoundsValue, v => myBoundsValue = v);

Notes: - Bounds2 is the struct from Colossal.Mathematics representing a 2D bounds (min/max). Ensure your mod references the Colossal.* assemblies. - The widget itself does not perform validation beyond serializing the flag; the UI consumer is expected to enforce or present appropriate controls based on "allowMinGreaterMax".