Package openmw.uiΒΆ

openmw.ui controls user interface.

Can be used only by local scripts, that are attached to a player.

Usage:

local ui = require('openmw.ui')

Type ui

ui.WIDGET_TYPE
ui.content(table)

Converts a given table of tables into an openmw.ui#Content

ui.create(layout)

Creates a UI element from the given layout table

ui.layers

Tools for working with layers

ui.showMessage(msg)

Shows given message at the bottom of the screen.

Type Content

Content:add(layout)

Adds the layout at the end of the Content (same as calling insert with last index + 1)

Content:indexOf(layout)

Finds the index of the given layout.

Content:insert(index, layout)

Puts the layout at given index by shifting all the elements after it

Type Element

Element:destroy()

Destroys the element

Element.layout

Access or replace the element's layout

Element:update()

Refreshes the rendered element to match the current layout state

Type Layers

Layers.indexOf(name)

Index of the layer with the givent name.

Layers.insertAfter(afterName, name, options)

Creates a layer and inserts it after another layer (shifts indexes of some other layers).

Type Layout

Layout.content

Optional openmw.ui#Content of children layouts

Layout.events

Optional table of event callbacks

Layout.name

Optional name of the layout. Allows access by name from Content

Layout.props

Optional table of widget properties

Type MouseEvent

MouseEvent.button

Mouse button which triggered the event (could be nil)

MouseEvent.offset

Position of the mouse cursor relative to the widget

MouseEvent.position

Absolute position of the mouse cursor

Type WIDGET_TYPE

WIDGET_TYPE.Text

Display text

WIDGET_TYPE.TextEdit

Accepts user text input

WIDGET_TYPE.Widget

Base widget type

WIDGET_TYPE.Window

Can be moved and resized by the user

Type ui

Field(s)

#WIDGET_TYPE ui.WIDGET_TYPE
ui.content(table)

Converts a given table of tables into an openmw.ui#Content

Parameter

  • #table table :

Return value

#Content:

ui.create(layout)

Creates a UI element from the given layout table

Parameter

Return value

#Element:

#Layers ui.layers

Tools for working with layers

ui.showMessage(msg)

Shows given message at the bottom of the screen.

Parameter

  • #string msg :

Type Content

Content.

An array-like container, which allows to reference elements by their name

Content is a list of #Layout.

Usages:

  • local content = ui.content {
       { name = 'input' },
    }
    -- bad idea!
    -- content[1].name = 'otherInput'
    -- do this instead:
    content.input = { name = 'otherInput' }
  • local content = ui.content {
       { name = 'display' },
       { name = 'submit' },
    }
    -- allowed, but shifts all the items after it "up" the array
    content.display = nil
    -- still no holes after this!
  • -- iterate over a Content
    for i = 1, #content do
       print('widget',content[i].name,'at',i)
    end

Field(s)

Content:add(layout)

Adds the layout at the end of the Content (same as calling insert with last index + 1)

Parameter

Content:indexOf(layout)

Finds the index of the given layout.

If it is not in the container, returns nil

Parameter

Return value

#number, #nil: index

Content:insert(index, layout)

Puts the layout at given index by shifting all the elements after it

Parameters

Type Element

Element.

An element of the user interface

Field(s)

Element:destroy()

Destroys the element

#Layout Element.layout

Access or replace the element's layout

Element:update()

Refreshes the rendered element to match the current layout state

Type Layers

Layers

Usage:

ui.layers.insertAfter('HUD', 'NewLayer', { interactive = true })
local fourthLayerName = ui.layers[4]
local windowsIndex = ui.layers.indexOf('Windows')

Field(s)

Layers.indexOf(name)

Index of the layer with the givent name.

Returns nil if the layer doesn't exist

Parameter

  • #string name : Name of the layer

Return value

#number, #nil: index

Layers.insertAfter(afterName, name, options)

Creates a layer and inserts it after another layer (shifts indexes of some other layers).

Parameters

  • #string afterName : Name of the layer after which the new layer will be inserted

  • #string name : Name of the new layer

  • #table options : Table with a boolean interactive field (default is true). Layers with interactive = false will ignore all mouse interactions.

Type Layout

Layout

Field(s)

#Content Layout.content

Optional openmw.ui#Content of children layouts

#table Layout.events

Optional table of event callbacks

#string Layout.name

Optional name of the layout. Allows access by name from Content

#table Layout.props

Optional table of widget properties

Type MouseEvent

Mouse event, passed as an argument to relevant UI events

Field(s)

#number MouseEvent.button

Mouse button which triggered the event (could be nil)

openmw.util#Vector2 MouseEvent.offset

Position of the mouse cursor relative to the widget

openmw.util#Vector2 MouseEvent.position

Absolute position of the mouse cursor

Type WIDGET_TYPE

Field(s)

WIDGET_TYPE.Text

Display text

WIDGET_TYPE.TextEdit

Accepts user text input

WIDGET_TYPE.Widget

Base widget type

WIDGET_TYPE.Window

Can be moved and resized by the user