/** * @brief Shows the player's active missions. * * @param parent Unused. * @param str Unused. */ static void info_missions_menu( unsigned int parent, char* str ) { (void) str; unsigned int wid; /* create the window */ wid = window_create( "Missions", -1, -1, MISSIONS_WIDTH, MISSIONS_HEIGHT ); window_setParent( wid, parent ); /* buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "closeMissions", "Back", window_close ); window_addButton( wid, -20, 40 + BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT, "btnAbortMission", "Abort", mission_menu_abort ); /* text */ window_addText( wid, 300+40, -60, 200, 40, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, 300+100, -60, 140, 40, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); window_addText( wid, 300+40, -100, 200, MISSIONS_HEIGHT - BUTTON_WIDTH - 120, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* Put a map. */ map_show( wid, 20, 20, 300, 260, 0.75 ); /* list */ mission_menu_genList(wid ,1); }
/** * @brief Rebinds a key. */ static void opt_setKey( unsigned int wid, char *str ) { (void) wid; (void) str; unsigned int new_wid; int w, h; /* Reset key. */ opt_lastKeyPress = 0; /* Create new window. */ w = 20 + 2*(BUTTON_WIDTH + 20); h = 20 + BUTTON_HEIGHT + 20 + 20 + 80 + 40; new_wid = window_create( "Set Keybinding", -1, -1, w, h ); window_handleEvents( new_wid, opt_setKeyEvent ); window_setParent( new_wid, wid ); /* Set text. */ window_addText( new_wid, 20, -40, w-40, 60, 0, "txtInfo", &gl_smallFont, &cBlack, "To use a modifier key hit that key twice in a row, otherwise it " "will register as a modifier. To set with any modifier click the checkbox." ); /* Create button to cancel. */ window_addButton( new_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnCancel", "Cancel", window_close ); /* Button to unset. */ window_addButton( new_wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnUnset", "Unset", opt_unsetKey ); /* Checkbox to set any modifier. */ window_addCheckbox( new_wid, -20, 20 + BUTTON_HEIGHT + 20, w-40, 20, "chkAny", "Set any modifier", NULL, 0 ); }
/** * @brief Opens the licenses menu. */ static void info_licenses_menu( unsigned int parent, char* str ) { (void) str; unsigned int wid; char **licenses; int nlicenses; int i; char **buf; /* Create window */ wid = window_create( "Licenses", -1, -1, LICENSES_WIDTH, LICENSES_HEIGHT ); window_setParent( wid, parent ); /* List. */ buf = player_getLicenses( &nlicenses ); licenses = malloc(sizeof(char*)*nlicenses); for (i=0; i<nlicenses; i++) licenses[i] = strdup(buf[i]); window_addList( wid, 20, -40, LICENSES_WIDTH-40, LICENSES_HEIGHT-80-BUTTON_HEIGHT, "lstLicenses", licenses, nlicenses, 0, NULL ); /* Buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "closeLicenses", "Close", window_close ); }
/** * @brief Shows the player what outfits he has. * * @param str Unused. */ static void info_outfits_menu( unsigned int parent, char* str ) { (void) str; char *buf; unsigned int wid; /* Create window */ wid = window_create( "Outfits", -1, -1, OUTFITS_WIDTH, OUTFITS_HEIGHT ); window_setParent( wid, parent ); /* Text */ window_addText( wid, 20, -40, 100, OUTFITS_HEIGHT-40, 0, "txtLabel", &gl_smallFont, &cDConsole, "Ship Outfits:" ); buf = pilot_getOutfits( player ); window_addText( wid, 20, -45-gl_smallFont.h, OUTFITS_WIDTH-40, OUTFITS_HEIGHT-60, 0, "txtOutfits", &gl_smallFont, &cBlack, buf ); free(buf); /* Buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "closeOutfits", "Close", window_close ); window_addButton( wid, -20-BUTTON_WIDTH-20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnLicenses", "Licenses", info_licenses_menu ); }
/** * @brief Shows the player his cargo. * * @param str Unused. */ static void info_cargo_menu( unsigned int parent, char* str ) { (void) str; unsigned int wid; char **buf; int nbuf; int i; /* Create the window */ wid = window_create( "Cargo", -1, -1, CARGO_WIDTH, CARGO_HEIGHT ); window_setParent( wid, parent ); /* Buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "closeCargo", "Back", window_close ); window_addButton( wid, -40 - BUTTON_WIDTH, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", "Jettison", cargo_jettison ); window_disableButton( wid, "btnJettisonCargo" ); /* List */ if (player->ncommodities==0) { /* No cargo */ buf = malloc(sizeof(char*)); buf[0] = strdup("None"); nbuf = 1; } else { /* List the player's cargo */ buf = malloc(sizeof(char*)*player->ncommodities); for (i=0; i<player->ncommodities; i++) { buf[i] = malloc(sizeof(char)*128); snprintf(buf[i],128, "%s%s %d", player->commodities[i].commodity->name, (player->commodities[i].id != 0) ? "*" : "", player->commodities[i].quantity); } nbuf = player->ncommodities; } window_addList( wid, 20, -40, CARGO_WIDTH - 40, CARGO_HEIGHT - BUTTON_HEIGHT - 80, "lstCargo", buf, nbuf, 0, cargo_update ); cargo_update(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); }