Popups - coldrockgames/gml-raptor GitHub Wiki

In raptor, a "popup" means:

  • A dynamically created layer, optionally paired with an additional fx_layer, which provides its own ui_root control tree.
  • You can use the public functions shown on this page to control those layer groups' visibility.
  • While a popup is visible, the entire scene beneath it will not react to mouse inputs (You have to take care for yourself about keyboard input, though, except for the InputBox and the StateMachine events, they handle popups correctly).
  • Popups can be stacked, multiple can be visible at the same time, but only the topmost will be interactive for the mouse.

The PopupManager

This class will be returned to you, when you call the popup_create function. It offers methods to control the visibility of a popup.

[!NOTE] This class is not meant to be instantiated by you directly. Always use popup_create to obtain an instance!

PopupManager functions

Function Description
show Shows the popup by setting the ui_layer and the fx_layer (if available) to visible=true.
hide Hides the popup by setting the ui_layer and the fx_layer (if available) to visible=false.
destroy Destroys the layer(s) and all instances assigned to them. hides them first, if they are currently visible.
get_ui_depth As popups are dynamically created, stacked layer groups, you can use this function to get the depth of the ui_layer of this popup. The fx_layer depth is always 1 higher. So, if your ui_depth is -21, the fx_depth = -20.
is_shown Query, whether a popup is currently visible.

Global Popup Functions

/// @func	popup_create(_name, _with_fx_layer = true)
/// @desc	Create a new popup layer group.
///		NOTE: If a group with the specified name already exists, 
///		this function will silently ignore the request.
///		(The existing popup will NOT be overwritten!)
function popup_create(_name, _with_fx_layer = true) {
/// @func	popup_get(_name)
/// @desc	Get the popup instance with the specified name.
///		If it does not exist, undefined is returned and
///		a warning is printed to the log.
function popup_get(_name) {
/// @func	popup_get_topmost()
/// @desc	Retrieves the topmost popup or undefined, if there is none
function popup_get_topmost() {
/// @func	popup_destroy(_name)
/// @desc	Destroy the popup with the specified name.
///		If it is currently visible, it will of course be hidden.
function popup_destroy(_name) {
/// @func	popup_destroy_all()
/// @desc	Destroy all popups
function popup_destroy_all() {
/// @func	popup_show(_name)
/// @desc	Shows the poup with the specified name.
///		If it does not exist, a warning is printed to the log.
function popup_show(_name) {
/// @func	popup_hide(_name)
/// @desc	Hides the popup with the specified name.
///		If it does not exist, it is silently ignored.
function popup_hide(_name) {
/// @func	popup_hide_all()
/// @desc	Hide all popups.
function popup_hide_all() {