/** * @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 main info window. */ static void info_openMain( unsigned int wid ) { char str[128], **buf, creds[ECON_CRED_STRLEN]; char **licenses; int nlicenses; int i; char *nt; int w, h; /* Get the dimensions. */ window_dimWindow( wid, &w, &h ); /* pilot generics */ nt = ntime_pretty( ntime_get(), 2 ); window_addText( wid, 40, 20, 120, h-80, 0, "txtDPilot", &gl_smallFont, &cDConsole, "Pilot:\n" "Date:\n" "Combat Rating:\n" "\n" "Money:\n" "Ship:\n" "Fuel:" ); credits2str( creds, player.p->credits, 2 ); snprintf( str, 128, "%s\n" "%s\n" "%s\n" "\n" "%s Credits\n" "%s\n" "%.0f (%d Jumps)", player.name, nt, player_rating(), creds, player.p->name, player.p->fuel, pilot_getJumps(player.p) ); window_addText( wid, 140, 20, 200, h-80, 0, "txtPilot", &gl_smallFont, &cBlack, str ); free(nt); /* menu */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", info_close ); /* List. */ buf = player_getLicenses( &nlicenses ); licenses = malloc(sizeof(char*)*nlicenses); for (i=0; i<nlicenses; i++) licenses[i] = strdup(buf[i]); window_addText( wid, -20, -40, w-80-200-40, 20, 1, "txtList", NULL, &cDConsole, "Licenses" ); window_addList( wid, -20, -70, w-80-200-40, h-110-BUTTON_HEIGHT, "lstLicenses", licenses, nlicenses, 0, NULL ); }
/** * @brief Gets the player's combat rating. * * @luareturn Returns the combat rating (in raw number) and the actual * standing in human readable form. * @luafunc getRating() */ static int playerL_getRating( lua_State *L ) { lua_pushnumber(L, player.crating); lua_pushstring(L, player_rating()); return 2; }