CorsixTH Lua Documentation

Window Class

Base class for user-interface dialogs.

Declared on: line 23 of Lua/window.lua.
Subclasses: TreeControl, UI, UIAdviser, UIBottomPanel, UIBuildRoom, UIConfirmDialog, UIFullscreen, UIFurnishCorridor, UIHireStaff, UIInformation, UIJukebox, UIMachine, UIMapEditor, UIMenuBar, UIMessage, UIPatient, UIPlaceObjects, UIPlaceStaff, UIQueue, UIQueuePopup, UIResizable, UIStaff, UIStaffRise, UIWatch

Method Index

Member Index

function Window:addBevelPanel(x, y, w, h, colour, highlight_colour, shadow_colour, disabled_colour)

Add a beveled `Panel` to the window.

A bevel panel is similar to a solid colour panel, except that it features a highlight and a shadow that makes it appear either lowered or raised.

Parameters:

NameTypeDescription
x integer The X pixel position to start the panel at.
y integer The Y pixel position to start the panel at.
w integer The width of the panel, in pixels.
h integer The height of the panel, in pixels.
colour colour or in or form or red or green or and or blue The colour for the panel.
highlight_colour colour or in or form or red or green or and or blue or or or nil [optional] The colour for the highlight.
shadow_colour colour or in or form or red or green or and or blue or or or nil [optional] The colour for the shadow.
disabled_colour colour or in or form or red or green or and or blue or or or nil [optional] The colour for the disabled panel.

Declared on: line 396 of Lua/window.lua.

function Window:addColourPanel(x, y, w, h, r, g, b)

Add a solid-colour `Panel` to the window.

A solid-colour panel is like a normal panel, expect it displays a solid colour rather than a bitmap.

Parameters:

NameTypeDescription
x integer The X pixel position to start the panel at.
y integer The Y pixel position to start the panel at.
w integer The width of the panel, in pixels.
h integer The height of the panel, in pixels.
r integer Value in [0, 255] giving the red component of the colour.
g integer Value in [0, 255] giving the green component of the colour.
b integer Value in [0, 255] giving the blue component of the colour.

Declared on: line 355 of Lua/window.lua.

function Window:addKeyHandler(key, handler, ...)

Parameters:

NameTypeDescription
key ? ?
handler ? ?
... ? ?

Declared on: line 122 of Lua/window.lua.

function Window:addPanel(sprite_index, x, y, w, h)

Add a `Panel` to the window.

Panels form the basic building blocks of most windows. A panel is a small bitmap coupled with a position, and by combining several panels, a window can be made. By using panels to construct windows, all of the common tasks like drawing and hit-testing are provided for you by the base class methods, thus reducing the amount of code required elsewhere.

Parameters:

NameTypeDescription
sprite_index integer Index into the window's sprite table of the bitmap to be displayed.
x integer The X pixel position to display the bitmap at.
y integer The Y pixel position to display the bitmap at.
w integer or nil If the panel is totally opaque, and the width of the panel (in pixels) is known, it should be specified here to speed up hit-tests.
h integer or nil If the panel is totally opaque, and the height of the panel (in pixels) is known, it should be specified here to speed up hit-tests.

Declared on: line 314 of Lua/window.lua.

function Window:addWindow(window)

Parameters:

NameTypeDescription
window ? ?

Declared on: line 443 of Lua/window.lua.

function Window:afterLoad(old, new)

Stub to be extended in subclasses, if needed.

Parameters:

NameTypeDescription
old ? ?
new ? ?

Declared on: line 1753 of Lua/window.lua.

function Window:beginDrag(x, y)

Initiate dragging of the window.

Parameters:

NameTypeDescription
x ? The X position of the cursor in window co-ordinatees.
y ? The Y position of the cursor in window co-ordinatees.

Declared on: line 1446 of Lua/window.lua.

function Window:bringToTop()

Bring the window to the top of its parent

Declared on: line 1592 of Lua/window.lua.

function Window:close()

Called before the window is closed

Declared on: line 104 of Lua/window.lua.

function Window:draw(canvas, x, y)

Parameters:

NameTypeDescription
canvas ? ?
x ? ?
y ? ?

Declared on: line 1214 of Lua/window.lua.

function Window:getSavedWindowPositionName()

