naev 0.12.5
nlua_tk.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
11#include <lua.h>
12#include <stdlib.h>
13
14#include "naev.h"
16
17#include "nlua_tk.h"
18
19#include "array.h"
20#include "dialogue.h"
21#include "input.h"
22#include "land.h"
23#include "land_outfits.h"
24#include "nlua_colour.h"
25#include "nlua_gfx.h"
26#include "nlua_outfit.h"
27#include "nluadef.h"
28#include "toolkit.h"
29
30/* Stuff for the custom toolkit. */
31#define TK_CUSTNAME "__cstdlg"
32#define TK_CUSTOMDONE "__customDone"
33typedef struct custom_functions_s {
34 lua_State *L;
35 nlua_env env;
36 int done;
37 /* Function references. */
38 int update;
39 int draw;
40 int keyboard;
41 int mouse;
42 int resize;
43 int textinput;
45static void cust_cleanup( void *data );
46static int cust_update( double dt, void *data );
47static void cust_render( double x, double y, double w, double h, void *data );
48static int cust_event( unsigned int wid, SDL_Event *event, void *data );
49static int cust_key( SDL_Keycode key, SDL_Keymod mod, int pressed, int isrepeat,
51static int cust_text( const char *str, custom_functions_t *cf );
52static int cust_mouse( int type, int button, double x, double y,
54static int cust_event_window( SDL_WindowEventID event, Sint32 w, Sint32 h,
56
57/* Toolkit methods. */
58static int tkL_isOpen( lua_State *L );
59static int tkL_query( lua_State *L );
60static int tkL_msg( lua_State *L );
61static int tkL_yesno( lua_State *L );
62static int tkL_input( lua_State *L );
63static int tkL_choice( lua_State *L );
64static int tkL_list( lua_State *L );
65static int tkL_merchantOutfit( lua_State *L );
66static int tkL_custom( lua_State *L );
67static int tkL_customRename( lua_State *L );
68static int tkL_customFullscreen( lua_State *L );
69static int tkL_customResize( lua_State *L );
70static int tkL_customSize( lua_State *L );
71static int tkL_customDone( lua_State *L );
72static int tkL_refresh( lua_State *L );
73
74static const luaL_Reg tkL_methods[] = {
75 { "isOpen", tkL_isOpen },
76 { "query", tkL_query },
77 { "msg", tkL_msg },
78 { "yesno", tkL_yesno },
79 { "input", tkL_input },
80 { "choice", tkL_choice },
81 { "list", tkL_list },
82 { "merchantOutfit", tkL_merchantOutfit },
83 { "custom", tkL_custom },
84 { "customRename", tkL_customRename },
85 { "customFullscreen", tkL_customFullscreen },
86 { "customResize", tkL_customResize },
87 { "customSize", tkL_customSize },
88 { "customDone", tkL_customDone },
89 { "refresh", tkL_refresh },
90 { 0, 0 } };
91
98int nlua_loadTk( nlua_env env )
99{
100 nlua_register( env, "tk", tkL_methods, 0 );
101 nlua_loadCol( env );
102 nlua_loadGFX( env );
103 return 0;
104}
105
124
131static int tkL_isOpen( lua_State *L )
132{
133 lua_pushboolean( L, toolkit_isOpen() );
134 return 1;
135}
136
149static int tkL_query( lua_State *L )
150{
151 const char *wdwname, *wgtname;
152 unsigned int wid;
153 int bx, by, x, y, w, h;
154 wdwname = luaL_checkstring( L, 1 );
155 wgtname = luaL_optstring( L, 2, NULL );
156 wid = window_get( wdwname );
157 if ( wid == 0 )
158 return 0;
159 window_posWindow( wid, &bx, &by );
160 if ( wgtname == NULL ) {
161 x = bx;
162 y = by;
163 window_dimWindow( wid, &w, &h );
164 } else {
165 window_posWidget( wid, wgtname, &x, &y );
166 window_dimWidget( wid, wgtname, &w, &h );
167 x += bx;
168 y += by;
169 }
170 lua_pushinteger( L, x );
171 lua_pushinteger( L, y );
172 lua_pushinteger( L, w );
173 lua_pushinteger( L, h );
174 return 4;
175}
176
192static int tkL_msg( lua_State *L )
193{
194 /* Get fixed arguments : title, string to display and image filename. */
195 const char *title = luaL_checkstring( L, 1 );
196 const char *str = luaL_checkstring( L, 2 );
197
198 if ( lua_gettop( L ) > 2 ) {
199 int width, height;
200 const char *img = luaL_checkstring( L, 3 );
201
202 // Get optional arguments : width and height
203 width = ( lua_gettop( L ) < 4 ) ? -1 : luaL_checkinteger( L, 4 );
204 height = ( lua_gettop( L ) < 5 ) ? -1 : luaL_checkinteger( L, 5 );
205
206 dialogue_msgImgRaw( title, str, img, width, height );
207 return 0;
208 }
209 dialogue_msgRaw( title, str );
210 return 0;
211}
212
223static int tkL_yesno( lua_State *L )
224{
225 const char *title = luaL_checkstring( L, 1 );
226 const char *str = luaL_checkstring( L, 2 );
227
228 int ret = dialogue_YesNoRaw( title, str );
229 lua_pushboolean( L, ret );
230 return 1;
231}
232
246static int tkL_input( lua_State *L )
247{
248 const char *title, *str;
249 char *ret;
250 int min, max;
251
252 title = luaL_checkstring( L, 1 );
253 min = luaL_checkint( L, 2 );
254 max = luaL_checkint( L, 3 );
255 str = luaL_checkstring( L, 4 );
256
257 ret = dialogue_inputRaw( title, min, max, str );
258 if ( ret != NULL ) {
259 lua_pushstring( L, ret );
260 free( ret );
261 } else
262 lua_pushnil( L );
263 return 1;
264}
265
279static int tkL_choice( lua_State *L )
280{
281 int ret, opts;
282 const char *title, *str;
283 char *result;
284
285 /* Handle parameters. */
286 opts = lua_gettop( L ) - 2;
287 title = luaL_checkstring( L, 1 );
288 str = luaL_checkstring( L, 2 );
289
290 /* Do an initial scan for invalid arguments. */
291 for ( int i = 0; i < opts; i++ )
292 luaL_checkstring( L, i + 3 );
293
294 /* Create dialogue. */
295 dialogue_makeChoice( title, str, opts );
296 for ( int i = 0; i < opts; i++ )
297 dialogue_addChoice( title, str, luaL_checkstring( L, i + 3 ) );
298 result = dialogue_runChoice();
299 if ( result == NULL ) /* Something went wrong, return nil. */
300 return 0;
301
302 /* Handle results. */
303 ret = -1;
304 for ( int i = 0; i < opts && ret == -1; i++ ) {
305 if ( strcmp( result, luaL_checkstring( L, i + 3 ) ) == 0 )
306 ret = i + 1; /* Lua uses 1 as first index. */
307 }
308
309 /* Push parameters. */
310 lua_pushnumber( L, ret );
311 lua_pushstring( L, result );
312
313 /* Clean up. */
314 free( result );
315
316 return 2;
317}
318
332static int tkL_list( lua_State *L )
333{
334 int ret, opts;
335 const char *title, *str;
336 char **choices;
337 NLUA_MIN_ARGS( 3 );
338
339 /* Handle parameters. */
340 opts = lua_gettop( L ) - 2;
341 title = luaL_checkstring( L, 1 );
342 str = luaL_checkstring( L, 2 );
343
344 /* Do an initial scan for invalid arguments. */
345 for ( int i = 0; i < opts; i++ )
346 luaL_checkstring( L, i + 3 );
347
348 /* Will be freed by the toolkit. */
349 choices = malloc( sizeof( char * ) * opts );
350 for ( int i = 0; i < opts; i++ )
351 choices[i] = strdup( luaL_checkstring( L, i + 3 ) );
352
353 ret = dialogue_listRaw( title, choices, opts, str );
354
355 /* Cancel returns -1, do nothing. */
356 if ( ret == -1 )
357 return 0;
358
359 /* Push index and choice string. */
360 lua_pushnumber( L, ret + 1 );
361 lua_pushstring( L, choices[ret] );
362
363 return 2;
364}
365
381static int tkL_merchantOutfit( lua_State *L )
382{
383 const Outfit **outfits;
384 unsigned int wid;
385 const char *name;
386 int w, h;
387
388 name = luaL_checkstring( L, 1 );
389
390 if ( !lua_istable( L, 2 ) )
391 NLUA_INVALID_PARAMETER( L, 2 );
392
393 outfits = array_create_size( const Outfit *, lua_objlen( L, 2 ) );
394 /* Iterate over table. */
395 lua_pushnil( L );
396 while ( lua_next( L, -2 ) != 0 ) {
397 array_push_back( &outfits, luaL_validoutfit( L, -1 ) );
398 lua_pop( L, 1 );
399 }
400
401 /* Create window. */
402 if ( SCREEN_W < LAND_WIDTH || SCREEN_H < LAND_HEIGHT ) {
403 w = -1; /* Fullscreen. */
404 h = -1;
405 } else {
406 w = LAND_WIDTH + 0.5 * ( SCREEN_W - LAND_WIDTH );
407 h = LAND_HEIGHT + 0.5 * ( SCREEN_H - LAND_HEIGHT );
408 }
409 wid = window_create( "wdwMerchantOutfit", name, -1, -1, w, h );
410 outfits_open( wid, outfits, lua_toboolean( L, 3 ) );
411
412 return 0;
413}
414
418static void cust_cleanup( void *data )
419{
420 custom_functions_t *cf = data;
421 lua_State *L = cf->L;
422 luaL_unref( L, LUA_REGISTRYINDEX, cf->update );
423 luaL_unref( L, LUA_REGISTRYINDEX, cf->draw );
424 luaL_unref( L, LUA_REGISTRYINDEX, cf->keyboard );
425 luaL_unref( L, LUA_REGISTRYINDEX, cf->mouse );
426 luaL_unref( L, LUA_REGISTRYINDEX, cf->resize );
427 luaL_unref( L, LUA_REGISTRYINDEX, cf->textinput );
428 luaL_unref( L, LUA_REGISTRYINDEX, cf->env );
429 free( cf );
430}
431
453static int tkL_custom( lua_State *L )
454{
455 int w = luaL_checkinteger( L, 2 );
456 int h = luaL_checkinteger( L, 3 );
457 const char *caption = luaL_checkstring( L, 1 );
458 custom_functions_t *cf = calloc( 1, sizeof( custom_functions_t ) );
459 int nodynamic;
460 char *buf, dlgname[STRMAX_SHORT];
461 ;
462
463 /* Set up custom function pointers. */
464 cf->L = L;
465 nlua_pushenv( L, __NLUA_CURENV ); /* e */
466 cf->env = luaL_ref( L, LUA_REGISTRYINDEX ); /* */
467#define GETFUNC( address, pos ) \
468 do { \
469 lua_pushvalue( L, ( pos ) ); \
470 luaL_checktype( L, -1, LUA_TFUNCTION ); \
471 ( address ) = luaL_ref( L, LUA_REGISTRYINDEX ); \
472 } while ( 0 )
473 GETFUNC( cf->update, 4 );
474 GETFUNC( cf->draw, 5 );
475 GETFUNC( cf->keyboard, 6 );
476 GETFUNC( cf->mouse, 7 );
477 GETFUNC( cf->resize, 8 );
478 GETFUNC( cf->textinput, 9 );
479#undef GETFUNC
480 nodynamic = lua_toboolean( L, 10 );
481
482 /* Set done condition. */
483 lua_pushboolean( L, 0 );
484 nlua_setenv( L, cf->env, TK_CUSTOMDONE );
485
486 /* Get current dialogue. */
487 buf = NULL;
488 nlua_getenv( L, cf->env, TK_CUSTNAME );
489 if ( lua_isstring( L, -1 ) )
490 buf = strdup( lua_tostring( L, -1 ) );
491 lua_pop( L, 1 );
492 /* Set new dialogue. */
493 static unsigned int dlgcust_counter = 0;
494 snprintf( dlgname, sizeof( dlgname ), "dlgCust%u", ++dlgcust_counter );
495 lua_pushstring( L, dlgname );
496 nlua_setenv( L, cf->env, TK_CUSTNAME );
497
498 /* Create the dialogue. */
499 dialogue_custom( dlgname, caption, w, h, cust_update, cust_render,
500 cust_event, cf, !nodynamic, cust_cleanup );
501 cf->done = 1;
502
503 /* Restore previous value. */
504 if ( buf == NULL )
505 lua_pushnil( L );
506 else
507 lua_pushstring( L, buf );
508 nlua_setenv( L, cf->env, TK_CUSTNAME );
509 free( buf );
510
511 return 0;
512}
513
514/* Get the dialogue WID. */
515static unsigned int dlgWid( lua_State *L )
516{
517 nlua_getenv( L, __NLUA_CURENV, TK_CUSTNAME );
518 unsigned int wid = window_get( luaL_checkstring( L, -1 ) );
519 lua_pop( L, 1 );
520 return wid;
521}
522
529static int tkL_customRename( lua_State *L )
530{
531 const char *s = luaL_checkstring( L, 1 );
532 unsigned int wid = dlgWid( L );
533 if ( wid == 0 )
534 return NLUA_ERROR( L, _( "custom dialogue not open" ) );
535 window_setDisplayname( wid, s );
536 return 0;
537}
538
545static int tkL_customFullscreen( lua_State *L )
546{
547 int enable = lua_toboolean( L, 1 );
548 unsigned int wid = dlgWid( L );
549 if ( wid == 0 )
550 return NLUA_ERROR( L, _( "custom dialogue not open" ) );
551 dialogue_customFullscreen( wid, enable );
552 return 0;
553}
554
562static int tkL_customResize( lua_State *L )
563{
564 int w, h;
565 unsigned int wid = dlgWid( L );
566 if ( wid == 0 )
567 return NLUA_ERROR( L, _( "custom dialogue not open" ) );
568 w = luaL_checkinteger( L, 1 );
569 h = luaL_checkinteger( L, 2 );
570 dialogue_customResize( wid, w, h );
571 return 0;
572}
573
581static int tkL_customSize( lua_State *L )
582{
583 int w, h;
584 unsigned int wid = dlgWid( L );
585 if ( wid == 0 )
586 return NLUA_ERROR( L, _( "custom dialogue not open" ) );
587 window_dimWindow( wid, &w, &h );
588 lua_pushinteger( L, w );
589 lua_pushinteger( L, h );
590 return 2;
591}
592
600static int tkL_customDone( lua_State *L )
601{
602 unsigned int wid = dlgWid( L );
603 if ( wid == 0 )
604 return NLUA_ERROR( L, _( "custom dialogue not open" ) );
605 lua_pushboolean( L, 1 );
606 nlua_setenv( L, __NLUA_CURENV,
607 TK_CUSTOMDONE ); /* Can only stop from same env... */
608 return 0;
609}
610
611static int cust_update( double dt, void *data )
612{
613 int ret;
615 if ( cf->done )
616 return 1; /* Mark done. */
617 lua_State *L = cf->L;
618 lua_rawgeti( L, LUA_REGISTRYINDEX, cf->update );
619 lua_pushnumber( L, dt );
620 if ( nlua_pcall( cf->env, 1, 0 ) ) {
621 cf->done = 1;
622 NLUA_WARN( L, _( "Custom dialogue internal error: %s" ),
623 lua_tostring( L, -1 ) );
624 lua_pop( L, 1 );
625 return 1;
626 }
627 /* Check if done. */
628 nlua_getenv( L, cf->env, TK_CUSTOMDONE );
629 ret = lua_toboolean( L, -1 );
630 lua_pop( L, 1 );
631 return ret;
632}
633static void cust_render( double x, double y, double w, double h, void *data )
634{
636 if ( cf->done )
637 return;
638 lua_State *L = cf->L;
639 lua_rawgeti( L, LUA_REGISTRYINDEX, cf->draw );
640 lua_pushnumber( L, x );
641 lua_pushnumber( L, y );
642 lua_pushnumber( L, w );
643 lua_pushnumber( L, h );
644 if ( nlua_pcall( cf->env, 4, 0 ) ) {
645 cf->done = 1;
646 NLUA_WARN( L, _( "Custom dialogue internal error: %s" ),
647 lua_tostring( L, -1 ) );
648 lua_pop( L, 1 );
649 }
650}
651static int cust_event( unsigned int wid, SDL_Event *event, void *data )
652{
653 (void)wid;
654 double x, y;
656 if ( cf->done )
657 return 0;
658
659 /* Handle all the events. */
660 switch ( event->type ) {
661 case SDL_MOUSEBUTTONDOWN:
662 x = gl_screen.x;
663 y = gl_screen.y;
664 return cust_mouse( 1, event->button.button, event->button.x + x,
665 event->button.y + y, cf );
666 case SDL_MOUSEBUTTONUP:
667 x = gl_screen.x;
668 y = gl_screen.y;
669 return cust_mouse( 2, event->button.button, event->button.x + x,
670 event->button.y + y, cf );
671 case SDL_MOUSEMOTION:
672 x = gl_screen.x;
673 y = gl_screen.y;
674 return cust_mouse( 3, -1, event->button.x + x, event->button.y + y, cf );
675 case SDL_MOUSEWHEEL:
676 return cust_mouse( 4, -1, event->wheel.x, event->wheel.y, cf );
677
678 case SDL_KEYDOWN:
679 return cust_key( event->key.keysym.sym, event->key.keysym.mod, 1,
680 event->key.repeat, cf );
681 case SDL_KEYUP:
682 return cust_key( event->key.keysym.sym, event->key.keysym.mod, 0,
683 event->key.repeat, cf );
684
685 case SDL_TEXTINPUT:
686 return cust_text( event->text.text, cf );
687
688 case SDL_WINDOWEVENT:
689 return cust_event_window( event->window.event, event->window.data1,
690 event->window.data2, cf );
691
692 default:
693 return 0;
694 }
695
696 return 0;
697}
698static int cust_key( SDL_Keycode key, SDL_Keymod mod, int pressed, int isrepeat,
700{
701 int b;
702 lua_State *L = cf->L;
703 lua_rawgeti( L, LUA_REGISTRYINDEX, cf->keyboard );
704 lua_pushboolean( L, pressed );
705 lua_pushstring( L, SDL_GetKeyName( key ) );
706 lua_pushstring( L, input_modToText( mod ) );
707 lua_pushboolean( L, isrepeat );
708 if ( nlua_pcall( cf->env, 4, 1 ) ) {
709 cf->done = 1;
710 NLUA_WARN( L, _( "Custom dialogue internal error: %s" ),
711 lua_tostring( L, -1 ) );
712 lua_pop( L, 1 );
713 return 0;
714 }
715 b = lua_toboolean( L, -1 );
716 lua_pop( L, 1 );
717 return b;
718}
719static int cust_text( const char *str, custom_functions_t *cf )
720{
721 int b;
722 lua_State *L = cf->L;
723 lua_rawgeti( L, LUA_REGISTRYINDEX, cf->textinput );
724 lua_pushstring( L, str );
725 if ( nlua_pcall( cf->env, 1, 1 ) ) {
726 cf->done = 1;
727 NLUA_WARN( L, _( "Custom dialogue internal error: %s" ),
728 lua_tostring( L, -1 ) );
729 lua_pop( L, 1 );
730 return 0;
731 }
732 b = lua_toboolean( L, -1 );
733 lua_pop( L, 1 );
734 return b;
735}
736static int cust_mouse( int type, int button, double x, double y,
738{
739 int b, nargs = 3;
740 lua_State *L = cf->L;
741 lua_rawgeti( L, LUA_REGISTRYINDEX, cf->mouse );
742 lua_pushnumber( L, x );
743 lua_pushnumber( L, y );
744 lua_pushnumber( L, type );
745 if ( type < 3 ) {
746 switch ( button ) {
747 case SDL_BUTTON_LEFT:
748 button = 1;
749 break;
750 case SDL_BUTTON_RIGHT:
751 button = 2;
752 break;
753 default:
754 button = 3;
755 break;
756 }
757 lua_pushnumber( L, button );
758 nargs++;
759 }
760 if ( nlua_pcall( cf->env, nargs, 1 ) ) {
761 cf->done = 1;
762 NLUA_WARN( L, _( "Custom dialogue internal error: %s" ),
763 lua_tostring( L, -1 ) );
764 lua_pop( L, 1 );
765 return 0;
766 }
767 b = lua_toboolean( L, -1 );
768 lua_pop( L, 1 );
769 return b;
770}
771static int cust_event_window( SDL_WindowEventID event, Sint32 w, Sint32 h,
773{
774 int b;
775 lua_State *L = cf->L;
776
777 if ( event == SDL_WINDOWEVENT_RESIZED )
778 return 1;
779
780 lua_rawgeti( L, LUA_REGISTRYINDEX, cf->resize );
781 lua_pushinteger( L, w );
782 lua_pushinteger( L, h );
783 if ( nlua_pcall( cf->env, 2, 1 ) ) {
784 cf->done = 1;
785 NLUA_WARN( L, _( "Custom dialogue internal error: %s" ),
786 lua_tostring( L, -1 ) );
787 lua_pop( L, 1 );
788 return 0;
789 }
790 b = lua_toboolean( L, -1 );
791 lua_pop( L, 1 );
792 return b;
793}
794
798static int tkL_refresh( lua_State *L )
799{
800 (void)L;
802 return 0;
803}
Provides macros to work with dynamic arrays.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
Definition array.h:102
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
Definition array.h:134
char * dialogue_runChoice(void)
Run the dialog and return the clicked string.
Definition dialogue.c:817
char * dialogue_inputRaw(const char *title, int min, int max, const char *msg)
Creates a dialogue that allows the player to write a message.
Definition dialogue.c:470
void dialogue_custom(const char *wdwname, const char *caption, int width, int height, int(*update)(double dt, void *data), void(*render)(double x, double y, double w, double h, void *data), int(*event)(unsigned int wid, SDL_Event *event, void *data), void *data, int dynamic, void(*freefunc)(void *data))
Opens a custom dialogue window.
Definition dialogue.c:890
int dialogue_customFullscreen(unsigned int wid, int enable)
Converts a custom dialogue to fullscreen.
Definition dialogue.c:956
int dialogue_listRaw(const char *title, char **items, int nitems, const char *msg)
Creates a list dialogue with OK and Cancel button.
Definition dialogue.c:614
int dialogue_YesNoRaw(const char *caption, const char *msg)
Runs a dialogue with both yes and no options.
Definition dialogue.c:373
int dialogue_customResize(unsigned int wid, int width, int height)
Resizes a custom dialogue.
Definition dialogue.c:992
void dialogue_addChoice(const char *caption, const char *msg, const char *opt)
Add a choice to the dialog.
Definition dialogue.c:796
void dialogue_msgImgRaw(const char *caption, const char *msg, const char *img, int width, int height)
Opens a dialogue window with an ok button, a fixed message and an image.
Definition dialogue.c:296
void dialogue_makeChoice(const char *caption, const char *msg, int opts)
Create the choice dialog. Need to add choices with below method.
Definition dialogue.c:773
void dialogue_msgRaw(const char *caption, const char *msg)
Opens a dialogue window with an ok button and a fixed message.
Definition dialogue.c:269
const char * input_modToText(SDL_Keymod mod)
Gets the human readable version of mod.
Definition input.c:611
void outfits_open(unsigned int wid, const Outfit **outfits, int blackmarket)
Opens the outfit exchange center window.
Header file with generic functions and naev-specifics.
nlua_env __NLUA_CURENV
Definition nlua.c:55
int nlua_loadCol(nlua_env env)
Loads the colour library.
Definition nlua_colour.c:57
int nlua_loadGFX(nlua_env env)
Loads the graphics library.
Definition nlua_gfx.c:112
const Outfit * luaL_validoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
static int tkL_customSize(lua_State *L)
Gets the size of a custom widget.
Definition nlua_tk.c:581
static int tkL_customRename(lua_State *L)
Renames the custom widget window.
Definition nlua_tk.c:529
static int tkL_isOpen(lua_State *L)
Bindings for interacting with the Toolkit.
Definition nlua_tk.c:131
static const luaL_Reg tkL_methods[]
Definition nlua_tk.c:74
static int tkL_msg(lua_State *L)
Creates a window with an ok button, and optionally an image.
Definition nlua_tk.c:192
int nlua_loadTk(nlua_env env)
Loads the Toolkit Lua library.
Definition nlua_tk.c:98
static int tkL_input(lua_State *L)
Creates a window that allows player to write text input.
Definition nlua_tk.c:246
static void cust_cleanup(void *data)
Cleans up after the window.
Definition nlua_tk.c:418
static int tkL_choice(lua_State *L)
Creates a window with a number of selectable options.
Definition nlua_tk.c:279
static int tkL_refresh(lua_State *L)
Forces the toolkit to rerender the screen.
Definition nlua_tk.c:798
static int tkL_query(lua_State *L)
Gets the position and dimensions of either a window or a widget.
Definition nlua_tk.c:149
static int tkL_yesno(lua_State *L)
Displays a window with Yes and No buttons.
Definition nlua_tk.c:223
static int tkL_customFullscreen(lua_State *L)
Sets the custom widget fullscreen.
Definition nlua_tk.c:545
static int tkL_list(lua_State *L)
Creates a window with an embedded list of choices.
Definition nlua_tk.c:332
static int tkL_customDone(lua_State *L)
Ends the execution of a custom widget.
Definition nlua_tk.c:600
static int tkL_customResize(lua_State *L)
Sets the custom widget fullscreen.
Definition nlua_tk.c:562
static int tkL_merchantOutfit(lua_State *L)
Opens an outfit merchant window.
Definition nlua_tk.c:381
static int tkL_custom(lua_State *L)
Creates a custom widget window.
Definition nlua_tk.c:453
glInfo gl_screen
Definition opengl.c:47
A ship outfit, depends radically on the type.
Definition outfit.h:372
lua_State * L
Definition nlua_tk.c:34
unsigned int window_create(const char *name, const char *displayname, const int x, const int y, const int w, const int h)
Creates a window.
Definition toolkit.c:688
void window_dimWidget(unsigned int wid, const char *name, int *w, int *h)
Gets the dimensions of a widget.
Definition toolkit.c:415
void window_dimWindow(unsigned int wid, int *w, int *h)
Gets the dimensions of a window.
Definition toolkit.c:370
int toolkit_isOpen(void)
Checks to see if the toolkit is open.
Definition toolkit.c:93
void window_posWidget(unsigned int wid, const char *name, int *x, int *y)
Gets a widget's position.
Definition toolkit.c:441
unsigned int window_get(const char *wdwname)
Gets the ID of a window.
Definition toolkit.c:662
void toolkit_rerender(void)
Marks the toolkit for needing a full rerender.
Definition toolkit.c:1675
void window_posWindow(unsigned int wid, int *x, int *y)
Gets the dimensions of a window.
Definition toolkit.c:392
int window_setDisplayname(unsigned int wid, const char *displayname)
Sets the displayname of a window.
Definition toolkit.c:625