naev 0.10.4
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 "hook.h"
20#include "land.h"
21#include "log.h"
22#include "map.h"
23#include "menu.h"
24#include "mission.h"
25#include "ndata.h"
26#include "nlua.h"
27#include "nlua_tk.h"
28#include "nstring.h"
29#include "ntime.h"
30#include "pilot.h"
31#include "player.h"
32#include "player_fleet.h"
33#include "player_gui.h"
34#include "player_inventory.h"
35#include "shiplog.h"
36#include "space.h"
37#include "tk/toolkit_priv.h"
38#include "toolkit.h"
39
40#define BUTTON_WIDTH 135
41#define BUTTON_HEIGHT 30
43#define SETGUI_WIDTH 400
44#define SETGUI_HEIGHT 300
46#define menu_Open(f) (menu_open |= (f))
47#define menu_Close(f) (menu_open &= ~(f))
49#define INFO_WINDOWS 7
51#define INFO_WIN_MAIN 0
52#define INFO_WIN_SHIP 1
53#define INFO_WIN_WEAP 2
54#define INFO_WIN_CARGO 3
55#define INFO_WIN_MISN 4
56#define INFO_WIN_STAND 5
57#define INFO_WIN_SHIPLOG 6
58static const char *info_names[INFO_WINDOWS] = {
59 N_("Main"),
60 N_("Ship"),
61 N_("Weapons"),
62 N_("Cargo"),
63 N_("Missions"),
64 N_("Standings"),
65 N_("Ship log"),
66};
71typedef struct InfoButton_s {
72 int id;
73 char *caption;
74 char *button;
76 /* Lua stuff .*/
77 nlua_env env;
78 int func;
79 SDL_Keycode key;
81static InfoButton_t *info_buttons = NULL;
82
83static unsigned int info_wid = 0;
84static unsigned int *info_windows = NULL;
85static int info_lastTab;
87static CstSlotWidget info_eq;
88static CstSlotWidget info_eq_weaps;
89static int *info_factions;
90
91static int selectedMission = 0;
92static int selectedLog = 0;
93static int selectedLogType = 0;
94static char **logTypes=NULL;
95static int ntypes=0;
96static int nlogs=0;
97static char **logs=NULL;
98static int *logIDs=NULL;
99static int logWidgetsReady=0;
100
101/*
102 * prototypes
103 */
104/* information menu */
105static void info_close( unsigned int wid, const char *str );
106static void info_openMain( unsigned int wid );
107static void info_setGui( unsigned int wid, const char *str );
108static void setgui_load( unsigned int wdw, const char *str );
109static void info_openShip( unsigned int wid );
110static void info_openWeapons( unsigned int wid );
111static void info_openCargo( unsigned int wid );
112static void info_openMissions( unsigned int wid );
113static void info_getDim( unsigned int wid, int *w, int *h, int *lw );
114static void info_buttonClick( unsigned int wid, const char *str );
115static void standings_close( unsigned int wid, const char *str );
116static void ship_update( unsigned int wid );
117static void weapons_genList( unsigned int wid );
118static void weapons_update( unsigned int wid, const char *str );
119static void weapons_autoweap( unsigned int wid, const char *str );
120static void weapons_fire( unsigned int wid, const char *str );
121static void weapons_inrange( unsigned int wid, const char *str );
122static void weapons_manual( unsigned int wid, const char *str );
123static void aim_lines( unsigned int wid, const char *str );
124static void weapons_renderLegend( double bx, double by, double bw, double bh, void* data );
125static void info_openStandings( unsigned int wid );
126static void info_shiplogView( unsigned int wid, const char *str );
127static void standings_update( unsigned int wid, const char *str );
128static void cargo_genList( unsigned int wid );
129static void cargo_update( unsigned int wid, const char *str );
130static void cargo_jettison( unsigned int wid, const char *str );
131static void mission_menu_abort( unsigned int wid, const char *str );
132static void mission_menu_genList( unsigned int wid, int first );
133static void mission_menu_update( unsigned int wid, const char *str );
134static void info_openShipLog( unsigned int wid );
135static const char* info_getLogTypeFilter( int lstPos );
136static void info_changeTab( unsigned int wid, const char *str, int old, int new );
137
138static int sort_buttons( const void *p1, const void *p2 )
139{
140 const InfoButton_t *b1 = p1;
141 const InfoButton_t *b2 = p2;
142 if (b1->priority < b2->priority)
143 return -1;
144 else if (b1->priority > b2->priority)
145 return +1;
146 return strcmp(b1->caption,b2->caption);
147}
148
149static void info_buttonFree( InfoButton_t *btn )
150{
151 free( btn->caption );
152 free( btn->button );
153 luaL_unref( naevL, LUA_REGISTRYINDEX, btn->func );
154}
155
156static void info_buttonRegen (void)
157{
158 int wid, w, h, rows, cols;
159 if (info_wid == 0)
160 return;
161
162 wid = info_windows[ INFO_WIN_MAIN ];
163 window_dimWindow( wid, &w, &h );
164 cols = (w-20) / (20+BUTTON_WIDTH);
165 rows = 1 + (array_size(info_buttons) + 1) / cols;
166
167 for (int i=0; i<array_size(info_buttons); i++) {
168 InfoButton_t *btn = &info_buttons[i];
169 int r = (i+2)/cols, c = (i+2)%cols;
170 if (widget_exists( wid, btn->button ))
171 window_destroyWidget( wid, btn->button );
172 window_addButtonKey( wid, -20 - c*(20+BUTTON_WIDTH), 20 + r*(20+BUTTON_HEIGHT),
174 btn->button, btn->caption, info_buttonClick, btn->key );
175 }
176 window_resizeWidget( wid, "lstInventory", w-80-240-40-40, h-90 - rows*(20+BUTTON_HEIGHT) );
177 window_moveWidget( wid, "lstInventory", -20, -70 );
178}
179
188int info_buttonRegister( const char *caption, int priority, SDL_Keycode key )
189{
190 static int button_idgen = 0;
191 int id;
192 InfoButton_t *btn;
193
194 if (info_buttons == NULL)
195 info_buttons = array_create( InfoButton_t );
196
197 btn = &array_grow( &info_buttons );
198 btn->id = ++button_idgen;
199 btn->caption= strdup( caption );
200 asprintf( &btn->button, "btnExtra::%s", caption );
201 btn->priority = priority;
202 btn->env = __NLUA_CURENV;
203 btn->func = luaL_ref( naevL, LUA_REGISTRYINDEX );
204 btn->key = key;
205
206 id = btn->id;
207 qsort( info_buttons, array_size(info_buttons), sizeof(InfoButton_t), sort_buttons );
208
209 info_buttonRegen();
210 return id;
211}
212
220{
221 for (int i=0; i<array_size(info_buttons); i++) {
222 InfoButton_t *btn = &info_buttons[i];
223 if (btn->id != id)
224 continue;
225 if (info_wid != 0) {
226 int wid = info_windows[ INFO_WIN_MAIN ];
227 if (widget_exists( wid, btn->button ))
228 window_destroyWidget( wid, btn->button );
229 }
230 info_buttonFree( btn );
231 array_erase( &info_buttons, btn, btn+1 );
232 info_buttonRegen();
233 return 0;
234 }
235 return -1;
236}
237
242{
243 for (int i=0; i<array_size(info_buttons); i++) {
244 InfoButton_t *btn = &info_buttons[i];
245 if (info_wid != 0) {
246 int wid = info_windows[ INFO_WIN_MAIN ];
247 if (widget_exists( wid, btn->button ))
248 window_destroyWidget( wid, btn->button );
249 }
250 info_buttonFree( btn );
251 }
252 array_free( info_buttons );
253 info_buttons = NULL;
254 info_buttonRegen();
255}
256
257static void info_buttonClick( unsigned int wid, const char *str )
258{
259 (void) wid;
260 for (int i=0; i<array_size(info_buttons); i++) {
261 InfoButton_t *btn = &info_buttons[i];
262 if (strcmp( btn->button, str )!=0)
263 continue;
264
265 lua_rawgeti( naevL, LUA_REGISTRYINDEX, btn->func );
266 if (nlua_pcall( btn->env, 0, 0 )) {
267 WARN( _("Failure to run info button with id '%d':\n%s"), btn->id, lua_tostring( naevL, -1 ) );
268 lua_pop( naevL, 1 );
269 }
270 land_needsTakeoff( 1 ); /* Script said so? */
271 return;
272 }
273}
274
278void menu_info( int window )
279{
280 int w, h;
281 const char *names[INFO_WINDOWS];
282
283 /* Not under manual control. */
284 if (pilot_isFlag( player.p, PILOT_MANUAL_CONTROL ))
285 return;
286
287 /* Open closes when previously opened. */
289 if ((info_wid > 0) && !window_isTop(info_wid))
290 return;
291 info_close( 0, NULL );
292 return;
293 }
294
295 /* Dimensions. */
296 w = 640;
297 h = 680;
298
299 /* Create the window. */
300 info_wid = window_create( "wdwInfo", _("Info"), -1, -1, w, h );
301 window_setCancel( info_wid, info_close );
302
303 /* Create tabbed window. */
304 for (size_t i=0; i<INFO_WINDOWS; i++)
305 names[i] = _(info_names[i]);
306 info_windows = window_addTabbedWindow( info_wid, -1, -1, -1, -1, "tabInfo",
307 INFO_WINDOWS, names, 0 );
308
309 /* Open the subwindows. */
310 info_openMain( info_windows[ INFO_WIN_MAIN ] );
311 info_openShip( info_windows[ INFO_WIN_SHIP ] );
312 info_openWeapons( info_windows[ INFO_WIN_WEAP ] );
313 info_openCargo( info_windows[ INFO_WIN_CARGO ] );
314 info_openMissions( info_windows[ INFO_WIN_MISN ] );
315 info_openStandings( info_windows[ INFO_WIN_STAND ] );
316 info_openShipLog( info_windows[ INFO_WIN_SHIPLOG ] );
317
318 menu_Open(MENU_INFO);
319
320 /* Opening hooks. */
321 hooks_run("info");
322
323 /* Set active window. */
324 window_tabWinOnChange( info_wid, "tabInfo", info_changeTab );
325 if (window == INFO_DEFAULT)
326 window = info_lastTab;
327 window_tabWinSetActive( info_wid, "tabInfo", CLAMP( 0, 6, window ) );
328}
333static void info_close( unsigned int wid, const char *str )
334{
335 (void) wid;
336 if (info_wid > 0) {
337 info_lastTab = window_tabWinGetActive( info_wid, "tabInfo" );
338
339 /* Copy weapon sets over if changed. */
341
342 window_close( info_wid, str );
343 info_wid = 0;
344 info_windows = NULL;
345 logs = NULL;
346 menu_Close(MENU_INFO);
347 }
348}
349
353void info_update (void)
354{
355 if (info_windows != NULL)
356 weapons_genList( info_windows[ INFO_WIN_WEAP ] );
357}
358
362static void info_openMain( unsigned int wid )
363{
364 const char **lic;
365 char str[STRMAX_SHORT], creds[ECON_CRED_STRLEN];
366 char **inventory;
367 char *nt;
368 int w, h, cargo_used, cargo_total, n;
369 unsigned int destroyed;
370 const PlayerItem *inv;
371 size_t k = 0, l = 0;
372
373 /* Get the dimensions. */
374 window_dimWindow( wid, &w, &h );
375
376 /* Compute ships destroyed. */
377 destroyed = 0;
378 for (int i=0; i<SHIP_CLASS_TOTAL; i++)
379 destroyed += player.ships_destroyed[i];
380
381 /* pilot generics */
382 nt = ntime_pretty( ntime_get(), 2 );
383 k += scnprintf( &str[k], sizeof(str)-k, "%s", _("Pilot:") );
384 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Date:") );
385 k += scnprintf( &str[k], sizeof(str)-k, "\n\n%s", _("Money:") );
386 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Current Ship:") );
387 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Fuel:") );
388 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", (player.fleet_capacity > 0) ? _("Cargo (fleet):") : _("Cargo:") );
389 k += scnprintf( &str[k], sizeof(str)-k, "\n\n%s", _("Time played:") );
390 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Times died:") );
391 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Times jumped:") );
392 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Times landed:") );
393 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Damage done:") );
394 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Damage taken:") );
395 k += scnprintf( &str[k], sizeof(str)-k, "\n%s", _("Ships destroyed:") );
396 window_addText( wid, 20, 20, 120, h-80, 0, "txtDPilot", &gl_smallFont, &cFontGrey, str );
397
398 credits2str( creds, player.p->credits, 2 );
399 l += scnprintf( &str[l], sizeof(str)-l, "%s", player.name );
400 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", nt );
401 l += scnprintf( &str[l], sizeof(str)-l, "\n\n%s", creds );
402 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", player.p->name );
403 l += scnprintf( &str[l], sizeof(str)-l, "\n%.0f (%d %s)",
404 player.p->fuel, pilot_getJumps(player.p), n_( "jump", "jumps", pilot_getJumps(player.p) ) );
405 cargo_used = pfleet_cargoUsed();
406 cargo_total = cargo_used + pfleet_cargoFree();
407 l += scnprintf( &str[l], sizeof(str)-l, "\n%d / %d %s", cargo_used, cargo_total, n_( "tonne", "tonnes", cargo_total ) );
408 l += scnprintf( &str[l], sizeof(str)-l, "%s", "\n\n" );
409 l += scnprintf( &str[l], sizeof(str)-l, _("%.1f hours"), player.time_played / 3600. );
410 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", num2strU((double)player.death_counter,0) );
411 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", num2strU((double)player.jumped_times, 0) );
412 l += scnprintf( &str[l], sizeof(str)-l, "\n%s\n", num2strU((double)player.landed_times, 0) );
413 l += scnprintf( &str[l], sizeof(str)-l, _("%s MJ"), num2strU(player.dmg_done_shield + player.dmg_done_armour, 0) );
414 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", "" );
415 l += scnprintf( &str[l], sizeof(str)-l, _("%s MJ"), num2strU(player.dmg_taken_shield + player.dmg_taken_armour, 0) );
416 l += scnprintf( &str[l], sizeof(str)-l, "\n%s", num2strU(destroyed, 0) );
417 window_addText( wid, 160, 20,
418 w-80-160-40+20-180, h-80,
419 0, "txtPilot", &gl_smallFont, NULL, str );
420 free(nt);
421
422 /* menu */
423 window_addButton( wid, -20, 20,
425 "btnClose", _("Close"), info_close );
426 window_addButtonKey( wid, -20 - (20+BUTTON_WIDTH), 20,
428 "btnSetGUI", _("Set GUI"), info_setGui, SDLK_g );
429
430 /* TODO probably add alt text with descriptions. */
431 lic = player_getLicenses();
432 inv = player_inventory();
433 n = array_size(lic) + array_size(inv);
434 /* List. */
435 if (n == 0) {
436 inventory = malloc(sizeof(char*));
437 inventory[0] = strdup(_("None"));
438 n = 1;
439 }
440 else {
441 int nlic = array_size(lic);
442 int ninv = array_size(inv);
443 inventory = malloc(sizeof(char*) * n);
444 for (int i=0; i<nlic; i++)
445 asprintf( &inventory[i], "#n%s#0%s", _("License: "), _(lic[i]) );
446 qsort( inventory, nlic, sizeof(char*), strsort );
447 for (int i=0; i<ninv; i++) {
448 const PlayerItem *pi = &inv[i];
449 if (pi->quantity == 0)
450 asprintf( &inventory[nlic+i], "%s", _(pi->name) );
451 else
452 asprintf( &inventory[nlic+i], _("%s (%d)"), _(pi->name), pi->quantity );
453 }
454 qsort( &inventory[nlic], ninv, sizeof(char*), strsort );
455 }
456 window_addText( wid, -20, -40, w-80-240-40-40, 20, 1, "txtList",
457 NULL, NULL, _("Inventory") );
458 window_addList( wid, -20, -70, w-80-240-40-40, h-110-BUTTON_HEIGHT,
459 "lstInventory", inventory, n, 0, NULL, NULL );
460 window_setFocus( wid, "lstInventory" );
461
462 info_buttonRegen();
463}
464
471static void setgui_close( unsigned int wdw, const char *str )
472{
473 (void) str;
474 window_destroy( wdw );
475}
476
483static void info_setGui( unsigned int wid, const char *str )
484{
485 (void) str;
486 char **guis;
487 int nguis;
488 char **gui_copy;
489
490 /* Get the available GUIs. */
491 guis = player_guiList();
492 nguis = array_size( guis );
493
494 /* In case there are none. */
495 if (guis == NULL) {
496 WARN(_("No GUI available."));
497 dialogue_alert( _("There are no GUI available, this means something went wrong somewhere. Inform the Naev maintainer.") );
498 return;
499 }
500
501 /* window */
502 wid = window_create( "wdwSetGUI", _("Select GUI"), -1, -1, SETGUI_WIDTH, SETGUI_HEIGHT );
503 window_setCancel( wid, setgui_close );
504
505 /* Copy GUI. */
506 gui_copy = malloc( sizeof(char*) * nguis );
507 for (int i=0; i<nguis; i++)
508 gui_copy[i] = strdup( guis[i] );
509
510 /* List */
511 window_addList( wid, 20, -50,
512 SETGUI_WIDTH-BUTTON_WIDTH/2 - 60, SETGUI_HEIGHT-70,
513 "lstGUI", gui_copy, nguis, 0, NULL, NULL );
514 toolkit_setList( wid, "lstGUI", gui_pick() );
515
516 /* buttons */
517 window_addButton( wid, -20, 20, BUTTON_WIDTH/2, BUTTON_HEIGHT,
518 "btnBack", _("Close"), setgui_close );
519 window_addButton( wid, -20, 30 + BUTTON_HEIGHT, BUTTON_WIDTH/2, BUTTON_HEIGHT,
520 "btnLoad", _("Load"), setgui_load );
521
522 /* default action */
523 window_setAccept( wid, setgui_load );
524}
525
532static void setgui_load( unsigned int wdw, const char *str )
533{
534 (void) str;
535 int wid = window_get( "wdwSetGUI" );
536 const char *gui = toolkit_getList( wid, "lstGUI" );
537
538 if (strcmp(gui,_("None")) == 0)
539 return;
540
541 /* Set the GUI. */
542 free( player.gui );
543 player.gui = strdup( gui );
544
545 /* Close menus before loading for proper rendering. */
546 setgui_close(wdw, NULL);
547
548 /* Load the GUI. */
549 gui_load( gui_pick() );
550}
551
557static void info_openShip( unsigned int wid )
558{
559 int w, h;
560 char buf[STRMAX];
561 size_t l = 0;
562
563 /* Get the dimensions. */
564 window_dimWindow( wid, &w, &h );
565
566 /* Buttons */
567 window_addButton( wid, -20, 20,
569 "closeOutfits", _("Close"), info_close );
570
571 /* Text. */
572 l += scnprintf( &buf[l], sizeof(buf)-l, "%s", _("Name:") );
573 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Model:") );
574 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Class:") );
575 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Crew:") );
576 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
577 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Mass:") );
578 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Jump Time:") );
579 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Thrust:") );
580 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Speed:") );
581 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Turn:") );
582 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Time Constant:") );
583 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
584 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Absorption:") );
585 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Shield:") );
586 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Armour:") );
587 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Energy:") );
588 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Cargo Space:") );
589 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Fuel:") );
590 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
591 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _("Stats:") );
592 window_addText( wid, 20, -40, 100, h-60, 0, "txtSDesc", &gl_smallFont, &cFontGrey, buf );
593 window_addText( wid, 160, -40, w-20-20-20-160-180., h-60, 0, "txtDDesc", &gl_smallFont,
594 NULL, NULL );
595
596 /* Custom widget. */
597 equipment_slotWidget( wid, -20, -40, 180, h-60, &info_eq );
598 info_eq.selected = &player.ps;
599 info_eq.canmodify = 0;
600
601 /* Update ship. */
602 ship_update( wid );
603}
604
608static void ship_update( unsigned int wid )
609{
610 char buf[STRMAX_SHORT], *hyp_delay;
611 size_t l = 0;
612 int cargo = pilot_cargoUsed( player.p ) + pilot_cargoFree( player.p );
613
614 hyp_delay = ntime_pretty( pilot_hyperspaceDelay( player.p ), 2 );
615 /* Generic */
616 l += scnprintf( &buf[l], sizeof(buf)-l, "%s", player.p->name );
617 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _(player.p->ship->name) );
618 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", _(ship_class(player.p->ship)) );
619 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%d", (int)floor(player.p->crew) );
620 /* Movement. */
621 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
622 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%.0f %s", player.p->solid->mass, n_( "tonne", "tonnes", player.p->solid->mass ) );
623 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
624 l += scnprintf( &buf[l], sizeof(buf)-l, _("%s average"), hyp_delay );
625 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
626 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f kN/tonne"), player.p->thrust / player.p->solid->mass );
627 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
628 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f m/s (max %.0f m/s)"),
629 player.p->speed, solid_maxspeed( player.p->solid, player.p->speed, player.p->thrust ) );
630 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
631 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f deg/s"), player.p->turn*180./M_PI );
632 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%.0f%%", player.p->stats.time_mod * player.p->ship->dt_default * 100. );
633 /* Health. */
634 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
635 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%.0f%%", player.p->dmg_absorb * 100. );
636 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
637 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f / %.0f MJ (%.1f MW)"), player.p->shield, player.p->shield_max, player.p->shield_regen );
638 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
639 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f / %.0f MJ (%.1f MW)"), player.p->armour, player.p->armour_max, player.p->armour_regen );
640 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%s", "" );
641 l += scnprintf( &buf[l], sizeof(buf)-l, _("%.0f / %.0f MJ (%.1f MW)"), player.p->energy, player.p->energy_max, player.p->energy_regen );
642 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%d / %d %s", pilot_cargoUsed( player.p ), cargo, n_( "tonne", "tonnes", cargo ) );
643 l += scnprintf( &buf[l], sizeof(buf)-l, "\n%.0f / %.0f %s (%d %s)",
644 player.p->fuel, player.p->fuel_max, n_( "unit", "units", player.p->fuel_max ),
645 pilot_getJumps(player.p), n_( "jump", "jumps", pilot_getJumps(player.p) ) );
646 l += scnprintf( &buf[l], sizeof(buf)-l, "%s", "\n\n" );
647
648 equipment_shipStats( &buf[l], sizeof(buf)-l, player.p, 0, 0 );
649 window_modifyText( wid, "txtDDesc", buf );
650 free( hyp_delay );
651}
652
656static void info_openWeapons( unsigned int wid )
657{
658 int w, h, x, y, wlen;
659
660 /* Get the dimensions. */
661 window_dimWindow( wid, &w, &h );
662
663 /* Custom widget. */
664 equipment_slotWidget( wid, 20, -40, 180, h-60, &info_eq_weaps );
665 info_eq_weaps.selected = &player.ps;
666 info_eq_weaps.weapons = 0;
667 info_eq_weaps.canmodify = 0;
668
669 /* Custom widget for legend. */
670 y = -220;
671 window_addCust( wid, 220, y, w-200-60, 100, "cstLegend", 0,
672 weapons_renderLegend, NULL, NULL, NULL, NULL );
673
674 /* Checkboxes. */
675 wlen = w - 220 - 20;
676 x = 220;
677 y -= 100;
678 window_addText( wid, x, y, wlen, 20, 0, "txtLocal", NULL, NULL,
679 _("Current Weapon Set Settings"));
680 y -= 20;
681 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
682 "chkFire", _("Enable instant Mode"), weapons_fire,
683 (pilot_weapSetTypeCheck( player.p, info_eq_weaps.weapons )==WEAPSET_TYPE_WEAPON) );
684 y -= 30;
685 window_addText( wid, x+10, y, wlen, 20, 0, "txtSInstant", NULL, NULL, _("(Weapons fire when this weapon set key is pressed)"));
686 y -= 20;
687 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
688 "chkInrange", _("Only shoot weapons that are in range"), weapons_inrange,
689 pilot_weapSetInrangeCheck( player.p, info_eq_weaps.weapons ) );
690 y -= 30;
691 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
692 "chkManual", _("Enable manual aiming mode."), weapons_manual,
693 pilot_weapSetManualCheck( player.p, info_eq_weaps.weapons ) );
694 y -= 40;
695 window_addText( wid, x, y, wlen, 20, 0, "txtGlobal", NULL, NULL,
696 _("Global Settings"));
697 y -= 20;
698 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
699 "chkAutoweap", _("Automatically handle weapons"), weapons_autoweap, player.p->autoweap );
700 y -= 30;
701 window_addCheckbox( wid, x+10, y, wlen, BUTTON_HEIGHT,
702 "chkHelper", _("Dogfight aiming helper"), aim_lines, player.p->aimLines );
703
704 /* List. Has to be generated after checkboxes. */
705 weapons_genList( wid );
706
707 /* Buttons */
708 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
709 "closeCargo", _("Close"), info_close );
710}
711
715static void weapons_genList( unsigned int wid )
716{
717 char **buf, tbuf[STRMAX_SHORT];
718 int n, w, h;
719
720 /* Get the dimensions. */
721 window_dimWindow( wid, &w, &h );
722
723 /* Destroy widget if needed. */
724 if (widget_exists( wid, "lstWeapSets" )) {
725 window_destroyWidget( wid, "lstWeapSets" );
726 n = toolkit_getListPos( wid, "lstWeapSets" );
727 }
728 else
729 n = -1;
730
731 /* List */
732 buf = malloc( sizeof(char*) * PILOT_WEAPON_SETS );
733 for (int i=0; i<PILOT_WEAPON_SETS; i++) {
734 const char *str = pilot_weapSetName( info_eq_weaps.selected->p, i );
735 if (str == NULL)
736 snprintf( tbuf, sizeof(tbuf), "%d - ??", (i+1)%10 );
737 else
738 snprintf( tbuf, sizeof(tbuf), "%d - %s", (i+1)%10, str );
739 buf[i] = strdup( tbuf );
740 }
741 window_addList( wid, 20+180+20, -40,
742 w - (20+180+20+20), 180,
743 "lstWeapSets", buf, PILOT_WEAPON_SETS,
744 0, weapons_update, NULL );
745 window_setFocus( wid, "lstWeapSets" );
746
747 /* Restore position. */
748 if (n >= 0)
749 toolkit_setListPos( wid, "lstWeapSets", n );
750}
751
755static void weapons_update( unsigned int wid, const char *str )
756{
757 (void) str;
758 int pos;
759
760 /* Update the position. */
761 pos = toolkit_getListPos( wid, "lstWeapSets" );
762 if (pos < 0)
763 return;
764 info_eq_weaps.weapons = pos;
765
766 /* Update fire mode. */
767 window_checkboxSet( wid, "chkFire",
768 (pilot_weapSetTypeCheck( player.p, pos ) == WEAPSET_TYPE_WEAPON) );
769
770 /* Update inrange. */
771 window_checkboxSet( wid, "chkInrange",
773
774 /* Update manual aiming. */
775 window_checkboxSet( wid, "chkManual",
777
778 /* Update autoweap. */
779 window_checkboxSet( wid, "chkAutoweap", player.p->autoweap );
780}
781
785static void weapons_autoweap( unsigned int wid, const char *str )
786{
787 /* Set state. */
788 int state = window_checkboxState( wid, str );
789
790 /* Run autoweapons if needed. */
791 if (state) {
792 int sure = dialogue_YesNoRaw( _("Enable autoweapons?"),
793 _("Are you sure you want to enable automatic weapon groups for the "
794 "ship?\n\nThis will overwrite all manually-tweaked weapons groups.") );
795 if (!sure) {
796 window_checkboxSet( wid, str, 0 );
797 return;
798 }
799 player.p->autoweap = 1;
801 weapons_genList( wid );
802 }
803 else
804 player.p->autoweap = 0;
805}
806
810static void weapons_fire( unsigned int wid, const char *str )
811{
812 int i, state, t, c;
813
814 /* Set state. */
815 state = window_checkboxState( wid, str );
816
817 /* See how to handle. */
818 t = pilot_weapSetTypeCheck( player.p, info_eq_weaps.weapons );
819 if (t == WEAPSET_TYPE_ACTIVE)
820 return;
821
822 if (state)
823 c = WEAPSET_TYPE_WEAPON;
824 else
825 c = WEAPSET_TYPE_CHANGE;
826 pilot_weapSetType( player.p, info_eq_weaps.weapons, c );
827
828 /* Check to see if they are all fire groups. */
829 for (i=0; i<PILOT_WEAPON_SETS; i++)
831 break;
832
833 /* Not able to set them all to fire groups. */
834 if (i >= PILOT_WEAPON_SETS) {
835 dialogue_alert( _("You can not set all your weapon sets to fire groups!") );
836 pilot_weapSetType( player.p, info_eq_weaps.weapons, WEAPSET_TYPE_CHANGE );
837 window_checkboxSet( wid, str, 0 );
838 }
839
840 /* Set default if needs updating. */
842
843 /* Must regen. */
844 weapons_genList( wid );
845}
846
850static void weapons_inrange( unsigned int wid, const char *str )
851{
852 int state = window_checkboxState( wid, str );
853 pilot_weapSetInrange( player.p, info_eq_weaps.weapons, state );
854}
855
859static void weapons_manual( unsigned int wid, const char *str )
860{
861 int state = window_checkboxState( wid, str );
862 pilot_weapSetManual( player.p, info_eq_weaps.weapons, state );
863}
864
868static void aim_lines( unsigned int wid, const char *str )
869{
870 int state = window_checkboxState( wid, str );
871 player.p->aimLines = state;
872}
873
877static void weapons_renderLegend( double bx, double by, double bw, double bh, void* data )
878{
879 (void) data;
880 (void) bw;
881 (void) bh;
882 double y;
883
884 y = by+bh-20;
885 gl_print( &gl_defFont, bx, y, &cFontWhite, p_("info", "Legend") );
886
887 y -= 20.;
888 toolkit_drawRect( bx, y, 10, 10, &cFontBlue, NULL );
889 gl_print( &gl_smallFont, bx+20, y, &cFontWhite, _("Outfit that can be activated") );
890
891 y -= 20.;
892 toolkit_drawRect( bx, y, 10, 10, &cFontYellow, NULL );
893 gl_print( &gl_smallFont, bx+20, y, &cFontWhite, _("Secondary Weapon (Right click toggles)") );
894
895 y -= 20.;
896 toolkit_drawRect( bx, y, 10, 10, &cFontRed, NULL );
897 gl_print( &gl_smallFont, bx+20, y, &cFontWhite, _("Primary Weapon (Left click toggles)") );
898}
899
905static void info_openCargo( unsigned int wid )
906{
907 int w, h;
908
909 /* Get the dimensions. */
910 window_dimWindow( wid, &w, &h );
911
912 /* Buttons */
913 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
914 "closeCargo", _("Close"), info_close );
915 window_addButton( wid, -40 - BUTTON_WIDTH, 20,
916 BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", _("Jettison"),
917 cargo_jettison );
918 window_disableButton( wid, "btnJettisonCargo" );
919
920 /* Description. */
921 window_addText( wid, 20, -40-200-20,
922 w - 40, h - BUTTON_HEIGHT - 260, 0,
923 "txtCargoDesc", NULL, NULL, NULL );
924
925 /* Generate the list. */
926 cargo_genList( wid );
927}
931static void cargo_genList( unsigned int wid )
932{
933 char **buf;
934 int nbuf;
935 int w, h;
937
938 /* Get the dimensions. */
939 window_dimWindow( wid, &w, &h );
940
941 /* Destroy widget if needed. */
942 if (widget_exists( wid, "lstCargo" ))
943 window_destroyWidget( wid, "lstCargo" );
944
945 /* List */
946 if (array_size(pclist)==0) {
947 /* No cargo */
948 buf = malloc(sizeof(char*));
949 buf[0] = strdup(_("None"));
950 nbuf = 1;
951 }
952 else {
953 /* List the player fleet's cargo. */
954 buf = malloc( sizeof(char*) * array_size(pclist) );
955 for (int i=0; i<array_size(pclist); i++) {
956 PilotCommodity *pc = &pclist[i];
957 int misn = (pc->id != 0);
958 int illegal = (array_size(pc->commodity->illegalto)>0);
959
960 asprintf(&buf[i], "%s %d%s%s",
961 _(pc->commodity->name),
962 pc->quantity,
963 misn ? _(" [#bMission#0]") : "",
964 illegal ? _(" (#rillegal#0)") : "" );
965 }
966 nbuf = array_size(pclist);
967 }
968 array_free(pclist);
969 window_addList( wid, 20, -40, w - 40, 200,
970 "lstCargo", buf, nbuf, 0, cargo_update, NULL );
971 window_setFocus( wid, "lstCargo" );
972}
977static void cargo_update( unsigned int wid, const char *str )
978{
979 (void) str;
980 char desc[STRMAX];
981 int pos, l;
982 const Commodity *com;
984
985 if (array_size(pclist) <= 0) {
986 window_modifyText( wid, "txtCargoDesc", NULL );
987 array_free(pclist);
988 return; /* No cargo, redundant check */
989 }
990
991 /* Can jettison all but mission cargo when not landed*/
992 if (landed)
993 window_disableButton( wid, "btnJettisonCargo" );
994 else
995 window_enableButton( wid, "btnJettisonCargo" );
996
997 pos = toolkit_getListPos( wid, "lstCargo" );
998 com = pclist[pos].commodity;
999
1000 if (!com->description)
1001 l = scnprintf( desc, sizeof(desc), "%s", _(com->name) );
1002 else
1003 l = scnprintf( desc, sizeof(desc), "%s\n\n%s", _(com->name), _(com->description) );
1004
1005 /* Only add fleet information with fleet capacity. */
1006 if ((player.fleet_capacity > 0) && (pclist[pos].quantity > 0)) {
1007 l += scnprintf( &desc[l], sizeof(desc)-l, "\n\n%s", _("Carried by the following ships in your fleet:\n") );
1008 PFleetCargo *plist = pfleet_cargoListShips( com );
1009 for (int i=0; i<array_size(plist); i++)
1010 l += scnprintf( &desc[l], sizeof(desc)-l, _("\n - %s (%d)"), plist[i].p->name, plist[i].q );
1011 array_free(plist);
1012 }
1013
1014 /* Add message on illegal outfits. */
1015 if (array_size(com->illegalto) > 0) {
1016 l += scnprintf( &desc[l], sizeof(desc)-l, "\n\n%s", _("Illegalized by the following factions:\n") );
1017 for (int i=0; i<array_size(com->illegalto); i++) {
1018 int f = com->illegalto[i];
1019 if (!faction_isKnown(f))
1020 continue;
1021
1022 l += scnprintf( &desc[l], sizeof(desc)-l, _("\n - %s"), _(faction_name(f)) );
1023 }
1024 }
1025 window_modifyText( wid, "txtCargoDesc", desc );
1026
1027 array_free(pclist);
1028}
1033static void cargo_jettison( unsigned int wid, const char *str )
1034{
1035 (void)str;
1036 int pos, ret;
1037 Mission *misn;
1038 HookParam hparam[3];
1039 PilotCommodity *pclist = pfleet_cargoList();
1040
1041 if (array_size(pclist) <= 0) {
1042 array_free(pclist);
1043 return; /* No cargo, redundant check */
1044 }
1045
1046 pos = toolkit_getListPos( wid, "lstCargo" );
1047
1048 /* Special case mission cargo. */
1049 if (pclist[pos].id != 0) {
1050 int f;
1051
1052 if (!dialogue_YesNo( _("Abort Mission"),
1053 _("Are you sure you want to abort this mission?") )) {
1054 array_free(pclist);
1055 return;
1056 }
1057
1058 /* Get the mission. */
1059 f = -1;
1060 for (int i=0; i<array_size(player_missions); i++) {
1061 for (int j=0; j<array_size(player_missions[i]->cargo); j++) {
1062 if (player_missions[i]->cargo[j] == pclist[pos].id) {
1063 f = i;
1064 break;
1065 }
1066 }
1067 if (f >= 0)
1068 break;
1069 }
1070 if (f < 0) {
1071 WARN(_("Cargo '%d' does not belong to any active mission."),
1072 pclist[pos].id);
1073 array_free( pclist );
1074 return;
1075 }
1076 misn = player_missions[f];
1077
1078 /* We run the "abort" function if it's found. */
1079 ret = misn_tryRun( misn, "abort" );
1080
1081 /* Now clean up mission. */
1082 if (ret != 2) {
1083 mission_cleanup( misn );
1084 mission_shift(pos);
1085 }
1086
1087 /* Reset markers. */
1089
1090 /* Reset claims. */
1092
1093 /* Regenerate list. */
1094 mission_menu_genList( info_windows[ INFO_WIN_MISN ], 0 );
1095 }
1096 else
1097 /* Remove the cargo */
1098 pfleet_cargoRm( pclist[pos].commodity, pclist[pos].quantity, 1 );
1099
1100 /* We reopen the menu to recreate the list now. */
1101 ship_update( info_windows[ INFO_WIN_SHIP ] );
1102 cargo_genList( wid );
1103 cargo_update( wid, NULL );
1104
1105 /* Run hooks. */
1106 hparam[0].type = HOOK_PARAM_STRING;
1107 hparam[0].u.str = pclist[pos].commodity->name,
1108 hparam[1].type = HOOK_PARAM_NUMBER;
1109 hparam[1].u.num = pclist[pos].quantity;
1110 hparam[2].type = HOOK_PARAM_SENTINEL;
1111 hooks_runParam( "comm_jettison", hparam );
1112
1113 /* Clean up. */
1114 array_free( pclist );
1115}
1116
1120static void info_getDim( unsigned int wid, int *w, int *h, int *lw )
1121{
1122 /* Get the dimensions. */
1123 window_dimWindow( wid, w, h );
1124 *lw = *w-60-BUTTON_WIDTH-120;
1125}
1126
1130static void standings_close( unsigned int wid, const char *str )
1131{
1132 (void) wid;
1133 (void) str;
1134 array_free(info_factions);
1135 info_factions = NULL;
1136}
1137
1138static int factionsSort( const void *p1, const void *p2 )
1139{
1140 int f1, f2;
1141 double v1, v2;
1142 f1 = *(int*)p1;
1143 f2 = *(int*)p2;
1144 v1 = round(faction_getPlayer(f1));
1145 v2 = round(faction_getPlayer(f2));
1146 if (v1 < v2)
1147 return 1;
1148 else if (v1 > v2)
1149 return -1;
1150 return strcmp(faction_longname(f1), faction_longname(f2));
1151}
1155static void info_openStandings( unsigned int wid )
1156{
1157 char **str;
1158 int w, h, lw;
1159
1160 /* Get dimensions. */
1161 info_getDim( wid, &w, &h, &lw );
1162
1163 /* On close. */
1164 window_onCleanup( wid, standings_close );
1165
1166 /* Buttons */
1167 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1168 "closeMissions", _("Close"), info_close );
1169
1170 /* Graphics. */
1171 window_addImage( wid, 0, 0, 0, 0, "imgLogo", NULL, 0 );
1172
1173 /* Text. */
1174 window_addText( wid, lw+40, 0, (w-(lw+60)), 20, 1, "txtName",
1175 &gl_defFont, NULL, NULL );
1176 window_addText( wid, lw+40, 0, (w-(lw+60)), 20, 1, "txtStanding",
1177 &gl_defFont, NULL, NULL );
1178 window_addText( wid, lw+40, 0, (w-(lw+60)), 300, 0, "txtDescription",
1179 &gl_defFont, NULL, NULL );
1180
1181 /* Gets the faction standings. */
1182 info_factions = faction_getKnown();
1183 str = malloc( sizeof(char*) * array_size(info_factions) );
1184 qsort( info_factions, array_size(info_factions), sizeof(int), factionsSort );
1185
1186 /* Create list. */
1187 for (int i=0; i<array_size(info_factions); i++) {
1188 int m = round( faction_getPlayer( info_factions[i] ) );
1189 asprintf( &str[i], "%s [ #%c%+d%%#0 ]",
1190 faction_longname( info_factions[i] ),
1191 faction_getColourChar( info_factions[i] ), m );
1192 }
1193
1194 /* Display list. */
1195 window_addList( wid, 20, -40, lw, h-60, "lstStandings",
1196 str, array_size(info_factions), 0, standings_update, NULL );
1197 window_setFocus( wid, "lstStandings" );
1198}
1199
1203static void standings_update( unsigned int wid, const char *str )
1204{
1205 (void) str;
1206 int p, y;
1207 const glTexture *t;
1208 int w, h, lw, m, l;
1209 char buf[STRMAX];
1210
1211 /* Get dimensions. */
1212 info_getDim( wid, &w, &h, &lw );
1213
1214 /* Get faction. */
1215 p = toolkit_getListPos( wid, "lstStandings" );
1216
1217 /* Render logo. */
1218 t = faction_logo( info_factions[p] );
1219 if (t != NULL) {
1220 int tw = t->w * (double)FACTION_LOGO_SM / MAX( t->w, t->h );
1221 int th = t->h * (double)FACTION_LOGO_SM / MAX( t->w, t->h );
1222 window_modifyImage( wid, "imgLogo", t, tw, th );
1223 y = -40;
1224 window_moveWidget( wid, "imgLogo", lw+40 + (w-(lw+60)-tw)/2, y - (FACTION_LOGO_SM-th)/2 );
1225 y -= FACTION_LOGO_SM;
1226 }
1227 else {
1228 window_modifyImage( wid, "imgLogo", NULL, 0, 0 );
1229 y = -20;
1230 }
1231
1232 /* Modify text. */
1233 y -= 20;
1234 m = round( faction_getPlayer( info_factions[p] ) );
1235 snprintf( buf, sizeof(buf), "#%c%+d%%#0 [ %s ]",
1236 faction_getColourChar( info_factions[p] ), m,
1237 faction_getStandingText( info_factions[p] ) );
1238 window_modifyText( wid, "txtName", faction_longname( info_factions[p] ) );
1239 window_moveWidget( wid, "txtName", lw+40, y );
1240 y -= 20;
1241 window_modifyText( wid, "txtStanding", buf );
1242 window_moveWidget( wid, "txtStanding", lw+40, y );
1243 y -= 30;
1244 l = scnprintf( buf, sizeof(buf), "%s\n\n", faction_description( info_factions[p] ) );
1245 l += scnprintf( &buf[l], sizeof(buf)-l, _("You can have a maximum reputation of %.0f%% with this faction."), round(faction_reputationMax( info_factions[p] )) );
1246 window_modifyText( wid, "txtDescription", buf );
1247 window_moveWidget( wid, "txtDescription", lw+40, y );
1248}
1249
1256static void info_openMissions( unsigned int wid )
1257{
1258 int w, h;
1259
1260 /* Get the dimensions. */
1261 window_dimWindow( wid, &w, &h );
1262
1263 /* buttons */
1264 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1265 "closeMissions", _("Close"), info_close );
1266 window_addButtonKey( wid, -20, 40 + BUTTON_HEIGHT,
1267 BUTTON_WIDTH, BUTTON_HEIGHT, "btnAbortMission", _("Abort"),
1268 mission_menu_abort, SDLK_a );
1269
1270 /* text */
1271 window_addText( wid, 300+40, -60,
1272 200, 40, 0, "txtSReward",
1273 &gl_smallFont, NULL, _("#nReward:#0") );
1274 window_addText( wid, 300+40, -80,
1275 200, 40, 0, "txtReward", &gl_smallFont, NULL, NULL );
1276 window_addText( wid, 300+40, -120,
1277 w - (300+40+40), h - BUTTON_HEIGHT - 120, 0,
1278 "txtDesc", &gl_smallFont, NULL, NULL );
1279
1280 /* Put a map. */
1281 map_show( wid, 20, 20, 300, 260, 0.75, 0., 0. );
1282
1283 /* list */
1284 mission_menu_genList(wid ,1);
1285}
1290static void mission_menu_genList( unsigned int wid, int first )
1291{
1292 int j;
1293 char** misn_names;
1294 int w, h;
1295
1296 if (!first)
1297 window_destroyWidget( wid, "lstMission" );
1298
1299 /* Get the dimensions. */
1300 window_dimWindow( wid, &w, &h );
1301
1302 /* list */
1303 misn_names = malloc(sizeof(char*) * MAX(1, array_size(player_missions)));
1304 selectedMission = -1;
1305 j = 0;
1306 for (int i=0; i<array_size(player_missions); i++)
1307 if (player_missions[i]->id != 0)
1308 misn_names[j++] = (player_missions[i]->title != NULL) ?
1309 strdup(player_missions[i]->title) : NULL;
1310
1311 if (j==0) { /* no missions */
1312 misn_names[j++] = strdup(_("No Missions"));
1313 window_modifyText( wid, "txtReward", _("None") );
1314 window_modifyText( wid, "txtDesc", _("You currently have no active missions.") );
1315 window_disableButton( wid, "btnAbortMission" );
1316 selectedMission = 0; /* misn_menu_update should do nothing. */
1317 }
1318 window_addList( wid, 20, -40,
1319 300, h-340,
1320 "lstMission", misn_names, j, selectedMission, mission_menu_update, NULL );
1321 window_setFocus( wid, "lstMission" );
1322}
1327static void mission_menu_update( unsigned int wid, const char *str )
1328{
1329 (void) str;
1330 Mission* misn;
1331 const StarSystem *sys;
1332 int pos = toolkit_getListPos(wid, "lstMission" );
1333
1334 if (pos < 0 || pos == selectedMission)
1335 return;
1336
1337 /* Modify the text. */
1338 selectedMission = pos;
1339 misn = player_missions[selectedMission];
1340 window_modifyText( wid, "txtReward", misn->reward );
1341 window_modifyText( wid, "txtDesc", misn->desc );
1342 window_enableButton( wid, "btnAbortMission" );
1343
1344 /* Select the system. */
1345 sys = mission_getSystemMarker( misn );
1346 if (sys != NULL)
1347 map_center( wid, sys->name );
1348}
1353static void mission_menu_abort( unsigned int wid, const char *str )
1354{
1355 (void) str;
1356 int pos, ret;
1357 Mission *misn;
1358
1359 if (!dialogue_YesNo( _("Abort Mission"),
1360 _("Are you sure you want to abort this mission?") ))
1361 return;
1362
1363 /* Get the mission. */
1364 pos = toolkit_getListPos(wid, "lstMission" );
1365 misn = player_missions[pos];
1366
1367 /* We run the "abort" function if it's found. */
1368 ret = misn_tryRun( misn, "abort" );
1369
1370 /* Now clean up mission. */
1371 if (ret != 2) {
1372 mission_cleanup( misn );
1373 mission_shift(pos);
1374 }
1375
1376 /* Reset markers. */
1378
1379 /* Reset claims. */
1381
1382 /* Regenerate list. */
1383 mission_menu_genList(wid ,0);
1384
1385 /* Regenerate bar if landed. */
1386 bar_regen();
1387}
1388
1389/* amount of screen available for logs: -20 below button, -20 above button, -40 from top, -20 x2 between logs.*/
1390#define LOGSPACING (h - 120 - BUTTON_HEIGHT )
1391
1396static void shiplog_menu_update( unsigned int wid, const char *str )
1397{
1398 int regenerateEntries=0;
1399 int w, h;
1400 int logType, log;
1401 int nentries;
1402 char **logentries;
1403
1404 if (!logWidgetsReady)
1405 return;
1406
1407 /* This is called when something is selected.
1408 * If a new log type has been selected, need to regenerate the log lists.
1409 * If a new log has been selected, need to regenerate the entries. */
1410 if (strcmp(str, "lstLogEntries" ) != 0) {
1411 /* has selected a type of log or a log */
1412 window_dimWindow( wid, &w, &h );
1413 logWidgetsReady=0;
1414
1415 logType = toolkit_getListPos( wid, "lstLogType" );
1416 log = toolkit_getListPos( wid, "lstLogs" );
1417
1418 if (logType != selectedLogType) {
1419 /* new log type selected */
1420 selectedLogType = logType;
1421 window_destroyWidget( wid, "lstLogs" );
1422 logs = NULL;
1423 shiplog_listLogsOfType( info_getLogTypeFilter(selectedLogType), &nlogs, &logs, &logIDs, 1 );
1424 if (selectedLog >= nlogs)
1425 selectedLog = 0;
1426 window_addList( wid, 20, 60 + BUTTON_HEIGHT + LOGSPACING / 2,
1427 w-40, LOGSPACING / 4,
1428 "lstLogs", logs, nlogs, 0, shiplog_menu_update, NULL );
1429
1430 toolkit_setListPos( wid, "lstLogs", selectedLog );
1431 regenerateEntries=1;
1432 }
1433 if (regenerateEntries || selectedLog != log) {
1434 selectedLog = CLAMP( 0, nlogs-1, log );
1435 /* list log entries of selected log type */
1436 window_destroyWidget( wid, "lstLogEntries" );
1437 shiplog_listLog( logIDs[selectedLog], info_getLogTypeFilter(selectedLogType), &nentries, &logentries, 1 );
1438 window_addList( wid, 20, 40 + BUTTON_HEIGHT,
1439 w-40, LOGSPACING / 2-20,
1440 "lstLogEntries", logentries, nentries, 0, shiplog_menu_update, info_shiplogView );
1441 toolkit_setListPos( wid, "lstLogEntries", 0 );
1442 window_setFocus( wid, "lstLogEntries" );
1443 }
1444 logWidgetsReady=1;
1445 }
1446}
1447
1451static const char* info_getLogTypeFilter( int lstPos )
1452{
1453 if (lstPos < 1)
1454 return NULL; /* "All" */
1455 return logTypes[lstPos];
1456}
1457
1462static void shiplog_menu_genList( unsigned int wid, int first )
1463{
1464 int w, h;
1465 int nentries;
1466 char **logentries;
1467
1468 /* Needs 3 lists:
1469 * 1. List of log types (and All)
1470 * 2. List of logs of the selected type (and All)
1471 * 3. Listing of the selected log
1472 */
1473 if (!first) {
1474 window_destroyWidget( wid, "lstLogType" );
1475 window_destroyWidget( wid, "lstLogs" );
1476 logs = NULL;
1477 window_destroyWidget( wid, "lstLogEntries" );
1478 }
1479 /* Get the dimensions. */
1480 window_dimWindow( wid, &w, &h );
1481
1482 /* list log types */
1483 shiplog_listTypes(&ntypes, &logTypes, 1);
1484 if ( selectedLogType >= ntypes )
1485 selectedLogType = 0;
1486 /* list logs of selected type */
1487 shiplog_listLogsOfType(info_getLogTypeFilter(selectedLogType), &nlogs, &logs, &logIDs, 1);
1488 if ( selectedLog >= nlogs )
1489 selectedLog = 0;
1490 /* list log entries of selected log */
1491 shiplog_listLog(logIDs[selectedLog], info_getLogTypeFilter(selectedLogType), &nentries, &logentries, 1);
1492 logWidgetsReady=0;
1493 window_addList( wid, 20, 80 + BUTTON_HEIGHT + 3*LOGSPACING/4 ,
1494 w-40, LOGSPACING / 4,
1495 "lstLogType", logTypes, ntypes, 0, shiplog_menu_update, NULL );
1496 window_addList( wid, 20, 60 + BUTTON_HEIGHT + LOGSPACING / 2,
1497 w-40, LOGSPACING / 4,
1498 "lstLogs", logs, nlogs, 0, shiplog_menu_update, NULL );
1499 window_addList( wid, 20, 40 + BUTTON_HEIGHT,
1500 w-40, LOGSPACING / 2-20,
1501 "lstLogEntries", logentries, nentries, 0, shiplog_menu_update, info_shiplogView );
1502 window_setFocus( wid, "lstLogEntries" );
1503 logWidgetsReady=1;
1504}
1505
1506static void info_shiplogMenuDelete( unsigned int wid, const char *str )
1507{
1508 (void) str;
1509 char buf[STRMAX_SHORT];
1510 int ret, logid;
1511
1512 if (logIDs[selectedLog] == LOG_ID_ALL) {
1513 dialogue_msg( "", _("You are currently viewing all logs in the selected log type. Please select a log title to delete.") );
1514 return;
1515 }
1516
1517 snprintf( buf, sizeof(buf),
1518 _("This will delete ALL \"%s\" log entries. This operation cannot be undone. Are you sure?"),
1519 logs[selectedLog]);
1520 ret = dialogue_YesNoRaw( "", buf );
1521 if (!ret)
1522 return;
1523 /* There could be several logs of the same name, so make sure we get the correct one. */
1524 /* selectedLog-1 since not including the "All" */
1525 logid = shiplog_getIdOfLogOfType( info_getLogTypeFilter(selectedLogType), selectedLog-1 );
1526 if (logid >= 0)
1527 shiplog_delete( logid );
1528 selectedLog = 0;
1529 selectedLogType = 0;
1530 shiplog_menu_genList(wid, 0);
1531}
1532
1533static void info_shiplogView( unsigned int wid, const char *str )
1534{
1535 char **logentries;
1536 int nentries;
1537 int pos;
1538 (void) str;
1539
1540 pos = toolkit_getListPos( wid, "lstLogEntries" );
1541 if (pos < 0)
1542 return;
1544 logIDs[selectedLog], info_getLogTypeFilter(selectedLogType), &nentries,
1545 &logentries, 1);
1546
1547 if (pos < nentries)
1548 dialogue_msgRaw( _("Log message"), logentries[pos] );
1549
1550 for (int i=0; i<nentries; i++)
1551 free( logentries[i] );
1552 free( logentries );
1553}
1554
1561static void info_shiplogAdd( unsigned int wid, const char *str )
1562{
1563 char *tmp;
1564 int logType, log;
1565 int logid;
1566 (void) str;
1567
1568 logType = toolkit_getListPos( wid, "lstLogType" );
1569 log = toolkit_getListPos( wid, "lstLogs" );
1570 if ( log < 0 || logIDs[log] == LOG_ID_ALL ) {
1571 tmp = dialogue_inputRaw( _("Add a log entry"), 0, 4096, _("Add an entry to your diary:") );
1572 if ( ( tmp != NULL ) && ( strlen(tmp) > 0 ) ) {
1573 if ( shiplog_getID( "Diary" ) == -1 )
1574 shiplog_create( "Diary", _("Your Diary"), "Diary", 0, 0 );
1575 shiplog_append( "Diary", tmp );
1576 free( tmp );
1577 }
1578 } else {
1579 tmp = dialogue_input( _("Add a log entry"), 0, 4096, _("Add an entry to the log titled '%s':"), logs[log] );
1580 if ( ( tmp != NULL ) && ( strlen(tmp) > 0 ) ) {
1581 logid = shiplog_getIdOfLogOfType( info_getLogTypeFilter(logType), log-1 );
1582 if ( logid >= 0 )
1583 shiplog_appendByID( logid, tmp );
1584 else
1585 dialogue_msgRaw( _("Cannot add log"), _("Cannot find this log! Something went wrong here!") );
1586 free( tmp );
1587 }
1588 }
1589 shiplog_menu_genList( wid, 0 );
1590
1591}
1592
1598static void info_openShipLog( unsigned int wid )
1599{
1600 int w, h, texth;
1601 /* re-initialise the statics */
1602 selectedLog = 0;
1603 selectedLogType = 0;
1604
1605 /* Get the dimensions. */
1606 window_dimWindow( wid, &w, &h );
1607 /* buttons */
1608 window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
1609 "closeShipLog", _("Close"), info_close );
1610 window_addButton( wid, -20 - 1*(20+BUTTON_WIDTH), 20,
1611 BUTTON_WIDTH, BUTTON_HEIGHT, "btnDeleteLog", _("Delete"),
1612 info_shiplogMenuDelete );
1613 window_addButton( wid, -20 - 2*(20+BUTTON_WIDTH), 20, BUTTON_WIDTH,
1614 BUTTON_HEIGHT, "btnViewLog", _("View Entry"),
1615 info_shiplogView );
1616 window_addButton( wid, -20 - 3*(20+BUTTON_WIDTH), 20, BUTTON_WIDTH,
1617 BUTTON_HEIGHT, "btnAddLog", _("Add Entry"),
1618 info_shiplogAdd );
1619 /* Description text */
1620 texth = gl_printHeightRaw( &gl_smallFont, w, "Select log type" );
1621 window_addText( wid, 20, 80 + BUTTON_HEIGHT + LOGSPACING,
1622 w - 40, texth, 0,
1623 "logDesc1", &gl_smallFont, NULL, _("Select log type:") );
1624
1625 window_addText( wid, 20, 60 + BUTTON_HEIGHT + 3* LOGSPACING / 4,
1626 w - 40, texth, 0,
1627 "logDesc2", &gl_smallFont, NULL, _("Select log title:") );
1628
1629 window_addText( wid, 20, 25 + BUTTON_HEIGHT + LOGSPACING / 2,
1630 w - 40, texth, 0,
1631 "logDesc3", &gl_smallFont, NULL, _("Log entries:") );
1632
1633#undef LOGSPACING
1634 /* list */
1635 shiplog_menu_genList(wid ,1);
1636}
1637
1641static void info_changeTab( unsigned int wid, const char *str, int old, int new )
1642{
1643 (void) wid;
1644 (void) str;
1645 (void) old;
1646 const char *hookname;
1647 switch (new) {
1648 case INFO_WIN_MAIN: hookname = "info_main"; break;
1649 case INFO_WIN_SHIP: hookname = "info_ship"; break;
1650 case INFO_WIN_WEAP: hookname = "info_weapons"; break;
1651 case INFO_WIN_CARGO: hookname = "info_cargo"; break;
1652 case INFO_WIN_MISN: hookname = "info_mission"; break;
1653 case INFO_WIN_STAND: hookname = "info_standing";break;
1654 case INFO_WIN_SHIPLOG:hookname= "info_shiplog"; break;
1655 default: ERR( _("Invalid info tab ID: %d"), new );
1656 }
1657 hooks_run( hookname );
1658}
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
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:465
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:436
int dialogue_YesNoRaw(const char *caption, const char *msg)
Runs a dialogue with both yes and no options.
Definition: dialogue.c:366
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
Definition: dialogue.c:218
void dialogue_msgRaw(const char *caption, const char *msg)
Opens a dialogue window with an ok button and a fixed message.
Definition: dialogue.c:261
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:344
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:427
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:1327
const char * faction_longname(int f)
Gets the faction's long name (formal, human-readable).
Definition: faction.c:346
int faction_isKnown(int id)
Is the faction known?
Definition: faction.c:273
char faction_getColourChar(int f)
Gets the faction character associated to its standing with the player.
Definition: faction.c:1040
const glTexture * faction_logo(int f)
Gets the faction's logo (ideally 256x256).
Definition: faction.c:451
const char * faction_name(int f)
Gets a factions "real" (internal) name.
Definition: faction.c:304
const char * faction_getStandingText(int f)
Gets the player's standing in human readable form.
Definition: faction.c:1054
double faction_getPlayer(int f)
Gets the player's standing with a faction.
Definition: faction.c:969
int * faction_getKnown()
Gets all the known factions in an array (array.h).
Definition: faction.c:217
double faction_reputationMax(int f)
Gets the maximum reputation of a faction.
Definition: faction.c:1151
const char * faction_description(int f)
Gets the faction's description (translated).
Definition: faction.c:380
int gl_printHeightRaw(const glFont *ft_font, const int width, const char *text)
Gets the height of a non-formatted string.
Definition: font.c:1026
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:690
int gui_load(const char *name)
Attempts to load the actual GUI.
Definition: gui.c:1839
char * gui_pick(void)
Determines which GUI should be used.
Definition: gui.c:1818
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
Definition: hook.c:967
int hooks_run(const char *stack)
Runs all the hooks of stack.
Definition: hook.c:987
Handles the info menu.
int info_buttonRegister(const char *caption, int priority, SDL_Keycode key)
Registers a button in the info menu.
Definition: info.c:188
#define INFO_DEFAULT
Definition: info.h:16
void info_update(void)
Updates the info windows.
Definition: info.c:353
int info_buttonUnregister(int id)
Unregisters a button in the info menu.
Definition: info.c:219
void info_buttonClear(void)
Clears all the registered buttons.
Definition: info.c:241
void menu_info(int window)
Opens the information menu.
Definition: info.c:278
void bar_regen(void)
Regenerates the bar list.
Definition: land.c:452
int landed
Definition: land.c:74
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:594
void mission_cleanup(Mission *misn)
Cleans up a mission.
Definition: mission.c:677
void mission_sysMark(void)
Marks all active systems that need marking.
Definition: mission.c:516
void mission_shift(int pos)
Puts the specified mission at the end of the player_missions array.
Definition: mission.c:729
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
static char buf[NEWS_MAX_LENGTH]
Definition: news.c:45
int misn_tryRun(Mission *misn, const char *func)
Tries to run a mission, but doesn't err if it fails.
Definition: nlua_misn.c:148
int asprintf(char **strp, const char *fmt,...)
Like sprintf(), but it allocates a large-enough string and returns the pointer in the first argument....
Definition: nstring.c:161
int strsort(const void *p1, const void *p2)
Sort function for sorting strings with qsort().
Definition: nstring.c:108
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:178
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:230
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(Pilot *p)
Calculates the hyperspace delay for a pilot.
Definition: pilot.c:2855
int pilot_getJumps(const Pilot *p)
Gets the amount of jumps the pilot has left.
Definition: pilot.c:1316
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.
Definition: pilot_cargo.c:189
int pilot_weapSetTypeCheck(Pilot *p, int id)
Checks the current weapon set type.
Definition: pilot_weapon.c:301
void pilot_weapSetInrange(Pilot *p, int id, int inrange)
Changes the weapon set inrange property.
Definition: pilot_weapon.c:346
void pilot_weapSetManual(Pilot *p, int id, int manual)
Changes the weapon set manual property.
Definition: pilot_weapon.c:372
int pilot_weapSetManualCheck(Pilot *p, int id)
Checks the current weapon set manual property.
Definition: pilot_weapon.c:359
void ws_copy(PilotWeaponSet dest[PILOT_WEAPON_SETS], const PilotWeaponSet src[PILOT_WEAPON_SETS])
Copies a weapon set over.
void pilot_weapSetType(Pilot *p, int id, int type)
Changes the weapon sets mode.
Definition: pilot_weapon.c:314
void pilot_weaponSetDefault(Pilot *p)
Gives the pilot a default 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.
Definition: pilot_weapon.c:333
const char * pilot_weapSetName(Pilot *p, int id)
Gets the name of a weapon set.
Definition: pilot_weapon.c:381
const char ** player_getLicenses()
Gets the array (array.h) of license names in the player's inventory.
Definition: player.c:3026
Player_t player
Definition: player.c:73
PilotCommodity * pfleet_cargoList(void)
Gets a list of all the cargo in the fleet.
Definition: player_fleet.c:373
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...
Definition: player_fleet.c:395
int pfleet_cargoFree(void)
Gets the total amount of free cargo space in the player's fleet.
Definition: player_fleet.c:255
int pfleet_cargoRm(const Commodity *com, int q, int jet)
Removes some cargo from the player's fleet.
Definition: player_fleet.c:335
int pfleet_cargoUsed(void)
Gets the total cargo space used by the player's fleet.
Definition: player_fleet.c:231
char ** player_guiList(void)
Gets the list of GUIs.
Definition: player_gui.c:116
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:151
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:35
const char * str
Definition: hook.h:39
union HookParam::@4 u
HookParamType type
Definition: hook.h:36
double num
Definition: hook.h:38
For use with registered info buttons.
Definition: info.c:71
int func
Definition: info.c:78
SDL_Keycode key
Definition: info.c:79
char * button
Definition: info.c:74
int priority
Definition: info.c:75
char * caption
Definition: info.c:73
nlua_env env
Definition: info.c:77
int id
Definition: info.c:72
Represents an active mission.
Definition: mission.h:79
char * reward
Definition: mission.h:86
char * desc
Definition: mission.h:85
char * title
Definition: mission.h:84
Stores a pilot commodity.
Definition: pilot.h:172
const Commodity * commodity
Definition: pilot.h:173
unsigned int id
Definition: pilot.h:175
int quantity
Definition: pilot.h:174
Solid * solid
Definition: pilot.h:220
ShipStats stats
Definition: pilot.h:286
double shield
Definition: pilot.h:246
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
Definition: pilot.h:311
double thrust
Definition: pilot.h:235
int aimLines
Definition: pilot.h:314
double crew
Definition: pilot.h:231
credits_t credits
Definition: pilot.h:317
double energy_regen
Definition: pilot.h:259
double armour_max
Definition: pilot.h:247
double speed
Definition: pilot.h:237
const Ship * ship
Definition: pilot.h:219
double fuel_max
Definition: pilot.h:252
double energy
Definition: pilot.h:257
int autoweap
Definition: pilot.h:313
double energy_max
Definition: pilot.h:258
double fuel
Definition: pilot.h:253
char * name
Definition: pilot.h:212
double shield_regen
Definition: pilot.h:250
double turn
Definition: pilot.h:240
double armour
Definition: pilot.h:244
double shield_max
Definition: pilot.h:248
double dmg_absorb
Definition: pilot.h:251
double armour_regen
Definition: pilot.h:249
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:137
unsigned int jumped_times
Definition: player.h:142
PlayerShip_t ps
Definition: player.h:102
char * name
Definition: player.h:103
double dmg_done_armour
Definition: player.h:138
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
Definition: player.h:141
double dmg_taken_armour
Definition: player.h:140
char * gui
Definition: player.h:124
double time_played
Definition: player.h:135
int fleet_capacity
Definition: player.h:131
double dmg_taken_shield
Definition: player.h:139
unsigned int death_counter
Definition: player.h:144
unsigned int landed_times
Definition: player.h:143
double time_mod
Definition: shipstats.h:308
double dt_default
Definition: ship.h:123
char * name
Definition: ship.h:95
double mass
Definition: physics.h:18
Abstraction for rendering sprite sheets.
Definition: opengl_tex.h:34
double w
Definition: opengl_tex.h:38
double h
Definition: opengl_tex.h:39
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:696
void window_setFocus(unsigned int wid, const char *wgtname)
Sets the focused widget in a window.
Definition: toolkit.c:2460
void window_setAccept(unsigned int wid, void(*accept)(unsigned int, const char *))
Sets the default accept function of the window.
Definition: toolkit.c:879
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:900
void toolkit_drawRect(int x, int y, int w, int h, const glColour *c, const glColour *lc)
Draws a rectangle.
Definition: toolkit.c:1340
void window_moveWidget(unsigned int wid, const char *name, int x, int y)
Moves a widget.
Definition: toolkit.c:467
void window_destroyWidget(unsigned int wid, const char *wgtname)
Destroys a widget in a window.
Definition: toolkit.c:1162
int window_isTop(unsigned int wid)
Checks to see if a window is at the top.
Definition: toolkit.c:551
unsigned int window_get(const char *wdwname)
Gets the ID of a window.
Definition: toolkit.c:671
void window_resizeWidget(unsigned int wid, const char *name, int w, int h)
Resizes a widget.
Definition: toolkit.c:495
void window_onCleanup(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the cleanup function of the window.
Definition: toolkit.c:858
int widget_exists(unsigned int wid, const char *wgtname)
Checks to see if a widget exists.
Definition: toolkit.c:1139
void window_close(unsigned int wid, const char *str)
Helper function to automatically close the window calling it.
Definition: toolkit.c:1031
void window_destroy(unsigned int wid)
Kills the window.
Definition: toolkit.c:1042
void weapons_update(const double dt)
Updates all the weapon layers.
Definition: weapon.c:548