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