10#include "SDL_events.h"
18#include "dev_sysedit.h"
23#include "dev_system.h"
24#include "dev_uniedit.h"
30#include "opengl_render.h"
35#define BUTTON_WIDTH 100
36#define BUTTON_HEIGHT 30
38#define SYSEDIT_EDIT_WIDTH 500
39#define SYSEDIT_EDIT_HEIGHT 400
41#define SYSEDIT_DRAG_THRESHOLD 300
42#define SYSEDIT_MOVE_THRESHOLD 10
44#define SYSEDIT_ZOOM_STEP 1.2
45#define SYSEDIT_ZOOM_MAX 1
46#define SYSEDIT_ZOOM_MIN -23
62typedef struct Select_s {
104static void sysedit_render(
double bx,
double by,
double w,
double h,
113 double x,
double y );
115 double x,
double y,
int sx,
int sy,
116 const glColour *
c,
int selected,
117 const char *caption );
119static int sysedit_mouseTrySelect(
const Select_t *sel,
double x,
double y,
120 double t,
double mx,
double my,
121 SDL_Keymod mod,
void ( *func )(
void ) );
122static int sysedit_mouse(
unsigned int wid,
const SDL_Event *event,
double mx,
123 double my,
double w,
double h,
double xr,
double yr,
126static void sysedit_close(
unsigned int wid,
const char *wgt );
129 const char *unused );
131static void sysedit_btnRename(
unsigned int wid_unused,
const char *unused );
135static void sysedit_btnGrid(
unsigned int wid_unused,
const char *unused );
136static void sysedit_btnEdit(
unsigned int wid_unused,
const char *unused );
153static void sysedit_btnTagsClose(
unsigned int wid,
const char *unused );
156static void sysedit_spobGFX(
unsigned int wid_unused,
const char *wgt );
166static void sysedit_editAsteroidsClose(
unsigned int wid,
const char *unused );
167static void sysedit_genAsteroidsList(
unsigned int wid );
168static void sysedit_btnAsteroidsDelete(
unsigned int wid,
const char *unused );
169static void sysedit_btnRmAsteroid(
unsigned int wid,
const char *unused );
170static void sysedit_btnAddAsteroid(
unsigned int wid,
const char *unused );
172static void sysedit_editExclusion(
void );
173static void sysedit_editExclusionClose(
unsigned int wid,
const char *unused );
174static void sysedit_btnExclusionDelete(
unsigned int wid,
const char *unused );
176static int sysedit_keys(
unsigned int wid, SDL_Keycode key, SDL_Keymod mod,
186static void sysedit_diffCreateSpobStr(
const Spob *spb, UniHunkType_t type,
188static void sysedit_diffCreateSpobInt(
const Spob *spb, UniHunkType_t type,
190static void sysedit_diffCreateSpobFloat(
const Spob *spb, UniHunkType_t type,
201 const glColour cBG = { 0., 0., 0., 0.95 };
217 snprintf( buf,
sizeof( buf ), _(
"%s - Star System Editor" ), sys->name );
227 window_addCust( wid, 0, 0, SCREEN_W, SCREEN_H,
"cstSysEdit", 1,
232 window_addRect( wid, SCREEN_W - 130, 0, 130, SCREEN_H,
"rctRCol", &cBG, 0 );
233 window_addRect( wid, 0, 0, SCREEN_W, 60,
"rctBBar", &cBG, 0 );
284 window_buttonCustomRender( wid,
"btnOptions",
285 window_buttonCustomRenderGear );
288 window_addButton( wid, 20, 20, 30, 30,
"btnZoomIn", p_(
"zoomin",
"+" ),
290 window_addButton( wid, 60, 20, 30, 30,
"btnZoomOut", p_(
"zoomout",
"-" ),
294 snprintf( buf,
sizeof( buf ), _(
"Radius: %.0f" ), sys->radius );
295 window_addText( wid, 100, 10, SCREEN_W / 2 - 140, 30, 0,
"txtSelected",
305static int sysedit_keys(
unsigned int wid, SDL_Keycode key, SDL_Keymod mod,
337 if ( conf.devautosave ) {
368 if ( fabs( fdata - p->population ) > 0. ) {
369 if ( uniedit_diffMode )
370 sysedit_diffCreateSpobFloat( p, HUNK_TYPE_SPOB_POPULATION, fdata );
372 p->population = fdata;
376 if ( strcmp( p->class, inp ) != 0 ) {
377 if ( uniedit_diffMode ) {
378 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_CLASS, strdup( inp ) );
381 if ( inp[0] ==
'\0' )
384 p->class = strdup( inp );
389 if ( ( inp != p->lua_file ) ||
390 ( ( p->lua_file != NULL ) && ( inp != NULL ) &&
391 strcmp( p->lua_file, inp ) != 0 ) ) {
392 if ( uniedit_diffMode ) {
393 if ( ( inp == NULL ) || ( strlen( inp ) == 0 ) )
394 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_LUA, NULL );
396 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_LUA, strdup( inp ) );
399 if ( ( inp == NULL ) || ( strlen( inp ) == 0 ) )
402 p->lua_file = strdup( inp );
407 if ( fabs( p->presence.base - fdata ) > 1e-5 ) {
408 if ( uniedit_diffMode )
409 sysedit_diffCreateSpobFloat( p, HUNK_TYPE_SPOB_PRESENCE_BASE, fdata );
411 p->presence.base = fdata;
413 fdata = atof( window_getInput(
sysedit_widEdit,
"inpPresenceBonus" ) );
414 if ( fabs( p->presence.bonus - fdata ) > 1e-5 ) {
415 if ( uniedit_diffMode )
416 sysedit_diffCreateSpobFloat( p, HUNK_TYPE_SPOB_PRESENCE_BONUS, fdata );
418 p->presence.bonus = fdata;
421 if ( data != p->presence.range ) {
422 if ( uniedit_diffMode )
423 sysedit_diffCreateSpobInt( p, HUNK_TYPE_SPOB_PRESENCE_RANGE, data );
425 p->presence.range = data;
428 if ( fabs( p->hide - fdata ) > 1e-5 ) {
429 if ( uniedit_diffMode )
430 sysedit_diffCreateSpobFloat( p, HUNK_TYPE_SPOB_HIDE, fdata );
443 if ( !uniedit_diffMode ) {
444 if ( conf.devautosave ) {
468 if ( uniedit_diffMode ) {
471 (
"Adding new spobs is not supported in diff mode!" ) );
477 _(
"What do you want to name the new spob?" ) );
483 dialogue_alert( _(
"Space object by the name of #r'%s'#0 already exists "
484 "in the #r'%s'#0 system" ),
496 char *cleanname = uniedit_nameFilter( p->name );
497 SDL_asprintf( &p->filename,
"%s.xml", cleanname );
504 good = !( ( b->class == NULL ) || ( b->gfx_spacePath == NULL ) ||
505 ( b->gfx_spaceName == NULL ) || ( b->gfx_exterior == NULL ) ||
506 ( b->gfx_exteriorPath == NULL ) );
508 p->class = strdup( b->class );
509 p->gfx_spacePath = strdup( b->gfx_spacePath );
510 p->gfx_spaceName = strdup( b->gfx_spaceName );
511 p->gfx_exterior = strdup( b->gfx_exterior );
512 p->gfx_exteriorPath = strdup( b->gfx_exteriorPath );
515 p->hide = HIDE_DEFAULT_SPOB;
516 p->radius = b->radius;
525 if ( conf.devautosave ) {
544 const char *title, *caption;
546 const char *opts[] = {
547 _(
"Asteroid Field" ),
548 _(
"Exclusion Zone" ),
553 title = _(
"Add asteroid field or exclusion zone?" );
554 caption = _(
"Do you wish to add an asteroid field or an asteroid exclusion "
555 "zone that will remove all asteroids that will appear in it?" );
562 ret = strdup( opts[0] );
564 if ( strcmp( ret, opts[0] ) == 0 ) {
568 if ( uniedit_diffMode ) {
570 _(
"New Asteroid Field Creation" ), 1, 32,
571 _(
"What do you want to label the new asteroid field? This is used "
572 "when referencing the asteroid field and is not displayed to "
579 ( strcmp(
sysedit_sys->asteroids[i].label, label ) == 0 ) ) {
581 "exists in system '%s'!" ),
588 uniedit_diffCreateSysStr(
sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_ADD,
597 }
else if ( strcmp( ret, opts[1] ) == 0 ) {
600 if ( uniedit_diffMode ) {
614 if ( conf.devautosave ) {
624 attr.name = strdup(
"label" );
625 attr.value = strdup( ast->
label );
630static void sysedit_btnRename(
unsigned int wid_unused,
const char *unused )
641 char *name, *oldName, *newName, *filtered;
645 if ( uniedit_diffMode )
647 _(
"What do you want to rename the spob #r%s#0?\n\n#rNote:#0 this "
648 "will only change the display name of the space object." );
651 _(
"What do you want to rename the spob #r%s#0?\n\n#rNote:#0 this "
652 "will rename and copy the space object data file." );
653 name =
dialogue_input( _(
"Rename Spob" ), 1, 32, prompt, p->name );
657 if ( uniedit_diffMode ) {
658 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_DISPLAYNAME,
663 dialogue_alert( _(
"Space object by the name of #r'%s'#0 already "
664 "exists in the #r'%s'#0 system" ),
672 filtered = strdup( p->filename );
673 SDL_asprintf( &oldName,
"%s/spob/%s", conf.dev_data_dir,
674 basename( filtered ) );
677 filtered = uniedit_nameFilter( name );
678 SDL_asprintf( &newName,
"%s/spob/%s.xml", conf.dev_data_dir,
682 if ( rename( oldName, newName ) )
683 WARN( _(
"Failed to rename '%s' to '%s'!" ), oldName, newName );
691 p->filename = newName;
712 if ( uniedit_diffMode ) {
714 _(
"Remove selected objects (excluding jumps)?" ),
715 _(
"Objects will be removed through the current diff." ) ) ) {
720 uniedit_diffCreateSysStr(
sysedit_sys, HUNK_TYPE_SPOB_REMOVE,
721 strdup( sp->
name ) );
724 if ( ( ast->
label == NULL ) ||
725 ( strcmp( ast->
label,
"" ) == 0 ) ) {
727 "mode is only supported when "
729 "have labels. Please set a label via "
730 "the property editor." ) );
733 uniedit_diffCreateSysStr(
744 if (
dialogue_YesNo( _(
"Remove selected objects (excluding jumps)?" ),
745 _(
"This can not be undone." ) ) ) {
750 char *filtered = uniedit_nameFilter( sp->
name );
751 SDL_asprintf( &file,
"%s/spob/%s.xml", conf.dev_data_dir,
786 if ( uniedit_diffMode ) {
788 _(
"Reseting systems is not supported in diff mode!" ) );
813 if ( uniedit_diffMode ) {
815 _(
"Scaling systems is not supported in diff mode!" ) );
821 _(
"Scale Star System" ), 1, 32,
822 _(
"By how much do you want to scale the star system?" ) );
831 if ( ( s < 0.1 ) || ( s > 10. ) ) {
833 _(
"Are you sure you want to scale the star "
834 "system by %.2f (from %.2f to %.2f)?" ),
835 s, sys->radius, sys->radius * s );
851 if ( fabs( factor - 1.0 ) < 1e-5 )
855 sys->radius *= factor;
856 snprintf( buf,
sizeof( buf ), _(
"Radius: %.0f" ), sys->radius );
858 window_modifyText(
sysedit_wid,
"txtSelected", buf );
861 for (
int i = 0; i <
array_size( sys->spobs ); i++ ) {
862 Spob *p = sys->spobs[i];
863 vec2_cset( &p->pos, p->pos.x * factor, p->pos.y * factor );
867 for (
int i = 0; i <
array_size( sys->jumps ); i++ ) {
868 JumpPoint *jp = &sys->jumps[i];
869 vec2_cset( &jp->pos, jp->pos.x * factor, jp->pos.y * factor );
873 for (
int i = 0; i <
array_size( sys->asteroids ); i++ ) {
875 vec2_cset( &ast->
pos, ast->
pos.
x * factor, ast->
pos.
y * factor );
878 for (
int i = 0; i <
array_size( sys->astexclude ); i++ ) {
880 vec2_cset( &exc->
pos, exc->
pos.
x * factor, exc->
pos.
y * factor );
921 for (
int i = 0; i <
array_size( sys->spobs ); i++ ) {
922 Spob *p = sys->spobs[i];
929 if ( p->gfx_space != NULL )
931 NULL, selected, p->name );
935 for (
int i = 0; i <
array_size( sys->jumps ); i++ ) {
937 JumpPoint *jp = &sys->jumps[i];
945 c = ( jp->flags & JP_AUTOPOS ) ? &cGreen : NULL;
949 jp->sy,
c, selected, jp->target->name );
953 for (
int i = 0; i <
array_size( sys->asteroids ); i++ ) {
964 for (
int i = 0; i <
array_size( sys->astexclude ); i++ ) {
976 for (
int i = 0; i <
array_size( safelanes ); i++ ) {
983 for (
int j = 0; j < 2; j++ ) {
985 case SAFELANE_LOC_SPOB:
987 posns[j] = &pnt->
pos;
989 case SAFELANE_LOC_DEST_SYS:
991 posns[j] = &njp->pos;
994 WARN( _(
"Invalid vertex type." ) );
1003 double x1, y1, x2, y2, ry, rx, r, rw, rh;
1004 x1 = x + posns[0]->
x * z;
1005 y1 = y + posns[0]->
y * z;
1006 x2 = x + posns[1]->
x * z;
1007 y2 = y + posns[1]->
y * z;
1010 r = atan2( ry, rx );
1011 rw = MOD( rx, ry ) / 2.;
1015 glUseProgram( shaders.safelane.program );
1017 &shaders.safelane, &col, 1 );
1040 tx = bx + ast->
pos.
x * z;
1041 ty = by + ast->
pos.
y * z;
1044 const glColour csel = COL_ALPHA( cFontBlue, 0.5 );
1050 ( selected ) ? &cRed : NULL, -1., _(
"Asteroid Field" ) );
1061 double tx, ty, z, r, rr;
1062 const glColour *col;
1068 tx = bx + aexcl->
pos.
x * z;
1069 ty = by + aexcl->
pos.
y * z;
1071 rr = r * sin( M_PI / 4. );
1074 const glColour csel = COL_ALPHA( cFontBlue, 0.5 );
1078 col = ( selected ) ? &cWhite : &cRed;
1089 double x,
double y )
1093 const double s = 1000.;
1096 double startx, starty, spacing;
1112 startx = bx + fmod( x - bx, spacing );
1113 starty = by + fmod( y - by, spacing );
1115 nx = lround( w / spacing );
1116 ny = lround( h / spacing );
1119 for (
int i = 0; i < nx; i++ ) {
1120 double d = startx + ( i * spacing );
1124 for (
int i = 0; i < ny; i++ ) {
1125 double d = starty + ( i * spacing );
1136 double x,
double y,
int sx,
int sy,
1137 const glColour *
c,
int selected,
1138 const char *caption )
1147 const glColour csel = COL_ALPHA( cFontBlue, 0.5 );
1152 tx = bx + ( x - gfx->
sw / 2. ) * z;
1153 ty = by + ( y - gfx->
sh / 2. ) * z;
1158 if ( caption != NULL ) {
1159 const glColour *col;
1179static int sysedit_mouseTrySelect(
const Select_t *sel,
double x,
double y,
1180 double t,
double mx,
double my,
1181 SDL_Keymod mod,
void ( *func )(
void ) )
1186 if ( (
pow2( mx - x ) +
pow2( my - y ) ) > t )
1198 if ( mod & ( KMOD_LCTRL | KMOD_RCTRL ) )
1218 if ( mod & ( KMOD_LCTRL | KMOD_RCTRL ) )
1237 double my,
double w,
double h,
double xr,
double yr,
1242 SDL_Keymod mod = SDL_GetModState();
1244 switch ( event->type ) {
1246 case SDL_MOUSEWHEEL:
1248 if ( ( mx < 0. ) || ( mx > w ) || ( my < 0. ) || ( my > h ) )
1251 if ( event->wheel.y > 0 )
1253 else if ( event->wheel.y < 0 )
1258 case SDL_MOUSEBUTTONDOWN:
1260 if ( ( mx < 0. ) || ( mx > w ) || ( my < 0. ) || ( my > h ) )
1269 for (
int i = 0; i <
array_size( sys->spobs ); i++ ) {
1270 Spob *p = sys->spobs[i];
1277 double t =
pow2( p->radius );
1281 if ( sysedit_mouseTrySelect( &sel, p->pos.x, p->pos.y, t, mx, my, mod,
1287 for (
int i = 0; i <
array_size( sys->jumps ); i++ ) {
1288 JumpPoint *jp = &sys->jumps[i];
1299 if ( sysedit_mouseTrySelect( &sel, jp->pos.x, jp->pos.y, t, mx, my,
1305 for (
int i = 0; i <
array_size( sys->astexclude ); i++ ) {
1314 if ( sysedit_mouseTrySelect( &sel, exc->
pos.
x, exc->
pos.
y, t, mx, my,
1315 mod, sysedit_editExclusion ) )
1320 for (
int i = 0; i <
array_size( sys->asteroids ); i++ ) {
1329 if ( sysedit_mouseTrySelect( &sel, ast->
pos.
x, ast->
pos.
y, t, mx, my,
1335 if ( !( mod & ( KMOD_LCTRL | KMOD_RCTRL ) ) ) {
1343 case SDL_MOUSEBUTTONUP:
1354 if ( conf.devautosave ) {
1360 uniedit_saveError();
1378 if ( conf.devautosave ) {
1384 uniedit_saveError();
1389 case SDL_MOUSEMOTION:
1416 switch ( sel->
type ) {
1418 p = sys->spobs[sel->
u.spob];
1419 if ( uniedit_diffMode ) {
1420 sysedit_diffCreateSpobFloat( p, HUNK_TYPE_SPOB_POS_X,
1422 sysedit_diffCreateSpobFloat( p, HUNK_TYPE_SPOB_POS_Y,
1431 jp = &sys->jumps[sel->
u.jump];
1432 if ( uniedit_diffMode ) {
1435 "supported in diff mode." ) );
1437 jp->flags &= ~( JP_AUTOPOS );
1445 if ( uniedit_diffMode ) {
1446 if ( ( ast->
label == NULL ) ||
1447 ( strcmp( ast->
label,
"" ) == 0 ) ) {
1449 _(
"Modifying asteroid fields in diff mode is only "
1452 "have labels. Please set a label via the "
1453 "property editor." ) );
1455 uniedit_diffCreateSysFloatAttr(
1457 ast->
pos.
x + xmove, sysedit_asteroidsAttr( ast ) );
1458 uniedit_diffCreateSysFloatAttr(
1460 ast->
pos.
y + ymove, sysedit_asteroidsAttr( ast ) );
1463 ast->
pos.
x += xmove;
1464 ast->
pos.
y += ymove;
1469 exc = &sys->astexclude[sel->
u.astexclude];
1470 if ( uniedit_diffMode ) {
1473 exc->
pos.
x += xmove;
1474 exc->
pos.
y += ymove;
1505 if ( strcmp( str,
"btnZoomIn" ) == 0 ) {
1509 }
else if ( strcmp( str,
"btnZoomOut" ) == 0 ) {
1540 int sel_spob, sel_jump, sel_asteroid, sel_exclusion;
1549 switch ( sel->
type ) {
1566 if ( sel_spob || sel_asteroid || sel_exclusion )
1621 WARN( _(
"Trying to deselect item that is not in selection!" ) );
1631 return ( memcmp( a, b,
sizeof(
Select_t ) ) == 0 );
1652 char buf[STRMAX_SHORT], title[128];
1659 snprintf( title,
sizeof( title ), _(
"Space Object Property Editor - %s" ),
1671 snprintf( buf,
sizeof( buf ),
"%s ", _(
"Name:" ) );
1673 window_addText( wid, 20, y, 180, 15, 0,
"txtNameLabel", &
gl_smallFont, NULL,
1675 snprintf( buf,
sizeof( buf ),
"%s", p->name );
1676 window_addText( wid, 20 + w, y, 180, 15, 0,
"txtName", &
gl_smallFont, NULL,
1680 sysedit_btnRename );
1687 snprintf( buf,
sizeof( buf ),
"%s ", _(
"Faction:" ) );
1689 window_addText( wid, 20, y, 180, 15, 0,
"txtFactionLabel", &
gl_smallFont,
1691 snprintf( buf,
sizeof( buf ),
"%s",
1692 p->presence.faction >= 0 ?
faction_name( p->presence.faction )
1694 window_addText( wid, 20 + w, y, 180, 15, 0,
"txtFaction", &
gl_smallFont,
1700 s = _(
"Population" );
1702 window_addText( wid, x, y, l, 20, 1,
"txtPop", NULL, NULL, s );
1703 window_addInput( wid, x += l + 5, y, 80, 20,
"inpPop", 12, 1, NULL );
1704 window_setInputFilter( wid,
"inpPop", INPUT_FILTER_NUMBER );
1709 window_addText( wid, x, y, l, 20, 1,
"txtClass", NULL, NULL, s );
1710 window_addInput( wid, x += l + 5, y, 30, 20,
"inpClass", 16, 1, NULL );
1715 window_addText( wid, x, y, l, 20, 1,
"txtLua", NULL, NULL, s );
1716 window_addInput( wid, x += l + 5, y, 180, 20,
"inpLua", 50, 1, NULL );
1721 s = _(
"Base Presence" );
1723 window_addText( wid, x, y, l, 20, 1,
"txtPresenceBase", NULL, NULL, s );
1724 window_addInput( wid, x += l + 5, y, 50, 20,
"inpPresenceBase", 5, 1, NULL );
1725 window_setInputFilter( wid,
"inpPresenceBase", INPUT_FILTER_NUMBER );
1728 s = _(
"Bonus Presence" );
1730 window_addText( wid, x, y, l, 20, 1,
"txtPresenceBonus", NULL, NULL, s );
1731 window_addInput( wid, x += l + 5, y, 50, 20,
"inpPresenceBonus", 5, 1,
1733 window_setInputFilter( wid,
"inpPresenceBonus", INPUT_FILTER_NUMBER );
1736 s = p_(
"sysedit",
"Range" );
1738 window_addText( wid, x, y, l, 20, 1,
"txtPresenceRange", NULL, NULL, s );
1739 window_addInput( wid, x += l + 5, y, 30, 20,
"inpPresenceRange", 1, 1,
1741 window_setInputFilter( wid,
"inpPresenceRange", INPUT_FILTER_NUMBER );
1748 window_addText( wid, x, y, l, 20, 1,
"txtHide", NULL, NULL, s );
1749 window_addInput( wid, x += l + 5, y, 50, 20,
"inpHide", 4, 1, NULL );
1750 window_setInputFilter( wid,
"inpHide", INPUT_FILTER_NUMBER );
1756 l =
scnprintf( buf,
sizeof( buf ),
"#n%s#0", _(
"Tags:" ) );
1757 for (
int i = 0; i <
array_size( p->tags ); i++ )
1758 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s %s",
1759 ( ( i > 0 ) ?
"," :
"" ), p->tags[i] );
1760 window_addText( wid, x, y, 240, 100, 0,
"txtTags", NULL, NULL, buf );
1763 window_addButton( wid, -20 - bw * 3 - 15 * 3, 35 +
BUTTON_HEIGHT, bw,
1766 window_addButton( wid, -20 - bw * 2 - 15 * 2, 35 +
BUTTON_HEIGHT, bw,
1773 window_addButton( wid, -20 - bw * 3 - 15 * 3, 20, bw,
BUTTON_HEIGHT,
1775 window_addButton( wid, -20 - bw * 2 - 15 * 2, 20, bw,
BUTTON_HEIGHT,
1777 window_addButton( wid, -20 - bw - 15, 20, bw,
BUTTON_HEIGHT,
"btnSpaceGFX",
1779 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
1783 snprintf( buf,
sizeof( buf ),
"%lf", p->population );
1784 window_setInput( wid,
"inpPop", buf );
1785 snprintf( buf,
sizeof( buf ),
"%s", p->class );
1786 window_setInput( wid,
"inpClass", buf );
1787 window_setInput( wid,
"inpLua", p->lua_file );
1788 snprintf( buf,
sizeof( buf ),
"%g", p->presence.base );
1789 window_setInput( wid,
"inpPresenceBase", buf );
1790 snprintf( buf,
sizeof( buf ),
"%g", p->presence.bonus );
1791 window_setInput( wid,
"inpPresenceBonus", buf );
1792 snprintf( buf,
sizeof( buf ),
"%d", p->presence.range );
1793 window_setInput( wid,
"inpPresenceRange", buf );
1794 snprintf( buf,
sizeof( buf ),
"%g", p->hide );
1795 window_setInput( wid,
"inpHide", buf );
1812 window_checkboxSet( wid,
"chkHidden",
jp_hidden );
1813 window_checkboxSet( wid,
"chkExit",
jp_exit );
1827 window_checkboxSet( wid,
"chkHidden",
jp_hidden );
1828 window_checkboxSet( wid,
"chkExit",
jp_exit );
1836 int s = window_checkboxState( wid, str );
1839 jp_setFlag( j, JP_NOLANES );
1841 jp_rmFlag( j, JP_NOLANES );
1851 char buf[STRMAX_SHORT];
1856 wid =
window_create(
"wdwJumpPointEditor", _(
"Jump Point Editor" ), -1, -1,
1864 snprintf( buf,
sizeof( buf ), _(
"Target: " ) );
1866 window_addText( wid, 20, y, 180, 15, 0,
"txtTargetLabel", &
gl_smallFont,
1868 snprintf( buf,
sizeof( buf ),
"%s", j->target->name );
1869 window_addText( wid, 20 + w, y, 180, 15, 0,
"txtName", &
gl_smallFont, NULL,
1880 if ( jp_isFlag( j, JP_HIDDEN ) )
1882 else if ( jp_isFlag( j, JP_EXITONLY ) )
1885 window_addCheckbox( wid, x, y, 100, 20,
"chkHidden", _(
"Hidden" ),
1888 window_addCheckbox( wid, x, y, 100, 20,
"chkExit", _(
"Exit only" ),
1891 window_addCheckbox( wid, x, y, 100, 20,
"chkNolanes", _(
"No lanes" ),
1893 jp_isFlag( j, JP_NOLANES ) );
1898 window_addText( wid, x, y, l, 20, 1,
"txtHide", NULL, NULL, s );
1899 window_addInput( wid, x + l + 8, y, 50, 20,
"inpHide", 4, 1, NULL );
1900 window_setInputFilter( wid,
"inpHide", INPUT_FILTER_NUMBER );
1904 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
1908 snprintf( buf,
sizeof( buf ),
"%g", j->hide );
1909 window_setInput( wid,
"inpHide", buf );
1920 if ( uniedit_diffMode ) {
1923 _(
"Editing jump points is not yet supported in diff mode." ) );
1930 jp_setFlag( j, JP_HIDDEN );
1931 jp_rmFlag( j, JP_EXITONLY );
1933 jp_setFlag( j, JP_EXITONLY );
1934 jp_rmFlag( j, JP_HIDDEN );
1936 jp_rmFlag( j, JP_HIDDEN );
1937 jp_rmFlag( j, JP_EXITONLY );
1951 char buf[STRMAX_SHORT];
1957 wid =
window_create(
"wdwAsteroidsEditor", _(
"Asteroid Field Editor" ), -1,
1969 window_addText( wid, x, y, l, 20, 1,
"txtLabel", NULL, NULL, s );
1970 if ( uniedit_diffMode )
1971 window_addText( wid, x + l + 8, y, 80, 20, 1,
"txtInpLabel", NULL, NULL,
1974 window_addInput( wid, x + l + 8, y, 80, 20,
"inpLabel", 10, 1, NULL );
1975 x += l + 20 + 80 + 8;
1976 s = _(
"Density: " );
1982 window_addText( wid, x, y, l, 20, 1,
"txtDensity", NULL, NULL, s );
1983 window_addInput( wid, x + l + 8, y, 80, 20,
"inpDensity", 10, 1, NULL );
1984 window_setInputFilter( wid,
"inpDensity", INPUT_FILTER_NUMBER );
1985 x += l + 20 + 80 + 8;
1986 s = _(
"Radius: " );
1992 window_addText( wid, x, y, l, 20, 1,
"txtInput", NULL, NULL, s );
1993 window_addInput( wid, x + l + 8, y, 80, 20,
"inpRadius", 10, 1, NULL );
1994 window_setInputFilter( wid,
"inpRadius", INPUT_FILTER_NUMBER );
1995 x += l + 20 + 80 + 8;
1996 s = _(
"Max Speed: " );
2002 window_addText( wid, x, y, l, 20, 1,
"txtMaxspeed", NULL, NULL, s );
2003 window_addInput( wid, x + l + 8, y, 80, 20,
"inpMaxspeed", 10, 1, NULL );
2004 window_setInputFilter( wid,
"inpMaxspeed", INPUT_FILTER_NUMBER );
2005 x += l + 20 + 80 + 8;
2012 window_addText( wid, x, y, l, 20, 1,
"txtAccel", NULL, NULL, s );
2013 window_addInput( wid, x + l + 8, y, 80, 20,
"inpAccel", 10, 1, NULL );
2014 window_setInputFilter( wid,
"inpAccel", INPUT_FILTER_NUMBER );
2021 window_addText( wid, 20, y, bw,
gl_smallFont.h, 1,
"txtAsteroidsHave", NULL,
2022 NULL, _(
"Asteroids" ) );
2023 window_addText( wid, 20 + bw + 15, y, bw,
gl_smallFont.h, 1,
2024 "txtAsteroidsAvailable", NULL, NULL, _(
"Available" ) );
2030 window_addButton( wid, 20, 20, bw,
BUTTON_HEIGHT,
"btnRmAsteroid",
2031 _(
"Rm Asteroid" ), sysedit_btnRmAsteroid );
2032 window_addButton( wid, 20 + bw + 15, 20, bw,
BUTTON_HEIGHT,
"btnAddAsteroid",
2033 _(
"Add Asteroid" ), sysedit_btnAddAsteroid );
2034 window_addButton( wid, 20 + 2 * ( bw + 15 ), 20, bw,
BUTTON_HEIGHT,
2035 "btnDelete", _(
"Delete" ), sysedit_btnAsteroidsDelete );
2036 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
2037 sysedit_editAsteroidsClose );
2041 sysedit_genAsteroidsList( wid );
2044 if ( !uniedit_diffMode && ( ast->
label != NULL ) )
2045 window_setInput( wid,
"inpLabel", ast->
label );
2046 snprintf( buf,
sizeof( buf ),
"%g", ast->
density );
2047 window_setInput( wid,
"inpDensity", buf );
2048 snprintf( buf,
sizeof( buf ),
"%g", ast->
radius );
2049 window_setInput( wid,
"inpRadius", buf );
2050 snprintf( buf,
sizeof( buf ),
"%g", ast->
maxspeed );
2051 window_setInput( wid,
"inpMaxspeed", buf );
2052 snprintf( buf,
sizeof( buf ),
"%g", ast->
accel );
2053 window_setInput( wid,
"inpAccel", buf );
2056static void sysedit_genAsteroidsList(
unsigned int wid )
2058 int hpos, apos, nhave, navail;
2063 char **have, **available;
2072 hpos = toolkit_getListPos( wid,
"lstAsteroidsHave" );
2073 apos = toolkit_getListPos( wid,
"lstAsteroidsAvailable" );
2082 y = wy + wh - 15 - h;
2087 have = malloc(
sizeof(
char * ) * nhave );
2088 for (
int i = 0; i < nhave; i++ )
2090 window_enableButton( wid,
"btnRmAsteroid" );
2093 window_disableButton( wid,
"btnRmAsteroid" );
2095 window_addList( wid, x, y, w, h,
"lstAsteroidsHave", have, nhave, 0, NULL,
2096 sysedit_btnRmAsteroid );
2103 available = malloc(
sizeof(
char * ) * navail );
2104 for (
int i = 0; i < navail; i++ )
2105 available[i] = strdup( astgroups[i].name );
2106 qsort( available, navail,
sizeof(
char * ),
strsort );
2107 window_enableButton( wid,
"btnAddAsteroid" );
2110 window_disableButton( wid,
"btnAddAsteroid" );
2112 window_addList( wid, x, y, w, h,
"lstAsteroidsAvailable", available, navail,
2113 0, NULL, sysedit_btnAddAsteroid );
2116 if ( hpos != -1 && apos != -1 ) {
2117 toolkit_setListPos( wid,
"lstAsteroidsHave", hpos );
2118 toolkit_setListPos( wid,
"lstAsteroidsAvailable", apos );
2122static void sysedit_btnRmAsteroid(
unsigned int wid,
const char *unused )
2125 int pos = toolkit_getListPos( wid,
"lstAsteroidsHave" );
2133 if ( uniedit_diffMode ) {
2134 if ( ( ast->
label == NULL ) || ( strcmp( ast->
label,
"" ) == 0 ) ) {
2136 _(
"Modifying asteroid fields in diff mode is only supported when "
2138 "have labels. Please set a label via the property editor." ) );
2141 uniedit_diffCreateSysStrAttr(
2142 sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_REMOVE_TYPE,
2143 ast->
groups[pos]->
name, sysedit_asteroidsAttr( ast ) );
2149 sysedit_genAsteroidsList( wid );
2152static void sysedit_btnAddAsteroid(
unsigned int wid,
const char *unused )
2155 const char *selected = toolkit_getList( wid,
"lstAsteroidsAvailable" );
2161 if ( uniedit_diffMode ) {
2162 if ( ( ast->
label == NULL ) || ( strcmp( ast->
label,
"" ) == 0 ) ) {
2164 _(
"Modifying asteroid fields in diff mode is only supported when "
2166 "have labels. Please set a label via the property editor." ) );
2170 HUNK_TYPE_SSYS_ASTEROIDS_ADD_TYPE,
2171 grp->
name, sysedit_asteroidsAttr( ast ) );
2176 sysedit_genAsteroidsList( wid );
2179static void sysedit_btnAsteroidsDelete(
unsigned int wid,
const char *unused )
2182 _(
"Remove Asteroid Field" ),
2183 _(
"Are you sure you want to remove this asteroid field?" ) );
2189 if ( uniedit_diffMode ) {
2190 if ( ( ast->
label == NULL ) || ( strcmp( ast->
label,
"" ) == 0 ) ) {
2192 _(
"Modifying asteroid fields in diff mode is only supported when "
2194 "have labels. Please set a label via the property editor." ) );
2197 uniedit_diffCreateSysStr(
sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_REMOVE,
2206 if ( conf.devautosave ) {
2208 uniedit_saveError();
2214static void sysedit_editAsteroidsClose(
unsigned int wid,
const char *unused )
2218 if ( uniedit_diffMode ) {
2219 double density, radius, maxspeed, accel;
2220 if ( ( ast->
label == NULL ) || ( strcmp( ast->
label,
"" ) == 0 ) ) {
2222 _(
"Editing asteroids in diff mode is only supported when they "
2223 "have labels. Please set a label via the property editor." ) );
2227 if ( ast->
density - density > DOUBLE_TOL )
2228 uniedit_diffCreateSysFloatAttr(
2229 sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_DENSITY, density,
2230 sysedit_asteroidsAttr( ast ) );
2232 if ( ast->
radius - radius > DOUBLE_TOL )
2233 uniedit_diffCreateSysFloatAttr(
2234 sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_RADIUS, density,
2235 sysedit_asteroidsAttr( ast ) );
2237 if ( ast->
maxspeed - maxspeed > DOUBLE_TOL )
2238 uniedit_diffCreateSysFloatAttr(
2239 sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_MAXSPEED, density,
2240 sysedit_asteroidsAttr( ast ) );
2242 if ( ast->
accel - accel > DOUBLE_TOL )
2243 uniedit_diffCreateSysFloatAttr(
2244 sysedit_sys, HUNK_TYPE_SSYS_ASTEROIDS_ACCEL, density,
2245 sysedit_asteroidsAttr( ast ) );
2251 if ( ( label != NULL ) && ( strcmp( label,
"" ) != 0 ) ) {
2255 ( strcmp(
sysedit_sys->asteroids[i].label, label ) == 0 ) ) {
2257 "exists in system '%s'!" ),
2264 ast->
label = strdup( label );
2274 if ( conf.devautosave ) {
2276 uniedit_saveError();
2282static void sysedit_editExclusion(
void )
2286 char buf[STRMAX_SHORT];
2293 _(
"Asteroid Exclusion Zone Editor" ), -1, -1,
2303 window_addText( wid, x, y, l, 20, 1,
"txtLabel", NULL, NULL, s );
2304 if ( uniedit_diffMode )
2305 window_addText( wid, x + l + 8, y, 80, 20, 1,
"txtInpLabel", NULL, NULL,
2308 window_addInput( wid, x + l + 8, y, 80, 20,
"inpLabel", 10, 1, NULL );
2309 x += l + 20 + 80 + 8;
2310 s = _(
"Radius: " );
2312 window_addText( wid, x, y, l, 20, 1,
"txtInput", NULL, NULL, s );
2313 window_addInput( wid, x + l + 8, y, 80, 20,
"inpRadius", 10, 1, NULL );
2314 window_setInputFilter( wid,
"inpRadius", INPUT_FILTER_NUMBER );
2318 window_addButton( wid, -20 - 15 - bw, 20, bw,
BUTTON_HEIGHT,
"btnDelete",
2319 _(
"Delete" ), sysedit_btnExclusionDelete );
2320 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
2321 sysedit_editExclusionClose );
2324 if ( !uniedit_diffMode && ( exc->
label != NULL ) )
2325 window_setInput( wid,
"inpLabel", exc->
label );
2326 snprintf( buf,
sizeof( buf ),
"%g", exc->
radius );
2327 window_setInput( wid,
"inpRadius", buf );
2330static void sysedit_btnExclusionDelete(
unsigned int wid,
const char *unused )
2333 _(
"Remove Asteroid Exclusion Zone" ),
2334 _(
"Are you sure you want to remove this asteroid exclusion zone?" ) );
2343 if ( conf.devautosave ) {
2345 uniedit_saveError();
2351static void sysedit_editExclusionClose(
unsigned int wid,
const char *unused )
2359 if ( ( label != NULL ) && ( strcmp( label,
"" ) != 0 ) ) {
2363 ( strcmp(
sysedit_sys->astexclude[i].label, label ) == 0 ) ) {
2365 "exists in system '%s'!" ),
2372 exc->
label = strdup( label );
2376 if ( conf.devautosave ) {
2378 uniedit_saveError();
2393 const char *desc, *bardesc;
2399 snprintf( title,
sizeof( title ), _(
"Space Object Information - %s" ),
2411 desc = p->description ? p->description : _(
"None" );
2412 bardesc = p->bar_description ? p->bar_description : _(
"None" );
2415 window_addButton( wid, -20 - bw * 3 - 15 * 3, 20, bw,
BUTTON_HEIGHT,
2416 "btnProperties", _(
"Properties" ),
2419 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
2423 window_addText( wid, x, y, w,
gl_defFont.h, 0,
"txtDescriptionLabel",
2424 &
gl_defFont, NULL, _(
"Landing Description" ) );
2426 window_addInput( wid, x, y, w, h,
"txtDescription", 1024, 0, NULL );
2427 window_setInputFilter( wid,
"txtDescription",
"[]{}~<>@#$^|_" );
2430 window_setInput( wid,
"txtDescription", desc );
2433 window_addText( wid, x, y, w,
gl_defFont.h, 0,
"txtBarDescriptionLabel",
2436 window_addInput( wid, x, y, w, h,
"txtBarDescription", 1024, 0, NULL );
2437 window_setInputFilter( wid,
"txtBarDescription",
"[]{}~<>@#$^|_" );
2439 window_setInput( wid,
"txtBarDescription", bardesc );
2449 const char *mydesc = window_getInput( wid,
"txtDescription" );
2450 const char *mybardesc = window_getInput( wid,
"txtBarDescription" );
2452 if ( ( mydesc != NULL ) && ( ( p->description == NULL ) ||
2453 ( strcmp( mydesc, p->description ) != 0 ) ) ) {
2454 if ( uniedit_diffMode ) {
2455 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_DESCRIPTION,
2458 free( p->description );
2459 p->description = strdup( mydesc );
2462 if ( ( mybardesc != NULL ) &&
2463 ( ( p->bar_description == NULL ) ||
2464 ( strcmp( mybardesc, p->bar_description ) != 0 ) ) ) {
2465 if ( uniedit_diffMode ) {
2466 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_BAR,
2467 strdup( mybardesc ) );
2469 free( p->bar_description );
2470 p->bar_description = strdup( mybardesc );
2491 int j, n, nservices;
2493 char **have, **lack;
2494 int x, y, w, h, hpos, lpos;
2501 hpos = toolkit_getListPos( wid,
"lstServicesHave" );
2502 lpos = toolkit_getListPos( wid,
"lstServicesLacked" );
2515 for (
int i = 1; i < SPOB_SERVICES_MAX; i <<= 1 ) {
2516 if ( !spob_hasService( p, i ) && ( i != SPOB_SERVICE_INHABITED ) )
2523 have = malloc(
sizeof(
char * ) *
MAX( nservices - n, 1 ) );
2524 if ( nservices == n )
2525 have[j++] = strdup( _(
"None" ) );
2527 for (
int i = 1; i < SPOB_SERVICES_MAX; i <<= 1 )
2528 if ( spob_hasService( p, i ) && ( i != SPOB_SERVICE_INHABITED ) )
2532 window_addList( wid, x, y, w, h,
"lstServicesHave", have, j, 0, NULL,
2538 lack = malloc(
sizeof(
char * ) *
MAX( 1, n ) );
2540 lack[j++] = strdup( _(
"None" ) );
2542 for (
int i = 1; i < SPOB_SERVICES_MAX; i <<= 1 )
2543 if ( !spob_hasService( p, i ) && ( i != SPOB_SERVICE_INHABITED ) )
2547 window_addList( wid, x, y, w, h,
"lstServicesLacked", lack, j, 0, NULL,
2551 if ( hpos != -1 && lpos != -1 ) {
2552 toolkit_setListPos( wid,
"lstServicesHave", hpos );
2553 toolkit_setListPos( wid,
"lstServicesLacked", lpos );
2563 const char *selected = toolkit_getList( wid,
"lstServicesLacked" );
2564 if ( ( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ) )
2569 if ( uniedit_diffMode ) {
2570 if ( !spob_hasService( p, SPOB_SERVICE_LAND ) )
2571 sysedit_diffCreateSpobStr(
2572 p, HUNK_TYPE_SPOB_SERVICE_ADD,
2574 if ( !spob_hasService( p, SPOB_SERVICE_INHABITED ) )
2575 sysedit_diffCreateSpobStr(
2576 p, HUNK_TYPE_SPOB_SERVICE_ADD,
2578 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_SERVICE_ADD,
2579 strdup( selected ) );
2595 const char *selected = toolkit_getList( wid,
"lstServicesHave" );
2596 if ( ( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ) )
2601 if ( uniedit_diffMode ) {
2602 if ( strcmp( selected,
"Land" ) == 0 ) {
2604 for (
int i = 1; i < SPOB_SERVICES_MAX; i <<= 1 ) {
2605 if ( !spob_hasService( p, i ) )
2606 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_SERVICE_ADD,
2610 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_SERVICE_REMOVE,
2611 strdup( selected ) );
2614 if ( strcmp( selected,
"Land" ) == 0 )
2632 wid =
window_create(
"wdwSpobTechEditor", _(
"Space Object Tech Editor" ),
2640 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
2645 window_addButton( wid, -20 - ( w + 15 ), y, w,
BUTTON_HEIGHT,
"btnRm",
2649 window_addButton( wid, -20, y, w,
BUTTON_HEIGHT,
"btnAdd", _(
"Add Tech" ),
2661 char **have, **lack;
2662 int j, n, x, y, w, h, hpos, lpos;
2669 hpos = toolkit_getListPos( wid,
"lstTechsHave" );
2670 lpos = toolkit_getListPos( wid,
"lstTechsLacked" );
2683 if ( p->tech != NULL )
2686 have = malloc(
sizeof(
char *) );
2687 have[n++] = strdup( _(
"None" ) );
2691 window_addList( wid, x, y, w, h,
"lstTechsHave", have, n, 0, NULL,
2697 if ( p->tech != NULL ) {
2699 for (
int i = 0; i < j; i++ )
2704 lack = malloc(
sizeof(
char *) );
2705 lack[n++] = strdup( _(
"None" ) );
2707 lack = malloc(
sizeof(
char * ) * j );
2709 for (
int i = 0; i < j; i++ )
2711 lack[n++] = strdup( tmp[i] );
2715 for (
int i = 0; i < j; i++ )
2723 window_addList( wid, x, y, w, h,
"lstTechsLacked", lack, n, 0, NULL,
2727 if ( hpos != -1 && lpos != -1 ) {
2728 toolkit_setListPos( wid,
"lstTechsHave", hpos );
2729 toolkit_setListPos( wid,
"lstTechsLacked", lpos );
2739 const char *selected = toolkit_getList( wid,
"lstTechsLacked" );
2740 if ( ( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ) )
2744 if ( uniedit_diffMode ) {
2745 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_TECH_ADD,
2746 strdup( selected ) );
2748 if ( p->tech == NULL )
2763 const char *selected = toolkit_getList( wid,
"lstTechsHave" );
2764 if ( ( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ) )
2768 if ( uniedit_diffMode ) {
2770 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_TECH_REMOVE,
2771 strdup( selected ) );
2794 wid =
window_create(
"wdwSpobTagsEditor", _(
"Space Object Tags Editor" ),
2802 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
2803 sysedit_btnTagsClose );
2807 window_addButton( wid, -20 - ( w + 15 ), y, w,
BUTTON_HEIGHT,
"btnRm",
2811 window_addButton( wid, -20, y, w,
BUTTON_HEIGHT,
"btnAdd", _(
"Add Tag" ),
2815 window_addButton( wid, -20 - ( w + 15 ), 20, w,
BUTTON_HEIGHT,
"btnNew",
2822 for (
int i = 0; i <
array_size( spob_all ); i++ ) {
2823 Spob *s = &spob_all[i];
2825 const char *t = s->
tags[j];
2846static void sysedit_btnTagsClose(
unsigned int wid,
const char *unused )
2848 char buf[STRMAX_SHORT];
2850 int l =
scnprintf( buf,
sizeof( buf ),
"#n%s#0", _(
"Tags:" ) );
2851 for (
int i = 0; i <
array_size( p->tags ); i++ )
2852 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s %s",
2853 ( ( i > 0 ) ?
"," :
"" ), p->tags[i] );
2865 char **have, **lack;
2866 int n, x, y, w, h, hpos, lpos, empty;
2873 hpos = toolkit_getListPos( wid,
"lstTagsHave" );
2874 lpos = toolkit_getListPos( wid,
"lstTagsLacked" );
2888 have = malloc( n *
sizeof(
char * ) );
2889 for (
int i = 0; i < n; i++ )
2890 have[i] = strdup( p->tags[i] );
2893 have = malloc(
sizeof(
char *) );
2894 have[n++] = strdup( _(
"None" ) );
2899 window_addList( wid, x, y, w, h,
"lstTagsHave", have, n, 0, NULL,
2909 lack[n++] = strdup( t );
2912 for (
int j = 0; j <
array_size( p->tags ); j++ )
2913 if ( strcmp( p->tags[j], t ) == 0 ) {
2918 lack[n++] = strdup( t );
2923 window_addList( wid, x, y, w, h,
"lstTagsLacked", lack, n, 0, NULL,
2927 if ( hpos != -1 && lpos != -1 ) {
2928 toolkit_setListPos( wid,
"lstTagsHave", hpos );
2929 toolkit_setListPos( wid,
"lstTagsLacked", lpos );
2939 const char *selected = toolkit_getList( wid,
"lstTagsLacked" );
2940 if ( ( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ) )
2944 if ( uniedit_diffMode ) {
2945 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_TAG_ADD,
2946 strdup( selected ) );
2948 if ( p->tags == NULL )
2963 const char *selected;
2965 selected = toolkit_getList( wid,
"lstTagsHave" );
2966 if ( ( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ) )
2971 if ( uniedit_diffMode ) {
2972 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_TAG_REMOVE,
2973 strdup( selected ) );
2976 for ( i = 0; i <
array_size( p->tags ); i++ )
2977 if ( strcmp( selected, p->tags[i] ) == 0 )
2982 array_erase( &p->tags, &p->tags[i], &p->tags[i + 1] );
2997 _(
"Please write the new tag to add to the spob." ) );
3002 if ( uniedit_diffMode ) {
3003 sysedit_diffCreateSpobStr( s, HUNK_TYPE_SPOB_TAG_ADD, tag );
3005 if ( s->
tags == NULL )
3025 int pos, j, y, h, bw, *factions;
3032 wid =
window_create(
"wdwModifyFaction", _(
"Modify Faction" ), -1, -1,
3038 str = malloc(
sizeof(
char *) * (
array_size( factions ) + 1 ) );
3039 str[0] = strdup( _(
"None" ) );
3041 for (
int i = 0; i <
array_size( factions ); i++ )
3044 qsort( &str[1], j - 1,
sizeof(
char * ),
strsort );
3047 if ( p->presence.faction >= 0 ) {
3050 for (
int i = 0; i < j; i++ )
3051 if ( strcmp( s, str[i] ) == 0 )
3063 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
3067 window_addButton( wid, -20 - ( bw + 15 ), 20, bw,
BUTTON_HEIGHT,
"btnAdd",
3079 const char *selected = toolkit_getList( wid,
"lstFactions" );
3080 if ( selected == NULL )
3084 if ( uniedit_diffMode ) {
3085 sysedit_diffCreateSpobStr( p, HUNK_TYPE_SPOB_FACTION,
3086 strdup( selected ) );
3089 if ( toolkit_getListPos( wid,
"lstFactions" ) == 0 ) {
3090 p->presence.faction = -1;
3099 p->presence.faction >= 0
3121 sysedit_editExclusion();
3132 char *path, buf[STRMAX_SHORT];
3135 ImageArrayCell *cells;
3140 land = ( strcmp( wgt,
"btnLandGFX" ) == 0 );
3144 snprintf( buf,
sizeof( buf ), _(
"%s - Space Object Properties" ), p->name );
3161 path =
land ? SPOB_GFX_EXTERIOR_PATH : SPOB_GFX_SPACE_PATH;
3162 files = PHYSFS_enumerateFiles( path );
3163 for ( nfiles = 0; files[nfiles]; nfiles++ ) {
3165 cells = calloc( nfiles,
sizeof( ImageArrayCell ) );
3168 for (
size_t i = 0; i < nfiles; i++ ) {
3169 PHYSFS_Stat path_stat;
3170 const char *filepath;
3171 snprintf( buf,
sizeof( buf ),
"%s/%s", path, files[i] );
3173 if ( !PHYSFS_stat( buf, &path_stat ) ) {
3174 WARN( _(
"Unable to check file type for '%s'!" ), buf );
3177 if ( path_stat.filetype != PHYSFS_FILETYPE_REGULAR )
3184 cells[j].caption = strdup( files[i] );
3185 filepath = (
land ? p->gfx_exteriorPath : p->gfx_spacePath );
3186 c = ( ( filepath == NULL ) || strcmp( files[i], filepath ) != 0 )
3189 memcpy( &cells[j].bg, &
c,
sizeof( glColour ) );
3192 PHYSFS_freeList( files );
3195 window_addImageArray( wid, 20, 20, w - 60 -
BUTTON_WIDTH, h - 60,
"iarGFX",
3196 128, 128, cells, j, NULL, NULL, NULL );
3197 toolkit_setImageArray( wid,
"iarGFX", path );
3218 land = ( strcmp( wgt,
"btnApplyLand" ) == 0 );
3222 str = toolkit_getImageArray( wid,
"iarGFX" );
3227 path =
land ? SPOB_GFX_EXTERIOR_PATH : SPOB_GFX_SPACE_PATH;
3228 snprintf( buf,
sizeof( buf ),
"%s/%s", path, str );
3231 free( p->gfx_exteriorPath );
3232 free( p->gfx_exterior );
3233 snprintf( buf,
sizeof( buf ), SPOB_GFX_EXTERIOR_PATH
"%s", str );
3234 p->gfx_exteriorPath = strdup( str );
3235 p->gfx_exterior = strdup( buf );
3237 free( p->gfx_spaceName );
3238 free( p->gfx_spacePath );
3239 p->gfx_spaceName = strdup( buf );
3240 p->gfx_spacePath = strdup( str );
3242 p->gfx_space = NULL;
3251static void sysedit_diffCreateSpobStr(
const Spob *spb, UniHunkType_t type,
3255 memset( &hunk, 0,
sizeof( hunk ) );
3259 hunk.
dtype = HUNK_DATA_STRING;
3261 uniedit_diffAdd( &hunk );
3263static void sysedit_diffCreateSpobInt(
const Spob *spb, UniHunkType_t type,
3267 memset( &hunk, 0,
sizeof( hunk ) );
3271 hunk.
dtype = HUNK_DATA_INT;
3273 uniedit_diffAdd( &hunk );
3275static void sysedit_diffCreateSpobFloat(
const Spob *spb, UniHunkType_t type,
3279 memset( &hunk, 0,
sizeof( hunk ) );
3283 hunk.
dtype = HUNK_DATA_FLOAT;
3284 hunk.
u.fdata = fdata;
3285 uniedit_diffAdd( &hunk );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#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_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void asteroids_computeInternals(AsteroidAnchor *a)
Updates internal alues of an asteroid field.
void asteroid_freeAnchor(AsteroidAnchor *ast)
Frees an asteroid anchor.
const AsteroidTypeGroup * astgroup_getAll(void)
Gets all the asteroid type groups.
AsteroidTypeGroup * astgroup_getName(const char *name)
Gets an asteroid type group by name.
void asteroid_initAnchor(AsteroidAnchor *ast)
Initializes an asteroid anchor.
int dpl_saveSpob(const Spob *p)
Saves a spob.
static Select_t sysedit_tsel
static void jp_type_check_nolanes_update(unsigned int wid, const char *str)
Updates the jump point checkboxes.
#define SYSEDIT_ZOOM_STEP
static void sysedit_btnGFXApply(unsigned int wid, const char *wgt)
Apply new graphics.
static void sysedit_selectRm(const Select_t *sel)
Removes a system from the selection.
static double sysedit_xpos
static int sysedit_nselect
static unsigned int sysedit_wid
static void jp_type_check_exit_update(unsigned int wid, const char *str)
Updates the jump point checkboxes.
static void sysedit_close(unsigned int wid, const char *wgt)
Closes the system editor widget.
static void sysedit_editPntClose(unsigned int wid, const char *unused)
Closes the spob editor, saving the changes made.
static void sysedit_buttonZoom(unsigned int wid, const char *str)
Handles the button zoom clicks.
static void sysedit_selectAdd(const Select_t *sel)
Adds a system to the selection.
static void sysedit_focusLose(unsigned int wid, const char *wgtname)
Called when it's de-focused.
static void sysedit_btnGrid(unsigned int wid_unused, const char *unused)
Toggles the grid.
static void sysedit_btnNewSpob(unsigned int wid_unused, const char *unused)
Enters the editor in new spob mode.
static int sysedit_selectCmp(const Select_t *a, const Select_t *b)
Compares two selections to see if they are the same.
#define SYSEDIT_EDIT_WIDTH
static void sysedit_btnReset(unsigned int wid_unused, const char *unused)
Resets jump points.
static int sysedit_keys(unsigned int wid, SDL_Keycode key, SDL_Keymod mod, int isrepeat)
Handles keybindings.
static void sysedit_render(double bx, double by, double w, double h, void *data)
System editor custom widget rendering.
static double sysedit_ypos
static int sysedit_isSelected(const Select_t *s)
Check to see if something is selected.
static void sysedit_renderAsteroidsField(double bx, double by, const AsteroidAnchor *ast, int selected)
Draws an asteroid field on the map.
static void sysedit_btnRmTag(unsigned int wid, const char *unused)
Removes a tech from a spob.
static unsigned int sysedit_widEdit
static void sysedit_genTagsList(unsigned int wid)
Generates the spob tech list.
static void sysedit_btnAddService(unsigned int wid, const char *unused)
Adds a service to a spob.
static void sysedit_genTechList(unsigned int wid)
Generates the spob tech list.
static void sysedit_btnGFXClose(unsigned int wid, const char *wgt)
Closes the spob graphic editor.
static void sysedit_deselect(void)
Deselects everything.
static void sysedit_checkButtons(void)
Checks to see which buttons should be active and the likes.
static void sysedit_btnRmTech(unsigned int wid, const char *unused)
Removes a tech from a spob.
static double sysedit_zoom
static void sysedit_btnFaction(unsigned int wid_unused, const char *unused)
Edits a spob's faction.
static void sysedit_spobGFX(unsigned int wid_unused, const char *wgt)
Opens the spob landing or space graphic editor.
static void sysedit_editAsteroids(void)
Opens the asteroid editor.
static char ** sysedit_tagslist
static void sysedit_renderSprite(const glTexture *gfx, double bx, double by, double x, double y, int sx, int sy, const glColour *c, int selected, const char *caption)
Renders a sprite for the custom widget.
static StarSystem * sysedit_sys
#define SYSEDIT_DRAG_THRESHOLD
static void sysedit_btnEdit(unsigned int wid_unused, const char *unused)
Opens the system property editor.
static void sysedit_btnNewTag(unsigned int wid, const char *unused)
Adds a tech to a spob.
#define SYSEDIT_MOVE_THRESHOLD
static void sysedit_renderAsteroidExclusion(double bx, double by, const AsteroidExclusion *aexcl, int selected)
Draws an asteroid exclusion zone on the map.
static void sysedit_spobDescClose(unsigned int wid, const char *unused)
Closes both the spob description window and the properties window.
static void sysedit_btnFactionSet(unsigned int wid, const char *unused)
Actually modifies the faction.
static unsigned int sysedit_dragTime
#define SYSEDIT_EDIT_HEIGHT
static void sysedit_spobDesc(unsigned int wid, const char *unused)
Displays the spob landing description and bar description in a separate window.
static void sysedit_editJumpClose(unsigned int wid, const char *unused)
Closes the jump editor, saving the changes made.
static void sysedit_btnScale(unsigned int wid_unused, const char *unused)
Interface for scaling a system from the system view.
static int sysedit_mselect
static void sysedit_genServicesList(unsigned int wid)
Generates the spob services list.
static void sysedit_btnRemove(unsigned int wid_unused, const char *unused)
Removes spobs.
void sysedit_open(StarSystem *sys)
Opens the system editor interface.
static void sysedit_btnRmService(unsigned int wid, const char *unused)
Removes a service from a spob.
static void sysedit_renderBG(double bx, double bw, double w, double h, double x, double y)
Renders the custom widget background.
static void sysedit_btnAddTag(unsigned int wid, const char *unused)
Adds a tech to a spob.
static void sysedit_btnTagsEdit(unsigned int wid, const char *unused)
Edits a spob's tags.
static void sysedit_editPnt(void)
Edits a spob.
static void sysedit_spobDescReturn(unsigned int wid, const char *unused)
Closes the spob description window and returns to the properties window.
static void sysedit_btnAddTech(unsigned int wid, const char *unused)
Adds a tech to a spob.
void sysedit_sysScale(StarSystem *sys, double factor)
Scales a system.
static int sysedit_mouse(unsigned int wid, const SDL_Event *event, double mx, double my, double w, double h, double xr, double yr, void *data)
System editor custom widget mouse handling.
static void jp_type_check_hidden_update(unsigned int wid, const char *str)
Updates the jump point checkboxes.
static void sysedit_btnTechEdit(unsigned int wid, const char *unused)
Edits a spob's tech.
static int sysedit_dragSel
static void sysedit_btnNewAsteroids(unsigned int wid_unused, const char *unused)
Enters the editor in new spob mode.
static void sysedit_editJump(void)
Edits a jump.
static Select_t * sysedit_select
int dsys_saveSystem(StarSystem *sys)
Saves a star system.
void uniedit_selectText(void)
Sets the selected system text.
char * dialogue_runChoice(void)
Run the dialog and return the clicked string.
char * dialogue_inputRaw(const char *title, int min, int max, const char *msg)
Creates a dialogue that allows the player to write a message.
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_addChoice(const char *caption, const char *msg, const char *opt)
Add a choice to the dialog.
void dialogue_alertRaw(const char *msg)
Displays an alert popup with only an ok button and a message.
void dialogue_makeChoice(const char *caption, const char *msg, int opts)
Create the choice dialog. Need to add choices with below method.
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
int economy_execQueued(void)
Calls economy_refresh if an economy update is queued.
const char * faction_name(int f)
Gets a factions "real" (internal) name.
const glColour * faction_colour(int f)
Gets the colour of the faction.
int * faction_getAll(void)
Returns all faction IDs in an array (array.h).
int faction_get(const char *name)
Gets a faction ID by name.
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.
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.
void land(Spob *p, int load)
Opens up all the land dialogue stuff.
Header file with generic functions and naev-specifics.
int strsort(const void *p1, const void *p2)
Sort function for sorting strings with qsort().
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the 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_renderLine(double x1, double y1, double x2, double y2, const glColour *c)
Draws a line.
void gl_renderScaleSprite(const glTexture *sprite, double bx, double by, int sx, int sy, double bw, double bh, const glColour *c)
Blits a scaled sprite, position is in absolute screen coordinates.
void gl_renderRectEmpty(double x, double y, double w, double h, const glColour *c)
Renders a rectangle.
void gl_renderCross(double x, double y, double r, const glColour *c)
Renders a cross at a given position.
void gl_renderCircle(double cx, double cy, double r, const glColour *c, int filled)
Draws a circle.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
void gl_freeTexture(glTexture *texture)
Frees a texture.
void safelanes_recalculate(void)
Update the safe lane locations in response to the universe changing (e.g., diff applied).
SafeLane * safelanes_get(int faction, int standing, const StarSystem *system)
Gets a set of safelanes for a faction and system.
void space_reconstructPresences(void)
Reset the presence of all systems.
int spob_exists(const char *spobname)
Check to see if a spob exists.
void systems_reconstructJumps(void)
Reconstructs the jumps.
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
int spob_rename(Spob *p, char *newname)
Renames a spob.
int spob_getService(const char *name)
Converts name to spob service flag.
void system_setFaction(StarSystem *sys)
Sets the system faction based on the spobs it has.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
const char * space_getRndSpob(int landable, unsigned int services, int(*filter)(Spob *p))
Gets the name of a random spob.
StarSystem * system_getIndex(int id)
Get the system by its index.
JumpPoint * jump_getTarget(const StarSystem *target, const StarSystem *sys)
Less safe version of jump_get that works with pointers.
void system_updateAsteroids(StarSystem *sys)
Updates some internal calculations about asteroids in a system.
int system_addSpob(StarSystem *sys, const char *spobname)
Adds a spob to a star system.
void spob_gfxLoad(Spob *spob)
Loads a spob's graphics (and radius).
Spob * spob_getIndex(int ind)
Gets spob by index.
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
const char * spob_getServiceName(int service)
Gets the (English) name for a service code.
Spob * spob_new(void)
Creates a new spob.
glTexture * jumppoint_gfx
void space_gfxLoad(StarSystem *sys)
Loads all the graphics for a star system.
int system_rmSpob(StarSystem *sys, const char *spobname)
Removes a spob from a star system.
Represents an asteroid field anchor.
AsteroidTypeGroup ** groups
Represents an asteroid exclusion zone.
Represents a group of asteroids.
Describes a safe lane, patrolled by a faction, within a system.
SafeLaneLocType point_type[2]
Selection generic for stuff in a system.
union Select_t::@276122134114171265212317144121344005263060322354 u
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
union UniHunkTarget_t::@075106202173013221375222217331323374140174001165 u
Represents a single hunk in the diff.
union UniHunk_t::@375235000240300110336260027115076046055102130370 u
Abstraction for rendering sprite sheets.
int tech_rmItemTech(tech_group_t *tech, const char *value)
Removes an item from a tech.
tech_group_t * tech_groupCreate(void)
Creates a tech group.
int tech_getItemCount(const tech_group_t *tech)
Gets the number of techs within a given group.
int tech_hasItem(const tech_group_t *tech, const char *item)
Checks whether a given tech group has the specified item.
int tech_addItemTech(tech_group_t *tech, const char *value)
Adds an item to a tech.
char ** tech_getItemNames(const tech_group_t *tech, int *n)
Gets the names of all techs within a given group.
char ** tech_getAllItemNames(int *n)
Gets the names of all techs.