Skip to content

Game.UI.Widgets.PageLayout

Assembly:
Assembly: Game (assembly name inferred from namespace; exact DLL not provided)
Namespace: Game.UI.Widgets

Type:
internal class PageLayout

Base:
LayoutContainer

Summary:
A simple layout container representing a UI "page" with a localized title and an optional back action. Implements IInvokable (so it can be invoked to perform the back action), IWidget (used as a widget in the UI system), and IJsonWritable (can serialize selected properties to JSON). The class is internal to the Game assembly and intended for use by the game's UI framework or mods that run within the same assembly context.


Fields

  • This class declares no explicit private fields.
    The class uses auto-implemented properties (title and backAction), which result in compiler-generated backing fields that are not shown in the source.

Properties

  • public Game.UI.Localization.LocalizedString title { get; set; }
    Holds the localized title for the page. This value is serialized via WriteProperties as the "title" JSON property.

  • [CanBeNull] public System.Action backAction { get; set; }
    Optional delegate that is invoked when the page's "back" action is requested. Marked with [CanBeNull], so callers should tolerate a null value. The presence of a back action is serialized as a boolean "hasBackAction" in the JSON output.

Constructors

  • public PageLayout()
    Initializes a new PageLayout and sets the layout mode on the base LayoutContainer: base.flex = FlexLayout.Fill. This makes the container fill available space by default.

Methods

  • public void Invoke()
    Implements IInvokable. Calls the backAction delegate: backAction(). Note: the method does not perform a null-check before invoking backAction — calling Invoke() when backAction is null will result in a NullReferenceException. Consumers should ensure backAction is assigned or check before invoking.

  • protected override void WriteProperties(IJsonWriter writer)
    Overrides the base implementation to write JSON properties describing the page. Behavior:

  • Calls base.WriteProperties(writer).
  • Writes a property named "title" and writes the title value via writer.Write(title).
  • Writes a property named "hasBackAction" and writes a boolean indicating whether backAction != null.
    This means the serialized JSON records the page title and whether a back action is present, but it does not serialize the action delegate itself.

Usage Example

// Create a page, set a localized title and a back action, then invoke it.
var page = new PageLayout();

// Assign a LocalizedString (constructor / factory depends on the localization API)
page.title = new Game.UI.Localization.LocalizedString("My Page Title");

// Assign a back action. Ensure not null if you plan to call Invoke().
page.backAction = () =>
{
    // Perform navigation or close the page
    CloseCurrentPage();
};

// Later, trigger the back action via Invoke()
page.Invoke();

// When serialized via IJsonWritable.WriteProperties, the output will include:
// "title": <title value>, "hasBackAction": true/false

Notes and remarks: - Because PageLayout is internal, it's intended for use within the Game assembly or by mods that run with access to that assembly internals. - The [CanBeNull] annotation on backAction documents that the delegate may be absent; however, Invoke() does not guard against null — callers are responsible for ensuring safety. - WriteProperties only reports whether a backAction exists; it does not attempt to serialize delegates.