Skip to content

dialog_react_util

Source: base/tealdef/gui/menu/dialog_react_util.d.tl

Notes

Generic modal dialog window (title, text, a row of choice buttons) used throughout the menus and the in-game GUI.

Example

-- from base/content/gui/gui/menu/mod_manager_react_util.tl (showMessageBox)
local close = function()
  wc.removeAllWindows(dialog_react_util.DialogWindow)
end
wc.addSingletonWindow(dialog_react_util.DialogWindow, {
  onClose = close,
  x = 0.5,
  y = 0.5,
  windowTitle = title,
  displayText = message,
  setBlockedForModal = setBlockedForModal,
  choices = { { text = _("OK") } },
  onBackChoiceIndex = 1,
})

DialogReactUtil

record global base/tealdef/gui/menu/dialog_react_util.d.tl:3

global record DialogReactUtil

Load: local dialog_react_util = ug_require "::/gui/menu/dialog_react_util.tl"

Notes

Util table of dialog_react_util.tl; holds the DialogWindow recipe.

Fields

Name Type Description
DialogWindow Recipe<DialogWindowParam> Window recipe of a modal, non-movable dialog with optional text and a list of choice buttons. used 60× in the base game

DialogReactUtil.DialogWindowParam

record base/tealdef/gui/menu/dialog_react_util.d.tl:4

record DialogWindowParam

Notes

Parameters of DialogReactUtil.DialogWindow.

Used in the base game: 2 times in 1 file

base/content/gui/gui/menu/dialog_react_util.tl:7

local DialogWindowContent = react.RegisterRecipe("DialogWindowContent", function(params : DialogReactUtil.DialogWindowParam) : TreeNodeId

Fields

Name Type Description
closable boolean Shows the window's close button when true. Default false (no close button).
windowTitle string Window title.
displayText string Body text, shown in a scroll area above the buttons. Optional.
x number Initial horizontal position of the window (passed as initialX; the base game uses 0.5 to centre it, or a screen position for pop-ups next to a control).
y number Initial vertical position of the window (passed as initialY; 0.5 centres it).
choices {Choice} Buttons of the dialog, in display order.
onBackChoiceIndex integer specifies which choice has to be choosen at on back, default does NOTHING (to avoid bad side effects)
mode Mode Layout of the buttons; "Flow" or "Box" (default).
windowClass string Extra style class added to the window after popover, dialog.
windowId string Id of the window.

Functions

onClose() base/tealdef/gui/menu/dialog_react_util.d.tl:16

Notes

Called when the dialog should close: after any choice, on a click outside the dialog, on menu-back, or from the window's close button. It must remove the window, usually with removeAllWindows(dialog_react_util.DialogWindow).

setBlockedForModal(blocked : boolean) base/tealdef/gui/menu/dialog_react_util.d.tl:18

Notes

Optional callback that the dialog calls with true when it mounts and with false when it unmounts or is clicked away, so the caller can block the UI behind it. Menus pass CommonMenuParams.setBlockedForModal.

DialogReactUtil.DialogWindowParam.Mode

enum base/tealdef/gui/menu/dialog_react_util.d.tl:5

enum Mode

Notes

How the choice buttons are laid out.

Value Description
"Flow" Buttons are placed in a flow layout that wraps onto several lines (used for the tag picker of the mod upload form).
"Box" Buttons are placed in one horizontal row inside a scroll area. Any value other than "Flow" (including nil) gives this layout.

DialogReactUtil.DialogWindowParam.Choice

record base/tealdef/gui/menu/dialog_react_util.d.tl:9

record Choice

Notes

One button of the dialog.

Fields

Name Type Description
text string Button label.
tooltip string Tooltip of the button.
isSecondary boolean nil/false by default
enabled boolean nil/false by default

Functions

onClick() base/tealdef/gui/menu/dialog_react_util.d.tl:12

Notes

Called when the button is clicked, after the dialog's onClose. Optional; a choice without onClick only closes the dialog.