CorsixTH Lua Documentation

GameUI Class

Variant of UI for running games

Declared on: line 24 of Lua/game_ui.lua.
Inheritance: GameUI » UI » Window

Method Index

Member Index

(*) only used in superclass methods
function GameUI:GameUI(app, local_hospital, map_editor)

Game UI constructor.

Parameters:

NameTypeDescription
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:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 423 of Lua/game_ui.lua.

function GameUI:WorldToScreen(x, y)

Parameters:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
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:limitCamera(mode)

Parameters:

NameTypeDescription
mode ? ?

Declared on: line 1036 of Lua/game_ui.lua.

function GameUI.limitPointToDiamond(dx, dy, visible_diamond, do_limit)

Parameters:

NameTypeDescription
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: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:

NameTypeDescription
scr_w ? ?
scr_h ? ?

Declared on: line 187 of Lua/game_ui.lua.

function GameUI:onKeyDown(rawchar, modifiers, is_repeat)

Parameters:

NameTypeDescription
rawchar ? ?
modifiers ? ?
is_repeat ? ?

Overrides: UI:onKeyDown.
Declared on: line 360 of Lua/game_ui.lua.

function GameUI:onKeyUp(rawchar, modifiers)

Parameters:

NameTypeDescription
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:

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

Overrides: UI:onMouseMove.
Declared on: line 594 of Lua/game_ui.lua.

function GameUI:onMouseUp(code, x, y)

Parameters:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
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:onWindowActive(gain)

Called when focus changes on game window.

Parameters:

NameTypeDescription
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:

NameTypeDescription
scale ? ?

Overrides: UI:onWindowDisplayScaleChanged.
Declared on: line 800 of Lua/game_ui.lua.

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

Parameters:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
dx ? ?
dy ? ?

Declared on: line 1009 of Lua/game_ui.lua.

function GameUI:scrollMapTo(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

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

function GameUI:setEditRoom(enabled)

Parameters:

NameTypeDescription
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:

NameTypeDescription
index ? ?

Declared on: line 1274 of Lua/game_ui.lua.

function GameUI:setWallsTransparent(mode)

Sets wall transparency to the specified parameter

Parameters:

NameTypeDescription
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:

NameTypeDescription
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:

NameTypeDescription
factor ? ?
follow_cursor ? ?

Declared on: line 223 of Lua/game_ui.lua.

function GameUI:startTutorial(chapter)

Parameters:

NameTypeDescription
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:

NameTypeDescription
chapter ? ?
phase_from ? ?
phase_to ? ?
... ? ?

Overrides: UI:tutorialStep.
Declared on: line 1208 of Lua/game_ui.lua.