UiSystem¶
Extends EngineObject.
Properties¶
width: numberThe width of the screen in pixels. Read-only.height: numberThe height of the screen in pixels. Read-only.density: numberHow many pixels a density-independent pixel (dp in RCSS) is: 1 on an ordinary screen, 2 on a high-density one, or what the player's UI scale says.debugger: booleanRmlUi's inspector (the element tree and styles of every document, and a log) as a window over the UI.wants_mouse: booleanTrue while the pointer is over an element of a document: the game should not also react to the mouse. Read-only.wants_keyboard: booleanTrue while a text field has the focus: typed text and keys are the UI's, not the game's. Read-only.
Methods¶
open_data_model¶
function open_data_model(self, name: string, fields: { [any]: any }): UiDataModel?
Opens a data model called name over a table: its fields are what documents with data-model="name" show. Null when there is a model of that name already. Open it before the documents that use it load (a script in the document's head can).
update¶
function update(self, deltaSeconds: number): boolean
Lays out what changed and runs animations, deltaSeconds after the last call. Returns whether anything changed.
on_update¶
function on_update(self, handler: (...any) -> ...any): number
Calls handler with the frame's time step at the start of every Update, before layout: where a script puts what changed in the game (a speed, a health value) into the UI, so that it is in the picture of this frame. Returns a number for RemoveUpdate. A handler that fails is logged and removed.
remove_update¶
function remove_update(self, id: number): ()
load_document¶
function load_document(self, path: string): UiElement?
Loads the RML document at path (res://ui/menu.rml). It is not shown until UiElement.Show. Null when it cannot be read or parsed (the log says why).
load_document_text¶
function load_document_text(self, rml: string, sourceUrl: string?): UiElement?
Loads a document from RML text; sourceUrl is what its relative paths (stylesheets, images) are relative to.
create_document¶
function create_document(self): UiElement?
An empty document, with a body to put elements in, for a UI built in code.
load_font¶
function load_font(self, path: string, family: string, bold: boolean?, italic: boolean?, fallback: boolean?): boolean
Loads a font from the file at path for the family family (documents say font-family: Family). False when it is not a font.
unlisten¶
function unlisten(self, token: number): boolean
Takes back a listener (the number UiElement.Listen returned). False when it was gone already.