Game.UI.Widgets.PagedBindings
Assembly:
Game (UI bindings assembly; part of the game's UI/modding code)
Namespace:
Game.UI.Widgets
Type:
class
Base:
IWidgetBindingFactory
Summary:
PagedBindings is a small binding-factory implementation that creates a trigger binding named "setCurrentPageIndex". The produced TriggerBinding accepts an integer page index and, when invoked, will set the target widget's current page index if the widget implements IPaged. If the resolved widget is null or does not implement IPaged, an error is logged to UnityEngine.Debug. The factory yields a single binding and does not store state.
Fields
- This type declares no fields.
This class is stateless — it only produces bindings on demand.
Properties
- This type exposes no public properties.
All behavior is provided through the CreateBindings method.
Constructors
public PagedBindings()
Default (implicit) constructor. No initialization is required.
Methods
public IEnumerable<IBinding> CreateBindings(string group, IReader<IWidget> pathResolver, ValueChangedCallback onValueChanged)
Creates and returns one or more bindings for the given group. In this implementation it yields a single TriggerBinding configured as follows:- Trigger name: "setCurrentPageIndex"
- Delegate signature: (IWidget widget, int pageIndex)
- Behavior: If the resolved widget implements IPaged, sets paged.currentPageIndex = pageIndex. If widget is null, logs "Invalid widget path"; if widget does not implement IPaged, logs "Widget does not implement IPaged".
- Notes:
- The method does not use the onValueChanged callback parameter.
- Returns an enumerable with a single TriggerBinding; callers should iterate and register bindings with the UI binding system.
Parameters:
- group: group name for the binding (used by the binding system to scope bindings).
- pathResolver: an IReader
Usage Example
// Example: registering/using the PagedBindings factory (pseudocode; adjust to your binding system)
var factory = new Game.UI.Widgets.PagedBindings();
// Obtain an IReader<IWidget> from your UI framework that can resolve widget paths.
// This depends on the UI/binding implementation in your mod or game code.
IReader<IWidget> resolver = /* get resolver from your UI system */;
// Create bindings for group "pagedControls". The factory yields one TriggerBinding.
foreach (var binding in factory.CreateBindings("pagedControls", resolver, null))
{
// Register the binding with the UI binding manager or attach it to the widget system.
// BindingManager.Register(binding) // example API; replace with actual registration call
}
// The produced TriggerBinding listens for the trigger "setCurrentPageIndex" with an int argument.
// When invoked on a widget that implements IPaged, it will run:
// paged.currentPageIndex = <providedPageIndex>
// Example IPaged widget (simplified)
public class MyPagedWidget : IWidget, IPaged
{
public int currentPageIndex { get; set; }
// ... other widget implementation ...
}