GameUI Class
Variant of UI for running games
Method Index
- ScreenToWorld(x, y)
- WorldToScreen(x, y)
- _determineKeyPressed(rawchar, modifiers, btn_maps) (inherited from UI)
- _isMouseScrollButtonDown()
- _onAddWindow(window) (inherited from UI)
- _onRemoveWindow(window) (inherited from UI)
- ableToClickEntity(entity) (inherited from UI)
- 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, ...) (inherited from UI)
- addOrRemoveDebugModeKeyHandlers() (inherited from UI)
- addPanel(sprite_index, x, y, w, h, apply_ui_scale, draw_flags) (inherited from Window)
- addWindow(window) (inherited from UI)
- afterLoad(old, new) (overrides UI:afterLoad)
- anyMustPauseWindowOpen() (inherited from UI)
- applyTransparency()
- beginDrag(x, y) (inherited from Window)
- beginShakeScreen(intensity)
- bringToTop() (inherited from Window)
- calculateMinimumZoom()
- changeWindow(width, height) (inherited from UI)
- close() (inherited from Window)
- closeWindow() (inherited from UI)
- draw(canvas) (overrides UI:draw)
- drawTooltip(canvas) (inherited from UI)
- endShakeScreen()
- exitApplication() (inherited from UI)
- fullscreenHotkey() (inherited from UI)
- getCursorPosition(window) (inherited from UI)
- getEffectiveZoom()
- getRealXY() (inherited from Window)
- getSavedWindowPositionName() (inherited from Window)
- getScreenOffset() (overrides UI:getScreenOffset)
- getTooltipAt(x, y) (inherited from Window)
- getTooltipForElement(elem, x, y) (inherited from Window)
- getWindow(window_class) (inherited from Window)
- getWindowActiveStatus() (inherited from UI)
- 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() (inherited from UI)
- keySpeedUp()
- keyTransparent()
- limitCamera(mode)
- limitPointToDiamond(dx, dy, visible_diamond, do_limit)
- makeButtonOnPanel(panel, x, y, w, h, sprite, on_click, on_click_self, on_rightclick) (inherited from Window)
- makeDebugFax()
- makeDebugRat()
- makeDynamicTooltip(callback, x, y, r, b, tooltip_x, tooltip_y) (inherited from Window)
- makeHotkeyBoxOnPanel(panel, confirm_callback, abort_callback) (inherited from Window)
- makeScreenshot() (inherited from UI)
- 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)
- makeVisibleDiamond(scr_w, scr_h)
- mustPause() (inherited from Window)
- onChangeLanguage() (inherited from Window)
- onChangeResolution() (overrides UI:onChangeResolution)
- onCursorWorldPositionChange() (overrides Window:onCursorWorldPositionChange)
- onEditingText(text, start, length) (inherited from UI)
- onKeyDown(rawchar, modifiers, is_repeat) (overrides UI:onKeyDown)
- onKeyUp(rawchar, modifiers) (overrides UI:onKeyUp)
- onMouseDown(code, x, y) (inherited from UI)
- onMouseMove(x, y, dx, dy) (overrides UI:onMouseMove)
- onMouseUp(code, x, y) (overrides UI:onMouseUp)
- onMouseWheel(x, y, touch, flipped) (overrides UI:onMouseWheel)
- onPinchBegin() (overrides UI:onPinchBegin)
- onPinchEnd() (overrides UI:onPinchEnd)
- onPinchUpdate(scale) (overrides UI:onPinchUpdate)
- onTextInput(text) (inherited from UI)
- onTick() (overrides UI:onTick)
- onWindowActive(gain) (overrides UI:onWindowActive)
- onWindowDisplayScaleChanged(scale) (overrides UI:onWindowDisplayScaleChanged)
- onWindowMaximised() (inherited from UI)
- onWindowPixelSizeChanged(width, height) (inherited from UI)
- onWindowResized(width, height, state) (inherited from UI)
- onWindowRestored() (inherited from UI)
- onWorldTick() (inherited from Window)
- pauseMovie() (inherited from UI)
- playAnnouncement(name, priority, played_callback, played_callback_delay) (overrides UI:playAnnouncement)
- playRandomAnnouncement(msgs, priority, chance_to_play, played_callback, played_callback_delay)
- playSound(name, played_callback, played_callback_delay, loops) (inherited from UI)
- quit(mapeditor) (overrides UI:quit)
- recallMapPosition(index)
- registerHotkeyBox(box) (inherited from UI)
- registerTextBox(box) (inherited from UI)
- releaseMouse() (inherited from UI)
- removeAllPanels() (inherited from Window)
- removeKeyHandler(keys, window) (inherited from UI)
- removeWindow(closing_window) (inherited from UI)
- resetApp() (inherited from UI)
- restartMapEditor()
- resync(ui)
- runDebugScript() (inherited from UI)
- scrollMap(dx, dy)
- scrollMapTo(x, y)
- sendToBottom(window) (inherited from Window)
- sendToTop(window) (inherited from Window)
- setCursor(cursor) (inherited from UI)
- setDefaultCursor(cursor) (inherited from UI)
- setDefaultPosition(x, y) (inherited from Window)
- setEditRoom(enabled)
- setMapRecallPosition(index)
- setMenuBackground() (inherited from UI)
- setMouseReleased(released) (inherited from UI)
- setPosition(x, y) (inherited from Window)
- setSize(width, height, apply_ui_scale) (inherited from Window)
- setWallsTransparent(mode)
- setWindowActiveStatus(state) (inherited from UI)
- setWorldHitTest(mode)
- setZoom(factor, follow_cursor)
- setupGlobalKeyHandlers() (overrides UI:setupGlobalKeyHandlers)
- showBriefing()
- showCheatsWindow()
- showLuaConsole() (inherited from UI)
- showMenuBar()
- startButtonBlinking(button_index) (inherited from Window)
- startTutorial(chapter)
- stopButtonBlinking() (inherited from Window)
- stopMovie() (inherited from UI)
- stopSound(sound) (inherited from UI)
- stopVideo() (inherited from UI)
- toggleAdviser() (inherited from UI)
- toggleCaptureMouse() (inherited from UI)
- togglePlayAnnouncements() (inherited from UI)
- togglePlayMusic() (inherited from UI)
- togglePlaySounds() (inherited from UI)
- toggleTransparent()
- toggleVideoMode(mode) (inherited from UI)
- tutorialStep(chapter, phase_from, phase_to, ...) (overrides UI:tutorialStep)
- unregisterHotkeyBox(box) (inherited from UI)
- unregisterTextBox(box) (inherited from UI)
- updateKeyScroll()
- updateTooltip() (inherited from UI)
Member Index
- active_button (*)
- active_scrollbar (*)
- adviser
- announcer
- app
- apply_ui_scale (*)
- background (*)
- background_height (*)
- background_width (*)
- blink_counter (*)
- blinking_button (*)
- bottom_panel
- btn_repeat_delay (*)
- button_codes
- buttons (*)
- buttons_down
- casebook_selected_disease (*)
- closed (*)
- current_momentum
- cursor
- cursor_entity
- cursor_near_rat
- cursor_room
- cursor_x
- cursor_y
- debug_cursor_entity
- default_button_sound (*)
- default_cursor
- do_world_hit_test
- down_count
- down_cursor
- drag_mouse_move
- draggable (*)
- dragging (*)
- edit_room
- edit_room_cursor
- editing_allowed (*)
- grab_cursor (*)
- height (*)
- hospital
- hotkeyboxes (*)
- in_visible_diamond
- key_handlers (*)
- key_noted (*)
- key_press_handled (*)
- key_remaps
- key_to_button_remaps
- last_hovered_entity
- limit_to_visible_diamond
- map_editor
- menu_bar
- modal_windows (*)
- modifiers_down (*)
- momentum
- mood_info
- mouse_released
- multigesturemove
- panel_sprites (*)
- panels (*)
- parent (*)
- recallpositions
- screen_offset_x
- screen_offset_y
- scroll_keys
- scrollbars (*)
- shake_screen_intensity
- shift_scroll_key_long
- shift_scroll_speed_pressed
- simulated_cursor
- speed_up_key_pressed
- subtitles
- temp_button_down (*)
- textboxes (*)
- tick_scroll_amount
- tick_scroll_amount_mouse
- tick_scroll_mult
- ticks_since_last_announcement
- toggled_transparency
- tooltip (*)
- tooltip_counter (*)
- tooltip_font (*)
- tooltip_regions (*)
- transparent_walls
- tutorial
- ui (*)
- visible (*)
- visible_diamond
- waiting_cursor
- width (*)
- windows
- x (*)
- x_original (*)
- y (*)
- y_original (*)
- zoom_factor
function GameUI:GameUI(app, local_hospital, map_editor)
Game UI constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
| app | Application | Application object. |
| local_hospital | ? | Hospital to display |
| map_editor | bool | Whether the map is editable. |
Declared on: line 46 of Lua/game_ui.lua.
function GameUI:ScreenToWorld(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
Declared on: line 423 of Lua/game_ui.lua.
function GameUI:WorldToScreen(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
Declared on: line 428 of Lua/game_ui.lua.
function GameUI:_isMouseScrollButtonDown()
Check whether the configured mouse drag button is being held down (true) or not (false).
fixme: right mouse scrolling currently breaks other mouse operations (see issue 2469).
Declared on: line 865 of Lua/game_ui.lua.
function GameUI:afterLoad(old, new)
Parameters:
| Name | Type | Description |
|---|---|---|
| old | ? | ? |
| new | ? | ? |
Overrides: UI:afterLoad.
Declared on: line 1321 of Lua/game_ui.lua.
function GameUI:applyTransparency()
Applies the current setting for wall transparency to the map
Declared on: line 1041 of Lua/game_ui.lua.
function GameUI:beginShakeScreen(intensity)
Start shaking the screen, e.g. an earthquake effect (unless disabled in config)
Parameters:
| Name | Type | Description |
|---|---|---|
| intensity | number | The magnitude of the effect, between 0 for no movement to 1 for significant shaking. |
Declared on: line 1020 of Lua/game_ui.lua.
function GameUI:calculateMinimumZoom()
makeVisibleDiamond. This function calculates the minimum zoom_factor that
would be allowed.
Declared on: line 203 of Lua/game_ui.lua.
function GameUI:draw(canvas)
Parameters:
| Name | Type | Description |
|---|---|---|
| canvas | ? | ? |
Overrides: UI:draw.
Declared on: line 251 of Lua/game_ui.lua.
function GameUI:endShakeScreen()
Stop the screen from shaking after beginShakeScreen is called.
Declared on: line 1031 of Lua/game_ui.lua.
function GameUI:getScreenOffset()
Overrides: UI:getScreenOffset.
Declared on: line 436 of Lua/game_ui.lua.
function GameUI:keySpeedUp()
Declared on: line 346 of Lua/game_ui.lua.
function GameUI:keyTransparent()
Declared on: line 351 of Lua/game_ui.lua.
function GameUI:limitCamera(mode)
Parameters:
| Name | Type | Description |
|---|---|---|
| mode | ? | ? |
Declared on: line 1036 of Lua/game_ui.lua.
function GameUI.limitPointToDiamond(dx, dy, visible_diamond, do_limit)
Parameters:
| Name | Type | Description |
|---|---|---|
| dx | ? | ? |
| dy | ? | ? |
| visible_diamond | ? | ? |
| do_limit | ? | ? |
Declared on: line 958 of Lua/game_ui.lua.
Note: Is a function rather than a method.
function GameUI:makeDebugFax()
Declared on: line 404 of Lua/game_ui.lua.
function GameUI:makeDebugRat()
Debug: ensure two visible ratholes and spawn a rat from one.
Declared on: line 414 of Lua/game_ui.lua.
function GameUI:makeVisibleDiamond(scr_w, scr_h)
Parameters:
| Name | Type | Description |
|---|---|---|
| scr_w | ? | ? |
| scr_h | ? | ? |
Declared on: line 187 of Lua/game_ui.lua.
function GameUI:onChangeResolution()
Overrides: UI:onChangeResolution.
Declared on: line 276 of Lua/game_ui.lua.
function GameUI:onCursorWorldPositionChange()
Overrides: Window:onCursorWorldPositionChange.
Declared on: line 447 of Lua/game_ui.lua.
function GameUI:onKeyDown(rawchar, modifiers, is_repeat)
Parameters:
| Name | Type | Description |
|---|---|---|
| rawchar | ? | ? |
| modifiers | ? | ? |
| is_repeat | ? | ? |
Overrides: UI:onKeyDown.
Declared on: line 360 of Lua/game_ui.lua.
function GameUI:onKeyUp(rawchar, modifiers)
Parameters:
| Name | Type | Description |
|---|---|---|
| rawchar | ? | ? |
| modifiers | ? | ? |
Overrides: UI:onKeyUp.
Declared on: line 378 of Lua/game_ui.lua.
function GameUI:onMouseMove(x, y, dx, dy)
TODO: try to remove duplication with UI:onMouseMove
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| dx | ? | ? |
| dy | ? | ? |
Overrides: UI:onMouseMove.
Declared on: line 594 of Lua/game_ui.lua.
function GameUI:onMouseUp(code, x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| code | ? | ? |
| x | ? | ? |
| y | ? | ? |
Overrides: UI:onMouseUp.
Declared on: line 698 of Lua/game_ui.lua.
function GameUI:onMouseWheel(x, y, touch, flipped)
Process SDL_EVENT_MOUSE_WHEEL
Parameters:
| Name | Type | Description |
|---|---|---|
| x | number | the amount scrolled horizontally (+x = right, -x = left) |
| y | number | the amount scrolled vertically (+y = up/away, -y = down/towards) |
| touch | boolean | whether the mouse wheel is from a touch gesture |
| flipped | boolean | whether the axis are flipped such as MacOS natural scrolling |
Overrides: UI:onMouseWheel.
Declared on: line 811 of Lua/game_ui.lua.
function GameUI:onPinchBegin()
Process SDL_EVENT_PINCH_BEGIN.
Overrides: UI:onPinchBegin.
Declared on: line 777 of Lua/game_ui.lua.
function GameUI:onPinchEnd()
Process SDL_EVENT_PINCH_END.
Overrides: UI:onPinchEnd.
Declared on: line 794 of Lua/game_ui.lua.
function GameUI:onPinchUpdate(scale)
Process SDL_EVENT_PINCH_UPDATE.
Scale < 1 is "zoom out". Scale > 1 is "zoom in"
Parameters:
| Name | Type | Description |
|---|---|---|
| scale | number | The scale change since the last SDL_EVENT_PINCH_UPDATE. |
Overrides: UI:onPinchUpdate.
Declared on: line 784 of Lua/game_ui.lua.
function GameUI:onTick()
Overrides: UI:onTick.
Declared on: line 877 of Lua/game_ui.lua.
function GameUI:onWindowActive(gain)
Called when focus changes on game window.
Parameters:
| Name | Type | Description |
|---|---|---|
| gain | number | 1 for in-focus, 0 for out-of-focus |
Overrides: UI:onWindowActive.
Declared on: line 585 of Lua/game_ui.lua.
function GameUI:onWindowDisplayScaleChanged(scale)
Parameters:
| Name | Type | Description |
|---|---|---|
| scale | ? | ? |
Overrides: UI:onWindowDisplayScaleChanged.
Declared on: line 800 of Lua/game_ui.lua.
function GameUI:playAnnouncement(name, priority, played_callback, played_callback_delay)
Parameters:
| Name | Type | Description |
|---|---|---|
| name | ? | ? |
| priority | ? | ? |
| played_callback | ? | ? |
| played_callback_delay | ? | ? |
Overrides: UI:playAnnouncement.
Declared on: line 861 of Lua/game_ui.lua.
function GameUI:playRandomAnnouncement(msgs, priority, chance_to_play, played_callback, played_callback_delay)
Announcements to the player.
Parameters:
| Name | Type | Description |
|---|---|---|
| msgs | array or of or string | Messages to select from. |
| priority | optional or valid or AnnouncementPriority or selection | Priority of announcement |
| chance_to_play | optional or float or in or range or 0 or 1 | Fraction of times that the call actually says something. |
| played_callback | ? | ? |
| played_callback_delay | ? | ? |
Declared on: line 840 of Lua/game_ui.lua.
function GameUI:quit(mapeditor)
Offers a confirmation window to quit the game and return to main menu
NB: overrides UI.quit, do NOT call it from here
Parameters:
| Name | Type | Description |
|---|---|---|
| mapeditor | boolean | If the user is quitting the map editor |
Overrides: UI:quit.
Declared on: line 1377 of Lua/game_ui.lua.
function GameUI:recallMapPosition(index)
Retrieves stored recall position and attempts to scroll to that position - will be limited to the bounds of the camera when zoomed out
param index (integer) Position in recallpositions table
Parameters:
| Name | Type | Description |
|---|---|---|
| index | ? | ? |
Declared on: line 1282 of Lua/game_ui.lua.
function GameUI:resync(ui)
Update UI state after the UI has been depersisted
When an UI object is depersisted, its state will reflect how the UI was at
the moment of persistence, which may be different to the keyboard / mouse
state at the moment of depersistence.
Parameters:
| Name | Type | Description |
|---|---|---|
| ui | UI | The previously existing UI object, from which values should be taken. |
Declared on: line 291 of Lua/game_ui.lua.
function GameUI:scrollMap(dx, dy)
Parameters:
| Name | Type | Description |
|---|---|---|
| dx | ? | ? |
| dy | ? | ? |
Declared on: line 1009 of Lua/game_ui.lua.
function GameUI:scrollMapTo(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
Declared on: line 951 of Lua/game_ui.lua.
function GameUI:setEditRoom(enabled)
Parameters:
| Name | Type | Description |
|---|---|---|
| enabled | ? | ? |
Declared on: line 1294 of Lua/game_ui.lua.
function GameUI:setMapRecallPosition(index)
Converts centre of screen coordinates to world tile positions and stores the values for later recall
param index (integer) Position in recallpositions table
Parameters:
| Name | Type | Description |
|---|---|---|
| index | ? | ? |
Declared on: line 1274 of Lua/game_ui.lua.
function GameUI:setWallsTransparent(mode)
Sets wall transparency to the specified parameter
Parameters:
| Name | Type | Description |
|---|---|---|
| mode | boolean | whether to enable or disable wall transparency |
Declared on: line 1046 of Lua/game_ui.lua.
function GameUI:setWorldHitTest(mode)
Change if the World should be tested for entities under the cursor
to disable, room to enable only for non-door objects in given room
Parameters:
| Name | Type | Description |
|---|---|---|
| mode | boolean or or or room | true to enable hit test (normal), false |
Declared on: line 440 of Lua/game_ui.lua.
function GameUI:setZoom(factor, follow_cursor)
Parameters:
| Name | Type | Description |
|---|---|---|
| factor | ? | ? |
| follow_cursor | ? | ? |
Declared on: line 223 of Lua/game_ui.lua.
function GameUI:setupGlobalKeyHandlers()
Overrides: UI:setupGlobalKeyHandlers.
Declared on: line 117 of Lua/game_ui.lua.
function GameUI:showBriefing()
Declared on: line 1366 of Lua/game_ui.lua.
function GameUI:showMenuBar()
Declared on: line 1393 of Lua/game_ui.lua.
function GameUI:startTutorial(chapter)
Parameters:
| Name | Type | Description |
|---|---|---|
| chapter | ? | ? |
Declared on: line 1266 of Lua/game_ui.lua.
function GameUI:tutorialStep(chapter, phase_from, phase_to, ...)
Called to trigger step to another part of the tutorial.
chapter: Individual parts of the tutorial. Step will only happen if it's the current chapter.
phase_from: Phase we need to be in for this step to happen. Multiple phases can be given here in an array.
phase_to: Phase we want to step to or "next" to go to next chapter or "end" to end tutorial.
returns true if we changed phase, false if we didn't
Parameters:
| Name | Type | Description |
|---|---|---|
| chapter | ? | ? |
| phase_from | ? | ? |
| phase_to | ? | ? |
| ... | ? | ? |
Overrides: UI:tutorialStep.
Declared on: line 1208 of Lua/game_ui.lua.
function GameUI:updateKeyScroll()
Declared on: line 322 of Lua/game_ui.lua.