naev 0.11.5
info.c
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "naev.h"
13#include "info.h"
14
15#include "array.h"
16#include "dialogue.h"
17#include "equipment.h"
18#include "gui.h"
19#include "gui_osd.h"
20#include "hook.h"
21#include "land.h"
22#include "log.h"
23#include "map.h"
24#include "menu.h"
25#include "mission.h"
26#include "ndata.h"
27#include "nlua.h"
28#include "nlua_tk.h"
29#include "nstring.h"
30#include "ntime.h"
31#include "pilot.h"
32#include "player.h"
33#include "player_fleet.h"
34#include "player_gui.h"
35#include "player_inventory.h"
36#include "shiplog.h"
37#include "space.h"
38#include "tk/toolkit_priv.h"
39#include "toolkit.h"
40
41#define BUTTON_WIDTH 135
42#define BUTTON_HEIGHT 30
44#define menu_Open(f) (menu_open |= (f))
45#define menu_Close(f) (menu_open &= ~(f))
47#define INFO_WINDOWS 7
49#define INFO_WIN_MAIN 0
50#define INFO_WIN_SHIP 1
51#define INFO_WIN_WEAP 2
52#define INFO_WIN_CARGO 3
53#define INFO_WIN_MISN 4
54#define INFO_WIN_STAND 5
55#define INFO_WIN_SHIPLOG 6
56static const char *info_names[INFO_WINDOWS] = {
57 N_("Main"),
58 N_("Ship"),
59 N_("Weapons"),
60 N_("Cargo"),
61 N_("Missions"),
62 N_("Standings"),
63 N_("Ship log"),
64};
69typedef struct InfoButton_s {
70 int id;
71 char *caption;
72 char *button;
74 /* Lua stuff .*/
75 nlua_env env;
76 int func;
77 SDL_Keycode key;
79static InfoButton_t *info_buttons = NULL;
80
81static unsigned int info_wid = 0;
82static unsigned int *info_windows = NULL;
83static int info_lastTab;
85static CstSlotWidget info_eq;
86static CstSlotWidget info_eq_weaps;
87static int *info_factions;
88
89static int selectedMission = 0;
90static int selectedLog = 0;
91static int selectedLogType = 0;
92static char **logTypes=NULL;
93static int ntypes=0;
94static int nlogs=0;
95static char **logs=NULL;
96static int *logIDs=NULL;
97static int logWidgetsReady=0;
98
99/*
100 * prototypes
101 */
102/* information menu */
103static void info_close( unsigned int wid, const char *str );
104static void info_openMain( unsigned int wid );
105static void info_openShip( unsigned int wid );
106static void info_openWeapons( unsigned int wid );
107static void info_openCargo( unsigned int wid );
108static void info_openMissions( unsigned int wid );
109static void info_getDim( unsigned int wid, int *w, int *h, int *lw );
110static void info_buttonClick( unsigned int wid, const char *str );
111static void standings_close( unsigned int wid, const char *str );
112static void ship_update( unsigned int wid );
113static void weapons_genList( unsigned int wid );
114static void weapons_updateList( unsigned int wid, const char *str );
115static void weapons_toggleList( unsigned int wid, const char *str );
116static void weapons_clear( unsigned int wid, const char *str );
117static void weapons_clearAll( unsigned int wid, const char *str );
118static void weapons_autoweap( unsigned int wid, const char *str );
119static void weapons_inrange( unsigned int wid, const char *str );
120static void weapons_manual( unsigned int wid, const char *str );
121static void weapons_volley( unsigned int wid, const char *str );
122static void aim_lines( unsigned int wid, const char *str );
123static void weapons_renderLegend( double bx, double by, double bw, double bh, void* data );
124static void info_openStandings( unsigned int wid );
125static void info_shiplogView( unsigned int wid, const char *str );
126static void standings_update( unsigned int wid, const char *str );
127static void cargo_genList( unsigned int wid );
128static void cargo_update( unsigned int wid, const char *str );
129static void cargo_jettison( unsigned int wid, const char *str );
130static void mission_menu_chk_hide( unsigned int wid, const char *str );
131static void mission_menu_chk_priority( unsigned int wid, const char *str );
132static void mission_menu_abort( unsigned int wid, const char *str );
133static void mission_menu_genList( unsigned int wid, int first );
134static void mission_menu_update( unsigned int wid, const char *str );
135static void info_openShipLog( unsigned int wid );
136static const char* info_getLogTypeFilter( int lstPos );
137static void info_changeTab( unsigned int wid, const char *str, int old, int new );
138
139static int sort_buttons( const void *p1, const void *p2 )
140{
141 const InfoButton_t *b1 = p1;
142 const InfoButton_t *b2 = p2;
143 if (b1->priority < b2->priority)
144 return -1;
145 else if (b1->priority > b2->priority)
146 return +1;
147 return strcmp(b1->caption,b2->caption);
148}
149
150static void info_buttonFree( InfoButton_t *btn )
151{
152 free( btn->caption );
153 free( btn->button );
154 luaL_unref( naevL, LUA_REGISTRYINDEX, btn->func );
155}
156
157static void info_buttonRegen (void)
158{
159 int wid, w, h, rows, cols;
160 if (info_wid == 0)
161 return;
162
163 wid = info_windows[ INFO_WIN_MAIN ];
164 window_dimWindow( wid, &w, &h );
165 cols = (w-20) / (20+BUTTON_WIDTH);
166 rows = 1 + (array_size(info_buttons)) / cols;
167
168 for (int i=0; i<array_size(info_buttons); i++) {
169 const InfoButton_t *btn = &info_buttons[i];
170 int r = (i+1)/cols, c = (i+1)%cols;
171 if (widget_exists( wid, btn->button ))
172 window_destroyWidget( wid, btn->button );
173 window_addButtonKey( wid, -20 - c*(20+BUTTON_WIDTH), 20 + r*(20+BUTTON_HEIGHT),
174 BUTTON_WIDTH, BUTTON_HEIGHT,
175 btn->button, btn->caption, info_buttonClick, btn->key );
176 }
177 window_resizeWidget( wid, "lstInventory", w-80-300-40-40, h-90 - rows*(20+BUTTON_HEIGHT) );
178 window_moveWidget( wid, "lstInventory", -20, -70 );
179}
180
189int info_buttonRegister( const char *caption, int priority, SDL_Keycode key )
190{
191 static int button_idgen = 0;
192 int id;
193 InfoButton_t *btn;
194
195 if (info_buttons == NULL)
196 info_buttons = array_create( InfoButton_t );
197
198 btn = &array_grow( &info_buttons );
199 btn->id = ++button_idgen;
200 btn->caption= strdup( caption );
201 SDL_asprintf( &btn->button, "btnExtra::%s", caption );
202 btn->priority = priority;
203 btn->env = __NLUA_CURENV;
204 btn->func = luaL_ref( naevL, LUA_REGISTRYINDEX );
205 btn->key = key;
206
207 id = btn->id;
208 qsort( info_buttons, array_size(info_buttons), sizeof(InfoButton_t), sort_buttons );
209
210 info_buttonRegen();
211 return id;
212}
213
220int info_buttonUnregister( int id )
221{
222 for (int i=0; i<array_size(info_buttons); i++) {
223 InfoButton_t *btn = &info_buttons[i];
224 if (btn->id != id)
225 continue;
226 if (info_wid != 0) {
227 int wid = info_windows[ INFO_WIN_MAIN ];
228 if (widget_exists( wid, btn->button ))
229 window_destroyWidget( wid, btn->button );
230 }
231 info_buttonFree( btn );
232 array_erase( &info_buttons, btn, btn+1 );
233 info_buttonRegen();
234 return 0;
235 }
236 return -1;
237}
238
242void info_buttonClear (void)
243{
244 for (int i=0; i<array_size(info_buttons); i++) {
245 InfoButton_t *btn = &info_buttons[i];
246 if (info_wid != 0) {
247 int wid = info_windows[ INFO_WIN_MAIN ];
248 if (widget_exists( wid, btn->button ))
249 window_destroyWidget( wid, btn->button );
250 }
251 info_buttonFree( btn );
252 }
253 array_free( info_buttons );
254 info_buttons = NULL;
255 info_buttonRegen();
256}
257
258static void info_buttonClick( unsigned int wid, const char *str )
259{
260 (void) wid;
261 for (int i=0; i<array_size(info_buttons); i++) {
262 InfoButton_t *btn = &info_buttons[i];
263 if (strcmp( btn->button, str )!=0)
264 continue;
265
266 lua_rawgeti( naevL, LUA_REGISTRYINDEX, btn->func );
267 if (nlua_pcall( btn->env, 0, 0 )) {
268 WARN( _("Failure to run info button with id '%d':\n%s"), btn->id, lua_tostring( naevL, -1 ) );
269 lua_pop( naevL, 1 );
270 }
271 land_needsTakeoff( 1 ); /* Script said so? */
272 return;
273 }
274}
275
279void menu_info( int window )
280{
281 int w, h;
282 const char *names[INFO_WINDOWS];
283
284 /* Not under manual control. */
285 if (pilot_isFlag( player.p, PILOT_MANUAL_CONTROL ))
286 return;
287
288 /* Open closes when previously opened. */
290 if ((info_wid > 0) && !window_isTop(info_wid))
291 return;
292 info_close( 0, NULL );
293 return;
294 }
295
296 /* Dimensions. */
297 w = 700;
298 h = 700;
299
300 /* Create the window. */
301 info_wid = window_create( "wdwInfo", _("Info"), -1, -1, w, h );
302 window_setCancel( info_wid, info_close );
303
304 /* Create tabbed window. */
305 for (size_t i=0; i<INFO_WINDOWS; i++)
306 names[i] = _(info_names[i]);
307 info_windows = window_addTabbedWindow( info_wid, -1, -1, -1, -1, "tabInfo",
308 INFO_WINDOWS, names, 0 );
309
310 /* Open the subwindows. */
311 info_openMain( info_windows[ INFO_WIN_MAIN ] );
312 info_openShip( info_windows[ INFO_WIN_SHIP ] );
313 info_openWeapons( info_windows[ INFO_WIN_WEAP ] );
314 info_openCargo( info_windows[ INFO_WIN_CARGO ] );
315 info_openMissions( info_windows[ INFO_WIN_MISN ] );
316 info_openStandings( info_windows[ INFO_WIN_STAND ] );
317 info_openShipLog( info_windows[ INFO_WIN_SHIPLOG ] );
318
319 menu_Open(MENU_INFO);
320
321 /* Opening hooks. */
322 hooks_run("info");
323
324 /* Set active window. */
325 window_tabWinOnChange( info_wid, "tabInfo", info_changeTab );
326 if (window == INFO_DEFAULT)
327 window = info_lastTab;
328 window_tabWinSetActive( info_wid, "tabInfo", CLAMP( 0, 6, window ) );
329}
334static void info_close( unsigned int wid, const char *str )
335{
336 (void) wid;
337 if (info_wid > 0) {
338 info_lastTab = window_tabWinGetActive( info_wid, "tabInfo" );
339
340 /* Update weapon sets. */
342
343 /* Copy weapon sets over if changed. */
345
346 window_close( info_wid, str );
347 info_wid = 0;
348 info_windows = NULL;
349 logs = NULL;
350 menu_Close(MENU_INFO);
351 }
352}
353
357void info_update (void)
358{
359 if (info_windows != NULL)
360 weapons_genList( info_windows[ INFO_WIN_WEAP ] );
361}
362
366static void info_openMain( unsigned int wid )
367{
368 const char **lic;
369 char str[STRMAX_SHORT], creds[ECON_CRED_STRLEN];
370 char **inventory;
371 char *nt;
372 int w, h, cargo_used, cargo_total, n;
373 unsigned int destroyed;
374 const PlayerItem *inv;
375 size_t k = 0, l = 0;
376
377 /* Get the dimensions. */
378 window_dimWindow( wid, &w, &h );
379
380 /* Compute ships destroyed. */
381 destroyed = 0;
382 for (int i=0; i<SHIP_CLASS_TOTAL; i++)
383 destroyed += player.ships_destroyed[i];
384
385 /* pilot generics */
386 nt = ntime_pretty( ntime_get(), 2 );
387 k += scnprintf( &str[k], sizeof(str)-k, "%s", _("Pilot:") );
388 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Date:") );
389 k += scnprintf( &str[k], sizeof(str)-k, "\n\n%s", _("Money:") );
390 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Current Ship:") );
391 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Fuel:") );
392 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", (player.fleet_capacity > 0) ? _("Cargo (fleet):") : _("Cargo:") );
393 k += scnprintf( &str[k], sizeof(str)-k, "\n\n%s", _("Time played:") );
394 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Times died:") );
395 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Times jumped:") );
396 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Times landed:") );
397 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Damage done:") );
398 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Damage taken:") );
399 /*k +=*/ scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Ships destroyed:") );
400 window_addText( wid, 20, 20, 160, h-80, 0, "txtDPilot", &gl_smallFont, &cFontGrey, str );
401
402 credits2str( creds, player.p->credits, 2 );
403 l += scnprintf( &str[l], sizeof(str)-l, "%s", player.name );
404 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", nt );
405 l += scnprintf( &str[l], sizeof(str)-l, "\n\n%s", creds );
406 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", player.p->name );
407 l += scnprintf( &str[l], sizeof(str)-l, "\n%.0f %s (%d %s)",
408 player.p->fuel, UNIT_UNIT, pilot_getJumps(player.p), n_( "jump", "jumps", pilot_getJumps(player.p) ) );
409 cargo_used = pfleet_cargoUsed();
410 cargo_total = cargo_used + pfleet_cargoFree();
411 l += scnprintf( &str[l], sizeof(str)-l, "\n%d / %d %s", cargo_used, cargo_total, UNIT_MASS );
412 l += scnprintf( &str[l], sizeof(str)-l, "%s", "\n\n" );
413 l += scnprintf( &str[l], sizeof(str)-l, _("%.1f hours"), player.time_played / 3600. );
414 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", num2strU((double)player.death_counter,0) );
415 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", num2strU((double)player.jumped_times, 0) );
416 l += scnprintf( &str[l], sizeof(str)-l, "\n%s\n", num2strU((double)player.landed_times, 0) );
417 l += scnprintf( &str[l], sizeof(str)-l, _("%s %s"), num2strU(player.dmg_done_shield + player.dmg_done_armour, 0), UNIT_ENERGY );
418 l += scnprintf( &str[l], sizeof(str)-l, "\n" );
419 l += scnprintf( &str[l], sizeof(str)-l, _("%s %s"), num2strU(player.dmg_taken_shield + player.dmg_taken_armour, 0), UNIT_ENERGY );
420 /*l +=*/ scnprintf( &str[l], sizeof(str)-l, "\n%s", num2strU(destroyed, 0) );
421 window_addText( wid, 200, 20,
422 w-80-200-40+20-180, h-80,
423 0, "txtPilot", &gl_smallFont, NULL, str );
424 free(nt);
425
426 /* menu */
427 window_addButton( wid, -20, 20,
428 BUTTON_WIDTH, BUTTON_HEIGHT,
429 "btnClose", _("Close"), info_close );
430
431 /* TODO probably add alt text with descriptions. */
432 lic = player_getLicenses();
433 inv = player_inventory();
434 n = array_size(lic) + array_size(inv);
435 /* List. */
436 if (n == 0) {
437 inventory = malloc(sizeof(char*));
438 inventory[0] = strdup(_("None"));
439 n = 1;
440 }
441 else {
442 int nlic = array_size(lic);
443 int ninv = array_size(inv);
444 inventory = malloc(sizeof(char*) * n);
445 for (int i=0; i<nlic; i++)
446 SDL_asprintf( &inventory[i], "#n%s#0%s", _("License: "), _(lic[i]) );
447 qsort( inventory, nlic, sizeof(char*), strsort );
448 for (int i=0; i<ninv; i++) {
449 const PlayerItem *pi = &inv[i];
450 if (pi->quantity == 0)
451 SDL_asprintf( &inventory[nlic+i], "%s", _(pi->name) );
452 else
453 SDL_asprintf( &inventory[nlic+i], _("%s (%s)"), _(pi->name), num2strU(pi->quantity,0) );
454 }
455 qsort( &inventory[nlic], ninv, sizeof(char*), strsort );
456 }
457 window_addText( wid, -20, -40, w-80-300-40-40, 20, 1, "txtList",
458 NULL, NULL, _("Inventory") );
459 window_addList( wid, -20, -70, w-80-300-40-40, h-110-BUTTON_HEIGHT,
460 "lstInventory", inventory, n, 0, NULL, NULL );
461 window_setFocus( wid, "lstInventory" );
462
463 info_buttonRegen();
464}
465
471static void info_openShip( unsigned int wid )
472{
473 int w, h;
474 char buf[STRMAX];
475 size_t l = 0;
476
477 /* Get the dimensions. */
478 window_dimWindow( wid, &w, &h );
479
480 /* Buttons */
481 window_addButton( wid, -20, 20,
482 BUTTON_WIDTH, BUTTON_HEIGHT,
483 "closeOutfits", _("Close"), info_close );
484
485 /* Text. */
486 l += scnprintf( &buf[l], sizeof(buf)-l, "%s", _("Name:") );
487 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Model:") );
488 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Class:") );
489 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Crew:") );
490 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
491 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Mass:") );
492 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Jump Time:") );
493 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Accel:") );
494 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Speed:") );
495 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Turn:") );
496 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Time Constant:") );
497 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
498 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Absorption:") );
499 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Shield:") );
500 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Armour:") );
501 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Energy:") );
502 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Cargo Space:") );
503 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Fuel:") );
504 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
505 /*l +=*/ scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Stats:") );
506 window_addText( wid, 20, -40, 160, h-60, 0, "txtSDesc", &gl_smallFont, &cFontGrey, buf );
507 window_addText( wid, 200, -40, w-20-20-20-200-180., h-60, 0, "txtDDesc", &gl_smallFont,
508 NULL, NULL );
509
510 /* Custom widget. */
511 equipment_slotWidget( wid, -20, -40, 180, h-60, &info_eq );
512 info_eq.selected = &player.ps;
513 info_eq.canmodify = 0;
514
515 /* Update ship. */
516 ship_update( wid );
517}
518
522static void ship_update( unsigned int wid )
523{
524 char buf[STRMAX_SHORT], *hyp_delay;
525 char sshield[NUM2STRLEN], sarmour[NUM2STRLEN], senergy[NUM2STRLEN];
526 char scargo[NUM2STRLEN], sfuel[NUM2STRLEN];
527 size_t l = 0;
528 int cargo = pilot_cargoUsed( player.p ) + pilot_cargoFree( player.p );
529
530 /* Some helpers. */
531 num2str( sshield, player.p->shield, 0 );
532 num2str( sarmour, player.p->armour, 0 );
533 num2str( senergy, player.p->energy, 0 );
534 num2str( scargo, pilot_cargoUsed(player.p), 0 );
535 num2str( sfuel, player.p->fuel, 0 );
536
537 hyp_delay = ntime_pretty( pilot_hyperspaceDelay( player.p ), 2 );
538 /* Generic */
539 l += scnprintf( &buf[l], sizeof(buf)-l, "%s", player.p->name );
540 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _(player.p->ship->name) );
541 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _(ship_class(player.p->ship)) );
542 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%d", (int)floor(player.p->crew) );
543 /* Movement. */
544 l += scnprintf( &buf[l], sizeof(buf)-l, "\n\n" );
545 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s %s"), num2strU(player.p->solid.mass,0), UNIT_MASS );
546 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
547 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s average"), hyp_delay );
548 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
549 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f %s"), player.p->accel, UNIT_ACCEL );
550 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
551 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f %s (max %.0f %s)"),
552 player.p->speed, UNIT_SPEED, solid_maxspeed( &player.p->solid, player.p->speed, player.p->accel ), UNIT_SPEED );
553 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
554 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f %s"), player.p->turn*180./M_PI, UNIT_ROTATION );
555 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%.0f%%", player.p->stats.time_mod * player.p->ship->dt_default*100. );
556 /* Health. */
557 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
558 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%.0f%%", player.p->dmg_absorb*100. );
559 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
560 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s / %s %s"),
561 sshield, num2strU(player.p->shield_max,0), UNIT_ENERGY );
562 l += scnprintf( &buf[l], sizeof(buf)-l, _(" (%s %s)"),
563 num2strU(player.p->shield_regen,1), UNIT_POWER );
564 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
565 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s / %s %s"),
566 sarmour, num2strU(player.p->armour_max,0), UNIT_ENERGY );
567 l += scnprintf( &buf[l], sizeof(buf)-l, _(" (%s %s)"),
568 num2strU(player.p->armour_regen,1), UNIT_POWER );
569 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
570 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s / %s %s"),
571 senergy, num2strU(player.p->energy_max,0), UNIT_ENERGY );
572 l += scnprintf( &buf[l], sizeof(buf)-l, _(" (%s %s)"),
573 num2strU(player.p->energy_regen,1), UNIT_POWER );
574 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
575 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s / %s %s"), scargo, num2strU(cargo,0), UNIT_MASS );
576 l += scnprintf( &buf[l], sizeof(buf)-l, "\n" );
577 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s / %s %s (%d %s)"),
578 sfuel, num2strU(player.p->fuel_max,0), UNIT_UNIT,
579 pilot_getJumps(player.p), n_( "jump", "jumps", pilot_getJumps(player.p) ) );
580 l += scnprintf( &buf[l], sizeof(buf)-l, "%s", "\n\n" );
581
582 equipment_shipStats( &buf[l], sizeof(buf)-l, player.p, 0, 0 );
583 window_modifyText( wid, "txtDDesc", buf );
584 free( hyp_delay );
585}
586
590static void info_openWeapons( unsigned int wid )
591{
592 int w, h, x, y, wlen;
593
594 /* Get the dimensions. */
595 window_dimWindow( wid, &w, &h );
596
597 /* Custom widget. */
598 equipment_slotWidget( wid, 20, -40, 180, h-60, &info_eq_weaps );
599 info_eq_weaps.selected = &player.ps;
600 info_eq_weaps.weapons = 0;
601 info_eq_weaps.canmodify = 0;
602
603 /* Custom widget for legend. */
604 y = -240;
605 window_addCust( wid, 220, y, w-200-60, 100, "cstLegend", 0,
606 weapons_renderLegend, NULL, NULL, NULL, NULL );
607
608 /* Checkboxes. */
609 wlen = w - 220 - 20;
610 x = 220;
611 y -= 95;
612 window_addButton( wid, x+10, y, BUTTON_WIDTH, BUTTON_HEIGHT,
613 "btnCycle", _("Cycle Mode"), weapons_toggleList );
614 window_addButton( wid, x+10+(BUTTON_WIDTH+10), y, BUTTON_WIDTH, BUTTON_HEIGHT,
615 "btnClear", _("Clear"), weapons_clear );
616 window_addButton( wid, x+10+(BUTTON_WIDTH+10)*2, y, BUTTON_WIDTH, BUTTON_HEIGHT,
617 "btnClearAll", _("Clear All"), weapons_clearAll );
618 y -= BUTTON_HEIGHT+10;
619 window_addText( wid, x+10, y, wlen, 100, 0, "txtSMode", NULL, NULL,
620 _("Cycles through the following modes:\n"
621 "- Switch: sets the selected weapons as primary and secondary weapons.\n"
622 "- Hold: turns on the selected outfits as long as key is held\n"
623 "- Toggle: toggles the selected outfits to on or off state"
624 ));
625 y -= 8+window_getTextHeight( wid, "txtSMode" );
626 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
627 "chkManual", _("Enable manual aiming mode"), weapons_manual,
628 pilot_weapSetManualCheck( player.p, info_eq_weaps.weapons ) );
629 y -= 28;
630 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
631 "chkVolley", _("Enable volley mode (weapons fire jointly)"), weapons_volley,
632 pilot_weapSetVolleyCheck( player.p, info_eq_weaps.weapons ) );
633 y -= 28;
634 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
635 "chkInrange", _("Only shoot weapons that are in range"), weapons_inrange,
636 pilot_weapSetInrangeCheck( player.p, info_eq_weaps.weapons ) );
637 y -= 28;
638 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
639 "chkHelper", _("Dogfight visual aiming helper (all sets)"), aim_lines, player.p->aimLines );
640 y -= 28;
641 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
642 "chkAutoweap", _("Automatically handle all weapons sets"), weapons_autoweap, player.p->autoweap );
643
644 /* List. Has to be generated after checkboxes. */
645 weapons_genList( wid );
646
647 /* Buttons */
648 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
649 "closeCargo", _("Close"), info_close );
650}
651
655static void weapons_genList( unsigned int wid )
656{
657 char **buf, tbuf[STRMAX_SHORT];
658 int n, w, h;
659
660 /* Get the dimensions. */
661 window_dimWindow( wid, &w, &h );
662
663 /* Destroy widget if needed. */
664 if (widget_exists( wid, "lstWeapSets" )) {
665 window_destroyWidget( wid, "lstWeapSets" );
666 n = toolkit_getListPos( wid, "lstWeapSets" );
667 }
668 else
669 n = -1;
670
671 /* List */
672 buf = malloc( sizeof(char*) * PILOT_WEAPON_SETS );
673 for (int i=0; i<PILOT_WEAPON_SETS; i++) {
674 const char *str = pilot_weapSetName( info_eq_weaps.selected->p, i );
675 if (str == NULL)
676 snprintf( tbuf, sizeof(tbuf), "%d - ??", (i+1)%10 );
677 else
678 snprintf( tbuf, sizeof(tbuf), "%d - %s", (i+1)%10, str );
679 buf[i] = strdup( tbuf );
680 }
681 window_addList( wid, 20+180+20, -40,
682 w - (20+180+20+20), 200,
683 "lstWeapSets", buf, PILOT_WEAPON_SETS,
684 0, weapons_updateList, weapons_toggleList );
685 window_setFocus( wid, "lstWeapSets" );
686
687 /* Restore position. */
688 if (n >= 0)
689 toolkit_setListPos( wid, "lstWeapSets", n );
690}
691
695static void weapons_updateList( unsigned int wid, const char *str )
696{
697 (void) str;
698 int pos;
699
700 /* Update the position. */
701 pos = toolkit_getListPos( wid, "lstWeapSets" );
702 if (pos < 0)
703 return;
704 info_eq_weaps.weapons = pos;
705
706 /* Update inrange. */
707 window_checkboxSet( wid, "chkInrange",
709
710 /* Update manual aiming. */
711 window_checkboxSet( wid, "chkManual",
713
714 /* Update autoweap. */
715 window_checkboxSet( wid, "chkAutoweap", player.p->autoweap );
716}
717
718static void weapons_toggleList( unsigned int wid, const char *str )
719{
720 int i, t, c;
721 (void) str;
722
723 /* See how to handle. */
724 t = pilot_weapSetTypeCheck( player.p, info_eq_weaps.weapons );
725 switch (t) {
726 case WEAPSET_TYPE_SWITCH:
727 c = WEAPSET_TYPE_HOLD;
728 break;
729 case WEAPSET_TYPE_HOLD:
730 c = WEAPSET_TYPE_TOGGLE;
731 break;
732 case WEAPSET_TYPE_TOGGLE:
733 c = WEAPSET_TYPE_SWITCH;
734 break;
735 default:
736 /* Shouldn't happen... but shuts up GCC */
737 c = WEAPSET_TYPE_SWITCH;
738 break;
739 }
740 pilot_weapSetType( player.p, info_eq_weaps.weapons, c );
741
742 /* Check to see if they are all fire groups. */
743 for (i=0; i<PILOT_WEAPON_SETS; i++)
744 if (pilot_weapSetTypeCheck( player.p, i )==WEAPSET_TYPE_SWITCH)
745 break;
746
747 /* Not able to set them all to fire groups. */
748 if (i >= PILOT_WEAPON_SETS) {
749 dialogue_alert(_("You need at least one switch group!"));
750 pilot_weapSetType( player.p, info_eq_weaps.weapons, WEAPSET_TYPE_SWITCH );
751 }
752
753 /* Set default if needs updating. */
755
756 /* Must regen. */
757 weapons_genList( wid );
758}
759
763static void weapons_clear( unsigned int wid, const char *str )
764{
765 (void) str;
766 pilot_weapSetClear( player.p, info_eq_weaps.weapons );
767
768 /* Must regen. */
769 weapons_genList( wid );
770}
771
775static void weapons_clearAll( unsigned int wid, const char *str )
776{
777 (void) str;
778 int sure = dialogue_YesNoRaw( _("Clear All Weapon Sets?"),
779 _("Are you sure you want to clear all your current weapon sets?") );
780 if (!sure)
781 return;
782
783 /* Clear them all. */
784 for (int i=0; i<PILOT_WEAPON_SETS; i++)
786
787 /* Must regen. */
788 weapons_genList( wid );
789}
790
794static void weapons_autoweap( unsigned int wid, const char *str )
795{
796 /* Set state. */
797 int state = window_checkboxState( wid, str );
798
799 /* Run autoweapons if needed. */
800 if (state) {
801 int sure = dialogue_YesNoRaw( _("Enable autoweapons?"),
802 _("Are you sure you want to enable automatic weapon groups for the "
803 "ship?\n\nThis will overwrite all manually-tweaked weapons groups.") );
804 if (!sure) {
805 window_checkboxSet( wid, str, 0 );
806 return;
807 }
808 player.p->autoweap = 1;
810 weapons_genList( wid );
811 }
812 else
813 player.p->autoweap = 0;
814}
815
819static void weapons_inrange( unsigned int wid, const char *str )
820{
821 int state = window_checkboxState( wid, str );
822 pilot_weapSetInrange( player.p, info_eq_weaps.weapons, state );
823}
824
828static void weapons_manual( unsigned int wid, const char *str )
829{
830 int state = window_checkboxState( wid, str );
831 pilot_weapSetManual( player.p, info_eq_weaps.weapons, state );
832}
833
837static void weapons_volley( unsigned int wid, const char *str )
838{
839 int state = window_checkboxState( wid, str );
840 pilot_weapSetVolley( player.p, info_eq_weaps.weapons, state );
841}
842
846static void aim_lines( unsigned int wid, const char *str )
847{
848 int state = window_checkboxState( wid, str );
849 player.p->aimLines = state;
850}
851
855static void weapons_renderLegend( double bx, double by, double bw, double bh, void* data )
856{
857 (void) data;
858 (void) bw;
859 (void) bh;
860 double y;
861
862 y = by+bh-20;
863 gl_print( &gl_defFont, bx, y, &cFontWhite, p_("info", "Legend") );
864
865 y -= 20.;
866 toolkit_drawRect( bx, y, 10, 10, &cFontBlue, NULL );
867 gl_print( &gl_smallFont, bx+20, y, &cFontWhite, _("Outfit that can be activated") );
868
869 y -= 20.;
870 toolkit_drawRect( bx, y, 10, 10, &cFontYellow, NULL );
871 gl_print( &gl_smallFont, bx+20, y, &cFontWhite, _("Secondary Weapon (Right click toggles)") );
872
873 y -= 20.;
874 toolkit_drawRect( bx, y, 10, 10, &cFontRed, NULL );
875 gl_print( &gl_smallFont, bx+20, y, &cFontWhite, _("Primary Weapon (Left click toggles)") );
876}
877
883static void info_openCargo( unsigned int wid )
884{
885 int w, h;
886
887 /* Get the dimensions. */
888 window_dimWindow( wid, &w, &h );
889
890 /* Buttons */
891 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
892 "closeCargo", _("Close"), info_close );
893 window_addButton( wid, -20-BUTTON_WIDTH-10, 20,
894 BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", _("Jettison"),
895 cargo_jettison );
896 window_disableButton( wid, "btnJettisonCargo" );
897
898 /* Description. */
899 window_addText( wid, 20, -40-200-20,
900 w - 40, h - BUTTON_HEIGHT - 260, 0,
901 "txtCargoDesc", NULL, NULL, NULL );
902
903 /* Generate the list. */
904 cargo_genList( wid );
905}
909static void cargo_genList( unsigned int wid )
910{
911 char **buf;
912 int nbuf;
913 int w, h;
915
916 /* Get the dimensions. */
917 window_dimWindow( wid, &w, &h );
918
919 /* Destroy widget if needed. */
920 if (widget_exists( wid, "lstCargo" ))
921 window_destroyWidget( wid, "lstCargo" );
922
923 /* List */
924 if (array_size(pclist)==0) {
925 /* No cargo */
926 buf = malloc(sizeof(char*));
927 buf[0] = strdup(_("None"));
928 nbuf = 1;
929 }
930 else {
931 /* List the player fleet's cargo. */
932 buf = malloc( sizeof(char*) * array_size(pclist) );
933 for (int i=0; i<array_size(pclist); i++) {
934 PilotCommodity *pc = &pclist[i];
935 int misn = (pc->id != 0);
936 int illegal = (array_size(pc->commodity->illegalto)>0);
937
938 SDL_asprintf(&buf[i], "%s %d%s%s",
939 _(pc->commodity->name),
940 pc->quantity,
941 misn ? _(" [#bMission#0]") : "",
942 illegal ? _(" (#rillegal#0)") : "" );
943 }
944 nbuf = array_size(pclist);
945 }
946 array_free(pclist);
947 window_addList( wid, 20, -40, w - 40, 200,
948 "lstCargo", buf, nbuf, 0, cargo_update, NULL );
949 window_setFocus( wid, "lstCargo" );
950}
955static void cargo_update( unsigned int wid, const char *str )
956{
957 (void) str;
958 char desc[STRMAX];
959 int pos, l;
960 const Commodity *com;
962
963 if (array_size(pclist) <= 0) {
964 window_modifyText( wid, "txtCargoDesc", NULL );
965 array_free(pclist);
966 return; /* No cargo, redundant check */
967 }
968
969 /* Can jettison all but mission cargo when not landed*/
970 if (landed)
971 window_disableButton( wid, "btnJettisonCargo" );
972 else
973 window_enableButton( wid, "btnJettisonCargo" );
974
975 pos = toolkit_getListPos( wid, "lstCargo" );
976 com = pclist[pos].commodity;
977
978 if (!com->description)
979 l = scnprintf( desc, sizeof(desc), "%s", _(com->name) );
980 else
981 l = scnprintf( desc, sizeof(desc), "%s\n\n%s", _(com->name), _(com->description) );
982
983 /* Only add fleet information with fleet capacity. */
984 if ((player.fleet_capacity > 0) && (pclist[pos].quantity > 0)) {
985 l += scnprintf( &desc[l], sizeof(desc)-l, "\n\n%s", _("Carried by the following ships in your fleet:\n") );
986 PFleetCargo *plist = pfleet_cargoListShips( com );
987 for (int i=0; i<array_size(plist); i++)
988 l += scnprintf( &desc[l], sizeof(desc)-l, _("\n - %s (%d)"), plist[i].p->name, plist[i].q );
989 array_free(plist);
990 }
991
992 /* Add message on illegal outfits. */
993 if (array_size(com->illegalto) > 0) {
994 l += scnprintf( &desc[l], sizeof(desc)-l, "\n\n%s", _("Illegalized by the following factions:\n") );
995 for (int i=0; i<array_size(com->illegalto); i++) {
996 int f = com->illegalto[i];
997 if (!faction_isKnown(f))
998 continue;
999
1000 l += scnprintf( &desc[l], sizeof(desc)-l, _("\n - %s"), _(faction_name(f)) );
1001 }
1002 }
1003 window_modifyText( wid, "txtCargoDesc", desc );
1004
1005 array_free(pclist);
1006}
1011static void cargo_jettison( unsigned int wid, const char *str )
1012{
1013 (void)str;
1014 int pos;
1015 HookParam hparam[3];
1016 PilotCommodity *pclist = pfleet_cargoList();
1017
1018 if (array_size(pclist) <= 0) {
1019 array_free(pclist);
1020 return; /* No cargo, redundant check */
1021 }
1022
1023 pos = toolkit_getListPos( wid, "lstCargo" );
1024
1025 /* Special case mission cargo. */
1026 if (pclist[pos].id != 0) {
1027 int f, ret;
1028 Mission *misn;
1029
1030 if (!dialogue_YesNo( _("Abort Mission"),
1031 _("Are you sure you want to abort this mission?") )) {
1032 array_free(pclist);
1033 return;
1034 }
1035
1036 /* Get the mission. */
1037 f = -1;
1038 for (int i=0; i<array_size(player_missions); i++) {
1039 for (int j=0; j<array_size(player_missions[i]->cargo); j++) {
1040 if (player_missions[i]->cargo[j] == pclist[pos].id) {
1041 f = i;
1042 break;
1043 }
1044 }
1045 if (f >= 0)
1046 break;
1047 }
1048 if (f < 0) {
1049 WARN(_("Cargo '%d' does not belong to any active mission."),
1050 pclist[pos].id);
1051 array_free( pclist );
1052 return;
1053 }
1054 misn = player_missions[f];
1055
1056 /* We run the "abort" function if it's found. */
1057 ret = misn_tryRun( misn, "abort" );
1058
1059 /* Now clean up mission. */
1060 if (ret != 2) {
1061 mission_cleanup( misn );
1062 mission_shift(pos);
1063 }
1064
1065 /* Reset markers. */
1067
1068 /* Reset claims. */
1070
1071 /* Regenerate list. */
1072 mission_menu_genList( info_windows[ INFO_WIN_MISN ], 0 );
1073 }
1074 else
1075 /* Remove the cargo */
1076 pfleet_cargoRm( pclist[pos].commodity, pclist[pos].quantity, 1 );
1077
1078 /* We reopen the menu to recreate the list now. */
1079 ship_update( info_windows[ INFO_WIN_SHIP ] );
1080 cargo_genList( wid );
1081 cargo_update( wid, NULL );
1082
1083 /* Run hooks. */
1084 hparam[0].type = HOOK_PARAM_COMMODITY;
1085 hparam[0].u.commodity = (Commodity*) pclist[pos].commodity; /* TODO not cast */
1086 hparam[1].type = HOOK_PARAM_NUMBER;
1087 hparam[1].u.num = pclist[pos].quantity;
1088 hparam[2].type = HOOK_PARAM_SENTINEL;
1089 hooks_runParam( "comm_jettison", hparam );
1090
1091 /* Clean up. */
1092 array_free( pclist );
1093}
1094
1098static void info_getDim( unsigned int wid, int *w, int *h, int *lw )
1099{
1100 /* Get the dimensions. */
1101 window_dimWindow( wid, w, h );
1102 *lw = *w-60-BUTTON_WIDTH-190;
1103}
1104
1108static void standings_close( unsigned int wid, const char *str )
1109{
1110 (void) wid;
1111 (void) str;
1112 array_free(info_factions);
1113 info_factions = NULL;
1114}
1115
1116static int factionsSort( const void *p1, const void *p2 )
1117{
1118 int f1, f2;
1119 double v1, v2;
1120 f1 = *(int*)p1;
1121 f2 = *(int*)p2;
1122 v1 = round(faction_getPlayer(f1));
1123 v2 = round(faction_getPlayer(f2));
1124 if (v1 < v2)
1125 return 1;
1126 else if (v1 > v2)
1127 return -1;
1128 return strcmp(faction_longname(f1), faction_longname(f2));
1129}
1133static void info_openStandings( unsigned int wid )
1134{
1135 char **str;
1136 int w, h, lw;
1137
1138 /* Get dimensions. */
1139 info_getDim( wid, &w, &h, &lw );
1140
1141 /* On close. */
1142 window_onClose( wid, standings_close );
1143
1144 /* Buttons */
1145 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1146 "closeMissions", _("Close"), info_close );
1147
1148 /* Graphics. */
1149 window_addImage( wid, 0, 0, 0, 0, "imgLogo", NULL, 0 );
1150
1151 /* Text. */
1152 window_addText( wid, lw+40, 0, (w-(lw+60)), 20, 0, "txtName",
1153 &gl_defFont, NULL, NULL );
1154 window_addText( wid, lw+40, 0, (w-(lw+60)), 20, 0, "txtStanding",
1155 &gl_defFont, NULL, NULL );
1156 window_addText( wid, lw+40, 0, (w-(lw+60)), h-80, 0, "txtDescription",
1157 &gl_defFont, NULL, NULL );
1158
1159 /* Gets the faction standings. */
1160 info_factions = faction_getKnown();
1161 str = malloc( sizeof(char*) * array_size(info_factions) );
1162 qsort( info_factions, array_size(info_factions), sizeof(int), factionsSort );
1163
1164 /* Create list. */
1165 for (int i=0; i<array_size(info_factions); i++) {
1166 int m = round( faction_getPlayer( info_factions[i] ) );
1167 SDL_asprintf( &str[i], "%s [ #%c%+d%%#0 ]",
1168 faction_longname( info_factions[i] ),
1169 faction_getColourChar( info_factions[i] ), m );
1170 }
1171
1172 /* Display list. */
1173 window_addList( wid, 20, -40, lw, h-60, "lstStandings",
1174 str, array_size(info_factions), 0, standings_update, NULL );
1175 window_setFocus( wid, "lstStandings" );
1176}
1177
1181static void standings_update( unsigned int wid, const char *str )
1182{
1183 (void) str;
1184 int p, x, y;
1185 const glTexture *t;
1186 int w, h, lw, m, l;
1187 const int *flist;
1188 char buf[STRMAX];
1189
1190 /* Get dimensions. */
1191 info_getDim( wid, &w, &h, &lw );
1192
1193 /* Get faction. */
1194 p = toolkit_getListPos( wid, "lstStandings" );
1195
1196 /* Render logo. */
1197 x = lw+40;
1198 y = -40;
1199 t = faction_logo( info_factions[p] );
1200 if (t != NULL) {
1201 int tw = t->w * (double)FACTION_LOGO_SM / MAX( t->w, t->h );
1202 int th = t->h * (double)FACTION_LOGO_SM / MAX( t->w, t->h );
1203 window_modifyImage( wid, "imgLogo", t, tw, th );
1204 window_moveWidget( wid, "imgLogo", x + (FACTION_LOGO_SM-tw), y - (FACTION_LOGO_SM-th)/2 );
1205 x += FACTION_LOGO_SM+20;
1206 //y -= FACTION_LOGO_SM;
1207 }
1208 else
1209 window_modifyImage( wid, "imgLogo", NULL, 0, 0 );
1210
1211 /* Modify text. */
1212 y -= 10;
1213 m = round( faction_getPlayer( info_factions[p] ) );
1214 snprintf( buf, sizeof(buf), p_("standings","#%c%+d%%#0 [ %s ]"),
1215 faction_getColourChar( info_factions[p] ), m,
1216 faction_getStandingText( info_factions[p] ) );
1217 window_modifyText( wid, "txtName", faction_longname( info_factions[p] ) );
1218 window_moveWidget( wid, "txtName", x, y );
1219 y -= 20;
1220 window_modifyText( wid, "txtStanding", buf );
1221 window_moveWidget( wid, "txtStanding", x, y );
1222 y -= 50;
1223 l = scnprintf( buf, sizeof(buf), "%s\n\n", faction_description( info_factions[p] ) );
1224 l += scnprintf( &buf[l], sizeof(buf)-l, _("You can have a maximum reputation of %.0f%% with this faction."), round(faction_reputationMax( info_factions[p] )) );
1225
1226 flist = faction_getAllies( info_factions[p] );
1227 if (array_size(flist)>0) {
1228 int added = 0;
1229 for (int i=0; i<array_size(flist); i++) {
1230 int f = flist[i];
1232 continue;
1233
1234 if (added==0) {
1235 l += scnprintf( &buf[l], sizeof(buf)-l, "\n\n%s", _("Ally Factions:") );
1236 added = 1;
1237 }
1238 l += scnprintf( &buf[l], sizeof(buf)-l, "\n- %s", faction_longname( f ) );
1239 }
1240 }
1241 flist = faction_getEnemies( info_factions[p] );
1242 if (array_size(flist)>0) {
1243 int added = 0;
1244 for (int i=0; i<array_size(flist); i++) {
1245 int f = flist[i];
1247 continue;
1248
1249 if (added==0) {
1250 l += scnprintf( &buf[l], sizeof(buf)-l, "\n\n%s", _("Enemy Factions:") );
1251 added = 1;
1252 }
1253 l += scnprintf( &buf[l], sizeof(buf)-l, "\n- %s", faction_longname( f ) );
1254 }
1255 }
1256
1257 window_modifyText( wid, "txtDescription", buf );
1258 window_moveWidget( wid, "txtDescription", lw+40, y );
1259}
1260
1267static void info_openMissions( unsigned int wid )
1268{
1269 int w, h;
1270
1271 /* Get the dimensions. */
1272 window_dimWindow( wid, &w, &h );
1273
1274 /* buttons */
1275 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1276 "closeMissions", _("Close"), info_close );
1277 window_addButtonKey( wid, -20-BUTTON_WIDTH-10, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1278 "btnAbortMission", _("Abort"), mission_menu_abort, SDLK_a );
1279
1280 /* Add a checkbox to hide the mission. */
1281 window_addCheckbox( wid, 300+40, 20+BUTTON_HEIGHT+10,
1282 w-300-60, BUTTON_HEIGHT,
1283 "chkHide", _("Hide mission on-screen display"),
1284 mission_menu_chk_hide, 0 );
1285 /* Checkbox to make the mission be top. */
1286 window_addCheckbox( wid, 300+40, 20+BUTTON_HEIGHT+10+gl_defFont.h+10,
1287 w-300-60, BUTTON_HEIGHT,
1288 "chkPrefer", _("Prioritize the mission"),
1289 mission_menu_chk_priority, 0 );
1290
1291 /* Mission Description */
1292 window_addText( wid, 300+40, -40,
1293 w-300-60, h - BUTTON_HEIGHT - 120, 0, "txtDesc",
1294 NULL, NULL, NULL );
1295
1296 /* Put a map. */
1297 map_show( wid, 20, 20, 300, 260, 0.75, 0., 0. );
1298
1299 /* list */
1300 mission_menu_genList(wid ,1);
1301}
1306static void mission_menu_genList( unsigned int wid, int first )
1307{
1308 int j;
1309 char** misn_names;
1310 int w, h;
1311
1312 if (!first)
1313 window_destroyWidget( wid, "lstMission" );
1314
1315 /* Get the dimensions. */
1316 window_dimWindow( wid, &w, &h );
1317
1318 /* list */
1319 misn_names = malloc(sizeof(char*) * MAX(1, array_size(player_missions)));
1320 selectedMission = -1;
1321 j = 0;
1322 for (int i=0; i<array_size(player_missions); i++)
1323 if (player_missions[i]->id != 0)
1324 misn_names[j++] = (player_missions[i]->title != NULL) ?
1325 strdup(player_missions[i]->title) : NULL;
1326
1327 if (j==0) { /* no missions */
1328 misn_names[j++] = strdup(_("No Missions"));
1329 window_modifyText( wid, "txtDesc", _("You currently have no active missions.") );
1330 window_disableButton( wid, "btnAbortMission" );
1331 window_disableCheckbox( wid, "chkHide" );
1332 window_disableCheckbox( wid, "chkPrefer" );
1333 selectedMission = 0; /* misn_menu_update should do nothing. */
1334 }
1335 window_addList( wid, 20, -40,
1336 300, h-340,
1337 "lstMission", misn_names, j, selectedMission, mission_menu_update, NULL );
1338 window_setFocus( wid, "lstMission" );
1339}
1344static void mission_menu_update( unsigned int wid, const char *str )
1345{
1346 (void) str;
1347 char buf[STRMAX];
1348 Mission* misn;
1349 const StarSystem *sys;
1350 int pos = toolkit_getListPos(wid, "lstMission" );
1351
1352 if (pos < 0 || pos == selectedMission)
1353 return;
1354
1355 /* Modify the text. */
1356 selectedMission = pos;
1357 misn = player_missions[selectedMission];
1358 snprintf( buf, sizeof(buf),_("%s\n#nReward:#0 %s\n\n%s"), misn->title, misn->reward, misn->desc );
1359 window_modifyText( wid, "txtDesc", buf );
1360 window_enableButton( wid, "btnAbortMission" );
1361 window_enableCheckbox( wid, "chkHide" );
1362 window_enableCheckbox( wid, "chkPrefer" );
1363 if (misn->osd == 0) {
1364 window_checkboxSet( wid, "chkHide", 0 );
1365 window_checkboxSet( wid, "chkPrefer", 0 );
1366 }
1367 else {
1368 window_checkboxSet( wid, "chkHide", osd_getHide( misn->osd ) );
1369 window_checkboxSet( wid, "chkPrefer", osd_getPriority( misn->osd ) != misn->data->avail.priority );
1370 }
1371
1372 /* Select the system. */
1373 sys = mission_getSystemMarker( misn );
1374 if (sys != NULL)
1375 map_center( wid, sys->name );
1376}
1377static void mission_menu_chk_hide( unsigned int wid, const char *str )
1378{
1379 Mission *misn;
1380 int pos = toolkit_getListPos(wid, "lstMission" );
1381 if ((pos < 0) || (pos > array_size(player_missions)))
1382 return;
1383 misn = player_missions[pos];
1384
1385 if (misn->osd == 0)
1386 return;
1387 osd_setHide( misn->osd, window_checkboxState(wid,str) );
1388}
1389static void mission_menu_chk_priority( unsigned int wid, const char *str )
1390{
1391 Mission *misn;
1392 int pos = toolkit_getListPos(wid, "lstMission" );
1393 if ((pos < 0) || (pos > array_size(player_missions)))
1394 return;
1395 misn = player_missions[pos];
1396
1397 if (misn->osd == 0)
1398 return;
1399 osd_setPriority( misn->osd, misn->data->avail.priority-100*window_checkboxState(wid,str) );
1400}
1405static void mission_menu_abort( unsigned int wid, const char *str )
1406{
1407 (void) str;
1408 int pos, ret;
1409 Mission *misn;
1410
1411 if (!dialogue_YesNo( _("Abort Mission"),
1412 _("Are you sure you want to abort this mission?") ))
1413 return;
1414
1415 /* Get the mission. */
1416 pos = toolkit_getListPos(wid, "lstMission" );
1417 misn = player_missions[pos];
1418
1419 /* We run the "abort" function if it's found. */
1420 ret = misn_tryRun( misn, "abort" );
1421
1422 /* Now clean up mission. */
1423 if (ret != 2) {
1424 mission_cleanup( misn );
1425 mission_shift(pos);
1426 }
1427
1428 /* Reset markers. */
1430
1431 /* Reset claims. */
1433
1434 /* Regenerate list. */
1435 mission_menu_genList(wid ,0);
1436
1437 /* Regenerate bar if landed. */
1438 bar_regen();
1439}
1440
1441/* amount of screen available for logs: -20 below button, -20 above button, -40 from top, -20 x2 between logs.*/
1442#define LOGSPACING (h - 120 - BUTTON_HEIGHT )
1443
1448static void shiplog_menu_update( unsigned int wid, const char *str )
1449{
1450 int w, h;
1451 int nentries;
1452 char **logentries;
1453
1454 if (!logWidgetsReady)
1455 return;
1456
1457 /* This is called when something is selected.
1458 * If a new log type has been selected, need to regenerate the log lists.
1459 * If a new log has been selected, need to regenerate the entries. */
1460 if (strcmp(str, "lstLogEntries" ) != 0) {
1461 int regenerateEntries=0;
1462 int logType, log;
1463
1464 /* has selected a type of log or a log */
1465 window_dimWindow( wid, &w, &h );
1466 logWidgetsReady=0;
1467
1468 logType = toolkit_getListPos( wid, "lstLogType" );
1469 log = toolkit_getListPos( wid, "lstLogs" );
1470
1471 if (logType != selectedLogType) {
1472 /* new log type selected */
1473 selectedLogType = logType;
1474 window_destroyWidget( wid, "lstLogs" );
1475 logs = NULL;
1476 shiplog_listLogsOfType( info_getLogTypeFilter(selectedLogType), &nlogs, &logs, &logIDs, 1 );
1477 if (selectedLog >= nlogs)
1478 selectedLog = 0;
1479 window_addList( wid, 20, 60 + BUTTON_HEIGHT + LOGSPACING / 2,
1480 w-40, LOGSPACING / 4,
1481 "lstLogs", logs, nlogs, 0, shiplog_menu_update, NULL );
1482
1483 toolkit_setListPos( wid, "lstLogs", selectedLog );
1484 regenerateEntries=1;
1485 }
1486 if (regenerateEntries || selectedLog != log) {
1487 selectedLog = CLAMP( 0, nlogs-1, log );
1488 /* list log entries of selected log type */
1489 window_destroyWidget( wid, "lstLogEntries" );
1490 shiplog_listLog( logIDs[selectedLog], info_getLogTypeFilter(selectedLogType), &nentries, &logentries, 1 );
1491 window_addList( wid, 20, 40 + BUTTON_HEIGHT,
1492 w-40, LOGSPACING / 2-20,
1493 "lstLogEntries", logentries, nentries, 0, shiplog_menu_update, info_shiplogView );
1494 toolkit_setListPos( wid, "lstLogEntries", 0 );
1495 window_setFocus( wid, "lstLogEntries" );
1496 }
1497 logWidgetsReady=1;
1498 }
1499}
1500
1504static const char* info_getLogTypeFilter( int lstPos )
1505{
1506 if (lstPos < 1)
1507 return NULL; /* "All" */
1508 return logTypes[lstPos];
1509}
1510
1515static void shiplog_menu_genList( unsigned int wid, int first )
1516{
1517 int w, h;
1518 int nentries;
1519 char **logentries;
1520
1521 /* Needs 3 lists:
1522 * 1. List of log types (and All)
1523 * 2. List of logs of the selected type (and All)
1524 * 3. Listing of the selected log
1525 */
1526 if (!first) {
1527 window_destroyWidget( wid, "lstLogType" );
1528 window_destroyWidget( wid, "lstLogs" );
1529 logs = NULL;
1530 window_destroyWidget( wid, "lstLogEntries" );
1531 }
1532 /* Get the dimensions. */
1533 window_dimWindow( wid, &w, &h );
1534
1535 /* list log types */
1536 shiplog_listTypes(&ntypes, &logTypes, 1);
1537 if ( selectedLogType >= ntypes )
1538 selectedLogType = 0;
1539 /* list logs of selected type */
1540 shiplog_listLogsOfType(info_getLogTypeFilter(selectedLogType), &nlogs, &logs, &logIDs, 1);
1541 if ( selectedLog >= nlogs )
1542 selectedLog = 0;
1543 /* list log entries of selected log */
1544 shiplog_listLog(logIDs[selectedLog], info_getLogTypeFilter(selectedLogType), &nentries, &logentries, 1);
1545 logWidgetsReady=0;
1546 window_addList( wid, 20, 80 + BUTTON_HEIGHT + 3*LOGSPACING/4 ,
1547 w-40, LOGSPACING / 4,
1548 "lstLogType", logTypes, ntypes, 0, shiplog_menu_update, NULL );
1549 window_addList( wid, 20, 60 + BUTTON_HEIGHT + LOGSPACING / 2,
1550 w-40, LOGSPACING / 4,
1551 "lstLogs", logs, nlogs, 0, shiplog_menu_update, NULL );
1552 window_addList( wid, 20, 40 + BUTTON_HEIGHT,
1553 w-40, LOGSPACING / 2-20,
1554 "lstLogEntries", logentries, nentries, 0, shiplog_menu_update, info_shiplogView );
1555 window_setFocus( wid, "lstLogEntries" );
1556 logWidgetsReady=1;
1557}
1558
1559static void info_shiplogMenuDelete( unsigned int wid, const char *str )
1560{
1561 (void) str;
1562 char buf[STRMAX_SHORT];
1563 int ret, logid;
1564
1565 if (logIDs[selectedLog] == LOG_ID_ALL) {
1566 dialogue_msg( "", _("You are currently viewing all logs in the selected log type. Please select a log title to delete.") );
1567 return;
1568 }
1569
1570 snprintf( buf, sizeof(buf),
1571 _("This will delete ALL \"%s\" log entries. This operation cannot be undone. Are you sure?"),
1572 logs[selectedLog]);
1573 ret = dialogue_YesNoRaw( "", buf );
1574 if (!ret)
1575 return;
1576 /* There could be several logs of the same name, so make sure we get the correct one. */
1577 /* selectedLog-1 since not including the "All" */
1578 logid = shiplog_getIdOfLogOfType( info_getLogTypeFilter(selectedLogType), selectedLog-1 );
1579 if (logid >= 0)
1580 shiplog_delete( logid );
1581 selectedLog = 0;
1582 selectedLogType = 0;
1583 shiplog_menu_genList(wid, 0);
1584}
1585
1586static void info_shiplogView( unsigned int wid, const char *str )
1587{
1588 char **logentries;
1589 int nentries;
1590 int pos;
1591 (void) str;
1592
1593 pos = toolkit_getListPos( wid, "lstLogEntries" );
1594 if (pos < 0)
1595 return;
1597 logIDs[selectedLog], info_getLogTypeFilter(selectedLogType), &nentries,
1598 &logentries, 1);
1599
1600 if (pos < nentries)
1601 dialogue_msgRaw( _("Log message"), logentries[pos] );
1602
1603 for (int i=0; i<nentries; i++)
1604 free( logentries[i] );
1605 free( logentries );
1606}
1607
1614static void info_shiplogAdd( unsigned int wid, const char *str )
1615{
1616 char *tmp;
1617 int logType, log;
1618 (void) str;
1619
1620 logType = toolkit_getListPos( wid, "lstLogType" );
1621 log = toolkit_getListPos( wid, "lstLogs" );
1622 if ( log < 0 || logIDs[log] == LOG_ID_ALL ) {
1623 tmp = dialogue_inputRaw( _("Add a log entry"), 0, 4096, _("Add an entry to your diary:") );
1624 if ( ( tmp != NULL ) && ( strlen(tmp) > 0 ) ) {
1625 if ( shiplog_getID( "Diary" ) == -1 )
1626 shiplog_create( "Diary", _("Your Diary"), "Diary", 0, 0 );
1627 shiplog_append( "Diary", tmp );
1628 free( tmp );
1629 }
1630 } else {
1631 tmp = dialogue_input( _("Add a log entry"), 0, 4096, _("Add an entry to the log titled '%s':"), logs[log] );
1632 if ( ( tmp != NULL ) && ( strlen(tmp) > 0 ) ) {
1633 int logid = shiplog_getIdOfLogOfType( info_getLogTypeFilter(logType), log-1 );
1634 if ( logid >= 0 )
1635 shiplog_appendByID( logid, tmp );
1636 else
1637 dialogue_msgRaw( _("Cannot add log"), _("Cannot find this log! Something went wrong here!") );
1638 free( tmp );
1639 }
1640 }
1641 shiplog_menu_genList( wid, 0 );
1642
1643}
1644
1650static void info_openShipLog( unsigned int wid )
1651{
1652 int w, h, texth;
1653 /* re-initialise the statics */
1654 selectedLog = 0;
1655 selectedLogType = 0;
1656
1657 /* Get the dimensions. */
1658 window_dimWindow( wid, &w, &h );
1659 /* buttons */
1660 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1661 "closeShipLog", _("Close"), info_close );
1662 window_addButton( wid, -20 - 1*(20+BUTTON_WIDTH), 20,
1663 BUTTON_WIDTH, BUTTON_HEIGHT, "btnDeleteLog", _("Delete"),
1664 info_shiplogMenuDelete );
1665 window_addButton( wid, -20 - 2*(20+BUTTON_WIDTH), 20, BUTTON_WIDTH,
1666 BUTTON_HEIGHT, "btnViewLog", _("View Entry"),
1667 info_shiplogView );
1668 window_addButton( wid, -20 - 3*(20+BUTTON_WIDTH), 20, BUTTON_WIDTH,
1669 BUTTON_HEIGHT, "btnAddLog", _("Add Entry"),
1670 info_shiplogAdd );
1671 /* Description text */
1672 texth = gl_printHeightRaw( &gl_smallFont, w, "Select log type" );
1673 window_addText( wid, 20, 80 + BUTTON_HEIGHT + LOGSPACING,
1674 w - 40, texth, 0,
1675 "logDesc1", &gl_smallFont, NULL, _("Select log type:") );
1676
1677 window_addText( wid, 20, 60 + BUTTON_HEIGHT + 3* LOGSPACING / 4,
1678 w - 40, texth, 0,
1679 "logDesc2", &gl_smallFont, NULL, _("Select log title:") );
1680
1681 window_addText( wid, 20, 25 + BUTTON_HEIGHT + LOGSPACING / 2,
1682 w - 40, texth, 0,
1683 "logDesc3", &gl_smallFont, NULL, _("Log entries:") );
1684
1685#undef LOGSPACING
1686 /* list */
1687 shiplog_menu_genList(wid ,1);
1688}
1689
1693static void info_changeTab( unsigned int wid, const char *str, int old, int new )
1694{
1695 (void) wid;
1696 (void) str;
1697 (void) old;
1698 const char *hookname;
1699 switch (new) {
1700 case INFO_WIN_MAIN: hookname = "info_main"; break;
1701 case INFO_WIN_SHIP: hookname = "info_ship"; break;
1702 case INFO_WIN_WEAP: hookname = "info_weapons"; break;
1703 case INFO_WIN_CARGO: hookname = "info_cargo"; break;
1704 case INFO_WIN_MISN: hookname = "info_mission"; break;
1705 case INFO_WIN_STAND: hookname = "info_standing";break;
1706 case INFO_WIN_SHIPLOG:hookname= "info_shiplog"; break;
1707 default: ERR( _("Invalid info tab ID: %d"), new );
1708 }
1709 hooks_run( hookname );
1710}
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
Definition array.h:158
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
Definition array.h:140
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:168
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
Definition array.h:119
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
Definition array.h:93
#define BUTTON_HEIGHT
Definition board.c:33
#define BUTTON_WIDTH
Definition board.c:32
void claim_activateAll(void)
Activates all the claims.
Definition claim.c:239
void credits2str(char *str, credits_t credits, int decimals)
Converts credits to a usable string for displaying.
Definition commodity.c:59
char * dialogue_inputRaw(const char *title, int min, int max, const char *msg)
Creates a dialogue that allows the player to write a message.
Definition dialogue.c:469
void dialogue_alert(const char *fmt,...)
Displays an alert popup with only an ok button and a message.
Definition dialogue.c:132
char * dialogue_input(const char *title, int min, int max, const char *fmt,...)
Creates a dialogue that allows the player to write a message.
Definition dialogue.c:441
int dialogue_YesNoRaw(const char *caption, const char *msg)
Runs a dialogue with both yes and no options.
Definition dialogue.c:373
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
Definition dialogue.c:230
void dialogue_msgRaw(const char *caption, const char *msg)
Opens a dialogue window with an ok button and a fixed message.
Definition dialogue.c:271
int dialogue_isOpen(void)
Checks to see if a dialogue is open.
Definition dialogue.c:98
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
Definition dialogue.c:352
void equipment_slotWidget(unsigned int wid, double x, double y, double w, double h, CstSlotWidget *data)
Creates the slot widget and initializes it.
Definition equipment.c:429
int equipment_shipStats(char *buf, int max_len, const Pilot *s, int dpseps, int name)
Creates and allocates a string containing the ship stats.
Definition equipment.c:1426
const char * faction_longname(int f)
Gets the faction's long name (formal, human-readable).
Definition faction.c:348
const int * faction_getEnemies(int f)
Gets the list of enemies of a faction.
Definition faction.c:485
int faction_isKnown(int id)
Is the faction known?
Definition faction.c:275
char faction_getColourChar(int f)
Gets the faction character associated to its standing with the player.
Definition faction.c:1052
const glTexture * faction_logo(int f)
Gets the faction's logo (ideally 256x256).
Definition faction.c:453
const char * faction_name(int f)
Gets a factions "real" (internal) name.
Definition faction.c:306
const char * faction_getStandingText(int f)
Gets the player's standing in human readable form.
Definition faction.c:1066
double faction_getPlayer(int f)
Gets the player's standing with a faction.
Definition faction.c:981
int faction_isDynamic(int id)
Is faction dynamic.
Definition faction.c:283
const int * faction_getAllies(int f)
Gets the list of allies of a faction.
Definition faction.c:515
int * faction_getKnown()
Gets all the known factions in an array (array.h).
Definition faction.c:219
int faction_isInvisible(int id)
Is the faction invisible?
Definition faction.c:250
double faction_reputationMax(int f)
Gets the maximum reputation of a faction.
Definition faction.c:1179
const char * faction_description(int f)
Gets the faction's description (translated).
Definition faction.c:382
int faction_isStatic(int id)
Is the faction static?
Definition faction.c:242
int gl_printHeightRaw(const glFont *ft_font, const int width, const char *text)
Gets the height of a non-formatted string.
Definition font.c:1027
glFont gl_smallFont
Definition font.c:154
glFont gl_defFont
Definition font.c:153
void gl_print(const glFont *ft_font, const double x, const double y, const glColour *c, const char *fmt,...)
Prints text on screen like printf.
Definition font.c:691
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
Definition hook.c:979
int hooks_run(const char *stack)
Runs all the hooks of stack.
Definition hook.c:999
Handles the info menu.
#define INFO_DEFAULT
Definition info.h:16
void bar_regen(void)
Regenerates the bar list.
Definition land.c:382
int landed
Definition land.c:75
Handles the important game menus.
#define menu_isOpen(f)
Definition menu.h:16
#define MENU_INFO
Definition menu.h:11
Mission ** player_missions
Definition mission.c:47
const StarSystem * mission_getSystemMarker(const Mission *misn)
Gets the first system that has been marked by a mission.
Definition mission.c:656
void mission_cleanup(Mission *misn)
Cleans up a mission.
Definition mission.c:739
void mission_sysMark(void)
Marks all active systems that need marking.
Definition mission.c:578
void mission_shift(int pos)
Puts the specified mission at the end of the player_missions array.
Definition mission.c:791
Header file with generic functions and naev-specifics.
#define CLAMP(a, b, x)
Definition naev.h:41
#define MAX(x, y)
Definition naev.h:39
int num2str(char dest[NUM2STRLEN], double n, int decimals)
Converts a numeric value to a string.
Definition nstring.c:120
int strsort(const void *p1, const void *p2)
Sort function for sorting strings with qsort().
Definition nstring.c:81
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
Definition nstring.c:99
const char * num2strU(double n, int decimals)
Unsafe version of num2str that uses an internal buffer. Every call overwrites the return value.
Definition nstring.c:163
ntime_t ntime_get(void)
Gets the current time.
Definition ntime.c:108
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
Definition ntime.c:173
ntime_t pilot_hyperspaceDelay(const Pilot *p)
Calculates the hyperspace delay for a pilot.
Definition pilot.c:2948
int pilot_getJumps(const Pilot *p)
Gets the amount of jumps the pilot has left.
Definition pilot.c:1273
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
Definition pilot_cargo.c:51
int pilot_cargoUsed(const Pilot *p)
Gets how much cargo ship has on board.
int pilot_weapSetTypeCheck(Pilot *p, int id)
Checks the current weapon set type.
void pilot_weapSetInrange(Pilot *p, int id, int inrange)
Changes the weapon set inrange property.
void pilot_weaponSafe(Pilot *p)
Sets the weapon set as safe.
void pilot_weapSetManual(Pilot *p, int id, int manual)
Changes the weapon set manual property.
void pilot_weapSetVolley(Pilot *p, int id, int volley)
Changes the weapon set volley property.
int pilot_weapSetManualCheck(Pilot *p, int id)
Checks the current weapon set manual property.
void ws_copy(PilotWeaponSet dest[PILOT_WEAPON_SETS], const PilotWeaponSet src[PILOT_WEAPON_SETS])
Copies a weapon set over.
int pilot_weapSetVolleyCheck(Pilot *p, int id)
Checks the current weapon set volley property.
void pilot_weaponSetDefault(Pilot *p)
Gives the pilot a default weapon set.
void pilot_weapSetClear(Pilot *p, int id)
Clears a weapon set.
void pilot_weaponAuto(Pilot *p)
Tries to automatically set and create the pilot's weapon set.
int pilot_weapSetInrangeCheck(Pilot *p, int id)
Checks the current weapon set inrange property.
const char * pilot_weapSetName(Pilot *p, int id)
Gets the name of a weapon set.
void pilot_weapSetType(Pilot *p, int id, WeaponSetType type)
Changes the weapon sets mode.
const char ** player_getLicenses()
Gets the array (array.h) of license names in the player's inventory.
Definition player.c:3069
Player_t player
Definition player.c:74
PilotCommodity * pfleet_cargoList(void)
Gets a list of all the cargo in the fleet.
PFleetCargo * pfleet_cargoListShips(const Commodity *com)
Gets the list of ships that are carry a certain commodity in the player fleet and the amount they are...
int pfleet_cargoFree(void)
Gets the total amount of free cargo space in the player's fleet.
int pfleet_cargoRm(const Commodity *com, int q, int jet)
Removes some cargo from the player's fleet.
int pfleet_cargoUsed(void)
Gets the total cargo space used by the player's fleet.
static PlayerItem * inventory
const PlayerItem * player_inventory(void)
Gets the whole player inventory.
static const double c[]
Definition rng.c:264
const char * ship_class(const Ship *s)
Gets the ship's class name in human readable form.
Definition ship.c:165
int shiplog_appendByID(int logid, const char *msg)
Adds to the log file.
Definition shiplog.c:202
void shiplog_listLog(int logid, const char *type, int *nentries, char ***logentries, int incempty)
Get all log entries matching logid, or if logid==LOG_ID_ALL, matching type, or if type==NULL,...
Definition shiplog.c:607
void shiplog_listLogsOfType(const char *type, int *nlogs, char ***logsOut, int **logIDs, int includeAll)
Lists matching logs (which haven't expired via "removeAfter") into the provided arrays.
Definition shiplog.c:522
void shiplog_delete(int logid)
Deletes a log (e.g. a cancelled mission may wish to do this, or the user might).
Definition shiplog.c:267
int shiplog_append(const char *idstr, const char *msg)
Appends to the log file.
Definition shiplog.c:174
int shiplog_create(const char *idstr, const char *logname, const char *type, int overwrite, int maxLen)
Creates a new log with given title of given type.
Definition shiplog.c:54
int shiplog_getID(const char *idstr)
Checks to see if the log family exists.
Definition shiplog.c:668
Represents a commodity.
Definition commodity.h:43
char * description
Definition commodity.h:45
int * illegalto
Definition commodity.h:59
char * name
Definition commodity.h:44
PlayerShip_t * selected
Definition equipment.h:14
The actual hook parameter.
Definition hook.h:38
HookParamType type
Definition hook.h:39
Commodity * commodity
Definition hook.h:47
union HookParam::@25 u
double num
Definition hook.h:41
For use with registered info buttons.
Definition info.c:69
int func
Definition info.c:76
SDL_Keycode key
Definition info.c:77
char * button
Definition info.c:72
int priority
Definition info.c:73
char * caption
Definition info.c:71
nlua_env env
Definition info.c:75
int id
Definition info.c:70
MissionAvail_t avail
Definition mission.h:65
Represents an active mission.
Definition mission.h:81
unsigned int osd
Definition mission.h:101
char * reward
Definition mission.h:88
char * desc
Definition mission.h:87
char * title
Definition mission.h:86
const MissionData * data
Definition mission.h:82
Stores a pilot commodity.
Definition pilot.h:179
const Commodity * commodity
Definition pilot.h:180
unsigned int id
Definition pilot.h:182
ShipStats stats
Definition pilot.h:294
double accel
Definition pilot.h:242
double shield
Definition pilot.h:253
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
Definition pilot.h:319
int aimLines
Definition pilot.h:322
double crew
Definition pilot.h:238
credits_t credits
Definition pilot.h:325
double energy_regen
Definition pilot.h:266
double armour_max
Definition pilot.h:254
double speed
Definition pilot.h:244
const Ship * ship
Definition pilot.h:226
double fuel_max
Definition pilot.h:259
double energy
Definition pilot.h:264
int autoweap
Definition pilot.h:321
double energy_max
Definition pilot.h:265
Solid solid
Definition pilot.h:227
double fuel
Definition pilot.h:260
char * name
Definition pilot.h:219
double shield_regen
Definition pilot.h:257
double turn
Definition pilot.h:247
double armour
Definition pilot.h:251
double shield_max
Definition pilot.h:255
double dmg_absorb
Definition pilot.h:258
double armour_regen
Definition pilot.h:256
Represents an item in the player inventory.
Pilot * p
Definition player.h:74
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
Definition player.h:75
Pilot * p
Definition player.h:101
double dmg_done_shield
Definition player.h:132
unsigned int jumped_times
Definition player.h:137
PlayerShip_t ps
Definition player.h:102
char * name
Definition player.h:103
double dmg_done_armour
Definition player.h:133
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
Definition player.h:136
double dmg_taken_armour
Definition player.h:135
double time_played
Definition player.h:130
int fleet_capacity
Definition player.h:126
double dmg_taken_shield
Definition player.h:134
unsigned int death_counter
Definition player.h:139
unsigned int landed_times
Definition player.h:138
double time_mod
Definition shipstats.h:308
double dt_default
Definition ship.h:124
char * name
Definition ship.h:95
double mass
Definition physics.h:45
int h
Definition font.h:18
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:36
double w
Definition opengl_tex.h:40
double h
Definition opengl_tex.h:41
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:691
void window_setFocus(unsigned int wid, const char *wgtname)
Sets the focused widget in a window.
Definition toolkit.c:2471
void window_dimWindow(unsigned int wid, int *w, int *h)
Gets the dimensions of a window.
Definition toolkit.c:371
void window_setCancel(unsigned int wid, void(*cancel)(unsigned int, const char *))
Sets the default cancel function of the window.
Definition toolkit.c:868
void window_onClose(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the default close function of the window.
Definition toolkit.c:826
void toolkit_drawRect(int x, int y, int w, int h, const glColour *c, const glColour *lc)
Draws a rectangle.
Definition toolkit.c:1343
void window_moveWidget(unsigned int wid, const char *name, int x, int y)
Moves a widget.
Definition toolkit.c:465
void window_destroyWidget(unsigned int wid, const char *wgtname)
Destroys a widget in a window.
Definition toolkit.c:1165
int window_isTop(unsigned int wid)
Checks to see if a window is at the top.
Definition toolkit.c:549
void window_resizeWidget(unsigned int wid, const char *name, int w, int h)
Resizes a widget.
Definition toolkit.c:493
int widget_exists(unsigned int wid, const char *wgtname)
Checks to see if a widget exists.
Definition toolkit.c:1142
void window_close(unsigned int wid, const char *str)
Helper function to automatically close the window calling it.
Definition toolkit.c:1026