naev 0.12.6
nlua_gui.c File Reference

Bindings for GUI functionality from Lua. More...

#include "nlua_gui.h"
#include "gui.h"
#include "gui_omsg.h"
#include "gui_osd.h"
#include "map_overlay.h"
#include "nlua_tex.h"
Include dependency graph for nlua_gui.c:

Go to the source code of this file.

Functions

static int guiL_viewport (lua_State *L)
 Lua bindings to interact with the GUI elements.
static int guiL_fpsPos (lua_State *L)
 Sets the position for the fps stuff.
static int guiL_osdInit (lua_State *L)
 Initializes the mission OSD (on-screen display).
static int guiL_mesgInit (lua_State *L)
 Sets up the message box from which the player receives input.
static int guiL_omsgInit (lua_State *L)
 Sets the center of the omsg messages and width.
static int guiL_radarInit (lua_State *L)
 Initializes the radar.
static int guiL_radarRender (lua_State *L)
 Renders the radar.
static int guiL_targetSpobGFX (lua_State *L)
 Sets the Lua spob target GFX.
static int guiL_targetPilotGFX (lua_State *L)
 Sets the Lua pilot target GFX.
static int guiL_mouseClickEnable (lua_State *L)
 Enables mouse clicking callback.
static int guiL_mouseMoveEnable (lua_State *L)
 Enables mouse movement callback.
static int guiL_setMapOverlayBounds (lua_State *L)
 Sets map boundaries.
int nlua_loadGUI (nlua_env env)
 Loads the GUI library.

Variables

static const luaL_Reg guiL_methods []

Detailed Description

Bindings for GUI functionality from Lua.

Definition in file nlua_gui.c.

Function Documentation

◆ guiL_fpsPos()

int guiL_fpsPos ( lua_State * L)
static

Sets the position for the fps stuff.

It can display the FPS and the current speed mod.

Lua function parameter: x X position for the fps stuff. Lua function parameter: y Y position for the fps stuff.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: fpsPos

Definition at line 118 of file nlua_gui.c.

◆ guiL_mesgInit()

int guiL_mesgInit ( lua_State * L)
static

Sets up the message box from which the player receives input.

Lua function parameter: number width Width of the message box. Lua function parameter: number x X position of message box. Lua function parameter: number y Y position of message box.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mesgInit

Definition at line 156 of file nlua_gui.c.

◆ guiL_mouseClickEnable()

int guiL_mouseClickEnable ( lua_State * L)
static

Enables mouse clicking callback.

It enables receiving mouse clicks with a callback function like:
function mouse_click( button, x, y, state )
With button being the ID of the button, x/y being the position clicked and state being true if pressed, false if lifted. It should return true if it used the mouse event or false if it let it through.

Lua function parameter:[opt=true] boolean enable Whether or not to enable the mouse click callback.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mouseClickEnable

Definition at line 274 of file nlua_gui.c.

◆ guiL_mouseMoveEnable()

int guiL_mouseMoveEnable ( lua_State * L)
static

Enables mouse movement callback.

It enables receiving mouse movements with a callback function like:
function mouse_move( x, y )
With x/y being the position of the mouse.

Lua function parameter:[opt] boolean enable Whether or not to enable the mouse movement callback.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mouseMoveEnable

Definition at line 296 of file nlua_gui.c.

◆ guiL_omsgInit()

int guiL_omsgInit ( lua_State * L)
static

Sets the center of the omsg messages and width.

Lua function parameter: number width Width of the omsg messages. Lua function parameter: number x X center of the omsg messages. Lua function parameter: number y Y center of the omsg messages.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: omsgInit

Definition at line 176 of file nlua_gui.c.

◆ guiL_osdInit()

int guiL_osdInit ( lua_State * L)
static

Initializes the mission OSD (on-screen display).

Lua function parameter: number x X position of the OSD display. Lua function parameter: number y Y position of the OSD display. Lua function parameter: number w Width of the OSD display. Lua function parameter: number h Height of the OSD display.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: osdInit

Definition at line 135 of file nlua_gui.c.

◆ guiL_radarInit()

int guiL_radarInit ( lua_State * L)
static

Initializes the radar.

Lua usage parameter: gui.radarInit( true, 82 ) – Circular radar with 82 radius.

Lua function parameter: number circle Whether or not it should be a circle. Lua function parameter: number width Width if it's not a circle or radius if it is a circle. Lua function parameter: number height Only needed if not a circle.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: radarInit

Definition at line 199 of file nlua_gui.c.

◆ guiL_radarRender()

int guiL_radarRender ( lua_State * L)
static

Renders the radar.

Lua usage parameter: gui.radarRender( 50, 50 )

