Skip to content

Game.UI.Widgets.UIntFieldBuilders

Assembly:
Assembly-CSharp (typical for Cities: Skylines 2 mods — replace with actual assembly if different)

Namespace:
Game.UI.Widgets

Type:
public class

Base:
IFieldBuilderFactory

Summary:
Factory that produces FieldBuilder delegates for fields of type uint. Depending on provided widget attributes and global bypass flags, it will create either a slider-backed field (UIntSliderField) or an input-backed field (UIntInputField). It also reads number range, step and unit metadata from attributes and wraps the provided IValueAccessor with a CastAccessor for the created field.


Fields

  • private static readonly uint kGlobalValueRange
    A default upper bound used for numeric widgets when EditorGenerator.sBypassValueLimits is false. Its value is 10,000,000 (10000000u). If sBypassValueLimits is true, uint.MaxValue is used instead.

Properties

  • None.

Constructors

  • public UIntFieldBuilders()
    Default parameterless constructor. The class holds no instance state and only exposes the TryCreate factory method.

Methods

  • public FieldBuilder TryCreate(Type memberType, object[] attributes)
    Attempts to create a FieldBuilder for the given member type and widget attributes:

  • If memberType is not typeof(uint), returns null (this factory only handles unsigned integer fields).

  • Initializes min to 0 and max to either kGlobalValueRange or uint.MaxValue depending on EditorGenerator.sBypassValueLimits.
  • Reads step via WidgetAttributeUtils.GetNumberStep(attributes, 1u).
  • Calls WidgetAttributeUtils.GetNumberRange(attributes, ref min, ref max):
    • If a numeric range is specified and WidgetAttributeUtils.RequiresInputField(attributes) is false, returns a FieldBuilder that constructs a UIntSliderField configured with min, max, step, unit (from GetNumberUnit), and accessor wrapped in CastAccessor.
    • Otherwise returns a FieldBuilder that constructs a UIntInputField configured with min, max, step and accessor wrapped in CastAccessor.

Notes: - The returned FieldBuilder has the signature IValueAccessor -> Field (concrete field types: UIntSliderField or UIntInputField). - The function relies on WidgetAttributeUtils helper methods and on the EditorGenerator.sBypassValueLimits flag to determine limits and presentation.

Usage Example

// Example of invoking the factory to get a FieldBuilder for a uint member
var factory = new Game.UI.Widgets.UIntFieldBuilders();
object[] attributes = new object[0]; // replace with actual widget attributes if any

// Try create a builder for a uint field
var builder = factory.TryCreate(typeof(uint), attributes);
if (builder != null)
{
    // Assume 'accessor' is an existing IValueAccessor for the target value
    IValueAccessor accessor = /* obtain accessor for the target uint value */ null;

    // Create the actual field (either UIntSliderField or UIntInputField)
    var field = builder(accessor);

    // Configure or add the field to your UI as needed...
}