UI Class
Top-level container for all other user-interface components.
Method Index
- _determineKeyPressed(rawchar, modifiers, btn_maps)
- _onAddWindow(window)
- _onRemoveWindow(window)
- ableToClickEntity(entity)
- addBevelPanel(x, y, w, h, colour, highlight_colour, shadow_colour, disabled_colour, lowered_colour, apply_ui_scale) (inherited from Window)
- addColourPanel(x, y, w, h, r, g, b, apply_ui_scale) (inherited from Window)
- addKeyHandler(keys, window, callback, ...) (overrides Window:addKeyHandler)
- addOrRemoveDebugModeKeyHandlers()
- addPanel(sprite_index, x, y, w, h, apply_ui_scale, draw_flags) (inherited from Window)
- addWindow(window) (overrides Window:addWindow)
- afterLoad(old, new) (overrides Window:afterLoad)
- anyMustPauseWindowOpen()
- beginDrag(x, y) (inherited from Window)
- bringToTop() (inherited from Window)
- changeWindow(width, height)
- close() (inherited from Window)
- closeWindow()
- draw(canvas) (overrides Window:draw)
- drawTooltip(canvas)
- exitApplication()
- fullscreenHotkey()
- getCursorPosition(window)
- getRealXY() (inherited from Window)
- getSavedWindowPositionName() (inherited from Window)
- getScreenOffset()
- getTooltipAt(x, y) (inherited from Window)
- getTooltipForElement(elem, x, y) (inherited from Window)
- getWindow(window_class) (inherited from Window)
- getWindowActiveStatus()
- getWindows(window_class) (inherited from Window)
- hitTest(x, y) (inherited from Window)
- hitTestPanel(x, y, panel) (inherited from Window)
- hoverTest(active_hover, mouse_x, mouse_y, min_x, max_x, min_y, max_y) (inherited from Window)
- initKeyAndButtonCodes()
- makeButtonOnPanel(panel, x, y, w, h, sprite, on_click, on_click_self, on_rightclick) (inherited from Window)
- makeDynamicTooltip(callback, x, y, r, b, tooltip_x, tooltip_y) (inherited from Window)
- makeHotkeyBoxOnPanel(panel, confirm_callback, abort_callback) (inherited from Window)
- makeScreenshot()
- makeScrollbarOnPanel(panel, slider_colour, callback, min_value, max_value, page_size, value) (inherited from Window)
- makeTextboxOnPanel(panel, confirm_callback, abort_callback) (inherited from Window)
- makeTooltip(text, x, y, r, b, tooltip_x, tooltip_y, apply_ui_scale) (inherited from Window)
- mustPause() (inherited from Window)
- onChangeLanguage() (inherited from Window)
- onChangeResolution() (overrides Window:onChangeResolution)
- onCursorWorldPositionChange(x, y) (inherited from Window)
- onEditingText(text, start, length)
- onKeyDown(rawchar, modifiers)
- onKeyUp(rawchar, modifiers)
- onMouseDown(code, x, y) (overrides Window:onMouseDown)
- onMouseMove(x, y, dx, dy) (overrides Window:onMouseMove)
- onMouseUp(code, x, y) (overrides Window:onMouseUp)
- onMouseWheel(x, y) (overrides Window:onMouseWheel)
- onPinchBegin()
- onPinchEnd()
- onPinchUpdate()
- onTextInput(text)
- onTick() (overrides Window:onTick)
- onWindowActive(gain)
- onWindowDisplayScaleChanged(scale)
- onWindowMaximised()
- onWindowPixelSizeChanged(width, height)
- onWindowResized(width, height, state)
- onWindowRestored()
- onWorldTick() (inherited from Window)
- pauseMovie()
- playAnnouncement(name, priority, played_callback, played_callback_delay)
- playSound(name, played_callback, played_callback_delay, loops)
- quit()
- registerHotkeyBox(box)
- registerTextBox(box)
- releaseMouse()
- removeAllPanels() (inherited from Window)
- removeKeyHandler(keys, window) (overrides Window:removeKeyHandler)
- removeWindow(closing_window) (overrides Window:removeWindow)
- resetApp()
- runDebugScript()
- sendToBottom(window) (inherited from Window)
- sendToTop(window) (inherited from Window)
- setCursor(cursor)
- setDefaultCursor(cursor)
- setDefaultPosition(x, y) (inherited from Window)
- setMenuBackground()
- setMouseReleased(released)
- setPosition(x, y) (inherited from Window)
- setSize(width, height, apply_ui_scale) (inherited from Window)
- setWindowActiveStatus(state)
- setupGlobalKeyHandlers()
- showLuaConsole()
- startButtonBlinking(button_index) (inherited from Window)
- stopButtonBlinking() (inherited from Window)
- stopMovie()
- stopSound(sound)
- stopVideo()
- toggleAdviser()
- toggleCaptureMouse()
- togglePlayAnnouncements()
- togglePlayMusic()
- togglePlaySounds()
- toggleVideoMode(mode)
- tutorialStep(...)
- unregisterHotkeyBox(box)
- unregisterTextBox(box)
- updateTooltip()
Member Index
- active_button (*)
- active_scrollbar (*)
- app
- apply_ui_scale (*)
- background
- background_height
- background_width
- blink_counter (*)
- blinking_button (*)
- btn_repeat_delay (*)
- button_codes
- buttons (*)
- buttons_down
- casebook_selected_disease
- closed (*)
- cursor
- cursor_entity
- cursor_x
- cursor_y
- debug_cursor_entity
- default_button_sound (*)
- default_cursor
- down_count
- down_cursor
- drag_mouse_move
- draggable (*)
- dragging (*)
- edit_room_cursor
- editing_allowed
- grab_cursor
- height (*)
- hotkeyboxes
- key_handlers
- key_noted
- key_press_handled
- key_remaps
- key_to_button_remaps
- modal_windows
- modifiers_down
- mouse_released
- panel_sprites (*)
- panels (*)
- parent (*)
- screen_offset_x
- screen_offset_y
- scrollbars (*)
- simulated_cursor
- temp_button_down
- textboxes
- tick_scroll_amount
- tick_scroll_amount_mouse
- tick_scroll_mult
- tooltip
- tooltip_counter
- tooltip_font
- tooltip_regions (*)
- ui (*)
- visible (*)
- waiting_cursor
- width (*)
- windows
- x (*)
- x_original (*)
- y (*)
- y_original (*)
function UI:UI(app, minimal)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| entity | ? | ? |
Declared on: line 902 of Lua/ui.lua.
function UI:addKeyHandler(keys, window, callback, ...)
Register a key handler / hotkey for a window.
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| window | window | What is to be displayed |
Overrides: Window:addWindow.
Declared on: line 1080 of Lua/ui.lua.
function UI:afterLoad(old, new)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| canvas | ? | ? |
Overrides: Window:draw.
Declared on: line 302 of Lua/ui.lua.
function UI:drawTooltip(canvas)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| window | ? | ? |
Declared on: line 1148 of Lua/ui.lua.
function UI:getScreenOffset()
Declared on: line 917 of Lua/ui.lua.
function UI:getWindowActiveStatus()
Gets the game window active status
Declared on: line 957 of Lua/ui.lua.
function UI:initKeyAndButtonCodes()
Declared on: line 48 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:onChangeResolution()
Overrides: Window:onChangeResolution.
Declared on: line 548 of Lua/ui.lua.
function UI:onEditingText(text, start, length)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| code | ? | ? |
| x | ? | ? |
| y | ? | ? |
Overrides: Window:onMouseDown.
Declared on: line 847 of Lua/ui.lua.
function UI:onMouseMove(x, y, dx, dy)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| dx | ? | ? |
| dy | ? | ? |
Overrides: Window:onMouseMove.
Declared on: line 1021 of Lua/ui.lua.
function UI:onMouseUp(code, x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| code | ? | ? |
| x | ? | ? |
| y | ? | ? |
Overrides: Window:onMouseUp.
Declared on: line 872 of Lua/ui.lua.
function UI:onMouseWheel(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| text | ? | ? |
Declared on: line 820 of Lua/ui.lua.
function UI:onTick()
Overrides: Window:onTick.
Declared on: line 1066 of Lua/ui.lua.
function UI:onWindowActive(gain)
Called when focus changes on game window.
Parameters:
| Name | Type | Description |
|---|---|---|
| gain | number | 1 for in-focus, 0 for out-of-focus |
Declared on: line 945 of Lua/ui.lua.
function UI:onWindowDisplayScaleChanged(scale)
Parameters:
| Name | Type | Description |
|---|---|---|
| scale | ? | ? |
Declared on: line 990 of Lua/ui.lua.
function UI:onWindowMaximised()
Declared on: line 1001 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:onWindowRestored()
Declared on: line 1007 of Lua/ui.lua.
function UI:pauseMovie()
Declared on: line 1279 of Lua/ui.lua.
function UI:playAnnouncement(name, priority, played_callback, played_callback_delay)
Stub with args for subclass GameUI.
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| box | ? | ? |
Declared on: line 583 of Lua/ui.lua.
function UI:registerTextBox(box)
Parameters:
| Name | Type | Description |
|---|---|---|
| box | ? | ? |
Declared on: line 570 of Lua/ui.lua.
function UI:releaseMouse()
Declared on: line 644 of Lua/ui.lua.
function UI:removeKeyHandler(keys, window)
Unregister a key handler previously registered by `addKeyHandler`.
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:runDebugScript()
Declared on: line 200 of Lua/ui.lua.
function UI:setCursor(cursor)
Parameters:
| Name | Type | Description |
|---|---|---|
| cursor | ? | ? |
Declared on: line 268 of Lua/ui.lua.
function UI:setDefaultCursor(cursor)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| released | ? | ? |
Declared on: line 628 of Lua/ui.lua.
function UI:setWindowActiveStatus(state)
Stores the game window active status
Parameters:
| Name | Type | Description |
|---|---|---|
| state | boolean | true for in-focus, false for out-of-focus |
Declared on: line 951 of Lua/ui.lua.
function UI:setupGlobalKeyHandlers()
Declared on: line 211 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:
| Name | Type | Description |
|---|---|---|
| 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:toggleAdviser()
Declared on: line 1055 of Lua/game_ui.lua.
function UI:toggleCaptureMouse()
Declared on: line 623 of Lua/ui.lua.
function UI:togglePlayMusic()
Declared on: line 1071 of Lua/game_ui.lua.
function UI:togglePlaySounds()
Declared on: line 1060 of Lua/game_ui.lua.
function UI:toggleVideoMode(mode)
Turns a video mode on and off
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| ... | ? | ? |
Declared on: line 1199 of Lua/ui.lua.
function UI:unregisterHotkeyBox(box)
Parameters:
| Name | Type | Description |
|---|---|---|
| box | ? | ? |
Declared on: line 587 of Lua/ui.lua.
function UI:unregisterTextBox(box)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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.