Class GGDialogContextHelper extends RefCounted
Helps manage user interfaces (dialogs) and access manager contexts.
UIs use context_ids when interacting with an inventory on behalf of an actor (character). Some UIs (i.e. inventory transfers) require multiple contexts -- one for each side. The GGDialogContextHelper is used to ensure the UI has all the context IDs it needs. If any contexts fail or are closed, the UI automatically closes.
To use:
- set the
- set the
Then, use
Finally, use
To use:
- set the
ui to the root [Node] of your UI scene- set the
on_success [Callable] to the callback closure that provides your UI scene with the context IDs returned by the [GGEntityAccessManager].Then, use
acquire_context() to acquire contexts for an object on behalf of an actor.Finally, use
await dialog.wait_for_contexts()() to wait for the contexts to have been acquired.# Signals
## Emitted when the contexts are acquiredsignal done## Emitted when all queued contexts are acquired. TODO: Godot 4.4: context_ids: Dictionary[GGEntityAccessManager, int]signal acquired(context_ids: Dictionary) ## Emitted when the helper closedsignal destroyed# Members
## Pending context requests; maps [GGEntityAccessManager] -> noncevar pending: Dictionary[GGEntityAccessManager, int] = {}## context IDs; maps [GGEntityAccessManager] -> context_idvar context_ids: Dictionary[GGEntityAccessManager, int] = {}## Indicates whether we're in a successful state.var success: bool = true## Called when a context ID was received.var on_success: Callable## Called when getting a context ID failed,var on_failure: Callable## Keep track of the UI. If it leaves the tree, we close the context.var ui: Node# Methods
## Opens a context with the [param entity_access_manager] on behalf of the [param actor].func acquire_context(entity_access_manager: GGEntityAccessManageractor: Node) -> void## Waits for all replies from the access manager to finish. This largely applies to the client waiting for responses from the server. If run on the server, and access manager policies are synchronous (the default), they've already been acquired.func wait_for_contexts() -> voidfunc get_context_id_for(entity_access_manager: GGEntityAccessManager) -> int## Cancels any pending context requests and closes any contexts already received. Automatically closes the UI if necessary.func close() -> void## Tells the [GGEntityAccessManager] to cancel any pending context requests for this helper.func cancel_pending() -> void## Tells the [GGEntityAccessManager] to close all Context IDs for this helper.func close_contexts() -> void