User Tools

Site Tools


This is an old revision of the document!


The gui Object

The gui object represents the GUI of the current .cgui file. It provides methods that affect the entire GUI as a whole, not just a single window of its window hierarchy.

activate(b)

Sets whether the GUI is active or not. Active GUIs are drawn and receive device (mouse and keyboard) and clock-tick events, inactive GUIs aren't drawn and don't receive events. (In order for a GUI to receive device events, more requirements must be met, see setInteractive() for more details.)

The default value is true.

Returns:

Nothing (nil).

close()

Same as calling activate(false).

Returns:

Nothing (nil).

Example:

    -- The next two lines are equivalent:
    gui:close();
    gui:activate(false);

setInteractive(b)

Sets whether the GUI is interactive or not. Only the top-most, interactive GUI receives device (mouse and keyboard) events. (In order for a GUI to receive events, it must also be active, see activate() for more details.)

A typical example for a non-interactive GUI is the local players HUD, or any static world GUI that just displays some information.

The default value is true.

Returns:

Nothing (nil).

setFullCover(b)

Sets whether this GUI is fullscreen and fully opaque, that is, whether this GUI covers everything beneath it.

If b is true, the GuiSys saves the rendering of the GUIs “below” this one, otherwise it doesn't. This can improve the GUI performance significantly if e.g. the player is at a point in the game where the world rendering FPS is low. In this case, if setFullCover(false) has been called, the world FPS also drags the GUI FPS down. If however setFullCover(true) has been called, the GuiSys omits the slow drawing of the world beneath this GUI, so that the GUIs FPS can be much higher.

The default value is false.

Returns:

Nothing (nil).

setMousePos(x, y)

Sets the position of the mouse cursor to the point at (x, y) (in virtual screen coordinates).

Returns:

Nothing (nil).

setMouseMat(s)

Sets the name of the MatSys material that is to be used as the mouse cursor.

This is not yet implemented. Instead the GuiSys always draws a simple built-in default cursor.

Returns:

Nothing (nil).

showMouse(b)

Sets whether the mouse cursor is shown at all.

Non-interactive GUIs normally don't show a mouse cursor whereas interactive GUIs do, but there also are exceptions, e.g. a GUI in which the user can control a 3D camera with the mouse is interactive but may not need a mouse cursor. (The clients main world rendering is an example for this.) Also fade-out or cinematic sequences can temporarily switch off the mouse-cursor with this method.

The default value is true.

Returns:

Nothing (nil).

setFocus(w)

Sets the keyboard input focus (the default receiver for keyboard events) to window w.

Note that calling this methods does not imply calls to w:OnFocusLose() and w:OnFocusGain(). This is contrary to focus changes due to a mouse click, where the GuiSys implicitly does the calls. With setFocus(w) however, the calling Lua code should make these calls itself if so desired.

Returns:

Nothing (nil).

Example:

    -- previousWin and myWin are some windows of this GUIs window hierarchy.
    previousWin:OnFocusLose();
    gui:setFocus(myWin);
    myWin:OnFocusGain();

By default, no window has the keyboard input focus.

__tostring()

Returns:

Returns a string that briefly describes the GUI.

scripting/gui.1158514033.txt.gz · Last modified: 2013-01-07 12:07 (external edit)