CorsixTH Lua Documentation

Panel Class

The basic component which makes up most `Window`s.

Declared on: line 162 of Lua/window.lua.
Full description:
The visual parts of most ingame dialogs are sprites from a sprite sheet. A `Panel` is an instance of a particular sprite, consisting of a sprite index and a position. It is advantageous to construct dialogs out of panels (using `Window:addPanel`) as the common operations on panels (like drawing them and hit-testing against them) are implemented in the `Window` class, thus reducing the amount of work that each individual dialog has to do.

Method Index

Member Index

function Panel:afterLoad(old, new)

Parameters:

NameTypeDescription
old ? ?
new ? ?

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

function Panel:clipLine(line, limit)

Checks if a given line drawn with the panel's label font would be longer than the given limit

and if so, shortens it enough to fit including "..." at the end

Parameters:

NameTypeDescription
line string the line to modify
limit int the maximum length in pixels the line should have

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

function Panel:drawLabel(canvas, x, y, limit)

Draw function for the label on a panel

Parameters:

NameTypeDescription
canvas ? The canvas to draw on (can be nil for test)
x ? x position to start drawing on
y ? y position to start drawing on
limit nil or or or int or int limit after which line and with character on that line to stop drawing

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

function Panel:makeButton(...)

Parameters:

NameTypeDescription
... ? ?

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

function Panel:makeHotkeyBox(...)

Parameters:

NameTypeDescription
... ? ?

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

function Panel:makeRepeatButton(...)

Parameters:

NameTypeDescription
... ? ?

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

function Panel:makeScrollbar(...)

Parameters:

NameTypeDescription
... ? ?

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

function Panel:makeTextbox(...)

Parameters:

NameTypeDescription
... ? ?

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

function Panel:makeToggleButton(...)

Parameters:

NameTypeDescription
... ? ?

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

function Panel:setAutoClip(mode)

Specifies whether auto clip (clipping text at the end so it fits) is enabled for this panel

Parameters:

NameTypeDescription
mode boolean true to activate, false to deactivate.

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

function Panel:setColour(col, preserve_disable)

Set the colour of a panel

Note: This works only with ColourPanel and BevelPanel, not normal (sprite) panels.

Parameters:

NameTypeDescription
col table Colour given as a table with three fields red, green and blue, each an integer value in [0, 255].
preserve_disable boolean If true, do not adjust the panel's disabled colour.

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

function Panel:setDynamicTooltip(callback, x, y)

Parameters:

NameTypeDescription
callback ? ?
x ? ?
y ? ?

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

function Panel:setLabel(label, font, align)

Specify a label to be drawn on top of the panel. Note: This works only with ColourPanel and BevelPanel, not normal (sprite) panels.

can be either of "left", "center", "right"

Parameters:

NameTypeDescription
label string The text to be drawn on top of the label.
font font [optional] The font to use. Default is Font01V in QData.
align string [optional] Alignment for non-multiline labels (multiline is always left)

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

function Panel:setPosition(x, y)

Set the position of a panel.

Parameters:

NameTypeDescription
x int New horizontal position of the panel.
y int New vertical position of the panel.

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

function Panel:setSize(width, height)

Set the size of a panel.

Parameters:

NameTypeDescription
width int New width of the panel.
height int New height of the panel.

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

function Panel:setTextWrap(enabled)

Set whether text wrapping is enabled for this panel.

Parameters:

NameTypeDescription
enabled bool Whether to text wrapping enabled.

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

function Panel:setTooltip(tooltip, x, y)

Specify a tooltip to be displayed when hovering this panel. x and y are optional position of bottom left of the tooltip. If not specified, will default to mouse position.

Parameters:

NameTypeDescription
tooltip ? ?
x ? ?
y ? ?

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

function Panel:setVisible(visibility)

Set the visibility of the panel.

Parameters:

NameTypeDescription
visibility bool New visibility of the panel.

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