29#include "land_outfits.h"
36#include "pilot_outfit.h"
38#include "player_fleet.h"
41#include "tk/toolkit_priv.h"
47#define EQUIPMENT_SHIPS "iarAvailShips"
48#define EQUIPMENT_OUTFIT_TAB "tabOutfits"
49#define EQUIPMENT_OUTFITS "iarAvailOutfits"
50#define EQUIPMENT_FILTER "inpFilterOutfits"
54#define BUTTON_WIDTH 200
55#define BUTTON_HEIGHT 40
57typedef struct ShipWidgetData_ {
77static nlua_env autoequip_env = LUA_NOREF;
85 int *sh,
int *ow,
int *oh,
int *ew,
int *eh,
86 int *cw,
int *ch,
int *bw,
int *bh );
92static void equipment_toggleDeploy(
unsigned int wid,
const char *wgt );
105 double bh,
void *data );
108static void equipment_freeShipData(
unsigned int wid,
const char *unused );
110 double h,
double my );
112 double x,
double y,
double w,
double h,
113 double rx,
double ry,
void *data );
115static char eq_qCol(
double cur,
double base,
int inv );
128static void equipment_outfitPopdown(
unsigned int wid,
const char *str );
135static int equipment_filter(
const Outfit *o );
136static int equipment_filterWeapon(
const Outfit *o );
137static int equipment_filterUtility(
const Outfit *o );
138static int equipment_filterStructure(
const Outfit *o );
139static int equipment_filterCore(
const Outfit *o );
140static int ( *tabfilters[] )(
const Outfit *o ) = {
141 equipment_filter, equipment_filterWeapon, equipment_filterUtility,
142 equipment_filterStructure, equipment_filterCore,
154 int id, active, minimal, n, nfits;
159 active = window_tabWinGetActive( wid, EQUIPMENT_OUTFIT_TAB );
160 id = toolkit_getImageArrayPos( wid, EQUIPMENT_OUTFITS );
172 case OUTFIT_SLOT_STRUCTURE:
173 slots =
eq_wgt.selected->p->outfit_structure;
175 case OUTFIT_SLOT_UTILITY:
176 slots =
eq_wgt.selected->p->outfit_utility;
178 case OUTFIT_SLOT_WEAPON:
179 slots =
eq_wgt.selected->p->outfit_weapon;
189 for (
int i = 0; i < n; i++ ) {
195 if ( o->
slot.
size == OUTFIT_SLOT_SIZE_NA )
206 if ( slots[minimal].outfit != NULL )
216 if ( o->
limit != NULL ) {
218 for (
int i = 0; i < n; i++ ) {
224 if ( o->
slot.
size == OUTFIT_SLOT_SIZE_NA )
228 if ( ( slots[i].outfit == NULL ) ||
229 ( slots[i].outfit->limit == NULL ) )
233 if ( strcmp( slots[i].outfit->limit, o->
limit ) != 0 )
251 size = OUTFIT_SLOT_SIZE_NA;
253 for (
int i = 0; i < n; i++ ) {
255 if ( slots[i].outfit != NULL )
263 if ( o->
slot.
size == OUTFIT_SLOT_SIZE_NA )
267 if ( ( size == OUTFIT_SLOT_SIZE_NA ) ||
268 ( slots[i].sslot->slot.size < size ) ) {
287 int *sh,
int *ow,
int *oh,
int *ew,
int *eh,
288 int *cw,
int *ch,
int *bw,
int *bh )
295 ssw = 550 + ( *w - LAND_WIDTH );
300 *sh = ( 1 * ssh ) / 3;
304 *oh = ( 2 * ssh ) / 3;
316 *ch = 140 + ( (
player.fleet_capacity > 0 ) ? 40 : 0 );
320 *bw =
MIN( LAND_BUTTON_WIDTH,
321 ( *w - 20 - ( sw != NULL ? *sw : 0 ) - 40 - 20 - 60 ) / 5 );
331 int w, h, sw, sh, ow, oh, bw, bh, ew, eh, cw, ch, x, y;
338 land_tabGenerate( LAND_WINDOW_EQUIPMENT );
345 equipment_getDim( wid, &w, &h, &sw, &sh, &ow, &oh, &ew, &eh, &cw, &ch, &bw,
351 window_addButtonKey( wid, x, y, bw, bh,
"btnCloseEquipment", _(
"Take Off" ),
354 window_addButtonKey( wid, x, y, bw, bh,
"btnSellShip", _(
"Sell Ship" ),
357 window_addButtonKey( wid, x, y, bw, bh,
"btnChangeShip", _(
"Swap Ship" ),
360 window_addButtonKey( wid, x, y, bw, bh,
"btnUnequipShip", _(
"Unequip" ),
363 window_addButtonKey( wid, x, y, bw, bh,
"btnAutoequipShip", _(
"Autoequip" ),
367 for (
int i = 0; i < OUTFIT_TABS; i++ ) {
368 toolkit_initImageArrayData( &
iar_data[i] );
381 x = 20 + sw + 20 + 180 + 10;
383 window_addText( wid, x, y, 130, y - 20 + h - bh, 0,
"txtSDesc", &
gl_defFont,
385 window_addText( wid, x, y, w - x - 128 - 30, y - 20 + h - bh, 0,
388 window_addText( wid, x, y, w - x - 20 - 128 - 20, y - 20 + h - bh, 0,
392 window_addText( wid, 30, -20, ow,
gl_defFont.h, 0,
"txtShipTitle",
394 window_addText( wid, 30, -40 - sh - 20, ow,
gl_defFont.h, 0,
396 _(
"Available Outfits" ) );
399 x = -20 - ( 128 - cw ) / 2;
401 window_addCheckbox( wid, x, y, cw, 30,
"chkFav", _(
"Favourite" ),
403 if (
player.fleet_capacity > 0 ) {
405 window_addCheckbox( wid, x, y, cw, 30,
"chkDeploy", _(
"Deployed" ),
406 equipment_toggleDeploy, 0 );
410 window_addButtonKey( wid, x, y, 128 + 8, bh,
"btnRenameShip", _(
"Rename" ),
413 window_addButtonKey( wid, x, y, 128 + 8, bh,
"btnShipMode",
429 window_addCust( wid, -20 - ( 128 - cw ) / 2, -20 - 150, cw, ch,
"cstMisc", 0,
439 window_addRect( wid, -20 + 4, -40 + 4, 128 + 8, 128 + 8,
"rctShip", &cBlack,
442 NULL, NULL, NULL, swd );
443 window_custSetDynamic( wid,
"cstShip", 1 );
471 window_custSetClipping( wid,
"cstEquipment", 0 );
483 const glColour *
c, *dc, *rc;
491 if ( ( o != NULL ) && ( lst[0].sslot->slot.type == o->
slot.
type ) )
498 for (
int i = 0; i <
array_size( lst ); i++ ) {
504 ( lst[i].
outfit == NULL ) )
514 else if ( level == 1 )
516 else if ( cantoggle )
535 if ( lst[i].outfit != NULL ) {
539 }
else if ( ( o != NULL ) &&
540 ( lst[i].sslot->slot.type == o->
slot.
type ) ) {
544 glUseProgram( shaders.status.program );
545 glUniform1f( shaders.status.paramf, ok );
552 if ( lst[i].sslot->locked )
554 else if ( lst[i].sslot->required )
556 else if ( lst[i].sslot->exclusive )
558 else if ( lst[i].sslot->slot.spid != 0 )
569 icon =
sp_icon( lst[i].sslot->slot.spid );
570 if ( icon != NULL ) {
573 double sx = x + w - 10.;
574 double sy = y + h - 10.;
576 if ( icon->
flags & OPENGL_TEX_SDF )
599 double *w,
double *h,
int *n,
int *m )
608 th = bh / (double)tm;
610 s =
MIN( th, tw ) - 20.;
647 selected = wgt->
slot;
654 x = bx + ( tw - w ) / 2 + 2 * tw;
655 y = by + bh - ( h + 20 ) + ( h + 20 - h ) / 2;
657 selected, wgt->
outfit, p, wgt );
660 selected -=
array_size( p->outfit_structure );
662 y = by + bh - ( h + 20 ) + ( h + 20 - h ) / 2;
664 selected, wgt->
outfit, p, wgt );
669 y = by + bh - ( h + 20 ) + ( h + 20 - h ) / 2;
671 selected, wgt->
outfit, p, wgt );
692 if (
eq_wgt.selected == NULL )
701 y = by + bh - 30 - h;
704 if (
player.fleet_capacity > 0 ) {
706 _(
"Fleet Capacity" ) );
708 percent =
CLAMP( 0., 1.,
709 1. - (
double)
player.fleet_used /
710 (
double)
player.fleet_capacity );
715 &cFontWhite,
"%d / %d",
726 percent = ( p->cpu_max > 0 )
727 ?
CLAMP( 0., 1., (
double)p->cpu / (
double)p->cpu_max )
730 toolkit_drawRect( x + w * percent, y - 2, w * ( 1. - percent ), h + 4, &cRed,
733 &cFontWhite,
"%d / %d", p->cpu, p->cpu_max );
739 _(
"Mass Limit Left" ) );
742 percent = ( p->stats.engine_limit > 0 )
744 ( p->stats.engine_limit - p->solid.mass ) /
745 p->stats.engine_limit )
751 &cFontWhite,
"%.0f / %.0f",
752 p->stats.engine_limit - p->solid.mass, p->stats.engine_limit );
755 if ( p->stats.engine_limit > 0. && p->solid.mass > p->stats.engine_limit ) {
757 _(
"!! %.0f%% Slower !!" ),
758 ( 1. - p->speed / p->speed_base ) * 100 );
778 int text_width, yoff;
782 for (
int i = 0; i <
array_size( lst ); i++ ) {
786 if ( lst[i].sslot->locked && ( lst[i].
outfit == NULL ) )
789 if ( lst[i].outfit != NULL ) {
797 if ( ( i == mover ) || subtitle ) {
800 if ( ( i == mover ) && wgt->
canmodify ) {
801 if ( lst[i].sslot->locked ) {
803 display = _(
"Locked" );
805 }
else if ( lst[i].outfit != NULL ) {
808 if ( display != NULL )
811 display = _(
"Right click to remove" );
814 }
else if ( ( wgt->
outfit != NULL ) &&
819 if ( display != NULL )
822 display = _(
"Right click to add" );
826 }
else if ( lst[i].outfit != NULL ) {
830 if ( display != NULL ) {
860 double bh,
void *data )
888 x = bx + ( tw - w ) / 2 + 2 * tw;
889 y = by + bh - ( h + 20 ) + ( h + 20 - h ) / 2;
893 y = by + bh - ( h + 20 ) + ( h + 20 - h ) / 2;
897 y = by + bh - ( h + 20 ) + ( h + 20 - h ) / 2;
914 pos =
scnprintf( alt,
sizeof( alt ),
"#o%s\n",
919 scnprintf( &alt[pos],
sizeof( alt ) - pos, _(
"#%c%s #%c%s #0slot" ),
926 scnprintf( &alt[pos],
sizeof( alt ) - pos, _(
" [exclusive]" ) );
927 if ( slot->
sslot->
locked && ( pos < (
int)
sizeof( alt ) ) )
928 pos +=
scnprintf( &alt[pos],
sizeof( alt ) - pos,
"#r%s#0",
931 scnprintf( &alt[pos],
sizeof( alt ) - pos,
"\n\n%s",
941 if ( slot->
lua_mem != LUA_NOREF ) {
942 size_t slen = strlen( alt );
964 double px, py, pw, ph;
968 const unsigned int wid = swd->wid;
971 if (
eq_wgt.selected == NULL )
977 unsigned int tick = SDL_GetTicks();
980 p->solid.dir += p->turn * dt;
981 if ( p->solid.dir > 2. * M_PI )
982 p->solid.dir = fmod( p->solid.dir, 2. * M_PI );
998 px = bx + ( bw - pw ) / 2;
999 py = by + ( bh - ph ) / 2;
1007 glGetIntegerv( GL_FRAMEBUFFER_BINDING, &fbo );
1010 glBindFramebuffer( GL_FRAMEBUFFER, fbo );
1012 s / swd->s, NULL, 0. );
1015 if ( debug_isFlag( DEBUG_MARK_EMITTER ) ) {
1017 double dircos, dirsin;
1020 int use_3d = ship_isFlag( p->ship, SHIP_3DTRAILS );
1025 if ( fabs( p->tilt ) > DOUBLE_TOL ) {
1030 mat4_rotate( &H, -p->solid.dir + M_PI_2, 0.0, 1.0, 0.0 );
1037 for ( i = 0; i <
array_size( p->ship->trail_emitters ); i++ ) {
1046 v.x = trail->
pos.v[0] * dircos - trail->
pos.v[1] * dirsin;
1047 v.y = trail->
pos.v[0] * dirsin + trail->
pos.v[1] * dircos +
1049 v.x *= pw / p->ship->size;
1050 v.y *= ph / p->ship->size;
1064 if ( (
eq_wgt.slot >= 0 ) &&
1065 p->outfits[
eq_wgt.slot]->sslot->slot.type == OUTFIT_SLOT_WEAPON ) {
1069 v.x *= pw / p->ship->size;
1070 v.y *= ph / p->ship->size;
1073 glUseProgram( shaders.crosshairs.program );
1074 glUniform1f( shaders.crosshairs.paramf, 2. );
1076 &cRadar_player, 1 );
1080static void equipment_freeShipData(
unsigned int wid,
const char *unused )
1084 glDeleteFramebuffers( 1, &swd->fbo );
1085 glDeleteTextures( 1, &swd->tex );
1086 glDeleteTextures( 1, &swd->texd );
1100 double h,
double my )
1102 for (
int i = 0; i <
array_size( lst ); i++ ) {
1104 if ( lst[i].sslot->locked && ( lst[i].
outfit == NULL ) )
1108 if ( ( my > y ) && ( my < y + h + 20. ) )
1131 double mx,
double my,
double y,
double h,
1139 if ( event->type == SDL_MOUSEBUTTONDOWN ) {
1142 if ( event->button.button == SDL_BUTTON_LEFT ) {
1144 int sel = selected + ret;
1145 if ( wgt->
slot == sel )
1148 const char *filtertext;
1149 int active, noutfits;
1160 if ( strlen( filtertext ) == 0 )
1168 EQUIPMENT_OUTFIT_TAB );
1171 (
const Outfit ***)&outfits, tabfilters[active],
1173 if ( noutfits <= 0 ) {
1176 for (
int i = 0; i < OUTFIT_TABS; i++ ) {
1180 (
const Outfit ***)&outfits, tabfilters[i],
1182 if ( noutfits > 0 ) {
1190 EQUIPMENT_OUTFIT_TAB, best );
1198 }
else if ( ( event->button.button == SDL_BUTTON_RIGHT ) &&
1209 if ( event->button.button == SDL_BUTTON_LEFT )
1211 else if ( event->button.button == SDL_BUTTON_RIGHT )
1216 if ( exists == level )
1245 double mx,
double my,
double bw,
double bh,
1246 double rx,
double ry,
void *data )
1266 if ( ( event->type != SDL_MOUSEBUTTONDOWN ) &&
1267 ( event->type != SDL_MOUSEMOTION ) )
1278 tw = bw / (double)n;
1282 x = ( tw - w ) / 2 + 2 * tw;
1283 y = bh - ( h + 20 ) + ( h + 20 - h ) / 2 - 10;
1284 if ( ( mx > x - 10 ) && ( mx < x + w + 10 ) ) {
1286 p->outfit_structure, p, selected, wgt );
1288 return !!(
event->type == SDL_MOUSEBUTTONDOWN );
1290 selected +=
array_size( p->outfit_structure );
1292 if ( ( mx > x - 10 ) && ( mx < x + w + 10 ) ) {
1294 p->outfit_utility, p, selected, wgt );
1296 return !!(
event->type == SDL_MOUSEBUTTONDOWN );
1300 if ( ( mx > x - 10 ) && ( mx < x + w + 10 ) ) {
1302 p->outfit_weapon, p, selected, wgt );
1304 return !!(
event->type == SDL_MOUSEBUTTONDOWN );
1323 int selslot =
eq_wgt.slot;
1326 if ( slot->
outfit != NULL ) {
1338 _(
"This action will recall your deployed "
1339 "fighters. Is that OK?" ) ) ) {
1344 for (
int j = 0; j <
array_size( p->outfits ); j++ ) {
1345 if ( p->outfits[j] == slot )
1383 if (
eq_wgt.selected->p->id > 0 )
1410 if (
eq_wgt.selected->p->autoweap ) {
1431 int nship = 0, noutfit = 0;
1432 double offship = 0, offoutfit = 0;
1433 char *selship = NULL;
1434 const char *s = NULL;
1454 noutfit = toolkit_getImageArrayPos( wid, EQUIPMENT_OUTFITS );
1455 offoutfit = toolkit_getImageArrayOffset( wid, EQUIPMENT_OUTFITS );
1459 nship = toolkit_getImageArrayPos( wid, EQUIPMENT_SHIPS );
1460 offship = toolkit_getImageArrayOffset( wid, EQUIPMENT_SHIPS );
1461 s = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
1462 selship = strdup( s );
1471 toolkit_setImageArrayPos( wid, EQUIPMENT_OUTFITS, noutfit );
1472 toolkit_setImageArrayOffset( wid, EQUIPMENT_OUTFITS, offoutfit );
1476 toolkit_setImageArrayPos( wid, EQUIPMENT_SHIPS, nship );
1477 toolkit_setImageArrayOffset( wid, EQUIPMENT_SHIPS, offship );
1479 s = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
1480 if ( ( s != NULL ) && ( strcmp( s, selship ) != 0 ) ) {
1481 int ret = toolkit_setImageArray( wid, EQUIPMENT_SHIPS, selship );
1483 toolkit_setImageArrayPos( wid, EQUIPMENT_SHIPS, nship );
1504 if ( strcmp( shipname,
player.p->name ) == 0 ) {
1523 if ( strcmp( shipname,
player.p->name ) == 0 ) {
1529 if ( ship_isFlag( ps->
p->
ship, SHIP_NOPLAYER ) ) {
1531 "be used as an escort." ),
1537 if ( ship_isFlag(
player.p->ship, SHIP_NOESCORT ) ) {
1539 _(
"You can not swap ships and set %s as an escort!" ),
1556 n_(
"You have %d tonne more cargo than the new ship can hold.",
1557 "You have %d tonnes more cargo than the new ship can hold.",
1562 if ( pilot_hasDeployed(
player.p ) ) {
1564 _(
"This action will recall your deployed "
1565 "fighters. Is that OK?" ) ) ) {
1583 if (
eq_wgt.selected == NULL )
1622 l +=
scnprintf( &buf[l], ( max_len - l ), _(
"%.2f DPS [%.2f EPS]\n" ),
1625 l +=
scnprintf( &buf[l], ( max_len - l ),
"%s\n",
1627 l +=
scnprintf( &buf[l], ( max_len - l ), _(
"%.0f fuel per jump\n" ),
1638 int state = window_checkboxState( wid, wgt );
1639 const char *shipname = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
1640 if ( strcmp( shipname,
player.p->name ) == 0 ) {
1641 player.ps.favourite = state;
1651static void equipment_toggleDeploy(
unsigned int wid,
const char *wgt )
1653 int state = window_checkboxState( wid, wgt );
1654 const char *shipname = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
1657 if (
player.fleet_capacity <= 0 )
1661 if ( strcmp( shipname,
player.p->name ) != 0 ) {
1663 if ( state && ship_isFlag( ps->
p->
ship, SHIP_NOESCORT ) ) {
1665 _(
"You can not set your ship '%s' as an escort!" ),
1672 window_checkboxSet( wid, wgt, 1 );
1695 ImageArrayCell *cships;
1706 equipment_getDim( wid, &w, &h, &sw, &sh, NULL, NULL, NULL, NULL, NULL, NULL,
1717 cships = calloc( nships,
sizeof( ImageArrayCell ) );
1720 cships[0].caption = strdup(
player.p->name );
1722 t =
gl_newImage( OVERLAY_GFX_PATH
"active.webp", 0 );
1724 if (
player.ps.favourite ) {
1725 t =
gl_newImage( OVERLAY_GFX_PATH
"favourite.webp", 0 );
1728 if (
player.p->ship->rarity > 0 ) {
1729 snprintf( r,
sizeof( r ), OVERLAY_GFX_PATH
"rarity_%d.webp",
1730 player.p->ship->rarity );
1737 for (
int i = 1; i <=
array_size( ps ); i++ ) {
1738 cships[i].image =
ship_gfxStore( ps[i - 1].p->ship, 256, 0., 0., 0. );
1739 cships[i].caption = strdup( ps[i - 1].p->name );
1740 cships[i].layers =
gl_copyTexArray( ps[i - 1].p->ship->gfx_overlays );
1741 if ( ps[i - 1].favourite ) {
1742 t =
gl_newImage( OVERLAY_GFX_PATH
"favourite.webp", 0 );
1745 if ( ps[i - 1].deployed ) {
1746 t =
gl_newImage( OVERLAY_GFX_PATH
"fleet.webp", 0 );
1749 if ( ps[i - 1].p->ship->rarity > 0 ) {
1750 snprintf( r,
sizeof( r ), OVERLAY_GFX_PATH
"rarity_%d.webp",
1751 ps[i - 1].p->ship->rarity );
1758 for (
int i = 0; i < nships; i++ ) {
1761 cships[i].alt = malloc( STRMAX );
1762 l = snprintf( &cships[i].alt[0], STRMAX, _(
"Ship Stats\n" ) );
1765 free( cships[i].alt );
1766 cships[i].alt = NULL;
1772 if ( !conf.big_icons ) {
1773 if ( toolkit_simImageArrayVisibleElements( sw, sh, iconsize, iconsize ) <
1776 if ( toolkit_simImageArrayVisibleElements( sw, sh, iconsize, iconsize ) <
1780 window_addImageArray( wid, 20, -40, sw, sh, EQUIPMENT_SHIPS, iconsize,
1783 toolkit_setImageArrayAccept( wid, EQUIPMENT_SHIPS,
1789static int equipment_filter(
const Outfit *o )
1795 if ( ( p != NULL ) && (
eq_wgt.slot >= 0 ) ) {
1808 for (
int j = 0; j <
array_size( ps ); j++ ) {
1809 const Pilot *pp = ps[j].
p;
1820 for (
int i = 0; i <
array_size( p->outfits ); i++ ) {
1827 return ( o->
slot.
size == OUTFIT_SLOT_SIZE_LIGHT );
1829 return ( o->
slot.
size == OUTFIT_SLOT_SIZE_MEDIUM );
1831 return ( o->
slot.
size == OUTFIT_SLOT_SIZE_HEAVY );
1835static int equipment_filterWeapon(
const Outfit *o )
1837 return equipment_filter( o ) && outfit_filterWeapon( o );
1839static int equipment_filterUtility(
const Outfit *o )
1841 return equipment_filter( o ) && outfit_filterUtility( o );
1843static int equipment_filterStructure(
const Outfit *o )
1845 return equipment_filter( o ) && outfit_filterStructure( o );
1847static int equipment_filterCore(
const Outfit *o )
1849 return equipment_filter( o ) && outfit_filterCore( o );
1858 int x, y, w, h, ow, oh;
1859 int ix, iy, iw, ih, barw;
1860 const char *filtertext;
1861 const char *tabnames[] = {
1862 _(
"All" ), _( OUTFIT_LABEL_WEAPON ), _( OUTFIT_LABEL_UTILITY ),
1863 _( OUTFIT_LABEL_STRUCTURE ), _( OUTFIT_LABEL_CORE ) };
1864 int noutfits, active;
1865 ImageArrayCell *coutfits;
1870 equipment_getDim( wid, &w, &h, NULL, NULL, &ow, &oh, NULL, NULL, NULL, NULL,
1882 window_addTabbedWindow( wid, x, y + oh - 30, ow, 30, EQUIPMENT_OUTFIT_TAB,
1883 OUTFIT_TABS, tabnames, 1 );
1885 barw = window_tabWinGetBarWidth( wid, EQUIPMENT_OUTFIT_TAB );
1887 iw =
CLAMP( 0, 150, ow - barw - 30 );
1891 iy = y + oh - 25 - 1;
1895 WARN( _(
"Very little space on equipment outfit tabs!" ) );
1899 window_addButton( wid, ix + iw - 30, iy, 30, 30,
"btnOutfitFilter", NULL,
1900 equipment_outfitPopdown );
1901 window_buttonCustomRender( wid,
"btnOutfitFilter",
1902 window_buttonCustomRenderGear );
1906 window_addInput( wid, ix, iy, iw, ih, EQUIPMENT_FILTER, 32, 1, NULL );
1907 inp_setEmptyText( wid, EQUIPMENT_FILTER, _(
"Filter…" ) );
1912 active = window_tabWinGetActive(
equipment_wid, EQUIPMENT_OUTFIT_TAB );
1924 filtertext = window_getInput(
equipment_wid, EQUIPMENT_FILTER );
1925 if ( strlen( filtertext ) == 0 )
1931 tabfilters[active], filtertext );
1934 ( p == NULL ) ?
player.p : p, 0 );
1940 if ( !conf.big_icons ) {
1941 if ( toolkit_simImageArrayVisibleElements( iw, ih, iconsize, iconsize ) <
1944 if ( toolkit_simImageArrayVisibleElements( iw, ih, iconsize, iconsize ) <
1948 window_addImageArray( wid, x + 4, y + 3, iw, ih, EQUIPMENT_OUTFITS, iconsize,
1953 toolkit_setImageArrayAccept( wid, EQUIPMENT_OUTFITS,
1962static char eq_qCol(
double cur,
double base,
int inv )
1964 if ( cur > 1.2 * base )
1965 return ( inv ) ?
'r' :
'g';
1966 else if ( cur < 0.8 * base )
1967 return ( inv ) ?
'g' :
'r';
1974static const char *
eq_qSym(
double cur,
double base,
int inv )
1976 if ( cur > 1.2 * base )
1977 return ( inv ) ?
"!! " :
"";
1978 else if ( cur < 0.8 * base )
1979 return ( inv ) ?
"" :
"!! ";
1983#define EQ_COMP( cur, base, inv ) \
1984 eq_qCol( cur, base, inv ), eq_qSym( cur, base, inv ), cur
1985#define EQ_COMP_I( cur, base, inv ) \
1986 eq_qCol( cur, base, inv ), eq_qSym( cur, base, inv )
1995 char buf[STRMAX], buf_price[ECON_CRED_STRLEN];
1996 char errorReport[STRMAX_SHORT], tbuf[64];
1997 const char *shipname, *acquired, *modelname;
1998 char scargo[NUM2STRLEN];
2002 int onboard, cargo, jumps, favourite, deployed, x, h, spaceworthy;
2003 int ww, wh, sw, sh, bw, bh, hacquired, hname, hmodelname;
2007 equipment_getDim( wid, &ww, &wh, &sw, &sh, NULL, NULL, NULL, NULL, NULL,
2016 shipname = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
2017 if ( strcmp( shipname,
player.p->name ) == 0 ) {
2028 prevship =
eq_wgt.selected;
2038 equipment_slotSelect( &
eq_wgt, ps );
2053 x = 20 + sw + 20 + 180 + 10;
2056 : _(
"You do not remember how you acquired this ship." );
2071 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s", _(
"Name:" ) );
2072 for (
int i = 0; i < hname - 1; i++ )
2073 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2074 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Model:" ) );
2075 for (
int i = 0; i < hmodelname - 1; i++ )
2076 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2077 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Class:" ) );
2078 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Acquired Date:" ) );
2079 for (
int i = 0; i < hacquired + 1; i++ )
2080 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2082 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Value:" ) );
2083 if (
player.fleet_capacity > 0 )
2084 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
2085 _(
"Fleet Capacity:" ) );
2086 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Crew:" ) );
2087 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Mass:" ) );
2088 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Jump Time:" ) );
2089 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Accel:" ) );
2090 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Speed:" ) );
2091 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Turn:" ) );
2093 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Time Constant:" ) );
2094 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Detected at:" ) );
2095 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Signature:" ) );
2096 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Stealth at:" ) );
2098 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Scanning time:" ) );
2099 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2100 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Absorption:" ) );
2101 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Shield:" ) );
2102 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Armour:" ) );
2103 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Energy:" ) );
2104 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Cargo Space:" ) );
2105 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Fuel:" ) );
2106 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2107 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Ship Status:" ) );
2109 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Time Flown:" ) );
2111 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Jumped Times:" ) );
2113 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Landed Times:" ) );
2114 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Damage Done:" ) );
2116 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Damage Taken:" ) );
2117 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
2118 _(
"Ships Destroyed:" ) );
2119 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n\n%s",
2120 _(
"Intrinsic Outfits:" ) );
2122 window_modifyText( wid,
"txtSDesc", buf );
2127 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s", ship->
name );
2128 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", modelname );
2129 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
2138 snprintf( tbuf,
sizeof( tbuf ), _(
"Unknown" ) );
2141 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", tbuf );
2145 window_modifyText( wid,
"txtAcquired", acquired );
2147 for (
int i = 0; i < hacquired + 1; i++ )
2148 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2151 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", buf_price );
2152 if (
player.fleet_capacity > 0 )
2156 &buf[l],
sizeof( buf ) - l,
"\n#%c%s%d#0",
2158 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s#0 %s",
2160 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2161 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s average" ), nt );
2162 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2164 scnprintf( &buf[l],
sizeof( buf ) - l, _(
"#%c%s%.0f#0 %s" ),
2167 &buf[l],
sizeof( buf ) - l,
2168 _(
"\n#%c%s%.0f#0 %s (max #%c%s%.0f#0 %s)" ),
2176 &buf[l],
sizeof( buf ) - l, _(
"\n#%c%s%.0f#0 %s" ),
2177 EQ_COMP( ship->
turn * 180. / M_PI, ship->
ship->
turn * 180. / M_PI, 0 ),
2179 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%.0f%%",
2181 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s %s\n",
2183 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s %s" ),
2185 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s %s\n",
2187 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%.1f %s" ),
2189 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n\n" );
2192 &buf[l],
sizeof( buf ) - l,
"#%c%s%.0f%%\n",
2194 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"#%c%s%s#0 %s" ),
2198 &buf[l],
sizeof( buf ) - l, _(
" (#%c%s%s#0 %s)" ),
2201 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2202 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"#%c%s%s#0 %s" ),
2206 &buf[l],
sizeof( buf ) - l, _(
" (#%c%s%s#0 %s)" ),
2209 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2210 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"#%c%s%s#0 %s" ),
2214 &buf[l],
sizeof( buf ) - l, _(
" (#%c%s%s#0 %s)" ),
2217 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2219 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s / #%c%s%s#0 %s" ),
2222 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2223 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s %s (%d %s)" ),
2225 n_(
"jump",
"jumps", jumps ) );
2226 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2227 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n#%c%s#0",
2228 spaceworthy ?
'0' :
'r', errorReport );
2231 for (
int i = 0; i < SHIP_CLASS_TOTAL; i++ )
2233 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2234 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s hours" ),
2236 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
2238 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
2240 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2241 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s %s" ),
2244 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
2246 scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s %s" ),
2249 scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
2252 window_modifyText( wid,
"txtDDesc", buf );
2257 ImageArrayCell *cells;
2260 for (
int i = 0; i < ncells; i++ )
2267 ty = -40 - window_getTextHeight( wid,
"txtSDesc" ) - 10;
2268 window_addImageArray( wid, tx, ty, ww - x - 128 - 30 - 10,
2269 ty - 20 + wh - bh - 30,
"iarIntrinsic", 64, 64,
2270 cells, ncells, NULL, NULL, NULL );
2279 window_checkboxSet( wid,
"chkFav", favourite );
2280 if (
player.fleet_capacity > 0 )
2281 window_checkboxSet( wid,
"chkDeploy", deployed );
2285 window_disableButton( wid,
"btnSellShip" );
2286 window_disableButton( wid,
"btnChangeShip" );
2288 window_enableButton( wid,
"btnChangeShip" );
2289 window_enableButton( wid,
"btnSellShip" );
2293 if ( ship_isFlag( ps->
p->
ship, SHIP_UNIQUE ) )
2294 window_disableButton( wid,
"btnSellShip" );
2313 active = window_tabWinGetActive( wid, EQUIPMENT_OUTFIT_TAB );
2314 i = toolkit_getImageArrayPos( wid, EQUIPMENT_OUTFITS );
2340 int m = toolkit_getListPos( wid, str );
2346 player.eq_outfitMode = m;
2349static void equipment_outfitPopdownActivate(
unsigned int wid,
const char *str )
2355static void equipment_outfitPopdown(
unsigned int wid,
const char *str )
2357 const char *name =
"lstOutfitPopdown";
2358 const char *modes[] = {
2359 N_(
"Show all outfits" ),
2360 N_(
"Show only outfits equipable on any of your ships" ),
2361 N_(
"Show only outfits equipable on current ship" ),
2362 N_(
"Show only light outfits" ),
2363 N_(
"Show only medium outfits" ),
2364 N_(
"Show only heavy outfits" ),
2367 const size_t n =
sizeof( modes ) /
sizeof(
const char * );
2375 modelist = malloc(
sizeof( modes ) );
2376 for (
size_t i = 0; i < n; i++ )
2377 modelist[i] = strdup( _( modes[i] ) );
2381 window_addList( wid, x + w, y - 120 + h, 350, 120, name, modelist, n,
2383 equipment_outfitPopdownActivate );
2399 iar_data_t old_data;
2401 toolkit_saveImageArrayData( wid, EQUIPMENT_OUTFITS, &
iar_data[old] );
2408 window_setInput( wid, EQUIPMENT_FILTER, NULL );
2415 toolkit_loadImageArrayData( wid, EQUIPMENT_OUTFITS, &old_data );
2426 const char *shipname = toolkit_getImageArray( wid, str );
2430 if (
player.fleet_capacity <= 0 )
2438 if ( strcmp( shipname,
player.p->name ) == 0 )
2441 if ( !ps->
deployed && ship_isFlag( ps->
p->
ship, SHIP_NOESCORT ) ) {
2443 _(
"You can not set your ship '%s' as an escort!" ),
2452 if (
player.fleet_capacity > 0 )
2453 window_checkboxSet( wid,
"chkDeploy", ps->
deployed );
2478 const char *shipname, *filtertext;
2482 shipname = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
2495 i = window_tabWinGetActive( wid, EQUIPMENT_OUTFIT_TAB );
2496 toolkit_saveImageArrayData( wid, EQUIPMENT_OUTFITS, &
iar_data[i] );
2498 filtertext = window_getInput(
equipment_wid, EQUIPMENT_FILTER );
2513 window_tabWinSetActive( wid, EQUIPMENT_OUTFIT_TAB, i );
2514 toolkit_loadImageArrayData( wid, EQUIPMENT_OUTFITS, &
iar_data[i] );
2516 window_setInput( wid, EQUIPMENT_FILTER, filtertext );
2522 toolkit_setImageArrayPos( wid, EQUIPMENT_SHIPS, 0 );
2523 toolkit_setImageArrayOffset( wid, EQUIPMENT_SHIPS, 0. );
2544 dialogue_alert( _(
"You can't unequip your ship when you have more cargo "
2545 "than it can hold without modifications!" ) );
2549 _(
"Are you sure you want to remove all equipment from "
2550 "your ship?" ) ) == 0 )
2552 if ( pilot_hasDeployed( ship ) ) {
2554 _(
"This action will recall your deployed "
2555 "fighters. Is that OK?" ) ) )
2614 const char *curship;
2615 const char *file = AUTOEQUIP_PATH;
2617 ship =
eq_wgt.selected->p;
2620 doswap = ( ship !=
player.p );
2622 curship =
player.p->name;
2627 if ( autoequip_env == LUA_NOREF ) {
2631 if ( buf == NULL ) {
2632 WARN( _(
"File '%s' not found!" ), file );
2636 autoequip_env = nlua_newEnv( file );
2639 if ( nlua_dobufenv( autoequip_env, buf, bufsize, file ) != 0 ) {
2640 WARN( _(
"Failed to run '%s': %s" ), file, lua_tostring(
naevL, -1 ) );
2642 lua_pop(
naevL, 1 );
2643 goto autoequip_cleanup;
2650 nlua_getenv(
naevL, autoequip_env,
"autoequip" );
2651 if ( !lua_isfunction(
naevL, -1 ) ) {
2652 WARN( _(
"'%s' doesn't have valid required 'autoequip' function!" ),
2654 lua_pop(
naevL, 1 );
2655 goto autoequip_cleanup;
2658 if ( nlua_pcall( autoequip_env, 1, 0 ) ) {
2659 WARN( _(
"'%s' failed to run required 'autoequip' function: %s" ), file,
2660 lua_tostring(
naevL, -1 ) );
2661 lua_pop(
naevL, 1 );
2662 goto autoequip_cleanup;
2684 char buf[ECON_CRED_STRLEN], *name;
2690 const char *shipname = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
2704 _(
"Are you sure you want to sell your ship %s for %s?" ), shipname,
2720 name = strdup( shipname );
2728 dialogue_msg( _(
"Ship Sold" ), _(
"You have sold your ship %s for %s." ),
2732 hparam[0].
type = HOOK_PARAM_SHIP;
2733 hparam[0].
u.
ship = s;
2734 hparam[1].
type = HOOK_PARAM_STRING;
2735 hparam[1].
u.
str = name;
2736 hparam[2].
type = HOOK_PARAM_SENTINEL;
2738 land_needsTakeoff( 1 );
2751 const char *shipname = toolkit_getImageArray( wid, EQUIPMENT_SHIPS );
2754 _(
"Please enter a new name for your %s:" ),
2758 if ( newname == NULL )
2764 _(
"Please do not give the ship the same name as another "
2765 "of your ships." ) );
2771 ship->
name = newname;
2791 if ( outfit_isProp( o, OUTFIT_PROP_UNIQUE ) &&
2802 if ( outfit_isProp( o, OUTFIT_PROP_UNIQUE ) )
2813 for (
int i = 0; i < OUTFIT_TABS; i++ )
2839 for (
int i = 0; i <
array_size( p->p->outfits ); i++ ) {
2841 if ( ( o != NULL ) && !outfit_gfxStoreLoaded( o ) ) {
2842 outfit_setProp( o, OUTFIT_PROP_NEEDSGFX );
2847 outfit_gfxStoreLoadNeeded();
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_end(array)
Returns a pointer to the end of the reserved memory space.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_begin(array)
Returns a pointer to the beginning of the reserved memory space.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void credits2str(char *str, credits_t credits, int decimals)
Converts credits to a usable string for displaying.
void dialogue_alert(const char *fmt,...)
Displays an alert popup with only an ok button and a message.
char * dialogue_input(const char *title, int min, int max, const char *fmt,...)
Creates a dialogue that allows the player to write a message.
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
void effect_clear(Effect **efxlist)
Clears an effect list, removing all active effects.
void equipment_slotDeselect(CstSlotWidget *wgt)
Deselects equipment stuff.
static int equipment_creating
static const char * eq_qSym(double cur, double base, int inv)
Gets the symbol for comparing a current value vs a ship base value.
static void equipment_rightClickShips(unsigned int wid, const char *str)
Toggles deployed status.
static double equipment_dir
static int equipment_mouseInColumn(const PilotOutfitSlot *lst, double y, double h, double my)
Handles a mouse press in column.
static CstSlotWidget eq_wgt
static int equipment_playerAddOutfit(const Outfit *o, int quantity)
Wrapper to only add unique outfits.
static void equipment_shipMode(unsigned int wid, const char *str)
Toggles the ship visualization mode.
static void equipment_changeTab(unsigned int wid, const char *wgt, int old, int tab)
Ensures the tab's selected item is reflected in the ship slot list.
static iar_data_t iar_data[OUTFIT_TABS]
static void equipment_sellShip(unsigned int wid, const char *str)
Player tries to sell a ship.
static int equipment_playerRmOutfit(const Outfit *o, int quantity)
Wrapper to only remove unique outfits.
static void equipment_getDim(unsigned int wid, int *w, int *h, int *sw, int *sh, int *ow, int *oh, int *ew, int *eh, int *cw, int *ch, int *bw, int *bh)
Gets the window dimensions.
static void equipment_renderColumn(double x, double y, double w, double h, const PilotOutfitSlot *lst, const char *txt, int selected, Outfit *o, Pilot *p, const CstSlotWidget *wgt)
Renders an outfit column.
static void equipment_outfitPopdownSelect(unsigned int wid, const char *str)
void equipment_regenLists(unsigned int wid, int outfits, int ships)
Regenerates the equipment window lists.
static void equipment_renameShip(unsigned int wid, const char *str)
Renames the selected ship.
static void equipment_renderOverlayColumn(double x, double y, double h, PilotOutfitSlot *lst, int mover, CstSlotWidget *wgt)
Renders an outfit column.
void equipment_cleanup(void)
Cleans up after the equipment stuff.
static void equipment_filterOutfits(unsigned int wid, const char *str)
Handles text input in the filter input widget.
static int equipment_outfitMode
static void equipment_genLists(unsigned int wid)
Generates a new ship/outfit lists if needed.
static void equipment_rightClickOutfits(unsigned int wid, const char *str)
Handles right-click on unequipped outfit.
void equipment_updateOutfits(unsigned int wid, const char *str)
Updates the player's outfit list.
static void equipment_transChangeShip(unsigned int wid, const char *str)
Changes ship.
static void equipment_genOutfitList(unsigned int wid)
Generates the outfit list.
static void equipment_toggleFav(unsigned int wid, const char *wgt)
Handles toggling of the favourite checkbox.
static void equipment_autoequipShip(unsigned int wid, const char *str)
Does the autoequip magic on the player's ship.
void equipment_slotWidget(unsigned int wid, double x, double y, double w, double h, CstSlotWidget *data)
Creates the slot widget and initializes it.
void equipment_updateShips(unsigned int wid, const char *str)
Updates the player's ship window.
static void equipment_renderShip(double bx, double by, double bw, double bh, void *data)
Renders the ship in the equipment window.
static void equipment_calculateSlots(const Pilot *p, double bw, double bh, double *w, double *h, int *n, int *m)
Calculates the size the slots need to be for a given window.
static int equipment_mouseColumn(unsigned int wid, const SDL_Event *event, double mx, double my, double y, double h, PilotOutfitSlot *os, Pilot *p, int selected, CstSlotWidget *wgt)
Handles a mouse press in a column.
static void equipment_renderMisc(double bx, double by, double bw, double bh, void *data)
Renders the custom equipment widget.
int equipment_canSwapPlayerShip(const char *shipname)
Makes sure it's valid to change ships in the equipment view.
int equipment_shipStats(char *buf, int max_len, const Pilot *s, int dpseps, int name)
Creates and allocates a string containing the ship stats.
void equipment_addAmmo(void)
Adds all the ammo it can to the player.
static int equipment_swapSlot(unsigned int wid, Pilot *p, PilotOutfitSlot *slot)
Swaps an equipment slot.
static char eq_qCol(double cur, double base, int inv)
Gets the colour for comparing a current value vs a ship base value.
static void equipment_changeShip(unsigned int wid)
Player attempts to change ship.
int equipment_canSellPlayerShip(const char *shipname)
Makes sure it's valid to sell a ship.
static int equipment_mouseSlots(unsigned int wid, const SDL_Event *event, double x, double y, double w, double h, double rx, double ry, void *data)
Does mouse input for the custom equipment widget.
static void equipment_unequipShip(unsigned int wid, const char *str)
Unequips the player's ship.
static unsigned int equipment_wid
void equipment_open(unsigned int wid)
Opens the player's equipment window.
static Outfit ** iar_outfits[OUTFIT_TABS]
static void equipment_renderSlots(double bx, double by, double bw, double bh, void *data)
Renders the equipment slots.
static void equipment_genShipList(unsigned int wid)
Generates the ship list.
static unsigned int equipment_lastick
static void equipment_renderOverlaySlots(double bx, double by, double bw, double bh, void *data)
Renders the equipment overlay.
int escort_clearDeployed(Pilot *p, int slot)
Clears deployed escorts of a pilot.
int gl_printHeightRaw(const glFont *ft_font, const int width, const char *text)
Gets the height of a non-formatted string.
int gl_printWidthRaw(const glFont *ft_font, const char *text)
Gets the width that it would take to print some text.
int gl_printMidRaw(const glFont *ft_font, int width, double x, double y, const glColour *c, double outlineR, const char *text)
Displays text centered in position and width.
int gl_printLinesRaw(const glFont *ft_font, const int width, const char *text)
Gets the number of lines of a non-formatted string.
int gl_printMaxRaw(const glFont *ft_font, const int max, double x, double y, const glColour *c, double outlineR, const char *text)
Behaves like gl_printRaw but stops displaying text after a certain distance.
int gl_printMid(const glFont *ft_font, const int width, double x, double y, const glColour *c, const char *fmt,...)
Displays text centered in position and width.
void gui_setShip(void)
Player just upgraded their ship or modified it.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
int hooks_run(const char *stack)
Runs all the hooks of stack.
void info_update(void)
Updates the info windows.
void land_errDialogueBuild(const char *fmt,...)
Generates error dialogues used by several landing tabs.
void land_errClear(void)
Clear error dialogues.
void land_buttonTakeoff(unsigned int wid, const char *unused)
Wrapper for takeoff mission button.
void land_refuel(void)
Refuels the player's current ship, if possible.
int land_errDisplay(void)
Displays an error if applicable.
int outfit_altText(char *buf, int n, const Outfit *o, const Pilot *plt)
Computes the alt text for an outfit.
ImageArrayCell * outfits_imageArrayCells(const Outfit **outfits, int *noutfits, const Pilot *p, int store)
Generates image array cells corresponding to outfits.
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
mat4 mat4_identity(void)
Creates an identity matrix.
void mat4_rotate(mat4 *m, double angle, double x, double y, double z)
Multiplies the given matrix by a rotation. (Follows the right-hand rule.)
void mat4_mul_vec(vec3 *out, const mat4 *m, const vec3 *v)
Multiplies a matrix with a vector (out = m * v);.
Header file with generic functions and naev-specifics.
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
int nlua_loadTk(nlua_env env)
Loads the Toolkit Lua library.
int num2str(char dest[NUM2STRLEN], double n, int decimals)
Converts a numeric value to a string.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
const char * num2strU(double n, int decimals)
Unsafe version of num2str that uses an internal buffer. Every call overwrites the return value.
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
void ntime_prettyBuf(char *str, int max, ntime_t t, int d)
Gets the time in a pretty human readable format filling a preset buffer.
void gl_renderShader(double x, double y, double w, double h, double r, const SimpleShader *shd, const glColour *c, int center)
Renders a simple shader.
void gl_renderRect(double x, double y, double w, double h, const glColour *c)
Renders a rectangle.
void gl_renderSDF(const glTexture *texture, double x, double y, double w, double h, const glColour *c, double angle, double outline)
SDF Texture blitting backend.
void gl_renderScale(const glTexture *texture, double bx, double by, double bw, double bh, const glColour *c)
Blits a texture scaling it.
void gl_renderScaleAspect(const glTexture *texture, double bx, double by, double bw, double bh, const glColour *c)
Blits a texture scaling it to fit a rectangle, but conserves aspect ratio.
void gl_renderTextureRaw(GLuint texture, uint8_t flags, double x, double y, double w, double h, double tx, double ty, double tw, double th, const glColour *c, double angle)
Texture blitting backend.
void gl_renderCross(double x, double y, double r, const glColour *c)
Renders a cross at a given position.
int gl_fboCreate(GLuint *fbo, GLuint *tex, GLsizei width, GLsizei height)
Creates a framebuffer and its associated texture.
glTexture ** gl_addTexArray(glTexture **tex, glTexture *t)
Adds an element to a texture array.
glTexture ** gl_copyTexArray(glTexture **tex)
Copy a texture array.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
int gl_fboAddDepth(GLuint fbo, GLuint *tex, GLsizei width, GLsizei height)
Adds a depth attachment to an FBO.
void gl_getSpriteFromDir(int *x, int *y, int sx, int sy, double dir)
Sets x and y to be the appropriate sprite for glTexture using dir.
int outfit_isLauncher(const Outfit *o)
Checks if outfit is a weapon launcher.
char outfit_slotTypeColourFont(const OutfitSlot *os)
Gets a font colour character that roughly matches an outfit slot type colour.
int outfit_fitsSlot(const Outfit *o, const OutfitSlot *s)
Checks to see if an outfit fits a slot.
int outfit_isFighterBay(const Outfit *o)
Checks if outfit is a fighter bay.
char outfit_slotSizeColourFont(const OutfitSlot *os)
Gets a font colour character that roughly matches an outfit slot size colour.
int outfit_amount(const Outfit *o)
Gets the amount an outfit can hold.
const char * slotName(const OutfitSlotType type)
int outfit_gfxStoreLoad(Outfit *o)
Loads the store graphics for the outfit.
const char * slotSize(const OutfitSlotSize o)
Gets the slot size as a string.
const glColour * outfit_slotSizeColour(const OutfitSlot *os)
Gets the slot size colour for an outfit slot.
void pilot_renderFramebuffer(Pilot *p, GLuint fbo, double fw, double fh, const Lighting *L)
Renders a pilot to a framebuffer.
ntime_t pilot_hyperspaceDelay(const Pilot *p)
Calculates the hyperspace delay for a pilot.
void pilot_dpseps(const Pilot *p, double *pdps, double *peps)
Calculates the dps and eps of a pilot.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoUsedMission(const Pilot *p)
Gets how much mission cargo ship has on board.
int pilot_cargoUsed(const Pilot *p)
Gets how much cargo ship has on board.
double pilot_ewScanTime(const Pilot *p)
Gets the time it takes to scan a pilot.
int pilot_getMount(const Pilot *p, const PilotOutfitSlot *w, vec2 *v)
Gets the mount position of a pilot.
int pilot_rmOutfit(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot.
void pilot_healLanded(Pilot *pilot)
Cures the pilot as if he was landed.
int pilot_maxAmmoO(const Pilot *p, const Outfit *o)
Gets the maximum available ammo for a pilot for a specific outfit.
int pilot_slotIsToggleable(const PilotOutfitSlot *o)
Checks to see if a slot has an active outfit that can be toggleable.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
void pilot_fillAmmo(Pilot *pilot)
Fills pilot's ammo completely.
int pilot_rmOutfitRaw(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot without doing any checks.
int pilot_reportSpaceworthy(const Pilot *p, char *buf, int bufSize)
Pilot safety report - makes sure stats are safe.
int pilot_rmAmmo(Pilot *pilot, PilotOutfitSlot *s, int quantity)
Removes some ammo from the pilot stock.
const char * pilot_canEquip(const Pilot *p, const PilotOutfitSlot *s, const Outfit *o)
Checks to see if can equip/remove an outfit from a slot.
int pilot_addOutfitRaw(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
Adds an outfit to the pilot, ignoring CPU or other limits.
void pilot_outfitLInitAll(Pilot *pilot)
Runs the pilot's Lua outfits init script.
void pilot_weapSetAdd(Pilot *p, int id, const PilotOutfitSlot *o)
Adds an outfit to a weapon set.
void pilot_weaponSafe(Pilot *p)
Sets the weapon set as safe.
void pilot_weapSetRm(Pilot *p, int id, const PilotOutfitSlot *o)
Removes a slot from a weapon set.
void ws_copy(PilotWeaponSet dest[PILOT_WEAPON_SETS], const PilotWeaponSet src[PILOT_WEAPON_SETS])
Copies a weapon set over.
int pilot_weapSetInSet(Pilot *p, int id, const PilotOutfitSlot *o)
Checks to see if a slot is in a weapon set.
int pilot_outfitOffAll(Pilot *p)
Disables all active outfits for a pilot.
int pilot_weapSetCheck(Pilot *p, int id, const PilotOutfitSlot *o)
Checks to see if a slot is in a weapon set and usable.
void pilot_weaponAuto(Pilot *p)
Tries to automatically set and create the pilot's weapon set.
int player_nships(void)
Gets the amount of ships player has in storage.
int player_rmOutfit(const Outfit *o, int quantity)
Remove an outfit from the player's outfit stack.
int player_getOutfitsFiltered(const Outfit ***outfits, int(*filter)(const Outfit *o), const char *name)
Prepares two arrays for displaying in an image array.
void player_swapShip(const char *shipname, int move_cargo)
Swaps player's current ship with their ship named shipname.
int player_addOutfit(const Outfit *o, int quantity)
Adds an outfit to the player outfit stack.
credits_t player_shipPrice(const char *shipname, int count_unique)
Calculates the price of one of the player's ships.
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
void player_rmShip(const char *shipname)
Removes one of the player's ships.
PlayerShip_t * player_getPlayerShip(const char *shipname)
Gets a specific ship.
credits_t player_modCredits(credits_t amount)
Modifies the amount of credits the player has.
int player_hasShip(const char *shipname)
Sees if player has a ship of a name.
void player_shipsSort(void)
Sorts the players ships.
int player_outfitOwned(const Outfit *o)
Gets how many of the outfit the player owns.
Pilot * player_getShip(const char *shipname)
Gets a specific ship.
int pfleet_toggleDeploy(PlayerShip_t *ps, int deploy)
Toggles a player ship as deployed.
int pfleet_cargoFree(void)
Gets the total amount of free cargo space in the player's fleet.
const char * ship_classDisplay(const Ship *s)
Gets the ship's display class in human readable form.
double ship_maxSize(void)
Gets the maximum size of a ship.
glTexture * ship_gfxStore(const Ship *s, int size, double dir, double updown, double glow)
Get the store gfx.
int ss_statsListDesc(const ShipStatList *ll, char *buf, int len, int newline)
Writes the ship statistics description.
int ss_statsDesc(const ShipStats *s, char *buf, int len, int newline)
Writes the ship statistics description.
const char * sp_description(unsigned int spid)
Gets the description of a slot property (in English).
const glTexture * sp_icon(unsigned int spid)
Gets the icon associated with the slot.
const char * sp_display(unsigned int spid)
Gets the display name of a slot property (in English).
ntime_t start_date(void)
Gets the starting date.
The actual hook parameter.
union HookParam::@114305201244257020071001257133270030317263020235 u
A ship outfit, depends radically on the type.
Stores an outfit the pilot has.
The representation of an in-game pilot.
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
PilotOutfitSlot ** outfits
PilotOutfitSlot * outfit_intrinsic
unsigned int landed_times
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
unsigned int jumped_times
const TrailSpec * trail_spec
Abstraction for rendering sprite sheets.