/** * @brief Opens the gameplay menu. */ static void opt_gameplay( unsigned int wid ) { (void) wid; char buf[PATH_MAX]; const char *path; int cw; int w, h, y, x, by, l; char *s; /* Get size. */ window_dimWindow( wid, &w, &h ); /* Close button */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", opt_close ); window_addButton( wid, -20 - 1*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnApply", "Apply", opt_gameplaySave ); window_addButton( wid, -20 - 2*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnDefaults", "Defaults", opt_gameplayDefaults ); /* Information. */ cw = (w-40); x = 20; y = -60; window_addText( wid, x, y, cw, 20, 1, "txtVersion", NULL, NULL, naev_version(1) ); y -= 20; #ifdef GIT_COMMIT window_addText( wid, x, y, cw, 20, 1, "txtCommit", NULL, NULL, "Commit: "GIT_COMMIT ); #endif /* GIT_COMMIT */ y -= 20; path = ndata_getPath(); if (path == NULL) snprintf( buf, sizeof(buf), "not using ndata" ); else snprintf( buf, sizeof(buf), "ndata: %s", path); window_addText( wid, x, y, cw, 20, 1, "txtNdata", NULL, NULL, buf ); y -= 40; by = y; /* Compiletime stuff. */ cw = (w-60)/2; y = by; x = 20; window_addText( wid, x+20, y, cw, 20, 0, "txtCompile", NULL, &cDConsole, "Compilation Flags" ); y -= 30; window_addText( wid, x, y, cw, h+y-20, 0, "txtFlags", NULL, NULL, "" #ifdef DEBUGGING #ifdef DEBUG_PARANOID "Debug Paranoid\n" #else /* DEBUG_PARANOID */ "Debug\n" #endif /* DEBUG_PARANOID */ #endif /* DEBUGGING */ #if defined(LINUX) "Linux\n" #elif defined(FREEBSD) "FreeBSD\n" #elif defined(MACOSX) "Mac OS X\n" #elif defined(WIN32) "Windows\n" #else "Unknown OS\n" #endif #ifdef USE_OPENAL "With OpenAL\n" #endif /* USE_OPENAL */ #ifdef USE_SDLMIX "With SDL_mixer\n" #endif #ifdef HAVE_LUAJIT "Using Lua JIT\n" #endif #ifdef NDATA_DEF "ndata: "NDATA_DEF"\n" #endif /* NDATA_DEF */ #ifdef PREFSDIR_DEF "preference directory: "PREFSDIR_DEF"\n" #endif /* PREFSDIR_DEF */ ); /* Options. */ y = by; x += cw; /* Autonav abort. */ x = 20 + cw + 20; window_addText( wid, x+65, y, 150, 150, 0, "txtAAutonav", NULL, &cDConsole, "Abort Autonav At:" ); y -= 20; /* Autonav abort fader. */ opt_getAutonavAbortStr( buf, sizeof(buf) ); window_addText( wid, x, y, cw, 20, 1, "txtAutonav", NULL, NULL, buf ); y -= 20; window_addFader( wid, x, y, cw, 20, "fadAutonav", 0., 1., conf.autonav_abort, opt_setAutonavAbort ); y -= 40; window_addText( wid, x+20, y, cw, 20, 0, "txtSettings", NULL, &cDConsole, "Settings" ); y -= 25; window_addCheckbox( wid, x, y, cw, 20, "chkZoomManual", "Enable manual zoom control", NULL, conf.zoom_manual ); y -= 25; window_addCheckbox( wid, x, y, cw, 20, "chkAfterburn", "Enable double-tap afterburn", NULL, conf.afterburn_sens ); y -= 25; window_addCheckbox( wid, x, y, cw, 20, "chkMouseThrust", "Enable mouse-flying thrust control", NULL, conf.mouse_thrust ); y -= 25; window_addCheckbox( wid, x, y, cw, 20, "chkCompress", "Enable savegame compression", NULL, conf.save_compress ); y -= 30; s = "Visible Messages"; l = gl_printWidthRaw( NULL, s ); window_addText( wid, -100, y, l, 20, 1, "txtSMSG", NULL, &cBlack, s ); window_addInput( wid, -50, y, 40, 20, "inpMSG", 4, 1, NULL ); y -= 30; s = "Max Time Compression Factor"; l = gl_printWidthRaw( NULL, s ); window_addText( wid, -100, y, l, 20, 1, "txtTMax", NULL, &cBlack, s ); window_addInput( wid, -50, y, 40, 20, "inpTMax", 4, 1, NULL ); y -= 30; /* Restart text. */ window_addText( wid, 20, 10, 3*(BUTTON_WIDTH + 20), 30, 0, "txtRestart", &gl_smallFont, &cBlack, NULL ); /* Update. */ opt_gameplayUpdate( wid, NULL ); }
/** * @brief Opens the main menu (titlescreen). */ void menu_main (void) { int offset_logo, offset_wdw, freespace; unsigned int bwid, wid; glTexture *tex; /* Play load music. */ music_choose("load"); /* Load background and friends. */ tex = gl_newImage( "gfx/NAEV.png", 0 ); main_naevLogo = tex; nebu_prep( 300., 0. ); /* Needed for nebula to not spaz out */ /* Calculate Logo and window offset. */ freespace = SCREEN_H - tex->sh - MAIN_HEIGHT; if (freespace < 0) { /* Not enough freespace, this can get ugly. */ offset_logo = SCREEN_W - tex->sh; offset_wdw = 0; } else { /* We'll want a maximum seperation of 30 between logo and text. */ if (freespace/3 > 25) { freespace -= 25; offset_logo = -25; offset_wdw = -25 - tex->sh - 25; } /* Otherwise space evenly. */ else { offset_logo = -freespace/3; offset_wdw = freespace/3; } } /* create background image window */ bwid = window_create( "BG", -1, -1, SCREEN_W, SCREEN_H ); window_onClose( bwid, menu_main_cleanBG ); window_addRect( bwid, 0, 0, SCREEN_W, SCREEN_H, "rctBG", &cBlack, 0 ); window_addCust( bwid, 0, 0, SCREEN_W, SCREEN_H, "cstBG", 0, menu_main_nebu, NULL, &menu_main_lasttick ); window_addImage( bwid, (SCREEN_W-tex->sw)/2., offset_logo, "imgLogo", tex, 0 ); window_addText( bwid, 0., 10, SCREEN_W, 30., 1, "txtBG", NULL, &cWhite, naev_version(1) ); /* create menu window */ wid = window_create( "Main Menu", -1, offset_wdw, MAIN_WIDTH, MAIN_HEIGHT ); window_addButton( wid, 20, 20 + (BUTTON_HEIGHT+20)*4, BUTTON_WIDTH, BUTTON_HEIGHT, "btnLoad", "Load Game", menu_main_load ); window_addButton( wid, 20, 20 + (BUTTON_HEIGHT+20)*3, BUTTON_WIDTH, BUTTON_HEIGHT, "btnNew", "New Game", menu_main_new ); window_addButton( wid, 20, 20 + (BUTTON_HEIGHT+20)*2, BUTTON_WIDTH, BUTTON_HEIGHT, "btnOptions", "Options", menu_options_button ); window_addButton( wid, 20, 20 + (BUTTON_HEIGHT+20), BUTTON_WIDTH, BUTTON_HEIGHT, "btnCredits", "Credits", menu_main_credits ); window_addButton( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", "Exit", menu_exit ); /* Make the background window a parent of the menu. */ window_setParent( bwid, wid ); /* Reset timer. */ menu_main_lasttick = SDL_GetTicks(); menu_Open(MENU_MAIN); }
/** * @brief Opens the main menu (titlescreen). */ void menu_main (void) { int offset_logo, offset_wdw, freespace; unsigned int bwid, wid; glTexture *tex; int h, y; if (menu_isOpen(MENU_MAIN)) { WARN( _("Menu main is already open.") ); return; } /* Clean up GUI - must be done before using SCREEN_W or SCREEN_H. */ gui_cleanup(); player_soundStop(); /* Stop sound. */ /* Play load music. */ music_choose("load"); /* Load background and friends. */ tex = gl_newImage( GFX_PATH"Naev.png", 0 ); main_naevLogo = tex; menu_main_bkg_system(); /* Set dimensions */ y = 20 + (BUTTON_HEIGHT+20)*5; h = y + 80; if (conf.devmode) { h += BUTTON_HEIGHT + 20; y += BUTTON_HEIGHT + 20; } /* Calculate Logo and window offset. */ freespace = SCREEN_H - tex->sh - h; if (freespace < 0) { /* Not enough freespace, this can get ugly. */ offset_logo = SCREEN_W - tex->sh; offset_wdw = 0; } /* Otherwise space evenly. */ else { offset_logo = -freespace/4; offset_wdw = freespace/2; } /* create background image window */ bwid = window_create( "BG", -1, -1, -1, -1 ); window_onClose( bwid, menu_main_cleanBG ); window_setBorder( bwid, 0 ); window_addImage( bwid, (SCREEN_W-tex->sw)/2., offset_logo, 0, 0, "imgLogo", tex, 0 ); window_addText( bwid, 0, 10, SCREEN_W, 30., 1, "txtBG", NULL, &cWhite, naev_version(1) ); /* create menu window */ wid = window_create( "Main Menu", -1, offset_wdw, MAIN_WIDTH, h ); window_setCancel( wid, main_menu_promptClose ); /* Buttons. */ window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnLoad", _("Load Game"), menu_main_load, SDLK_l ); y -= BUTTON_HEIGHT+20; window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnNew", _("New Game"), menu_main_new, SDLK_n ); y -= BUTTON_HEIGHT+20; window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnTutorial", _("Tutorial"), menu_main_tutorial, SDLK_t ); y -= BUTTON_HEIGHT+20; if (conf.devmode) { window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnEditor", _("Editors"), menu_editors_open, SDLK_e ); y -= BUTTON_HEIGHT+20; } window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnOptions", _("Options"), menu_options_button, SDLK_o ); y -= BUTTON_HEIGHT+20; window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnCredits", _("Credits"), menu_main_credits, SDLK_c ); y -= BUTTON_HEIGHT+20; window_addButtonKey( wid, 20, y, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", _("Exit"), menu_exit, SDLK_x ); /* Disable load button if there are no saves. */ if (!save_hasSave()) window_disableButton( wid, "btnLoad" ); /* Make the background window a child of the menu. */ window_setParent( bwid, wid ); unpause_game(); menu_Open(MENU_MAIN); }
/** * @brief The entry point of Naev. * * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. * @return EXIT_SUCCESS on success. */ int main( int argc, char** argv ) { char buf[PATH_MAX]; /* Save the binary path. */ binary_path = strdup(argv[0]); /* Print the version */ LOG( " "APPNAME" v%s", naev_version(0) ); #ifdef GIT_COMMIT DEBUG( " git HEAD at " GIT_COMMIT ); #endif /* GIT_COMMIT */ /* Initializes SDL for possible warnings. */ SDL_Init(0); /* Initialize the threadpool */ threadpool_init(); /* Set up debug signal handlers. */ debug_sigInit(); /* Must be initialized before input_init is called. */ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { WARN("Unable to initialize SDL Video: %s", SDL_GetError()); return -1; } /* Get desktop dimensions. */ #if SDL_VERSION_ATLEAST(1,2,10) const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo(); gl_screen.desktop_w = vidinfo->current_w; gl_screen.desktop_h = vidinfo->current_h; #else /* #elif SDL_VERSION_ATLEAST(1,2,10) */ gl_screen.desktop_w = 0; gl_screen.desktop_h = 0; #endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */ /* We'll be parsing XML. */ LIBXML_TEST_VERSION xmlInitParser(); /* Input must be initialized for config to work. */ input_init(); conf_setDefaults(); /* set the default config values */ /* * Attempts to load the data path from datapath.lua * At this early point in the load process, the binary path * is the only place likely to be checked. */ conf_loadConfigPath(); /* Parse the user data path override first. */ conf_parseCLIPath( argc, argv ); /* Create the home directory if needed. */ if (nfile_dirMakeExist("%s", nfile_configPath())) WARN("Unable to create config directory '%s'", nfile_configPath()); /* Set the configuration. */ nsnprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_configPath()); #if HAS_UNIX /* TODO get rid of this cruft ASAP. */ int oldconfig = 0; if (!nfile_fileExists( buf )) { char *home, buf2[PATH_MAX]; home = SDL_getenv( "HOME" ); if (home != NULL) { nsnprintf( buf2, PATH_MAX, "%s/.naev/"CONF_FILE, home ); if (nfile_fileExists( buf2 )) oldconfig = 1; } } #endif /* HAS_UNIX */ conf_loadConfig(buf); /* Lua to parse the configuration file */ conf_parseCLI( argc, argv ); /* parse CLI arguments */ /* Enable FPU exceptions. */ #if defined(HAVE_FEENABLEEXCEPT) && defined(DEBUGGING) if (conf.fpu_except) feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); #endif /* defined(HAVE_FEENABLEEXCEPT) && defined(DEBUGGING) */ /* Open data. */ if (ndata_open() != 0) ERR("Failed to open ndata."); /* Load the start info. */ if (start_load()) ERR("Failed to load module start data."); /* Load the data basics. */ LOG(" %s", ndata_name()); DEBUG(); /* Display the SDL Version. */ print_SDLversion(); DEBUG(); /* random numbers */ rng_init(); /* * OpenGL */ if (gl_init()) { /* initializes video output */ ERR("Initializing video output failed, exiting..."); SDL_Quit(); exit(EXIT_FAILURE); } window_caption(); gl_fontInit( NULL, NULL, conf.font_size_def ); /* initializes default font to size */ gl_fontInit( &gl_smallFont, NULL, conf.font_size_small ); /* small font */ /* Display the load screen. */ loadscreen_load(); loadscreen_render( 0., "Initializing subsystems..." ); time_ms = SDL_GetTicks(); /* * Input */ if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) { if (joystick_init()) WARN("Error initializing joystick input"); if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */ if (joystick_use(joystick_get(conf.joystick_nam))) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } free(conf.joystick_nam); } else if (conf.joystick_ind >= 0) /* use a joystick id instead */ if (joystick_use(conf.joystick_ind)) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } } /* * OpenAL - Sound */ if (conf.nosound) { LOG("Sound is disabled!"); sound_disabled = 1; music_disabled = 1; } if (sound_init()) WARN("Problem setting up sound!"); music_choose("load"); /* FPS stuff. */ fps_setPos( 15., (double)(gl_screen.h-15-gl_defFont.h) ); /* Misc graphics init */ if (nebu_init() != 0) { /* Initializes the nebula */ /* An error has happened */ ERR("Unable to initialize the Nebula subsystem!"); /* Weirdness will occur... */ } gui_init(); /* initializes the GUI graphics */ toolkit_init(); /* initializes the toolkit */ map_init(); /* initializes the map. */ cond_init(); /* Initialize conditional subsystem. */ cli_init(); /* Initialize console. */ /* Data loading */ load_all(); /* Generate the CSV. */ if (conf.devcsv) dev_csv(); /* Unload load screen. */ loadscreen_unload(); /* Start menu. */ menu_main(); /* Force a minimum delay with loading screen */ if ((SDL_GetTicks() - time_ms) < NAEV_INIT_DELAY) SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time_ms) ); fps_init(); /* initializes the time_ms */ #if HAS_UNIX /* Tell the player to migrate their configuration files out of ~/.naev */ /* TODO get rid of this cruft ASAP. */ if ((oldconfig) && (!conf.datapath)) { char path[PATH_MAX], *script, *home; uint32_t scriptsize; int ret; nsnprintf( path, PATH_MAX, "%s/naev-confupdate.sh", ndata_getDirname() ); home = SDL_getenv("HOME"); ret = dialogue_YesNo( "Warning", "Your configuration files are in a deprecated location and must be migrated:\n" " \er%s/.naev/\e0\n\n" "The update script can likely be found in your Naev data directory:\n" " \er%s\e0\n\n" "Would you like to run it automatically?", home, path ); /* Try to run the script. */ if (ret) { ret = -1; /* Running from ndata. */ if (ndata_getPath() != NULL) { script = ndata_read( "naev-confupdate.sh", &scriptsize ); if (script != NULL) ret = system(script); } /* Running from laid-out files or ndata_read failed. */ if ((nfile_fileExists(path)) && (ret == -1)) { script = nfile_readFile( (int*)&scriptsize, path ); if (script != NULL) ret = system(script); } /* We couldn't find the script. */ if (ret == -1) { dialogue_alert( "The update script was not found at:\n\er%s\e0\n\n" "Please locate and run it manually.", path ); } /* Restart, as the script succeeded. */ else if (!ret) { dialogue_msg( "Update Completed", "Configuration files were successfully migrated. Naev will now restart." ); execv(argv[0], argv); } else { /* I sincerely hope this else is never hit. */ dialogue_alert( "The update script encountered an error. Please exit Naev and move your config and save files manually:\n\n" "\er%s/%s\e0 =>\n \eD%s\e0\n\n" "\er%s/%s\e0 =>\n \eD%s\e0\n\n" "\er%s/%s\e0 =>\n \eD%snebula/\e0\n\n", home, ".naev/conf.lua", nfile_configPath(), home, ".naev/{saves,screenshots}/", nfile_dataPath(), home, ".naev/gen/*.png", nfile_cachePath() ); } } else {
/** * @brief The entry point of NAEV. * * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. * @return EXIT_SUCCESS on success. */ int main( int argc, char** argv ) { char buf[PATH_MAX]; /* Save the binary path. */ binary_path = argv[0]; /* Print the version */ LOG( " "APPNAME" v%s", naev_version(0) ); #ifdef GIT_COMMIT DEBUG( " git HEAD at " GIT_COMMIT ); #endif /* GIT_COMMIT */ /* Initializes SDL for possible warnings. */ SDL_Init(0); /* Set up debug signal handlers. */ debug_sigInit(); /* Create the home directory if needed. */ if (nfile_dirMakeExist("%s", nfile_basePath())) WARN("Unable to create naev directory '%s'", nfile_basePath()); /* Must be initialized before input_init is called. */ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { WARN("Unable to initialize SDL Video: %s", SDL_GetError()); return -1; } /* Get desktop dimensions. */ #if SDL_VERSION_ATLEAST(1,2,10) const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo(); gl_screen.desktop_w = vidinfo->current_w; gl_screen.desktop_h = vidinfo->current_h; #else /* #elif SDL_VERSION_ATLEAST(1,2,10) */ gl_screen.desktop_w = 0; gl_screen.desktop_h = 0; #endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */ /* We'll be parsing XML. */ LIBXML_TEST_VERSION xmlInitParser(); /* Input must be initialized for config to work. */ input_init(); /* Set the configuration. */ snprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_basePath()); conf_setDefaults(); /* set the default config values */ conf_loadConfig(buf); /* Lua to parse the configuration file */ conf_parseCLI( argc, argv ); /* parse CLI arguments */ /* Enable FPU exceptions. */ #if !(HAS_WIN32) && defined(DEBUGGING) if (conf.fpu_except) feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); #endif /* DEBUGGING */ /* Open data. */ if (ndata_open() != 0) ERR("Failed to open ndata."); /* Load the data basics. */ LOG(" %s", ndata_name()); DEBUG(); /* Display the SDL Version. */ print_SDLversion(); DEBUG(); /* random numbers */ rng_init(); /* * OpenGL */ if (gl_init()) { /* initializes video output */ ERR("Initializing video output failed, exiting..."); SDL_Quit(); exit(EXIT_FAILURE); } window_caption(); gl_fontInit( NULL, NULL, FONT_SIZE ); /* initializes default font to size */ gl_fontInit( &gl_smallFont, NULL, FONT_SIZE_SMALL ); /* small font */ /* Display the load screen. */ loadscreen_load(); loadscreen_render( 0., "Initializing subsystems..." ); time = SDL_GetTicks(); /* * Input */ if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) { if (joystick_init()) WARN("Error initializing joystick input"); if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */ if (joystick_use(joystick_get(conf.joystick_nam))) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } free(conf.joystick_nam); } else if (conf.joystick_ind >= 0) /* use a joystick id instead */ if (joystick_use(conf.joystick_ind)) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } } /* * OpenAL - Sound */ if (conf.nosound) { LOG("Sound is disabled!"); sound_disabled = 1; music_disabled = 1; } if (sound_init()) WARN("Problem setting up sound!"); music_choose("load"); /* Misc graphics init */ if (nebu_init() != 0) { /* Initializes the nebula */ /* An error has happened */ ERR("Unable to initialize the Nebula subsystem!"); /* Weirdness will occur... */ } gui_init(); /* initializes the GUI graphics */ toolkit_init(); /* initializes the toolkit */ map_init(); /* initializes the map. */ cond_init(); /* Initialize conditional subsystem. */ /* Data loading */ load_all(); /* Unload load screen. */ loadscreen_unload(); /* Start menu. */ menu_main(); /* Force a minimum delay with loading screen */ if ((SDL_GetTicks() - time) < NAEV_INIT_DELAY) SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time) ); time = SDL_GetTicks(); /* initializes the time */ /* * main loop */ SDL_Event event; /* flushes the event loop since I noticed that when the joystick is loaded it * creates button events that results in the player starting out acceling */ while (SDL_PollEvent(&event)); /* primary loop */ while (!quit) { while (SDL_PollEvent(&event)) { /* event loop */ if (event.type == SDL_QUIT) quit = 1; /* quit is handled here */ input_handle(&event); /* handles all the events and player keybinds */ } main_loop(); } /* Save configuration. */ conf_saveConfig(buf); /* cleanup some stuff */ player_cleanup(); /* cleans up the player stuff */ gui_free(); /* cleans up the player's GUI */ weapon_exit(); /* destroys all active weapons */ pilots_free(); /* frees the pilots, they were locked up :( */ cond_exit(); /* destroy conditional subsystem. */ land_exit(); /* Destroys landing vbo and friends. */ /* data unloading */ unload_all(); /* cleanup opengl fonts */ gl_freeFont(NULL); gl_freeFont(&gl_smallFont); /* Close data. */ ndata_close(); /* Destroy conf. */ conf_cleanup(); /* Frees some memory the configuration allocated. */ /* exit subsystems */ map_exit(); /* destroys the map. */ toolkit_exit(); /* kills the toolkit */ ai_exit(); /* stops the Lua AI magic */ joystick_exit(); /* releases joystick */ input_exit(); /* cleans up keybindings */ nebu_exit(); /* destroys the nebula */ gl_exit(); /* kills video output */ sound_exit(); /* kills the sound */ news_exit(); /* destroys the news. */ /* Free the icon. */ if (naev_icon) free(naev_icon); SDL_Quit(); /* quits SDL */ /* all is well */ exit(EXIT_SUCCESS); }
/** * @brief Opens the gameplay menu. */ static void opt_gameplay( unsigned int wid ) { (void) wid; char buf[PATH_MAX]; const char *path; int cw; int w, h, y, x, by, l; char *s; /* Get size. */ window_dimWindow( wid, &w, &h ); /* Close button */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", opt_close ); window_addButton( wid, -20 - 1*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnApply", "Apply", opt_gameplaySave ); window_addButton( wid, -20 - 2*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnDefaults", "Defaults", opt_gameplayDefaults ); /* Information. */ cw = (w-40); x = 20; y = -60; window_addText( wid, x, y, cw, 20, 1, "txtVersion", NULL, NULL, naev_version(1) ); y -= 20; #ifdef GIT_COMMIT window_addText( wid, x, y, cw, 20, 1, "txtCommit", NULL, NULL, "Commit: "GIT_COMMIT ); #endif /* GIT_COMMIT */ y -= 20; path = ndata_getPath(); if (path == NULL) snprintf( buf, sizeof(buf), "not using ndata" ); else snprintf( buf, sizeof(buf), "ndata: %s", path); window_addText( wid, x, y, cw, 20, 1, "txtNdata", NULL, NULL, buf ); y -= 50; by = y; /* Compiletime stuff. */ cw = (w-60)/2; y = by; x = 20; window_addText( wid, x+20, y, cw, 20, 0, "txtCompile", NULL, &cDConsole, "Compilation Flags" ); y -= 30; window_addText( wid, x, y, cw, h+y-20, 0, "txtFlags", NULL, NULL, "" #ifdef DEBUGGING #ifdef DEBUG_PARANOID "Debug Paranoid\n" #else /* DEBUG_PARANOID */ "Debug\n" #endif /* DEBUG_PARANOID */ #endif /* DEBUGGING */ #if defined(LINUX) "Linux\n" #elif defined(FREEBSD) "FreeBSD\n" #elif defined(MACOSX) "Mac OS X\n" #elif defined(WIN32) "Windows\n" #else "Unknown OS\n" #endif #ifdef USE_OPENAL "With OpenAL\n" #endif /* USE_OPENAL */ #ifdef USE_SDLMIX "With SDL_mixer\n" #endif #ifdef NDATA_DEF "ndata: "NDATA_DEF"\n" #endif /* NDATA_DEF */ ); /* Options. */ y = by; x += cw; window_addText( wid, x+20, y, cw, 20, 0, "txtSettings", NULL, &cDConsole, "Settings" ); y -= 30; window_addCheckbox( wid, x, y, cw, 20, "chkAfterburn", "Enable doubletap afterburn", NULL, conf.afterburn_sens ); y -= 20; window_addCheckbox( wid, x, y, cw, 20, "chkCompress", "Enable savegame compression", NULL, conf.save_compress ); y -= 50; s = "Visible messages"; l = gl_printWidthRaw( NULL, s ); window_addText( wid, x, y, l, 20, 1, "txtSMSG", NULL, &cBlack, s ); window_addInput( wid, x+l+20, y, 40, 20, "inpMSG", 4, 1 ); y -= 20; /* Restart text. */ window_addText( wid, -20, 20+BUTTON_HEIGHT+20, 3*(BUTTON_WIDTH + 20), 30, 1, "txtRestart", &gl_smallFont, &cBlack, NULL ); /* Update. */ opt_gameplayUpdate( wid, NULL ); }