Lua function parameter: number x X position to render at. Lua function parameter: number y Y position to render at.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: radarRender

Definition at line 226 of file nlua_gui.c.

◆ guiL_setMapOverlayBounds()

int guiL_setMapOverlayBounds ( lua_State * L)
static

Sets map boundaries.

Lua function parameter: number top Top boundary in pixels Lua function parameter: number right Right boundary in pixels Lua function parameter: number bottom Bottom boundary in pixels Lua function parameter: number left Left boundary in pixels

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setMapOverlayBounds

Definition at line 316 of file nlua_gui.c.

◆ guiL_targetPilotGFX()

int guiL_targetPilotGFX ( lua_State * L)
static

Sets the Lua pilot target GFX.

Lua function parameter: Tex tex Texture to set for the pilot targeting.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: targetPilotGFX

Definition at line 255 of file nlua_gui.c.

◆ guiL_targetSpobGFX()

int guiL_targetSpobGFX ( lua_State * L)
static

Sets the Lua spob target GFX.

Lua function parameter: Tex tex Texture to set for the spob targeting.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: targetSpobGFX

Definition at line 243 of file nlua_gui.c.

◆ guiL_viewport()

int guiL_viewport ( lua_State * L)
static

Lua bindings to interact with the GUI elements.

An example would be:

gui.radarRender( 0, 0 ) -- Renders the radar in the bottom left.

Lua module: gui

Sets the gui viewport.

Basically this limits what the rest of the game considers as the screen. Careful when using this or you can make the game look ugly and unplayable. So use common sense and try to avoid windows smaller than 800x600 if possible.

Lua usage parameter: gui.viewport( 0, 0, screen_w, screen_h ) – Resets viewport. Lua usage parameter: gui.viewport( 0, 20, screen_w, screen_h-20 ) – Gives 20 pixels for a bottom bar.

Lua function parameter: number x X position to start clipping (bottom left is 0.) Lua function parameter: number y Y position to start clipping (bottom left is 0.) Lua function parameter: number w Width of the clipping (width of the screen is default). Lua function parameter: number h Height of the clipping (height of the screen is default).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: viewport

Definition at line 96 of file nlua_gui.c.

◆ nlua_loadGUI()

int nlua_loadGUI ( nlua_env env)

Loads the GUI library.

Parameters
envEnvironment to load GUI library into.
Returns
0 on success.

Definition at line 58 of file nlua_gui.c.

Variable Documentation

◆ guiL_methods

const luaL_Reg guiL_methods[]
static
Initial value:
= {
{ "viewport", guiL_viewport },
{ "fpsPos", guiL_fpsPos },
{ "osdInit", guiL_osdInit },
{ "mesgInit", guiL_mesgInit },
{ "omsgInit", guiL_omsgInit },
{ "radarInit", guiL_radarInit },
{ "radarRender", guiL_radarRender },
{ "targetSpobGFX", guiL_targetSpobGFX },
{ "targetPilotGFX", guiL_targetPilotGFX },
{ "mouseClickEnable", guiL_mouseClickEnable },
{ "mouseMoveEnable", guiL_mouseMoveEnable },
{ "setMapOverlayBounds", guiL_setMapOverlayBounds },
{ 0, 0 } }
static int guiL_radarInit(lua_State *L)
Initializes the radar.
Definition nlua_gui.c:199
static int guiL_mouseMoveEnable(lua_State *L)
Enables mouse movement callback.
Definition nlua_gui.c:296
static int guiL_mesgInit(lua_State *L)
Sets up the message box from which the player receives input.
Definition nlua_gui.c:156
static int guiL_osdInit(lua_State *L)
Initializes the mission OSD (on-screen display).
Definition nlua_gui.c:135
static int guiL_viewport(lua_State *L)
Lua bindings to interact with the GUI elements.
Definition nlua_gui.c:96
static int guiL_mouseClickEnable(lua_State *L)
Enables mouse clicking callback.
Definition nlua_gui.c:274
static int guiL_targetPilotGFX(lua_State *L)
Sets the Lua pilot target GFX.
Definition nlua_gui.c:255
static int guiL_setMapOverlayBounds(lua_State *L)
Sets map boundaries.
Definition nlua_gui.c:316
static int guiL_omsgInit(lua_State *L)
Sets the center of the omsg messages and width.
Definition nlua_gui.c:176
static int guiL_radarRender(lua_State *L)
Renders the radar.
Definition nlua_gui.c:226
static int guiL_fpsPos(lua_State *L)
Sets the position for the fps stuff.
Definition nlua_gui.c:118
static int guiL_targetSpobGFX(lua_State *L)
Sets the Lua spob target GFX.
Definition nlua_gui.c:243

GUI methods.

Definition at line 37 of file nlua_gui.c.