naev 0.12.5
nlua_gui.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
11
12#include "naev.h"
14
15#include "nlua_gui.h"
16
17#include "gui.h"
18#include "gui_omsg.h"
19#include "gui_osd.h"
20#include "map_overlay.h"
21#include "nlua_tex.h"
22
23/* GUI methods. */
24static int guiL_viewport( lua_State *L );
25static int guiL_fpsPos( lua_State *L );
26static int guiL_osdInit( lua_State *L );
27static int guiL_mesgInit( lua_State *L );
28static int guiL_omsgInit( lua_State *L );
29static int guiL_radarInit( lua_State *L );
30static int guiL_radarRender( lua_State *L );
31static int guiL_targetSpobGFX( lua_State *L );
32static int guiL_targetPilotGFX( lua_State *L );
33static int guiL_mouseClickEnable( lua_State *L );
34static int guiL_mouseMoveEnable( lua_State *L );
35static int guiL_setMapOverlayBounds( lua_State *L );
36
37static const luaL_Reg guiL_methods[] = {
38 { "viewport", guiL_viewport },
39 { "fpsPos", guiL_fpsPos },
40 { "osdInit", guiL_osdInit },
41 { "mesgInit", guiL_mesgInit },
42 { "omsgInit", guiL_omsgInit },
43 { "radarInit", guiL_radarInit },
44 { "radarRender", guiL_radarRender },
45 { "targetSpobGFX", guiL_targetSpobGFX },
46 { "targetPilotGFX", guiL_targetPilotGFX },
47 { "mouseClickEnable", guiL_mouseClickEnable },
48 { "mouseMoveEnable", guiL_mouseMoveEnable },
49 { "setMapOverlayBounds", guiL_setMapOverlayBounds },
50 { 0, 0 } };
51
58int nlua_loadGUI( nlua_env env )
59{
60 /* Register the values */
61 nlua_register( env, "gui", guiL_methods, 0 );
62 return 0;
63}
64
75
96static int guiL_viewport( lua_State *L )
97{
98 /* Parameters. */
99 double x = luaL_checknumber( L, 1 );
100 double y = luaL_checknumber( L, 2 );
101 double w = luaL_checknumber( L, 3 );
102 double h = luaL_checknumber( L, 4 );
103
104 /* Set the viewport. */
105 gui_setViewport( x, y, w, h );
106 return 0;
107}
108
118static int guiL_fpsPos( lua_State *L )
119{
120 double x = luaL_checknumber( L, 1 );
121 double y = luaL_checknumber( L, 2 );
122 fps_setPos( x, y );
123 return 0;
124}
125
135static int guiL_osdInit( lua_State *L )
136{
137 /* Parameters. */
138 int x = luaL_checkinteger( L, 1 );
139 int y = luaL_checkinteger( L, 2 );
140 int w = luaL_checkinteger( L, 3 );
141 int h = luaL_checkinteger( L, 4 );
142
143 /* Set up. */
144 osd_setup( x, y, w, h );
145 return 0;
146}
147
156static int guiL_mesgInit( lua_State *L )
157{
158 /* Parse parameters. */
159 int w = luaL_checkinteger( L, 1 );
160 int x = luaL_checkinteger( L, 2 );
161 int y = luaL_checkinteger( L, 3 );
162
163 /* Initialize. */
164 gui_messageInit( w, x, y );
165 return 0;
166}
167
176static int guiL_omsgInit( lua_State *L )
177{
178 /* Parse parameters. */
179 double w = luaL_checkinteger( L, 1 );
180 double x = luaL_checkinteger( L, 2 );
181 double y = luaL_checkinteger( L, 3 );
182
183 /* Initialize. */
184 omsg_position( x, y, w );
185 return 0;
186}
187
199static int guiL_radarInit( lua_State *L )
200{
201 int id, circle, width, height;
202
203 /* Parse parameters. */
204 circle = lua_toboolean( L, 1 );
205 width = luaL_checkinteger( L, 2 );
206 if ( !circle )
207 height = luaL_checkinteger( L, 3 );
208 else
209 height = width;
210
211 /* Create the radar. */
212 id = gui_radarInit( circle, width, height );
213 lua_pushnumber( L, id );
214 return 1;
215}
216
226static int guiL_radarRender( lua_State *L )
227{
228 /* Parse parameters. */
229 double x = luaL_checknumber( L, 1 );
230 double y = luaL_checknumber( L, 2 );
231
232 /* Render the radar. */
233 gui_radarRender( x, y );
234 return 0;
235}
236
243static int guiL_targetSpobGFX( lua_State *L )
244{
246 return 0;
247}
248
255static int guiL_targetPilotGFX( lua_State *L )
256{
258 return 0;
259}
260
274static int guiL_mouseClickEnable( lua_State *L )
275{
276 int b;
277 if ( lua_gettop( L ) > 0 )
278 b = lua_toboolean( L, 1 );
279 else
280 b = 1;
282 return 0;
283}
284
296static int guiL_mouseMoveEnable( lua_State *L )
297{
298 int b;
299 if ( lua_gettop( L ) > 0 )
300 b = lua_toboolean( L, 1 );
301 else
302 b = 1;
304 return 0;
305}
306
316static int guiL_setMapOverlayBounds( lua_State *L )
317{
318 int top = luaL_checkinteger( L, 1 );
319 int right = luaL_checkinteger( L, 2 );
320 int bottom = luaL_checkinteger( L, 3 );
321 int left = luaL_checkinteger( L, 4 );
322
323 ovr_boundsSet( top, right, bottom, left );
324 return 0;
325}
int gui_radarInit(int circle, int w, int h)
Initializes the radar.
Definition gui.c:910
void gui_radarRender(double x, double y)
Renders the GUI radar.
Definition gui.c:925
void gui_mouseMoveEnable(int enable)
Enables the mouse movement callback.
Definition gui.c:2357
void gui_mouseClickEnable(int enable)
Enables the mouse click callback.
Definition gui.c:2349
void gui_messageInit(int width, int x, int y)
Initializes the message system.
Definition gui.c:211
void gui_targetPilotGFX(const glTexture *gfx)
Sets the pilot target GFX.
Definition gui.c:2185
void gui_targetSpobGFX(const glTexture *gfx)
Sets the spob target GFX.
Definition gui.c:2176
void gui_setViewport(double x, double y, double w, double h)
Sets the viewport.
Definition gui.c:1656
void fps_setPos(double x, double y)
Sets the position to display the FPS.
Definition naev.c:944
Header file with generic functions and naev-specifics.
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
int nlua_loadGUI(nlua_env env)
Loads the GUI library.
Definition nlua_gui.c:58
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 const luaL_Reg guiL_methods[]
Definition nlua_gui.c:37
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
glTexture * luaL_checktex(lua_State *L, int ind)
Gets texture at index or raises error if there is no texture at index.
Definition nlua_tex.c:97