/** * @brief Opens the small ingame menu. */ void menu_small (void) { unsigned int wid; /* Check if menu should be openable. */ if ((player == NULL) || player_isFlag(PLAYER_DESTROYED) || pilot_isFlag(player,PILOT_DEAD) || comm_isOpen() || dialogue_isOpen() || /* Shouldn't open over dialogues. */ (menu_isOpen(MENU_MAIN) || menu_isOpen(MENU_SMALL) || menu_isOpen(MENU_DEATH) )) return; wid = window_create( "Menu", -1, -1, MENU_WIDTH, MENU_HEIGHT ); window_setCancel( wid, menu_small_close ); window_addButton( wid, 20, 20 + BUTTON_HEIGHT*2 + 20*2, BUTTON_WIDTH, BUTTON_HEIGHT, "btnResume", "Resume", menu_small_close ); window_addButton( wid, 20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnOptions", "Options", menu_options_button ); window_addButton( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", "Exit", menu_small_exit ); menu_Open(MENU_SMALL); }
/** * @brief Player death menu, appears when player got creamed. */ void menu_death (void) { unsigned int wid; wid = window_create( "Death", -1, -1, DEATH_WIDTH, DEATH_HEIGHT ); /* Propose the player to continue if the samegame exist, if not, propose to restart */ char path[PATH_MAX]; snprintf(path, PATH_MAX, "%ssaves/%s.ns", nfile_basePath(), player_name); if (nfile_fileExists(path)) window_addButton( wid, 20, 20 + BUTTON_HEIGHT*2 + 20*2, BUTTON_WIDTH, BUTTON_HEIGHT, "btnContinue", "Continue", menu_death_continue ); else window_addButton( wid, 20, 20 + BUTTON_HEIGHT*2 + 20*2, BUTTON_WIDTH, BUTTON_HEIGHT, "btnRestart", "Restart", menu_death_restart ); window_addButton( wid, 20, 20 + (BUTTON_HEIGHT+20), BUTTON_WIDTH, BUTTON_HEIGHT, "btnMain", "Main Menu", menu_death_main ); window_addButton( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", "Exit Game", menu_exit ); menu_Open(MENU_DEATH); /* Makes it all look cooler since everything still goes on. */ unpause_game(); }
/** * @brief Player death menu, appears when player got creamed. */ void menu_death (void) { unsigned int wid; char path[PATH_MAX]; wid = window_create( "Death", -1, -1, DEATH_WIDTH, DEATH_HEIGHT ); window_onClose( wid, menu_death_close ); /* Allow the player to continue if the savegame exists, if not, propose to restart */ nsnprintf(path, PATH_MAX, "%ssaves/%s.ns", nfile_dataPath(), player.name); if (!player_isTut() && nfile_fileExists(path)) window_addButtonKey( wid, 20, 20 + BUTTON_HEIGHT*2 + 20*2, BUTTON_WIDTH, BUTTON_HEIGHT, "btnContinue", _("Continue"), menu_death_continue, SDLK_c ); else window_addButtonKey( wid, 20, 20 + BUTTON_HEIGHT*2 + 20*2, BUTTON_WIDTH, BUTTON_HEIGHT, "btnRestart", _("Restart"), menu_death_restart, SDLK_r ); window_addButtonKey( wid, 20, 20 + (BUTTON_HEIGHT+20), BUTTON_WIDTH, BUTTON_HEIGHT, "btnMain", _("Main Menu"), menu_death_main, SDLK_m ); window_addButtonKey( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", _("Exit Game"), menu_exit, SDLK_x ); menu_Open(MENU_DEATH); /* Makes it all look cooler since everything still goes on. */ unpause_game(); }
/** * @brief Opens the information menu. */ void menu_info (void) { char str[128]; char *nt; unsigned int wid; /* Can't open menu twice. */ if (menu_isOpen(MENU_INFO) || dialogue_isOpen()) return; /* Pauses the player's sounds. */ player_soundPause(); wid = window_create( "Info", -1, -1, INFO_WIDTH, INFO_HEIGHT ); /* pilot generics */ nt = ntime_pretty( ntime_get() ); window_addText( wid, 20, 20, 120, INFO_HEIGHT-60, 0, "txtDPilot", &gl_smallFont, &cDConsole, "Pilot:\n" "Date:\n" "Combat\n" " Rating:\n" "\n" "Ship:\n" "Fuel:\n" ); snprintf( str, 128, "%s\n" "%s\n" "\n" "%s\n" "\n" "%s\n" "%d (%d jumps)" , player_name, nt, player_rating(), player->name, (int)player->fuel, pilot_getJumps(player) ); window_addText( wid, 80, 20, INFO_WIDTH-120-BUTTON_WIDTH, INFO_HEIGHT-60, 0, "txtPilot", &gl_smallFont, &cBlack, str ); free(nt); /* menu */ window_addButton( wid, -20, (20 + BUTTON_HEIGHT)*4 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, player->ship->name, "Ship", ship_view ); window_addButton( wid, -20, (20 + BUTTON_HEIGHT)*3 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits", "Outfts", info_outfits_menu ); window_addButton( wid, -20, (20 + BUTTON_HEIGHT)*2 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnCargo", "Cargo", info_cargo_menu ); window_addButton( wid, -20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnMissions", "Missions", info_missions_menu ); window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", menu_info_close ); menu_Open(MENU_INFO); }
/** * @brief Opens the options menu. */ void menu_options (void) { unsigned int wid; wid = window_create( "Options", -1, -1, OPTIONS_WIDTH, OPTIONS_HEIGHT ); window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", menu_options_close ); window_addButton( wid, -20 - (BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnKeybinds", "Keybindings", menu_options_keybinds ); window_addButton( wid, -20 - 2 * (BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnAudio", "Audio", menu_options_audio ); menu_Open(MENU_OPTIONS); }
/** * @brief Player death menu, appears when player got creamed. */ void menu_death (void) { unsigned int wid; wid = window_create( "Death", -1, -1, DEATH_WIDTH, DEATH_HEIGHT ); window_addButton( wid, 20, 20 + (BUTTON_HEIGHT+20), BUTTON_WIDTH, BUTTON_HEIGHT, "btnMain", "Main Menu", menu_death_main ); window_addButton( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", "Exit Game", (void(*)(unsigned int, char*)) exit_game ); menu_Open(MENU_DEATH); /* Makes it all look cooler since everything still goes on. */ unpause_game(); }
/** * @brief Menu to ask if player really wants to quit. */ int menu_askQuit (void) { /* Asked twice, quit. */ if (menu_isOpen( MENU_ASKQUIT )) { exit_game(); return 1; } /* Ask if should quit. */ menu_Open( MENU_ASKQUIT ); if (dialogue_YesNoRaw( _("Quit Naev"), _("Are you sure you want to quit Naev?") )) { exit_game(); return 1; } menu_Close( MENU_ASKQUIT ); return 0; }
/** * @brief Provisional Menu for when there will be multiple editors */ static void menu_editors_open( unsigned int wid, char *unused ) { (void) unused; int h, y; /*WARN("Entering function.");*/ /* Menu already open, quit. */ if (menu_isOpen( MENU_EDITORS )) { return; } /* Close the Main Menu */ menu_main_close(); unpause_game(); /* Set dimensions */ y = 20 + (BUTTON_HEIGHT+20)*2; h = y + 80; wid = window_create( "Editors", -1, -1, MENU_WIDTH + EDITORS_EXTRA_WIDTH, h ); window_setCancel( wid, menu_editors_close ); /* Set buttons for the editors */ window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH, BUTTON_HEIGHT, "btnUniverse", "Universe Map", uniedit_open, SDLK_u ); y -= BUTTON_HEIGHT+20; window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH, BUTTON_HEIGHT, "btnMapEdit", "Map Outfits", mapedit_open, SDLK_m ); y -= BUTTON_HEIGHT+20; window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH, BUTTON_HEIGHT, "btnMain", "Exit to Main Menu", menu_editors_close, SDLK_x ); /* Editors menu is open. */ menu_Open( MENU_EDITORS ); /*WARN("Exiting function.");*/ return; }
/** * @brief Opens the information menu. */ void menu_info( int window ) { int w, h; /* Not under manual control. */ if (pilot_isFlag( player.p, PILOT_MANUAL_CONTROL )) return; /* Open closes when previously opened. */ if (menu_isOpen(MENU_INFO) || dialogue_isOpen()) { info_close( 0, NULL ); return; } /* Dimensions. */ w = 600; h = 500; /* Create the window. */ info_wid = window_create( "Info", -1, -1, w, h ); window_setCancel( info_wid, info_close ); /* Create tabbed window. */ info_windows = window_addTabbedWindow( info_wid, -1, -1, -1, -1, "tabInfo", INFO_WINDOWS, info_names ); /* Open the subwindows. */ info_openMain( info_windows[ INFO_WIN_MAIN ] ); info_openShip( info_windows[ INFO_WIN_SHIP ] ); info_openWeapons( info_windows[ INFO_WIN_WEAP ] ); info_openCargo( info_windows[ INFO_WIN_CARGO ] ); info_openMissions( info_windows[ INFO_WIN_MISN ] ); info_openStandings( info_windows[ INFO_WIN_STAND ] ); menu_Open(MENU_INFO); /* Set active window. */ window_tabWinSetActive( info_wid, "tabInfo", CLAMP( 0, 5, window ) ); }
/** * @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); }