Game.UI.Widgets.BoundsFieldBuilders
Assembly: Assembly-CSharp
Namespace: Game.UI.Widgets
Type: public class BoundsFieldBuilders
Base: IFieldBuilderFactory
Summary:
Implements IFieldBuilderFactory to create UI field builders for bounds types used by the game's widget system. Depending on the requested member type (Bounds1, Bounds2, Bounds3) and attributes supplied, TryCreate returns a FieldBuilder delegate that constructs the appropriate input widget (slider or input field). It uses WidgetAttributeUtils to read attributes such as numeric range, step and whether min can be greater than max, and wraps the provided IValueAccessor in a CastAccessor
Fields
- This type declares no instance fields.
The class is stateless and only exposes behavior through TryCreate.
Properties
- This type declares no properties.
The factory pattern here provides creation behavior via a method rather than storing state.
Constructors
public BoundsFieldBuilders()
Default public parameterless constructor (implicit). Use to obtain an instance of the factory.
Methods
public FieldBuilder TryCreate(Type memberType, object[] attributes)
Examines memberType and attribute metadata to return a FieldBuilder delegate that constructs an appropriate bounds editing widget, or null when the type is not supported.
Detailed behavior:
- If memberType == typeof(Bounds1)
- Initializes min/max to float.MinValue/float.MaxValue and step from WidgetAttributeUtils.GetNumberStep(attributes, 0.01f).
- Reads allowMinGreaterMax via WidgetAttributeUtils.AllowsMinGreaterMax(attributes).
- If WidgetAttributeUtils.GetNumberRange(attributes, ref min, ref max) returns true and WidgetAttributeUtils.RequiresInputField(attributes) is false, returns a FieldBuilder that constructs a Bounds1SliderField with configured min, max, step, allowMinGreaterMax and an accessor wrapped as CastAccessor
Notes:
- FieldBuilder is a delegate that takes an IValueAccessor and returns an instance of a widget/input field (e.g., Bounds1SliderField, Bounds1InputField, etc.).
- WidgetAttributeUtils provides helper methods to interpret widget attributes (number step, numeric range, whether to force an input field, and min/max behavior).
- CastAccessor
Usage Example
// Create factory
var factory = new BoundsFieldBuilders();
// Example: request builder for a Bounds1 field with no extra attributes
FieldBuilder builder = factory.TryCreate(typeof(Bounds1), new object[0]);
if (builder != null)
{
// Assume 'accessor' is an IValueAccessor that targets a Bounds1-backed value
IValueAccessor accessor = /* obtain or implement accessor */;
var field = builder(accessor); // returns a Bounds1InputField or Bounds1SliderField depending on attributes
// Add 'field' to your UI container or configure further as needed
}
Additional implementation notes: - If you supply attributes that include a numeric range (via the game's widget attribute system) and do not require an input field, Bounds1 will prefer a slider representation. If no range is present or an input field is required, an input field is used instead. - Bounds2 and Bounds3 are always created as input fields by this factory (no slider branch present in this implementation).