naev 0.11.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"
15#include "nlua_gui.h"
16
17#include "gui.h"
18#include "gui_omsg.h"
19#include "gui_osd.h"
20#include "log.h"
21#include "map_overlay.h"
22#include "nlua_tex.h"
23#include "nluadef.h"
24
25/* GUI methods. */
26static int guiL_viewport( lua_State *L );
27static int guiL_fpsPos( lua_State *L );
28static int guiL_osdInit( lua_State *L );
29static int guiL_mesgInit( lua_State *L );
30static int guiL_omsgInit( lua_State *L );
31static int guiL_radarInit( lua_State *L );
32static int guiL_radarRender( lua_State *L );
33static int guiL_targetSpobGFX( lua_State *L );
34static int guiL_targetPilotGFX( lua_State *L );
35static int guiL_mouseClickEnable( lua_State *L );
36static int guiL_mouseMoveEnable( lua_State *L );
37static int guiL_setMapOverlayBounds( lua_State *L );
38static const luaL_Reg guiL_methods[] = {
39 { "viewport", guiL_viewport },
40 { "fpsPos", guiL_fpsPos },
41 { "osdInit", guiL_osdInit },
42 { "mesgInit", guiL_mesgInit },
43 { "omsgInit", guiL_omsgInit },
44 { "radarInit", guiL_radarInit },
45 { "radarRender", guiL_radarRender },
46 { "targetSpobGFX", guiL_targetSpobGFX },
47 { "targetPilotGFX", guiL_targetPilotGFX },
48 { "mouseClickEnable", guiL_mouseClickEnable },
49 { "mouseMoveEnable", guiL_mouseMoveEnable },
50 { "setMapOverlayBounds", guiL_setMapOverlayBounds },
51 {0,0}
52};
60int nlua_loadGUI( nlua_env env )
61{
62 /* Register the values */
63 nlua_register(env, "gui", guiL_methods, 0);
64
65 return 0;
66}
67
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
198static int guiL_radarInit( lua_State *L )
199{
200 int id, circle, width, height;
201
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
271static int guiL_mouseClickEnable( lua_State *L )
272{
273 int b;
274 if (lua_gettop(L) > 0)
275 b = lua_toboolean(L,1);
276 else
277 b = 1;
279 return 0;
280}
281
292static int guiL_mouseMoveEnable( lua_State *L )
293{
294 int b;
295 if (lua_gettop(L) > 0)
296 b = lua_toboolean(L,1);
297 else
298 b = 1;
300 return 0;
301}
302
312static int guiL_setMapOverlayBounds( lua_State *L )
313{
314 int top = luaL_checkinteger(L,1);
315 int right = luaL_checkinteger(L,2);
316 int bottom = luaL_checkinteger(L,3);
317 int left = luaL_checkinteger(L,4);
318
319 ovr_boundsSet( top, right, bottom, left );
320 return 0;
321}
int gui_radarInit(int circle, int w, int h)
Initializes the radar.
Definition gui.c:868
void gui_radarRender(double x, double y)
Renders the GUI radar.
Definition gui.c:883
void gui_mouseMoveEnable(int enable)
Enables the mouse movement callback.
Definition gui.c:2254
void gui_mouseClickEnable(int enable)
Enables the mouse click callback.
Definition gui.c:2246
void gui_targetPilotGFX(glTexture *gfx)
Sets the pilot target GFX.
Definition gui.c:2088
void gui_messageInit(int width, int x, int y)
Initializes the message system.
Definition gui.c:217
void gui_targetSpobGFX(glTexture *gfx)
Sets the spob target GFX.
Definition gui.c:2079
void gui_setViewport(double x, double y, double w, double h)
Sets the viewport.
Definition gui.c:1566
void fps_setPos(double x, double y)
Sets the position to display the FPS.
Definition naev.c:934
Header file with generic functions and naev-specifics.
static int guiL_radarInit(lua_State *L)
Initializes the radar.
Definition nlua_gui.c:198
static int guiL_mouseMoveEnable(lua_State *L)
Enables mouse movement callback.
Definition nlua_gui.c:292
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:60
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:271
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:312
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:38
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:100