docs
Systems
Presentation
UISystem
Public API Reference

UICommandFactory

Static class in SaffronLibrary.Prime.Systems.UI. Builds and sends UI-domain commands.

RegisterFlowControllable

Builds a Register command for Domain.UI, sets the registration key under CoreParamKeys.Key and the component under UIParamKeys.FlowControllable, and sends it with BusUtility.Send.

public static void RegisterFlowControllable(string registrationKey, IFlowControllable flowControllable)
  • registrationKey: The key the component is routed under.
  • flowControllable: The component to register.

UICommandVerb

Enum of command verbs for the UI domain. Values are sent as int in Command.Verb.

public enum UICommandVerb
{
    None = 0,
    Open = 1,
    Close = 2,
    Add = 3,
    Remove = 4,
    Set = 5,
    Reset = 6,
    Refresh = 7,
    Show = 8,
    Hide = 9,
    Enable = 10,
    Disable = 11,
    Save = 12,
    Load = 13,
    Place = 14,
    Register = 15,
}

UIEventVerb

Enum of event verbs for the UI domain. Values are sent as int in Event.Verb.

public enum UIEventVerb
{
    None = 0,
    Clicked = 1,
    DoubleClicked = 2,
    Released = 7,
    Selected = 11,
    Changed = 8,
    Submitted = 9,
    Backed = 10,
    Opened = 3,
    Closed = 4,
    Focused = 5,
    Scrolled = 12,
    Finished = 13,
}

UIRequestVerb

Enum of request verbs for the UI domain. This file defines the enum only. The code in this system does not use it.

public enum UIRequestVerb
{
    None = 0,
    Confirm = 1,
    Cancel = 2,
    Open = 3,
    Navigate = 4,
    Register = 5,
}

UISubjects

Enum that identifies which UI element a command or event concerns. Used as the value of UIParamKeys.UISubject.

public enum UISubjects
{
    None = 0,
    Pointer = 1,
    Popup = 2,
    Image = 3,
    Inventory = 4,
    Button = 5,
    Scroller = 6,
    Panel = 7,
    Timer = 8,
}

UIParamKeyNames

Public static class of string names for the UI parameter keys. The Base and Schema members are private and are not listed.

public static class UIParamKeyNames
{
    public const string UISubject;        // "core.ui.subjects"
    public const string PointerLocation;  // "core.ui.pointerLocation"
    public const string FlowControllable; // "core.ui.flowControllable"
    public const string Target;           // "core.ui.target"
    public const string Rect;             // "core.ui.rect"
    public const string Interaction;      // "core.ui.interaction"
    public const string ImageOpacity;     // "core.ui.imageOpacity"
    public const string Command;          // "core.ui.command"
}

UIParamKeys

Public static class of typed parameter keys. Each field is a ParamKey<T> built from a name in UIParamKeyNames.

public static class UIParamKeys
{
    public static readonly ParamKey<ICommand> Command;
    public static readonly ParamKey<Vector2> PointerLocation;
    public static readonly ParamKey<UISubjects> UISubject;
    public static readonly ParamKey<IFlowControllable> FlowControllable;
 
    public static class Navigate
    {
        public static readonly ParamKey<string> Target;
    }
 
    public static class Layout
    {
        public static readonly ParamKey<RectTransform> Rect;
    }
 
    public static class State
    {
        public static readonly ParamKey<bool> Interaction;
    }
 
    public static class Visual
    {
        public static readonly ParamKey<float> ImageOpacity;
    }
}

Navigate, Layout, State, and Visual are nested public static classes. The keys inside them are not used by the code in this system.

UIEventFactory

Public static partial class. Builds UI events and sends them with BusUtility.Raise. The private helper CreateUIEvent is not listed.

OnPointerClick

Raises a Clicked event with subject Pointer and the location stored under UIParamKeys.PointerLocation.

public static void OnPointerClick(UnityEngine.Vector2 location)

OnDoubleClicked

Raises a DoubleClicked event. It sets no params.

public static void OnDoubleClicked()

OnButtonClicked (no arguments)

Raises a Clicked event with subject Button.

public static void OnButtonClicked()

OnButtonClicked (with identifiers)

Raises a Clicked event with subject Button, the tag under CoreParamKeys.Tag, the registration key under CoreParamKeys.RegistrationKey, and the domain target under CoreParamKeys.DomainContext.

public static void OnButtonClicked(string tag, string registrationKey, Domain domainTarget)

RaiseUIPageEvent

Raises an event with the given verb and the page tag under CoreParamKeys.Tag.

public static void RaiseUIPageEvent(UIEventVerb verb, string pageTag)

UIRoot

Public abstract class that derives from MonoBehaviour and implements IFlowControllable.

public abstract class UIRoot : MonoBehaviour, IFlowControllable
{
    public abstract string RegistrationKey { get; }
 
    protected void Start();
 
    public void Register();
}
  • RegistrationKey: Abstract. Derived classes must provide the key the component is registered under.
  • Start: Protected and not virtual. It calls Register. Derived classes cannot override it, so they must register in another way if they need to change this timing.
  • Register: Calls UICommandFactory.RegisterFlowControllable with RegistrationKey and this instance.

UIFlowController

Public abstract class that derives from FlowController. Owns the UI domain.

public abstract class UIFlowController : FlowController
{
    protected sealed override Domain Domain { get; }   // always Domain.UI
 
    protected override void HandleCommand(ICommand cmd);
 
    protected bool TryGetCommandProcessor(string registrationKey, out ICommandProcessor processor);
}
  • Domain: Returns Domain.UI. It is sealed, so subclasses cannot change it.
  • HandleCommand: Ignores commands with no Key param. A Register verb is passed to the private registration logic. Any other command is passed to the ICommandProcessor registered under its key, if there is one.
  • TryGetCommandProcessor: Returns true and the processor if one is registered under registrationKey. Otherwise returns false.

The class also has private registration members, which are not listed here.