naev 0.12.5
menu.c
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "SDL_events.h"
11
12#include "naev.h"
14
15#include "menu.h"
16
17#include "array.h"
18#include "camera.h"
19#include "conf.h"
20#include "dev_mapedit.h"
21#include "dev_uniedit.h"
22#include "dialogue.h"
23#include "gui.h"
24#include "hook.h"
25#include "info.h"
26#include "intro.h"
27#include "land.h"
28#include "load.h"
29#include "log.h"
30#include "music.h"
31#include "ndata.h"
32#include "ntracing.h"
33#include "options.h"
34#include "pause.h"
35#include "pilot.h"
36#include "player.h"
37#include "render.h"
38#include "safelanes.h"
39#include "save.h"
40#include "sound.h"
41#include "space.h"
42#include "start.h"
43#include "tk/toolkit_priv.h" /* Needed for menu_main_resize */
44#include "toolkit.h"
45
46#define MAIN_WIDTH 200
47
48#define MENU_WIDTH 200
49#define MENU_HEIGHT 250
50
51#define DEATH_WIDTH 200
52#define DEATH_HEIGHT 200
53
54#define BUTTON_WIDTH 160
55#define BUTTON_HEIGHT 30
56
57#define EDITORS_EXTRA_WIDTH 60
58
59#define menu_Open( f ) ( menu_open |= ( f ) )
60#define menu_Close( f ) \
61 ( menu_open &= ~( f ) )
63int menu_open = 0;
64int bg_needs_reset = 1;
65
66static glTexture *main_naevLogo = NULL;
67static int menu_small_allowsave = 1;
68
69/*
70 * prototypes
71 */
72/* Generic. */
73static void menu_exit( unsigned int wid, const char *str );
74/* main menu */
75static int menu_main_bkg_system( void );
76static void main_menu_promptClose( unsigned int wid, const char *unused );
77static void menu_main_load( unsigned int wid, const char *str );
78static void menu_main_new( unsigned int wid, const char *str );
79static void menu_main_credits( unsigned int wid, const char *str );
80static void menu_main_cleanBG( unsigned int wid, const char *str );
81/* small menu */
82static void menu_small_load( unsigned int wid, const char *str );
83static void menu_small_resume( unsigned int wid, const char *str );
84static void menu_small_info( unsigned int wid, const char *str );
85static void menu_small_exit( unsigned int wid, const char *str );
86static void exit_game( void );
87/* death menu */
88static void menu_death_continue( unsigned int wid, const char *str );
89static void menu_death_restart( unsigned int wid, const char *str );
90static void menu_death_main( unsigned int wid, const char *str );
91static void menu_death_close( unsigned int wid, const char *str );
92/* editors menu */
93/* - Universe Editor */
94/* - Back to Main Menu */
95static void menu_editors_open( unsigned int wid_unused, const char *unused );
96static void menu_editors_close( unsigned int wid, const char *str );
97/* options button. */
98static void menu_options_button( unsigned int wid, const char *str );
99
105static int menu_main_bkg_system( void )
106{
107 if ( !bg_needs_reset ) {
108 pause_setSpeed( 1. );
109 sound_setSpeed( 1. );
110 return 0;
111 }
112
113 const nsave_t *saves;
114 const char *sys;
115 double cx, cy;
116
117 /* Clean pilots. */
119 sys = NULL;
120
121 load_refresh();
122 saves = load_getList( NULL );
123
124 if ( array_size( saves ) > 0 ) {
125 const nsave_t *ns = &saves[0];
126
127 /* Try to apply unidiff. */
128 load_gameDiff( ns[0].path );
129
130 /* Get start position. */
131 if ( spob_exists( ns[0].spob ) ) {
132 const Spob *pnt = spob_get( ns[0].spob );
133 if ( pnt != NULL ) {
134 sys = spob_getSystemName( ns[0].spob );
135 if ( sys != NULL ) {
136 cx = pnt->pos.x;
137 cy = pnt->pos.y;
138 }
139 }
140 }
141 }
142
143 /* In case save game has no diff. */
144 if ( !safelanes_calculated() )
146
147 /* Fallback if necessary. */
148 if ( sys == NULL ) {
149 sys = start_system();
150 start_position( &cx, &cy );
151 }
152
153 /* Have to normalize values by zoom. */
154 cx += SCREEN_W / 4. / conf.zoom_far;
155 cy += SCREEN_H / 8. / conf.zoom_far;
156
157 /* Initialize. */
158 space_init( sys, 0 ); /* More lively with simulation. */
159 cam_setTargetPos( cx, cy, 0 );
160 cam_setZoom( conf.zoom_far );
161 pause_setSpeed( 1. );
162 sound_setSpeed( 1. );
163
164 return 0;
165}
166
170void menu_main( void )
171{
172 int offset_logo, offset_wdw, freespace;
173 unsigned int bwid, wid;
174 glTexture *tex;
175 int h, y;
176
177 if ( menu_isOpen( MENU_MAIN ) ) {
178 WARN( _( "Menu main is already open." ) );
179 return;
180 }
181
182 /* Clean up land if triggered with player.gameover() while landed. */
183 if ( landed )
184 land_cleanup();
185
186 /* Close all open windows. */
188
189 /* Clean up GUI - must be done before using SCREEN_W or SCREEN_H. */
190 gui_cleanup();
191 player_soundStop(); /* Stop sound. */
193 render_postprocessCleanup();
194
195 /* Play load music. */
196 music_choose( "load" );
197
198 /* Load background and friends. */
199 gl_freeTexture( main_naevLogo );
200 tex = gl_newImage( GFX_PATH "Naev.webp", 0 );
201 main_naevLogo = tex;
202 menu_main_bkg_system();
203
204 /* Set dimensions */
205 y = 20 + ( BUTTON_HEIGHT + 20 ) * 4;
206 h = y + 80;
207 if ( conf.devmode ) {
208 h += BUTTON_HEIGHT + 20;
209 y += BUTTON_HEIGHT + 20;
210 }
211
212 /* Calculate Logo and window offset. */
213 freespace = SCREEN_H - tex->sh - h;
214 if ( freespace < 0 ) { /* Not enough freespace, this can get ugly. */
215 offset_logo = SCREEN_W - tex->sh;
216 offset_wdw = 0;
217 }
218 /* Otherwise space evenly. */
219 else {
220 offset_logo = -freespace / 4;
221 offset_wdw = freespace / 2;
222 }
223
224 /* create background image window */
225 bwid = window_create( "wdwBG", "", -1, -1, -1, -1 );
226 window_onClose( bwid, menu_main_cleanBG );
227 window_setBorder( bwid, 0 );
228 window_addImage( bwid, ( SCREEN_W - tex->sw ) / 2., offset_logo, 0, 0,
229 "imgLogo", tex, 0 );
230 window_addText( bwid, 0, 10, SCREEN_W, 30., 1, "txtBG", NULL, &cWhite,
231 naev_version( 1 ) );
232
233 /* create menu window */
234 wid = window_create( "wdwMainMenu", _( "Main Menu" ), -1, offset_wdw,
235 MAIN_WIDTH, h );
236 window_setCancel( wid, main_menu_promptClose );
237
238 /* Buttons. */
239 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnLoad",
240 _( "Load Game" ), menu_main_load, SDLK_l );
241 y -= BUTTON_HEIGHT + 20;
242 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnNew",
243 _( "New Game" ), menu_main_new, SDLK_n );
244 y -= BUTTON_HEIGHT + 20;
245 if ( conf.devmode ) {
246 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnEditor",
247 _( "Editors" ), menu_editors_open, SDLK_e );
248 y -= BUTTON_HEIGHT + 20;
249 }
250 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnOptions",
251 _( "Options" ), menu_options_button, SDLK_o );
252 y -= BUTTON_HEIGHT + 20;
253 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnCredits",
254 p_( "Menu|", "Credits" ), menu_main_credits, SDLK_c );
255 y -= BUTTON_HEIGHT + 20;
256 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit",
257 _( "Exit Game" ), menu_exit, SDLK_x );
258
259 /* Disable load button if there are no saves. */
260 if ( array_size( load_getList( NULL ) ) == 0 ) {
261 window_disableButton( wid, "btnLoad" );
262 window_setFocus( wid, "btnNew" );
263 } else
264 window_setFocus( wid, "btnLoad" );
265
266 /* Make the background window a child of the menu. */
267 window_setParent( bwid, wid );
268
269 unpause_game();
270 menu_Open( MENU_MAIN );
271}
272
280{
281 int w, h, bgw, bgh, tw, th;
282 int offset_logo, offset_wdw, freespace;
283 int menu_id, bg_id;
284
285 if ( !menu_isOpen( MENU_MAIN ) )
286 return;
287
288 menu_id = window_get( "wdwMainMenu" );
289 bg_id = window_get( "wdwBG" );
290
291 window_dimWindow( menu_id, &w, &h );
292 window_dimWindow( bg_id, &bgw, &bgh );
293
294 freespace = SCREEN_H - main_naevLogo->sh - h;
295 if ( freespace < 0 ) {
296 offset_logo = SCREEN_H - main_naevLogo->sh;
297 offset_wdw = 0;
298 } else {
299 offset_logo = -freespace / 4;
300 offset_wdw = freespace / 2;
301 }
302
303 window_moveWidget( bg_id, "imgLogo", ( bgw - main_naevLogo->sw ) / 2.,
304 offset_logo );
305
306 window_dimWidget( bg_id, "txtBG", &tw, &th );
307
308 if ( tw > SCREEN_W ) {
309 /* RIP abstractions. X must be set manually because window_moveWidget
310 * transforms negative coordinates. */
311 Widget *wgt = window_getwgt( bg_id, "txtBG" );
312 if ( wgt )
313 wgt->x = ( SCREEN_W - tw ) / 2;
314 } else
315 window_moveWidget( bg_id, "txtBG", ( SCREEN_W - tw ) / 2, 10. );
316
317 window_move( menu_id, -1, offset_wdw );
318}
319
323static void main_menu_promptClose( unsigned int wid, const char *unused )
324{
325 (void)wid;
326 (void)unused;
327 exit_game();
328}
329
333void menu_main_close( void )
334{
335 if ( window_exists( "wdwMainMenu" ) ) {
336 unsigned int wid = window_get( "wdwMainMenu" );
337 window_destroy( wid );
338 } else
339 WARN( _( "Main menu does not exist." ) );
340
341 menu_Close( MENU_MAIN );
342 pause_game();
343}
344
348static void menu_main_load( unsigned int wid, const char *str )
349{
350 (void)str;
351 (void)wid;
353}
358static void menu_main_new( unsigned int wid, const char *str )
359{
360 (void)str;
361 (void)wid;
362
363 /* Closes the main menu window. */
364 window_destroy( wid );
365 menu_Close( MENU_MAIN );
366 pause_game();
367
368 /* Start the new player. */
369 player_new();
370}
375static void menu_main_credits( unsigned int wid, const char *str )
376{
377 (void)str;
378 window_destroy( wid );
379 menu_Close( MENU_MAIN );
380 intro_display( "AUTHORS", "credits" );
381 bg_needs_reset = 0;
382 menu_main();
383 bg_needs_reset = 1;
384 /* We'll need to start music again. */
385 music_choose( "load" );
386}
391static void menu_exit( unsigned int wid, const char *str )
392{
393 (void)str;
394 (void)wid;
395
396 naev_quit();
397}
403static void menu_main_cleanBG( unsigned int wid, const char *str )
404{
405 (void)wid;
406 (void)str;
407
408 gl_freeTexture( main_naevLogo );
409 main_naevLogo = NULL;
410}
411
412/*
413 *
414 * in-game menu
415 *
416 */
420void menu_small( int docheck, int info, int options, int allowsave )
421{
422 int can_save;
423 unsigned int wid;
424 int y, h;
425
426 /* Check if menu should be openable. */
427 if ( docheck &&
428 ( player_isFlag( PLAYER_DESTROYED ) ||
429 dialogue_isOpen() || /* Shouldn't open over dialogues. */
431 return;
432
433 if ( menu_isOpen( MENU_SMALL ) )
434 return;
435
436 can_save = allowsave && landed && !player_isFlag( PLAYER_NOSAVE );
437 menu_small_allowsave = allowsave;
438
439 h = MENU_HEIGHT - ( BUTTON_HEIGHT + 20 ) * ( !info + !options );
440 y = 20 + ( BUTTON_HEIGHT + 20 ) * ( 2 + !!info + !!options );
441 wid = window_create( "wdwMenuSmall", _( "Menu" ), -1, -1, MENU_WIDTH,
442 h + BUTTON_HEIGHT + 20 );
443
444 window_setCancel( wid, menu_small_resume );
445
446 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnResume",
447 _( "Resume" ), menu_small_resume, SDLK_r );
448 y -= BUTTON_HEIGHT + 20;
449 if ( info ) {
450 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnInfo",
451 _( "Info" ), menu_small_info, SDLK_i );
452 y -= BUTTON_HEIGHT + 20;
453 }
454 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnSave",
455 can_save ? _( "Load / Save" ) : _( "Load" ),
456 menu_small_load, SDLK_l );
457 y -= BUTTON_HEIGHT + 20;
458 if ( options ) {
459 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT,
460 "btnOptions", _( "Options" ), menu_options_button,
461 SDLK_o );
462 y -= BUTTON_HEIGHT + 20;
463 }
464 window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit",
465 _( "Exit to Title" ), menu_small_exit, SDLK_x );
466
467 menu_Open( MENU_SMALL );
468}
469
475static void menu_small_load( unsigned int wid, const char *str )
476{
477 (void)wid;
478 (void)str;
479
480 load_refresh(); /* FIXME: Substitute proper cache invalidation in case of
481 save_all() etc. */
482 load_loadSnapshotMenu( player.name, !menu_small_allowsave );
483}
484
489static void menu_small_resume( unsigned int wid, const char *str )
490{
491 (void)str;
492 window_destroy( wid );
493 menu_Close( MENU_SMALL );
494}
495
500{
501 if ( window_exists( "wdwMenuSmall" ) )
502 window_destroy( window_get( "wdwMenuSmall" ) );
503 else
504 WARN( _( "Small menu does not exist." ) );
505
506 menu_Close( MENU_SMALL );
507}
508
514static void menu_small_info( unsigned int wid, const char *str )
515{
516 (void)str;
517 (void)wid;
518
519 menu_info( INFO_MAIN );
520}
521
522static int menu_small_exit_hook( void *unused )
523{
524 (void)unused;
525 unsigned int wid;
526
527 /* Still stuck in a dialogue, so we have to do another hook pass. */
528 if ( dialogue_isOpen() ) {
529 hook_addFunc( menu_small_exit_hook, NULL, "safe" );
530 return 0;
531 }
532
533 /* if landed we must save anyways */
534 if ( landed && land_canSave() ) {
535 save_all();
536 land_cleanup();
537 }
538
539 /* Close info menu if open. */
540 if ( menu_isOpen( MENU_INFO ) ) {
541 unsigned int info_wid = window_get( "wdwInfo" );
542 window_destroy( info_wid );
543 menu_Close( MENU_INFO );
544 }
545
546 /* Stop player sounds because sometimes they hang. */
547 player_restoreControl( 0, _( "Exited game." ) );
549 NTracingMessageL( "Exited to main menu" );
550
551 /* Clean up. */
552 wid = window_get( "wdwMenuSmall" );
553 window_destroy( wid );
554 menu_Close( MENU_SMALL );
555 menu_main();
556 return 0;
557}
558
563static void menu_small_exit( unsigned int wid, const char *str )
564{
565 (void)wid;
566 (void)str;
567
568 if ( !menu_small_allowsave && landed && land_canSave() ) {
569 if ( !dialogue_YesNoRaw(
570 _( "Exit to Menu?" ),
571 _( "Are you sure you wish to exit to menu right now? The game "
572 "#rwill not be saved#0 since last time you landed!" ) ) )
573 return;
574 }
575
576 /* Break out of potential inner loops. */
577 SDL_Event event;
578 SDL_memset( &event, 0, sizeof( event ) );
579 event.type = SDL_LOOPDONE;
580 SDL_PushEvent( &event );
581
582 hook_addFunc( menu_small_exit_hook, NULL, "safe" );
583}
584
588static void exit_game( void )
589{
590 /* if landed we must save anyways */
591 if ( landed && land_canSave() ) {
592 save_all();
593 land_cleanup();
594 }
595 SDL_Event quit;
596 quit.type = SDL_QUIT;
597 SDL_PushEvent( &quit );
598}
599
604static void menu_death_continue( unsigned int wid, const char *str )
605{
606 (void)str;
607
608 window_destroy( wid );
609 menu_Close( MENU_DEATH );
610
611 save_reload();
612 player.death_counter++; /* Add death here. */
613 player.ps.death_counter++;
614}
615
620static void menu_death_restart( unsigned int wid, const char *str )
621{
622 (void)str;
623
624 window_destroy( wid );
625 menu_Close( MENU_DEATH );
626
627 player_new();
628}
629
633void menu_death( void )
634{
635 unsigned int wid;
636
637 wid = window_create( "wdwRIP", _( "Death" ), -1, -1, DEATH_WIDTH,
638 DEATH_HEIGHT );
639 window_onClose( wid, menu_death_close );
640
641 /* Allow the player to continue if the saved game exists, if not, propose to
642 * restart */
643 load_refresh();
644 if ( array_size( load_getList( player.name ) ) > 0 )
645 window_addButtonKey( wid, 20, 20 + BUTTON_HEIGHT * 2 + 20 * 2,
646 BUTTON_WIDTH, BUTTON_HEIGHT, "btnContinue",
647 _( "Continue" ), menu_death_continue, SDLK_c );
648 else
649 window_addButtonKey( wid, 20, 20 + BUTTON_HEIGHT * 2 + 20 * 2,
650 BUTTON_WIDTH, BUTTON_HEIGHT, "btnRestart",
651 _( "Restart" ), menu_death_restart, SDLK_r );
652
653 window_addButtonKey( wid, 20, 20 + ( BUTTON_HEIGHT + 20 ), BUTTON_WIDTH,
654 BUTTON_HEIGHT, "btnMain", _( "Main Menu" ),
655 menu_death_main, SDLK_m );
656 window_addButtonKey( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit",
657 _( "Exit Game" ), menu_exit, SDLK_x );
658 menu_Open( MENU_DEATH );
659
660 /* Makes it all look cooler since everything still goes on. */
661 if ( !landed )
662 unpause_game();
663}
664
668static void menu_death_main( unsigned int wid, const char *str )
669{
670 (void)str;
671
672 window_destroy( wid );
673 menu_Close( MENU_DEATH );
674
675 /* Game will repause now since toolkit closes and reopens. */
676 menu_main();
677}
681static void menu_death_close( unsigned int wid, const char *str )
682{
683 (void)wid;
684 (void)str;
685 pause_game(); /* Repause the game. */
686}
687
691static void menu_options_button( unsigned int wid, const char *str )
692{
693 (void)wid;
694 (void)str;
695 opt_menu();
696}
697
701int menu_askQuit( void )
702{
703 /* Asked twice, quit. */
704 if ( menu_isOpen( MENU_ASKQUIT ) ) {
705 exit_game();
706 return 1;
707 }
708
709 /* Ask if should quit. */
710 menu_Open( MENU_ASKQUIT );
711 if ( dialogue_YesNoRaw( _( "Quit Naev" ),
712 _( "Are you sure you want to quit Naev?" ) ) ) {
713 exit_game();
714 return 1;
715 }
716 menu_Close( MENU_ASKQUIT );
717
718 return 0;
719}
720
724static void menu_editors_open( unsigned int wid, const char *unused )
725{
726 (void)unused;
727 int h, y;
728
729 /* Menu already open, quit. */
730 if ( menu_isOpen( MENU_EDITORS ) ) {
731 return;
732 }
733
734 /* Close the Main Menu */
736 unpause_game();
737
738 /* Clear known flags - specifically for the SYSTEM_HIDDEN flag. */
740
741 /* Set dimensions */
742 y = 20 + ( BUTTON_HEIGHT + 20 ) * 2;
743 h = y + 80;
744
745 wid = window_create( "wdwEditors", _( "Editors" ), -1, -1,
746 MENU_WIDTH + EDITORS_EXTRA_WIDTH, h );
747 window_setCancel( wid, menu_editors_close );
748
749 /* Set buttons for the editors */
750 window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH,
751 BUTTON_HEIGHT, "btnUniverse", _( "Universe Editor" ),
752 uniedit_open, SDLK_u );
753 y -= BUTTON_HEIGHT + 20;
754 window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH,
755 BUTTON_HEIGHT, "btnMapEdit", _( "Map Outfits" ),
756 mapedit_open, SDLK_m );
757 y -= BUTTON_HEIGHT + 20;
758 window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH,
759 BUTTON_HEIGHT, "btnMain", _( "Exit to Main Menu" ),
760 menu_editors_close, SDLK_x );
761
762 /* Editors menu is open. */
763 menu_Open( MENU_EDITORS );
764}
765
770static void menu_editors_close( unsigned int wid, const char *str )
771{
772 (void)str;
773
774 /* Close the Editors Menu and mark it as closed */
775 window_destroy( wid );
776 menu_Close( MENU_EDITORS );
777
778 /* Restores Main Menu */
779 bg_needs_reset = 0;
780 menu_main();
781 bg_needs_reset = 1;
782}
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:179
#define BUTTON_HEIGHT
Definition board.c:28
#define BUTTON_WIDTH
Definition board.c:27
void cam_setZoom(double zoom)
Sets the camera zoom.
Definition camera.c:77
void cam_setTargetPos(double x, double y, int soft_over)
Sets the camera target to a position.
Definition camera.c:194
void mapedit_open(unsigned int wid_unused, const char *unused)
Opens the system editor interface.
void uniedit_open(unsigned int wid_unused, const char *unused)
Opens the system editor interface.
int dialogue_YesNoRaw(const char *caption, const char *msg)
Runs a dialogue with both yes and no options.
Definition dialogue.c:373
int dialogue_isOpen(void)
Checks to see if a dialogue is open.
Definition dialogue.c:96
void gui_cleanup(void)
Cleans up the GUI.
Definition gui.c:2047
unsigned int hook_addFunc(int(*func)(void *), void *data, const char *stack)
Adds a function hook to be run.
Definition hook.c:634
Handles the info menu.
#define INFO_MAIN
Definition info.h:8
int intro_display(const char *text, const char *mus)
Displays the introduction sequence.
Definition intro.c:323
void land_cleanup(void)
Cleans up some land-related variables.
Definition land.c:1952
int landed
Definition land.c:78
int land_canSave(void)
Whether or not the player can save.
Definition land.c:182
void load_loadSnapshotMenu(const char *name, int disablesave)
Opens the load snapshot menu.
Definition load.c:709
int load_refresh(void)
Loads or refreshes saved games for the player.
Definition load.c:233
void load_loadGameMenu(void)
Opens the load game menu.
Definition load.c:627
const nsave_t * load_getList(const char *name)
Gets the array (array.h) of loaded saves.
Definition load.c:612
int load_gameDiff(const char *file)
Loads the diffs from game file.
Definition load.c:1232
Handles the important game menus.
#define MENU_SMALL
Definition menu.h:10
#define MENU_MAIN
Definition menu.h:9
void menu_small_close(void)
Closes the small menu.
Definition menu.c:499
void menu_main(void)
Opens the main menu (titlescreen).
Definition menu.c:170
#define MENU_EDITORS
Definition menu.h:15
#define menu_isOpen(f)
Definition menu.h:16
int menu_askQuit(void)
Menu to ask if player really wants to quit.
Definition menu.c:701
void menu_death(void)
Player death menu, appears when player got creamed.
Definition menu.c:633
#define MENU_ASKQUIT
Definition menu.h:14
void menu_main_close(void)
Closes the main menu.
Definition menu.c:333
#define MENU_INFO
Definition menu.h:11
void menu_main_resize(void)
Resizes the main menu and its background.
Definition menu.c:279
#define MENU_DEATH
Definition menu.h:12
int music_choose(const char *situation)
Actually runs the music stuff, based on situation.
Definition music.c:426
static int quit
Definition naev.c:98
void naev_quit(void)
Flags naev to quit.
Definition naev.c:145
Uint32 SDL_LOOPDONE
Definition naev.c:99
Header file with generic functions and naev-specifics.
const char * naev_version(int long_version)
Returns the version in a human readable string.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
Definition opengl_tex.c:587
void gl_freeTexture(glTexture *texture)
Frees a texture.
Definition opengl_tex.c:835
void opt_menu(void)
Creates the options menu thingy.
Definition options.c:141
void pause_game(void)
Pauses the game.
Definition pause.c:25
void pause_setSpeed(double mod)
Adjusts the game's dt modifier.
Definition pause.c:61
void unpause_game(void)
Unpauses the game.
Definition pause.c:43
void pilots_cleanAll(void)
Even cleans up the player.
Definition pilot.c:4148
void player_new(void)
Creates a new player.
Definition player.c:256
void player_resetSpeed(void)
Resets the player speed stuff.
Definition player.c:1521
void player_soundStop(void)
Stops playing player sounds.
Definition player.c:966
void player_restoreControl(int reason, const char *str)
Aborts autonav and other states that take control of the ship.
Definition player.c:1535
Player_t player
Definition player.c:77
int safelanes_calculated(void)
Whether or not the safe lanes have been calculated at least once.
Definition safelanes.c:327
void safelanes_recalculate(void)
Update the safe lane locations in response to the universe changing (e.g., diff applied).
Definition safelanes.c:296
void save_reload(void)
Reload the current saved game.
Definition save.c:216
int save_all(void)
Saves the current game.
Definition save.c:97
void sound_setSpeed(double s)
Sets the speed to play the sound at.
Definition sound.c:1158
void space_init(const char *sysname, int do_simulate)
Initializes the system.
Definition space.c:1620
int spob_exists(const char *spobname)
Check to see if a spob exists.
Definition space.c:1185
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
Definition space.c:1107
void space_clearKnown(void)
Clears all system knowledge.
Definition space.c:3945
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
Definition space.c:1082
void start_position(double *x, double *y)
Gets the starting position of the player.
Definition start.c:255
const char * start_system(void)
Gets the starting system name.
Definition start.c:245
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Definition space.h:102
vec2 pos
Definition space.h:109
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43
double sw
Definition opengl_tex.h:53
double sh
Definition opengl_tex.h:54
A naev save.
Definition load.h:25
double y
Definition vec2.h:47
double x
Definition vec2.h:46
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_setFocus(unsigned int wid, const char *wgtname)
Sets the focused widget in a window.
Definition toolkit.c:2488
void window_dimWindow(unsigned int wid, int *w, int *h)
Gets the dimensions of a window.
Definition toolkit.c:370
void window_move(unsigned int wid, int x, int y)
Moves a window to the specified coordinates.
Definition toolkit.c:176
void window_setCancel(unsigned int wid, void(*cancel)(unsigned int, const char *))
Sets the default cancel function of the window.
Definition toolkit.c:868
void toolkit_closeAll(void)
Closes all open toolkit windows.
Definition toolkit.c:1016
void window_onClose(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the default close function of the window.
Definition toolkit.c:824
void window_moveWidget(unsigned int wid, const char *name, int x, int y)
Moves a widget.
Definition toolkit.c:463
Widget * window_getwgt(unsigned int wid, const char *name)
Gets a widget from window id and widgetname.
Definition toolkit.c:345
unsigned int window_get(const char *wdwname)
Gets the ID of a window.
Definition toolkit.c:662
void window_setBorder(unsigned int wid, int enable)
Sets or removes the border of a window.
Definition toolkit.c:942
void window_setParent(unsigned int wid, unsigned int parent)
Sets a window as a window's parent.
Definition toolkit.c:787
int window_exists(const char *wdwname)
Checks to see if a window exists.
Definition toolkit.c:591
void window_destroy(unsigned int wid)
Kills the window.
Definition toolkit.c:1039