CorsixTH Lua Documentation

UI Class

Top-level container for all other user-interface components.

Declared on: line 23 of Lua/ui.lua.
Inheritance: UI ยป Window
Subclasses: GameUI

Method Index

Member Index

(*) only used in superclass methods
function UI:UI(app, minimal)

Parameters:

NameTypeDescription
app ? ?
minimal ? ?

Declared on: line 138 of Lua/ui.lua.

function UI:_determineKeyPressed(rawchar, modifiers, btn_maps)

Private function to determine the key pressed based on current modifiers

Parameters:

NameTypeDescription
rawchar string The key pressed as given by SDL
modifiers table Current key modifiers, e.g. numlock
btn_maps table Used for keydown events only, a table of keys that are designated to perform mouse actions.

Declared on: line 692 of Lua/ui.lua.

function UI:_onAddWindow(window)

Function for signaling that the window is added. To pause game if the necessary requirements are met.

Parameters:

NameTypeDescription
window object window added

Declared on: line 1120 of Lua/ui.lua.

function UI:_onRemoveWindow(window)

Function for signaling that the window is to be removed. To unpause game if the necessary requirements are met.

Parameters:

NameTypeDescription
window object window to be removed

Declared on: line 1129 of Lua/ui.lua.

function UI:ableToClickEntity(entity)

Determines if a cursor entity can be clicked @param entity (Entity,nil) cursor entity clicked on if any @return true if can be clicked on, false otherwise (boolean)

Parameters:

NameTypeDescription
entity ? ?

Declared on: line 902 of Lua/ui.lua.

function UI:addKeyHandler(keys, window, callback, ...)

Register a key handler / hotkey for a window.

Parameters:

NameTypeDescription
keys string or or or table The keyboard key which should trigger the callback (for example, "left" or "z" or "F9"), or a list with modifier(s) and the key (e.g. {"ctrl", "s"}).
window Window The UI window which should receive the callback.
callback function The method to be called on `window` when `key` is pressed.
... ? Additional arguments to `callback`.

Overrides: Window:addKeyHandler.
Declared on: line 322 of Lua/ui.lua.

function UI:addWindow(window)

Adds a window to the game

This also handles pause and permitted interaction behaviour as required

Parameters:

NameTypeDescription
window window What is to be displayed

Overrides: Window:addWindow.
Declared on: line 1080 of Lua/ui.lua.

function UI:afterLoad(old, new)

Parameters:

NameTypeDescription
old ? ?
new ? ?

Overrides: Window:afterLoad.
Declared on: line 1169 of Lua/ui.lua.

function UI:anyMustPauseWindowOpen()

Function to check if we have any must pause windows open

Declared on: line 1138 of Lua/ui.lua.

function UI:changeWindow(width, height)

Parameters:

NameTypeDescription
width ? ?
height ? ?

Declared on: line 596 of Lua/ui.lua.

function UI:closeWindow()

Closes one window (the topmost / active window, if possible)

Declared on: line 1225 of Lua/ui.lua.

function UI:draw(canvas)

Parameters:

NameTypeDescription
canvas ? ?

Overrides: Window:draw.
Declared on: line 302 of Lua/ui.lua.

function UI:drawTooltip(canvas)

Parameters:

NameTypeDescription
canvas ? ?

Declared on: line 286 of Lua/ui.lua.

function UI:exitApplication()

Added this function as quit does not exit the application, it only exits the game to the menu screen

Declared on: line 1262 of Lua/ui.lua.

function UI:fullscreenHotkey()

Dedicated hotkey function for toggling fullscreen

Declared on: line 648 of Lua/ui.lua.

function UI:getCursorPosition(window)

Parameters:

NameTypeDescription
window ? ?

Declared on: line 1148 of Lua/ui.lua.

function UI:getWindowActiveStatus()

Gets the game window active status

Declared on: line 957 of Lua/ui.lua.

function UI:makeScreenshot()

Perform the Screenshot action (usually by key bind 'global_screenshot')

Declared on: line 1204 of Lua/ui.lua.

function UI:onEditingText(text, start, length)

Parameters:

NameTypeDescription
text ? ?
start ? ?
length ? ?

Declared on: line 816 of Lua/ui.lua.

function UI:onKeyDown(rawchar, modifiers)

Called when the user presses a key on the keyboard

Parameters:

NameTypeDescription
rawchar string The name of the key the user pressed.
modifiers table The current applied modifiers to key input e.g. numlock

Declared on: line 714 of Lua/ui.lua.

function UI:onKeyUp(rawchar, modifiers)

Called when the user releases a key on the keyboard

Parameters:

NameTypeDescription
rawchar string The name of the key the user pressed.
modifiers table The current applied modifiers to key input e.g. numlock

Declared on: line 763 of Lua/ui.lua.

function UI:onMouseDown(code, x, y)

Parameters:

NameTypeDescription
code ? ?
x ? ?
y ? ?

Overrides: Window:onMouseDown.
Declared on: line 847 of Lua/ui.lua.

function UI:onMouseMove(x, y, dx, dy)

Parameters:

NameTypeDescription
x ? ?
y ? ?
dx ? ?
dy ? ?

Overrides: Window:onMouseMove.
Declared on: line 1021 of Lua/ui.lua.

function UI:onMouseUp(code, x, y)

Parameters:

NameTypeDescription
code ? ?
x ? ?
y ? ?

Overrides: Window:onMouseUp.
Declared on: line 872 of Lua/ui.lua.

