Skip to content

PopupUI ​

Inherits: Control

Inherited by: DefaultPopupUI

The root of a popup scene. Build a popup as a scene with this script on its root: whatever the developer wants it to be (a tutorial page, a message, a toast, an achievement) with a button called ExitButton if it should have one (a node whose name is made unique with %: it closes the popup). How it behaves (ESC, pause, blocking, closing by itself, once only, what to do when another popup is open) is set with the options of this node in the inspector, on the saved scene. Save the scene and the popup is in the database. A new popup is made with the Create new popup button of the UI Settings editor.

Description ​

Override setup(data) to show what the caller passes, and on_shown() for what happens when the popup appears. Call close() to close it (a button of your own, the end of an animation).

Properties ​

boolclose_on_escapetrue
boolblock_gameplay_inputtrue
boolpause_gamefalse
floatauto_close_seconds0.0
boolshow_oncefalse
PopupData.WhenBusywhen_another_is_openPopupData.WhenBusy.QUEUE

Variables ​

Dictionarydata{}
GameHost.SystemHubsystem_hub

Methods ​

voidinitialize_ui( p_system_hub: GameHost.SystemHub )
voidsetup( p_data: Dictionary )
voidon_shown()
voidclose()

Signals ​

closed( popup: PopupUI ) ​

Emitted when the popup closes (the manager removes it)

Property descriptions ​

Behaviour

bool close_on_escape = true ​

ESC closes the popup (when it is the one on top)

bool block_gameplay_input = true ​

Gameplay does not react to the mouse and the keys while the popup is open (the popup itself does)

bool pause_game = false ​

The game is paused while the popup is open (time stands still)

float auto_close_seconds = 0.0 ​

The popup closes itself after this many seconds (real seconds, also while the game is paused; 0 = it waits to be closed)

bool show_once = false ​

The popup is shown once in a game (tutorials): after that it is never shown again, also not after a load. A new game shows it again

PopupData.WhenBusy when_another_is_open = PopupData.WhenBusy.QUEUE ​

What to do when this popup is asked for while another popup is on the screen

Variable descriptions ​

Dictionary data = ​

What the caller passed to show_popup

GameHost.SystemHub system_hub ​

The systems of the game

Method descriptions ​

void initialize_ui( p_system_hub: GameHost.SystemHub ) ​

Called by the manager when the popup is made, before it appears

void setup( p_data: Dictionary ) ​

Called with what the caller passed (title, text, anything: it is up to the scene). Override it

void on_shown() ​

Called when the popup is on the screen. Override it (an animation, a sound)

void close() ​

Close the popup