Module CorsixTH.CorsixTH.Lua.ui
Top-level container for all other user-interface components.
Functions
| UI:addKeyHandler (keys, window, callback, ...) | Register a key handler / hotkey for a window. |
| UI:checkForMustPauseWindows () | Function to check if we have any must pause windows open |
| UI:closeWindow () | Closes one window (the topmost / active window, if possible) |
| UI:fullscreenHotkey () | Dedicated hotkey function for toggling fullscreen |
| UI:onKeyDown (rawchar, modifiers, is_repeat) | Called when the user presses a key on the keyboard |
| UI:onKeyUp (rawchar) | Called when the user releases a key on the keyboard |
| UI:onMultiGesture () | Process SDL_MULTIGESTURE events. |
| UI:onTextInput (text) | Called in-between onKeyDown and onKeyUp. |
| UI:onWindowActive (gain) | Called when the mouse enters or leaves the game window. |
| UI:onWindowResize (width, height) | Window has been resized by the user |
| UI:quit () | Triggers quitting the application |
| UI:removeKeyHandler (keys, window) | Unregister a key handler previously registered by `addKeyHandler`. |
| UI:resetApp () | Triggers reset of the application (reloads .lua files) |
| UI:setMenuBackground () | Set the menu background image
The menu size closest to, but no larger than the height of the currently set game window is selected. |
| UI:showLuaConsole () | Shows the Lua console |
| UI:stopMovie () | Tries to stop a video, if one is currently playing |
| UI:toggleFullscreen () | Turns fullscreen on and off |
Functions
- UI:addKeyHandler (keys, window, callback, ...)
-
Register a key handler / hotkey for a window.
Parameters:
- keys (string 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`.
- UI:checkForMustPauseWindows ()
-
Function to check if we have any must pause windows open
Returns:
-
(bool) Returns true if a must pause window is found
- UI:closeWindow ()
-
Closes one window (the topmost / active window, if possible)
Returns:
-
true if a window was closed
- UI:fullscreenHotkey ()
- Dedicated hotkey function for toggling fullscreen
- UI:onKeyDown (rawchar, modifiers, is_repeat)
-
Called when the user presses a key on the keyboard
Parameters:
- rawchar (string) The name of the key the user pressed.
- modifiers
- is_repeat (boolean) True if this is a key repeat event
- UI:onKeyUp (rawchar)
-
Called when the user releases a key on the keyboard
Parameters:
- rawchar (string) The name of the key the user pressed.
- UI:onMultiGesture ()
-
Process SDL_MULTIGESTURE events.
Returns:
-
(boolean) event processed indicator
- UI:onTextInput (text)
-
Called in-between onKeyDown and onKeyUp. The argument 'text' is a
string containing the input localized according to the keyboard layout
the user uses.
Parameters:
- text It's time for any active textbox to get input.
- UI:onWindowActive (gain)
-
Called when the mouse enters or leaves the game window.
Parameters:
- gain
- UI:onWindowResize (width, height)
-
Window has been resized by the user
Parameters:
- width (integer) New window width
- height (integer) New window height
- UI:quit ()
- Triggers quitting the application
- UI:removeKeyHandler (keys, window)
-
Unregister a key handler previously registered by `addKeyHandler`.
Parameters:
- keys (string 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`.
- UI:resetApp ()
- Triggers reset of the application (reloads .lua files)
- UI:setMenuBackground ()
-
Set the menu background image
The menu size closest to, but no larger than the height of the currently set game window is selected. If no image fits that criteria the smallest available image is used.
- UI:showLuaConsole ()
- Shows the Lua console
- UI:stopMovie ()
- Tries to stop a video, if one is currently playing
- UI:toggleFullscreen ()
-
Turns fullscreen on and off
Returns:
-
success true if toggle succeeded