function UI:onMouseWheel(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

Overrides: Window:onMouseWheel.
Declared on: line 898 of Lua/ui.lua.

function UI:onPinchBegin()

Process SDL_PINCH_BEGIN events.

Declared on: line 1045 of Lua/ui.lua.

function UI:onPinchEnd()

Process SDL_PINCH_END events.

Declared on: line 1059 of Lua/ui.lua.

function UI:onPinchUpdate()

Process SDL_PINCH_UPDATE events.

Declared on: line 1052 of Lua/ui.lua.

function UI:onTextInput(text)

string containing the input localized according to the keyboard layout

the user uses.

Parameters:

NameTypeDescription
text ? ?

Declared on: line 820 of Lua/ui.lua.

function UI:onWindowActive(gain)

Called when focus changes on game window.

Parameters:

NameTypeDescription
gain number 1 for in-focus, 0 for out-of-focus

Declared on: line 945 of Lua/ui.lua.

function UI:onWindowDisplayScaleChanged(scale)

Parameters:

NameTypeDescription
scale ? ?

Declared on: line 990 of Lua/ui.lua.

function UI:onWindowPixelSizeChanged(width, height)

Render area size has been changed This could be because the user resized the window or updated the size through settings, or on a system where the window size is independent of the render size the window could have been dragged from a HiDPI monitor to a standard DPI monitor.

Parameters:

NameTypeDescription
width integer New renderer width
height integer New renderer height

Declared on: line 978 of Lua/ui.lua.

function UI:onWindowResized(width, height, state)

Window has been resized by the user

Parameters:

NameTypeDescription
width integer New window width
height integer New window height
state integer Window state: 0 - window, 1 - fullscreen, 2 - maximised, 3 - minimized

Declared on: line 963 of Lua/ui.lua.

function UI:playAnnouncement(name, priority, played_callback, played_callback_delay)

Stub with args for subclass GameUI.

Parameters:

NameTypeDescription
name ? ?
priority ? ?
played_callback ? ?
played_callback_delay ? ?

Declared on: line 251 of Lua/ui.lua.

function UI:playSound(name, played_callback, played_callback_delay, loops)

Play a sound effect

Parameters:

NameTypeDescription
name string The name of the sound to be played. Can include wildcards (*).
played_callback function A function to be called when the sound has finished playing. Can be nil.
played_callback_delay integer An optional delay in milliseconds before the played_callback is called.
loops integer number of times to play the audio. -1 for infinite.

Declared on: line 227 of Lua/ui.lua.

function UI:quit()

Triggers quitting the application

Declared on: line 1267 of Lua/ui.lua.

function UI:registerHotkeyBox(box)

Parameters:

NameTypeDescription
box ? ?

Declared on: line 583 of Lua/ui.lua.

function UI:registerTextBox(box)

Parameters:

NameTypeDescription
box ? ?

Declared on: line 570 of Lua/ui.lua.

function UI:removeKeyHandler(keys, window)

Unregister a key handler previously registered by `addKeyHandler`.

Parameters:

NameTypeDescription
keys string or or or table The key or list of modifiers+key of a key / window pair previously passed to `addKeyHandler`.
window Window The window of a key / window pair previously passed to `addKeyHandler`.

Overrides: Window:removeKeyHandler.
Declared on: line 426 of Lua/ui.lua.

function UI:removeWindow(closing_window)

Remove a window from the game

This also handles pause and permitted interaction behaviour as required

Parameters:

NameTypeDescription
closing_window window What is to be removed

Overrides: Window:removeWindow.
Declared on: line 1101 of Lua/ui.lua.

function UI:resetApp()

Triggers reset of the application (reloads .lua files)

Declared on: line 1257 of Lua/ui.lua.

function UI:setCursor(cursor)

Parameters:

NameTypeDescription
cursor ? ?

Declared on: line 268 of Lua/ui.lua.

function UI:setDefaultCursor(cursor)

Parameters:

NameTypeDescription
cursor ? ?

Declared on: line 255 of Lua/ui.lua.

function UI:setMenuBackground()

set game window is selected. If no image fits that criteria the smallest

available image is used.

Declared on: line 518 of Lua/ui.lua.

function UI:setMouseReleased(released)

Parameters:

NameTypeDescription
released ? ?

Declared on: line 628 of Lua/ui.lua.

function UI:setWindowActiveStatus(state)

Stores the game window active status

Parameters:

NameTypeDescription
state boolean true for in-focus, false for out-of-focus

Declared on: line 951 of Lua/ui.lua.

function UI:showLuaConsole()

Shows the Lua console

Declared on: line 1252 of Lua/ui.lua.

function UI:stopMovie()

Tries to stop a video, if one is currently playing

Declared on: line 1272 of Lua/ui.lua.

function UI:stopSound(sound)

Stop the given sound see Audio:stopSound

Parameters:

NameTypeDescription
sound table sound to stop

Declared on: line 244 of Lua/ui.lua.

function UI:stopVideo()

Stub for compatibility with savegames r1896-1921

Declared on: line 1285 of Lua/ui.lua.

function UI:toggleVideoMode(mode)

Turns a video mode on and off

Parameters:

NameTypeDescription
mode ? ?

Declared on: line 663 of Lua/ui.lua.

function UI:tutorialStep(...)

Stub to allow the function to be called in e.g. the information dialog without having to worry about a GameUI being present

Parameters:

NameTypeDescription
... ? ?

Declared on: line 1199 of Lua/ui.lua.

function UI:unregisterHotkeyBox(box)

Parameters:

NameTypeDescription
box ? ?

Declared on: line 587 of Lua/ui.lua.

function UI:unregisterTextBox(box)

Parameters:

NameTypeDescription
box ? ?

Declared on: line 574 of Lua/ui.lua.

function UI:updateTooltip()

Amount of ticks until a tooltip is displayed

Declared on: line 921 of Lua/ui.lua.