Get the name of the saved window position group.

When the user drags a window, the new position of the window is saved, and then when any windows in the same group are opened in the future, the position of the new window is set to the saved position. By default, each window class is its own group, but by overriding this method, that can be changed.

Declared on: line 1357 of Lua/window.lua.

function Window:getTooltipAt(x, y)

Tooltips are either associated with buttons, panels, or a region. (see Button:setTooltip, Panel:setTooltip, Window:make[Dynamic]Tooltip)

Button tooltips take precedence over region tooltips, which again take precedence over panels. Returns tooltip in form of { text = .. , x = .. , y = .. } or nil for no tooltip.

Parameters:

NameTypeDescription
x integer The X co-ordinate relative to the top-left corner.
y integer The Y co-ordinate relative to the top-left corner.

Declared on: line 1717 of Lua/window.lua.

function Window:getTooltipForElement(elem, x, y)

An 'element' can either be a panel, a button, or a tooltip region.

Parameters:

NameTypeDescription
elem ? ?
x ? ?
y ? ?

Declared on: line 1701 of Lua/window.lua.

function Window:getWindow(window_class)

Searches (direct) child windows for window of the given class, and returns one (or nil if there weren't any at all).

Parameters:

NameTypeDescription
window_class class The class of window to search for.

Declared on: line 484 of Lua/window.lua.

function Window:getWindows(window_class)

Searches (direct) child windows for window of the given class, and returns a (potentially empty) list of matching windows.

Parameters:

NameTypeDescription
window_class class The class of window to search for.

Declared on: line 497 of Lua/window.lua.

function Window:hitTest(x, y)

Used to test if the window has a (non-transparent) pixel at the given position.

Parameters:

NameTypeDescription
x integer The X co-ordinate of the pixel to test, relative to the top-left corner of the window.
y integer The Y co-ordinate of the pixel to test, relative to the top-left corner of the window.

Declared on: line 1280 of Lua/window.lua.

function Window:hitTestPanel(x, y, panel)

Parameters:

NameTypeDescription
x ? ?
y ? ?
panel ? ?

Declared on: line 1264 of Lua/window.lua.

function Window:makeButtonOnPanel(panel, x, y, w, h, sprite, on_click, on_click_self, on_rightclick)

Convert a static panel into a clickable button.

Parameters:

NameTypeDescription
panel Panel The panel to convert into a button.
x integer The X co-ordinate of the clickable rectangle on the panel.
y integer The Y co-ordinate of the clickable rectangle on the panel.
w integer The width of the clickable rectangle on the panel.
h integer The height of the clickable rectangle on the panel.
sprite integer An index into the window's sprite sheet. The panel will display this sprite when the button is being pressed.
on_click function The function to be run when the user left-clicks the button. Takes three arguments: `on_click_self`, the toggle state (nil for normal buttons, true/false for toggle buttons), the button itself.
on_click_self function or nil The first value to pass to `on_click`. If nil or not given, then the window is passed as the first argument.
on_rightclick function or nil The function to be called when the user right-clicks the button.

Declared on: line 683 of Lua/window.lua.

function Window:makeDynamicTooltip(callback, x, y, r, b, tooltip_x, tooltip_y)

Create a dynamic tooltip to be displayed in a certain region.

tooltip_x and tooltip_y are optional; if not specified, it will default to top center of region.

Parameters:

NameTypeDescription
callback function A function that returns the string to display or nil for no tooltip.
x integer The X co-ordinate relative to the top-left corner.
y integer The Y co-ordinate relative to the top-left corner.
r integer The right (X + width) co-ordinate relative to the top-left corner.
b integer The bottom (Y + height) co-ordinate relative to the top-left corner.
tooltip_x integer [optional] The X co-ordinate to display the tooltip at.
tooltip_y integer [optional] The Y co-ordinate to display the tooltip at.

Declared on: line 1682 of Lua/window.lua.

function Window:makeScrollbarOnPanel(panel, slider_colour, callback, min_value, max_value, page_size, value)

Convert a static panel into a scrollbar.

Scrollbars consist of a base panel (the panel given as a parameter) and an additional slider panel (automatically created BevelPanel).

Parameters:

NameTypeDescription
panel panel The panel that will serve as the scrollbar base.
slider_colour colour or in or form or red or green or and or blue The colour for the slider.
callback function Function that is called whenever the slider position changes.
min_value integer The minimum value the scrollbar can represent.
max_value integer The maximum value the scrollbar can represent.
page_size integer The amount of objects represented on one page.
value integer or nil The current value, or min_value if not specified.

Declared on: line 805 of Lua/window.lua.

function Window:makeTextboxOnPanel(panel, confirm_callback, abort_callback)

Convert a static panel into a textbox.

Textboxes consist of the panel given as a parameter, which is made into a ToggleButton automatically, and handle keyboard input while active.

Parameters:

NameTypeDescription
panel panel The panel that will serve as the textbox base.
confirm_callback function The function to call when text is confirmed.
abort_callback function The function to call when entering is aborted.

Declared on: line 1177 of Lua/window.lua.

function Window:makeTooltip(text, x, y, r, b, tooltip_x, tooltip_y)

Create a static (non-changeable) tooltip to be displayed in a certain region.

tooltip_x and tooltip_y are optional; if not specified, it will default to top center of region.

Parameters:

NameTypeDescription
text string The string to display.
x integer The X co-ordinate relative to the top-left corner.
y integer The Y co-ordinate relative to the top-left corner.
r integer The right (X + width) co-ordinate relative to the top-left corner.
b integer The bottom (Y + height) co-ordinate relative to the top-left corner.
tooltip_x integer [optional] The X co-ordinate to display the tooltip at.
tooltip_y integer [optional] The Y co-ordinate to display the tooltip at.

Declared on: line 1663 of Lua/window.lua.

function Window:onChangeResolution()

Called after the resolution of the game window changes

Declared on: line 97 of Lua/window.lua.

function Window:onCursorWorldPositionChange(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

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

function Window:onMouseDown(button, x, y)

Parameters:

NameTypeDescription
button ? ?
x ? ?
y ? ?

Declared on: line 1307 of Lua/window.lua.

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

Called when the user moves the mouse.

Parameters:

NameTypeDescription
x integer The new X co-ordinate of the cursor, relative to the top-left corner of the window.
y integer The new Y co-ordinate of the cursor, relative to the top-left corner of the window.
dx integer The number of pixels which the cursor moved horizontally.
dy integer The number of pixels which the cursor moved vertically.

Declared on: line 1487 of Lua/window.lua.

function Window:onMouseUp(button, x, y)

Parameters:

NameTypeDescription
button ? ?
x ? ?
y ? ?

Declared on: line 1367 of Lua/window.lua.

function Window:onTick()

Called regularly at a rate independent of the game speed.

Declared on: line 1544 of Lua/window.lua.

function Window:onWorldTick()

Called regularly at the same rate that entities are ticked.

Declared on: line 1583 of Lua/window.lua.

function Window:removeWindow(window)

Parameters:

NameTypeDescription
window ? ?

Declared on: line 468 of Lua/window.lua.

function Window:sendToBottom(window)

Tell the window to bring the specified sub-window to its bottom

Parameters:

NameTypeDescription
window ? ?

Declared on: line 1630 of Lua/window.lua.

function Window:sendToTop(window)

Tell the window to bring the specified sub-window to its top

Parameters:

NameTypeDescription
window ? ?

Declared on: line 1599 of Lua/window.lua.

function Window:setDefaultPosition(x, y)

Sets the window's default onscreen position and onscreen position. The given x and y are interpreted as for setPosition(x, y), and are the default position for the window. If the user has previously repositioned a window of the same type, then setDefaultPosition() will set the window to that previous position, otherwise it sets it to the default position.

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 79 of Lua/window.lua.

function Window:setPosition(x, y)

Sets the window's onscreen position. Each of x and y can be: Integers >= 0 - Absolute pixel positions of top/left edge of window relative to top/left edge of screen Integers < 0 - Absolute pixel positions of right/bottom edge of window relative to right/bottom edge of screen. Use -0.1 to mean -0. Reals in [0, 1) -

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 53 of Lua/window.lua.

function Window:startButtonBlinking(button_index)

Parameters:

NameTypeDescription
button_index ? ?

Declared on: line 1644 of Lua/window.lua.

Page generated on Sat Feb 07, 2015 at 18:38:28 by LDocGen.