10#include "SDL_events.h"
19#include "dev_uniedit.h"
25#include "dev_sysedit.h"
26#include "dev_system.h"
38#include "tk/toolkit_priv.h"
43#define BUTTON_WIDTH 100
44#define BUTTON_HEIGHT 30
46#define UNIEDIT_EDIT_WIDTH 400
47#define UNIEDIT_EDIT_HEIGHT 450
49#define UNIEDIT_FIND_WIDTH 400
50#define UNIEDIT_FIND_HEIGHT 500
52#define UNIEDIT_DRAG_THRESHOLD 300
53#define UNIEDIT_MOVE_THRESHOLD 10
54#define UNIEDIT_CLICK_THRESHOLD 20.
55#define UNIEDIT_DOUBLECLICK_THRESHOLD 300
57#define UNIEDIT_ZOOM_STEP 1.2
58#define UNIEDIT_ZOOM_MAX 5.
59#define UNIEDIT_ZOOM_MIN -5.
64typedef enum UniEditMode_ {
72typedef enum UniEditViewMode_ {
74 UNIEDIT_VIEW_VIRTUALSPOBS,
77 UNIEDIT_VIEW_BACKGROUND,
78 UNIEDIT_VIEW_ASTEROIDS,
79 UNIEDIT_VIEW_INTERFERENCE,
81 UNIEDIT_VIEW_PRESENCE_SUM,
82 UNIEDIT_VIEW_PRESENCE,
87int uniedit_diffMode = 0;
88int uniedit_diffSaved = 0;
139static void uniedit_options_setpath(
unsigned int wid,
const char *unused );
140static void uniedit_options_close(
unsigned int wid,
const char *unused );
150static void uniedit_chkNolanes(
unsigned int wid,
const char *wgtname );
164static void uniedit_btnTagsClose(
unsigned int wid,
const char *unused );
167static void uniedit_render(
double bx,
double by,
double w,
double h,
172static int uniedit_mouse(
unsigned int wid,
const SDL_Event *event,
double mx,
173 double my,
double w,
double h,
double rx,
double ry,
175static void uniedit_renderFactionDisks(
double x,
double y,
double r );
176static void uniedit_renderVirtualSpobs(
double x,
double y,
double r );
178static void uniedit_close(
unsigned int wid,
const char *wgt );
179static void uniedit_save(
unsigned int wid_unused,
const char *unused );
180static void uniedit_btnView(
unsigned int wid_unused,
const char *unused );
181static void uniedit_btnJump(
unsigned int wid_unused,
const char *unused );
182static void uniedit_btnEdit(
unsigned int wid_unused,
const char *unused );
183static void uniedit_btnNew(
unsigned int wid_unused,
const char *unused );
184static void uniedit_btnOpen(
unsigned int wid_unused,
const char *unused );
185static void uniedit_btnFind(
unsigned int wid_unused,
const char *unused );
187static int uniedit_keys(
unsigned int wid, SDL_Keycode key, SDL_Keymod mod,
190static void uniedit_diffEditor(
unsigned int wid_unused,
const char *unused );
191static void uniedit_diff_toggle(
unsigned int wid,
const char *wgt );
192static void uniedit_diff_load(
unsigned int wid,
const char *wgt );
193static void uniedit_diff_remove(
unsigned int wid,
const char *wgt );
194static void uniedit_diff_close(
unsigned int wid,
const char *unused );
195static void uniedit_diffSsysPos( StarSystem *s,
double x,
double y );
196static void uniedit_diffClear(
void );
198static void uniedit_saveTest(
void );
209 const glColour cBG = { 0., 0., 0., 0.95 };
217 uniedit_diffSaved = 1;
234 wid =
window_create(
"wdwUniverseEditor", _(
"Universe Editor" ), -1, -1, -1,
242 window_addCust( wid, 0, 0, SCREEN_W, SCREEN_H,
"cstSysEdit", 1,
248 window_addRect( wid, SCREEN_W - 130, 0, 130, SCREEN_H,
"rctRCol", &cBG, 0 );
249 window_addRect( wid, 0, 0, SCREEN_W, 60,
"rctBBar", &cBG, 0 );
252 window_addButtonKey( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
258 window_addButton( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
260 uniedit_diffMode ? _(
"Save Diff" ) : _(
"Save All" ),
265 window_addButton( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
267 uniedit_diffEditor );
271 window_addButton( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
277 window_addButtonKey( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
283 window_addButtonKey( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
289 window_addButtonKey( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
295 window_addButtonKey( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
301 window_addButtonKey( wid, -15, 20 + (
BUTTON_HEIGHT + 20 ) * buttonPos,
309 window_buttonCustomRender( wid,
"btnOptions",
310 window_buttonCustomRenderGear );
313 window_addButton( wid, 20, 20, 30, 30,
"btnZoomIn", p_(
"zoomin",
"+" ),
315 window_addButton( wid, 60, 20, 30, 30,
"btnZoomOut", p_(
"zoomout",
"-" ),
319 window_addText( wid, -10, -20, 110, 200, 0,
"txtNebula", &
gl_smallFont, NULL,
323 window_addText( wid, -10, -80 -
gl_smallFont.h - 5, 110, 200, 0,
327 window_addText( wid, 100, 10, SCREEN_W / 2 - 140, 30, 0,
"txtSelected",
337static void uniedit_saveDirectoryChoose(
void *data,
338 const char *
const *filelist,
343 if (filelist == NULL) {
344 WARN( _(
"Error calling %s: %s" ),
"SDL_ShowOpenFolderDialog",
347 }
else if (filelist[0] == NULL) {
352 free( conf.dev_data_dir );
353 conf.dev_data_dir = strdup( filelist[0] );
356void uniedit_saveError(
void )
358 const char *datadir =
359 ( conf.dev_data_dir == NULL ) ?
"[NULL]" : conf.dev_data_dir;
361 _(
"There has been an error saving data from the "
362 "editor! Please check "
363 "the error logs or open the console for more "
364 "information. You likely "
365 "have the wrong path set."
367 "The current data directory is '#b%s#0'"
369 "Do you wish to choose a new directory?" ),
372 SDL_ShowOpenFolderDialog( uniedit_saveDirectoryChoose, NULL,
373 gl_screen.window, conf.dev_data_dir, 0 );
376static int uniedit_saveTestDirectory(
const char *path )
383 snprintf( buf,
sizeof( buf ),
"%s/.naevtestpath", path );
393static void uniedit_saveTest(
void )
396 if (conf.dev_data_dir == NULL) {
398 _(
"Invalid Save Directory" ),
399 _(
"Data directory is not set. Do you wish to choose a directory "
400 "to save files with the editor to? You will be unable to save "
403 "Do you wish to choose a new directory?" ) ))
405 SDL_ShowOpenFolderDialog( uniedit_saveDirectoryChoose, NULL,
406 gl_screen.window, conf.dev_data_dir, 0 );
410 snprintf( buf,
sizeof( buf ),
"%s/ssys/", conf.dev_data_dir );
411 if (uniedit_saveTestDirectory( buf ))
413 snprintf( buf,
sizeof( buf ),
"%s/spob/", conf.dev_data_dir );
414 if (uniedit_saveTestDirectory( buf ))
420 _(
"The writing directory for the editor does not "
421 "seem to exist. Maybe the path is wrong?\n"
423 "The current data directory is '#b%s#0'"
425 "Do you wish to choose a new directory?" ),
428 SDL_ShowOpenFolderDialog( uniedit_saveDirectoryChoose, NULL,
429 gl_screen.window, conf.dev_data_dir, 0 );
435static int uniedit_keys(
unsigned int wid, SDL_Keycode key, SDL_Keymod mod,
449 if (mod & ( KMOD_LCTRL | KMOD_RCTRL )) {
463 for (
int i = 0; i < n; i++) {
482 if (uniedit_diffMode && !uniedit_diffSaved) {
484 _(
"#rUnsaved Progress" ),
485 _(
"You have #runsaved changes#0 to the universe diff. Are you "
486 "sure you wish to close the editor and #rlose all your "
506static void uniedit_save_callback(
void *userdata,
const char *
const *filelist,
512 if (filelist == NULL) {
513 WARN( _(
"Error calling %s: %s" ),
"SDL_ShowSaveFileDialog",
516 }
else if (filelist[0] == NULL) {
522 ddiff_save( uniedit_diff, filelist[0] );
523 uniedit_diffSaved = 1;
528static void uniedit_save(
unsigned int wid_unused,
const char *unused )
533 if (uniedit_diffMode) {
535 { .name = _(
"Diff XML file" ), .pattern =
"xml" },
539 snprintf( buf,
sizeof( buf ),
"%s/unidiff/newunidiff.xml",
541 SDL_ShowSaveFileDialog( uniedit_save_callback, NULL,
gl_screen.window,
555void uniedit_options(
unsigned int wid_unused,
const char *unused )
562 char buf[STRMAX_SHORT];
564 window_create(
"wdwEditorOptions", _(
"Editor Options" ), -1, -1, w, h );
572 snprintf( buf,
sizeof( buf ),
"#nData Path:#0 %s", conf.dev_data_dir );
573 window_addText( wid, 20, y, w - 40, 20, 0,
"txtDataPath", NULL, NULL, buf );
576 _(
"Set Path" ), uniedit_options_setpath );
580 window_addCheckbox( wid, 20, y, w - 40, 20,
"chkEditAutoSave",
581 _(
"Automatically save changes" ), NULL,
585static void uniedit_options_setpath_callback(
void *userdata,
586 const char *
const *filelist,
590 unsigned int wid = *(
unsigned int *)userdata;
591 char buf[STRMAX_SHORT];
593 if (filelist == NULL) {
594 WARN( _(
"Error calling %s: %s" ),
"SDL_ShowOpenFolderDialog",
597 }
else if (filelist[0] == NULL) {
603 free( conf.dev_data_dir );
604 conf.dev_data_dir = strdup( filelist[0] );
606 snprintf( buf,
sizeof( buf ),
"#nData Path:#0 %s", conf.dev_data_dir );
607 window_modifyText( wid,
"txtDataPath", buf );
609static void uniedit_options_setpath(
unsigned int wid,
const char *unused )
612 SDL_ShowOpenFolderDialog( uniedit_options_setpath_callback, &wid,
613 gl_screen.window, conf.dev_data_dir, 0 );
616static void uniedit_options_close(
unsigned int wid,
const char *unused )
619 conf.devautosave = window_checkboxState( wid,
"chkEditAutoSave" );
622static int factionGenerates(
int f,
int tocheck,
double *w )
626 if (fg[i].
id == tocheck) {
651 for (
int i = 0; i <
array_size( factions ); i++) {
654 for (
int j = 0; j <
array_size( spobs ); j++) {
656 if (( p->presence.faction != f ) &&
657 !factionGenerates( p->presence.faction, f, NULL ))
659 if (p->presence.base == 0. && p->presence.bonus == 0.)
669 wid =
window_create(
"wdwUniEditView", _(
"Select a View Mode" ), -1, -1,
675 str = malloc(
sizeof(
char * ) * (
array_size( factions ) + n ) );
676 str[0] = strdup( _(
"Default" ) );
677 str[1] = strdup( _(
"Virtual Spobs" ) );
678 str[2] = strdup( _(
"System Radius" ) );
679 str[3] = strdup( _(
"No Lanes" ) );
680 str[4] = strdup( _(
"Background" ) );
681 str[5] = strdup( _(
"Asteroids" ) );
682 str[6] = strdup( _(
"Interference" ) );
683 str[7] = strdup( _(
"Tech" ) );
684 str[8] = strdup( _(
"Sum of Presences" ) );
686 for (
int i = 0; i <
array_size( factions ); i++) {
692 qsort( &str[n], k - n,
sizeof(
char * ),
strsort );
768static void uniedit_renderFactionDisks(
double x,
double y,
double r )
780 double tx, ty, sr, presence;
799static void uniedit_renderVirtualSpobs(
double x,
double y,
double r )
801 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
811 sr = 5. * M_PI * sqrt( (
double)
array_size( sys->spobs_virtual ) ) *
819static void uniedit_renderRadius(
double x,
double y,
double r )
821 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
831 sr = 5. * M_PI * sqrt( sys->radius / 10e3 ) *
uniedit_zoom;
838static void uniedit_renderNolanes(
double x,
double y,
double r )
840 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
846 if (!sys_isFlag( sys, SYSTEM_NOLANES ))
860static void uniedit_renderBackground(
double x,
double y,
double r )
862 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
868 if (sys->background == NULL)
882static void uniedit_renderAsteroids(
double x,
double y,
double r )
884 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
889 double density = sys->asteroid_density;
904static void uniedit_renderInterference(
double x,
double y,
double r )
906 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
916 sr = 5. * M_PI * sqrt( sys->interference / 20. ) *
uniedit_zoom;
923static void uniedit_renderTech(
double x,
double y,
double r )
925 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
932 for (
int j = 0; j <
array_size( sys->spobs ); j++) {
933 if (sys->spobs[j]->tech != NULL) {
951static void uniedit_renderPresenceSum(
double x,
double y,
double r )
953 const glColour
c = { .r = 1., .g = 1., .b = 1., .a = 0.3 };
960 for (
int j = 0; j <
array_size( sys->presence ); j++)
961 total +=
MAX( 0., sys->presence[j].value );
976void uniedit_renderMap(
double bx,
double by,
double w,
double h,
double x,
977 double y,
double zoom,
double r )
984 case UNIEDIT_VIEW_DEFAULT:
985 map_renderDecorators( x, y, zoom, 1, 1. );
986 map_renderFactionDisks( x, y, zoom, r, 1, 1. );
987 map_renderSystemEnvironment( x, y, zoom, 1, 1. );
990 case UNIEDIT_VIEW_VIRTUALSPOBS:
991 uniedit_renderVirtualSpobs( x, y, r );
994 case UNIEDIT_VIEW_RADIUS:
995 uniedit_renderRadius( x, y, r );
998 case UNIEDIT_VIEW_NOLANES:
999 uniedit_renderNolanes( x, y, r );
1002 case UNIEDIT_VIEW_BACKGROUND:
1003 uniedit_renderBackground( x, y, r );
1006 case UNIEDIT_VIEW_ASTEROIDS:
1007 uniedit_renderAsteroids( x, y, r );
1010 case UNIEDIT_VIEW_INTERFERENCE:
1011 uniedit_renderInterference( x, y, r );
1014 case UNIEDIT_VIEW_TECH:
1015 uniedit_renderTech( x, y, r );
1018 case UNIEDIT_VIEW_PRESENCE_SUM:
1019 uniedit_renderPresenceSum( x, y, r );
1022 case UNIEDIT_VIEW_PRESENCE:
1024 uniedit_renderFactionDisks( x, y, r );
1029 map_renderJumps( x, y, zoom, r, 1 );
1032 map_renderSystems( bx, by, x, y, zoom, w, h, r, MAPMODE_EDITOR );
1035 map_renderNames( bx, by, x, y, zoom, w, h, 1, 1. );
1037 glClear( GL_DEPTH_BUFFER_BIT );
1056 uniedit_renderMap( bx, by, w, h, x, y,
uniedit_zoom, r );
1061 glUseProgram( shaders.selectspob.program );
1062 glUniform1f( shaders.selectspob.dt,
uniedit_dt );
1065 &shaders.selectspob, &cWhite, 1 );
1069static char getValCol(
double val )
1077static int getPresenceVal(
int f,
const SpobPresence *ap,
double *base,
1082 if (( ap->
faction != f ) && !( gf = factionGenerates( ap->
faction, f, &w ) ))
1088 *base = ap->
base * w;
1089 *bonus = ap->
bonus * w;
1100 double x, y, mx, my, sx, sy;
1101 double value, base, bonus;
1102 char buf[STRMAX] = {
'\0' };
1103 StarSystem *sys, *cur, *mousesys;
1122 double l, r, b, t, rx, ry;
1123 const glColour col = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 0.5 };
1139 if (( x > SCREEN_W - 130 ) || ( y < 60 ))
1157 if ((
pow2( sx - mx ) +
pow2( sy - my ) ) >
1163 if (mousesys == NULL)
1178 for (
int j = 0; j <
array_size( sys->spobs_virtual ); j++) {
1180 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s%s",
1181 ( l > 0 ) ?
"\n" :
"", va->
name );
1190 scnprintf( &buf[0],
sizeof( buf ), _(
"System Radius: %s" ),
1198 if (sys->background != NULL) {
1199 scnprintf( &buf[0],
sizeof( buf ), _(
"Background: %s" ),
1210 l =
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"Density: %g" ),
1211 sys->asteroid_density );
1212 for (
int i = 0; i <
array_size( sys->asteroids ); i++) {
1215 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s%s",
1216 ( l > 0 ) ?
"\n" :
"", ast->
groups[j]->
name );
1225 if (sys->interference > 0.) {
1226 scnprintf( &buf[0],
sizeof( buf ), _(
"Interference: %.0f%%" ),
1227 sys->interference );
1235 char *techlist[256];
1237 const int len =
sizeof( techlist ) /
sizeof(
char * );
1245 for (
int j = 0; j <
array_size( sys->spobs ); j++) {
1246 const Spob *spob = sys->spobs[j];
1249 if (spob->
tech == NULL)
1252 for (
int k = 0; ( k < n ) && ( ntechs < len - 1 ); k++)
1253 techlist[ntechs++] = techs[k];
1256 qsort( techlist, ntechs,
sizeof(
char * ),
strsort );
1257 for (
int k = 0; k < ntechs; k++) {
1258 if (( k > 0 ) && ( strcmp( techlist[k - 1], techlist[k] ) == 0 ))
1260 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s%s",
1261 ( l > 0 ) ?
"\n" :
"", techlist[k] );
1263 for (
int k = 0; k < ntechs; k++)
1264 free( techlist[k] );
1278 for (
int j = 0; j <
array_size( sys->presence ); j++)
1279 value +=
MAX( sys->presence[j].value, 0. );
1282 l =
scnprintf( buf,
sizeof( buf ), _(
"Total: %.0f" ), value );
1283 for (
int j = 0; j <
array_size( sys->presence ); j++) {
1284 sp = &sys->presence[j];
1285 if (sp->
value <= 0.)
1287 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s: %.0f = %.0f + %.0f",
1305 buf,
sizeof( buf ),
"#%c%.0f#0 = #%c%.0f#0 + #%c%.0f#0 [%s - %s]",
1306 getValCol( value ), value, getValCol( base ), base, getValCol( bonus ),
1310 for (
int j = 0; j <
array_size( sys->spobs ); j++) {
1311 Spob *spob = sys->spobs[j];
1312 if (!getPresenceVal( f, &spob->
presence, &base, &bonus ))
1314 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
1315 "\n#%c%.0f#0 (#%c%+.0f#0) [%s]", getValCol( base ),
1316 base, getValCol( bonus ), bonus,
spob_name( spob ) );
1318 for (
int j = 0; j <
array_size( sys->spobs_virtual ); j++) {
1321 if (!getPresenceVal( f, &va->
presences[p], &base, &bonus ))
1323 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
1324 "\n#%c%.0f#0 (#%c%+.0f#0) [%s]", getValCol( base ),
1325 base, getValCol( bonus ), bonus, _( va->
name ) );
1330 for (
int k = 0; k <
array_size( sys->jumps ); k++) {
1331 cur = sys->jumps[k].target;
1332 for (
int j = 0; j <
array_size( cur->spobs ); j++) {
1333 Spob *spob = cur->spobs[j];
1334 if (!getPresenceVal( f, &spob->
presence, &base, &bonus ))
1336 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
1337 "\n#%c%.0f#0 (#%c%+.0f#0) [%s (%s)]",
1338 getValCol( base ), base * 0.5, getValCol( bonus ),
1339 bonus * 0.5,
spob_name( spob ), _( cur->name ) );
1341 for (
int j = 0; j <
array_size( cur->spobs_virtual ); j++) {
1344 if (!getPresenceVal( f, &va->
presences[p], &base, &bonus ))
1348 "\n#%c%.0f#0 (#%c%+.0f#0) [%s (%s)]",
1349 getValCol( base ), base * 0.5, getValCol( bonus ),
1350 bonus * 0.5, _( va->
name ), _( cur->name ) );
1374 double my,
double w,
double h,
double rx,
double ry,
1378 unsigned int lastClick;
1379 StarSystem *clickedsys;
1384 mod = SDL_GetModState();
1386 switch (event->type) {
1388 case SDL_MOUSEWHEEL:
1390 if (( mx < 0. ) || ( mx > w - 130. ) || ( my < 60. ) || ( my > h ))
1393 if (event->wheel.y > 0)
1395 else if (event->wheel.y < 0)
1400 case SDL_MOUSEBUTTONDOWN:
1402 if (( mx < 0. ) || ( mx > w - 130. ) || ( my < 60. ) || ( my > h ))
1431 if ((
pow2( mx - sys->pos.x ) +
pow2( my - sys->pos.y ) ) >
1447 if (clickedsys != NULL) {
1469 if (( clickedsys != NULL ) && inselection) {
1473 if (mod & ( KMOD_LCTRL | KMOD_RCTRL ))
1482 if (clickedsys != NULL) {
1484 if (!( mod & ( KMOD_LCTRL | KMOD_RCTRL ) ))
1494 if (mod & ( KMOD_LCTRL | KMOD_RCTRL | KMOD_LSHIFT | KMOD_RSHIFT )) {
1495 if (mod & ( KMOD_LSHIFT | KMOD_RSHIFT ))
1507 case SDL_MOUSEBUTTONUP:
1530 if (conf.devautosave) {
1535 uniedit_saveError();
1555 double x = sys->pos.x;
1556 double y = sys->pos.y;
1557 if (( x >= l ) && ( x <= r ) && ( y >= b ) && ( y <= t ))
1565 case SDL_MOUSEMOTION:
1572 double a1, a2, amod;
1579 a1 = atan2( cy, cx );
1582 a2 = atan2( cy, cx );
1589 double a = atan2( sy, sx );
1590 double m = hypot( sx, sy );
1633 dialogue_alert( _(
"The Star System '%s' already exists!" ), name );
1640char *uniedit_nameFilter(
const char *name )
1642 size_t len = strlen( name ) + 1;
1643 char *out = malloc( len );
1644 strncpy( out, name, len );
1645 out[len - 1] =
'\0';
1649 while ((
c = u8_nextchar( name, &i ) )) {
1651 if ((
c ==
' ' ) || (
c ==
'/' ) || (
c ==
'\\' ) || (
c ==
':' ) ||
1653 size_t o = u8_offset( name, j );
1655 }
else if (isupper(
c )) {
1656 size_t o = u8_offset( name, j );
1657 out[o] = tolower(
c );
1670 int cancelall_prompt = 0;
1672 char *name, *oldName, *newName;
1677 if (uniedit_diffMode)
1678 prompt = _(
"What do you want to rename #r%s#0?\n\n#rNote:#0 this "
1679 "will only change the display name of the system." );
1681 prompt = _(
"What do you want to rename #r%s#0?\n\n#rNote:#0 this "
1682 "will rename and copy the system data file." );
1684 system_name( sys ) );
1690 _(
"Do you want to cancel renaming all "
1691 "selected star systems?" ) ))
1693 cancelall_prompt = 1;
1698 if (uniedit_diffMode) {
1699 uniedit_diffCreateSysStr( sys, HUNK_TYPE_SSYS_DISPLAYNAME,
1712 filtered = strdup( sys->filename );
1713 SDL_asprintf( &oldName,
"%s/ssys/%s", conf.dev_data_dir,
1714 basename( filtered ) );
1717 filtered = uniedit_nameFilter( name );
1718 SDL_asprintf( &newName,
"%s/ssys/%s.xml", conf.dev_data_dir,
1722 if (rename( oldName, newName ))
1723 WARN( _(
"Failed to rename '%s' to '%s'!" ), oldName, newName );
1726 free( sys->filename );
1729 sys->filename = newName;
1736 for (
int j = 0; j <
array_size( sys->jumps ); j++)
1753 if (uniedit_diffMode) {
1755 (
"Adding new systems is not supported in diff mode!" ) );
1761 _(
"What do you want to name the new system?" ) );
1781 sys->spacedust = DUST_DENSITY_DEFAULT;
1782 sys->radius = RADIUS_DEFAULT;
1785 char *cleanname = uniedit_nameFilter( sys->name );
1786 SDL_asprintf( &sys->filename,
"%s.xml", cleanname );
1793 if (conf.devautosave) {
1795 uniedit_saveError();
1807 for (
int j = 0; j <
array_size( isys->jumps ); j++) {
1808 StarSystem *target = isys->jumps[j].target;
1810 if (target == sys) {
1813 if (uniedit_diffMode) {
1814 uniedit_diffCreateSysStr( isys, HUNK_TYPE_JUMP_REMOVE,
1815 strdup( sys->name ) );
1826 if (uniedit_diffMode) {
1827 uniedit_diffCreateSysStr( isys, HUNK_TYPE_JUMP_ADD,
1828 strdup( sys->name ) );
1836 if (!uniedit_diffMode) {
1843 if (conf.devautosave) {
1850 uniedit_saveError();
1870 window_modifyText(
uniedit_wid,
"txtSelected", _(
"#nNo selection" ) );
1871 window_modifyText(
uniedit_wid,
"txtNebula", _(
"N/A" ) );
1872 window_modifyText(
uniedit_wid,
"txtPresence", _(
"N/A" ) );
1913 WARN( _(
"Trying to remove system '%s' from selection when not selected." ),
1934 window_modifyText(
uniedit_wid,
"txtSelected", buf );
1942 if (sys->nebu_density > 0.)
1943 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
1944 _(
"%.0f Density\n%.1f Volatility\n%.0f Hue" ),
1945 sys->nebu_density, sys->nebu_volatility,
1946 sys->nebu_hue * 360. );
1947 if (sys->interference > 0.)
1949 _(
"%s%.1f Interference" ),
1950 ( l > 0 ) ?
"\n" :
"", sys->interference );
1952 window_modifyText(
uniedit_wid,
"txtNebula", buf );
1955 map_updateFactionPresence(
uniedit_wid,
"txtPresence", sys, 1 );
1958 _(
"Multiple selected" ) );
1960 _(
"Multiple selected" ) );
1965 -40 - window_getTextHeight(
uniedit_wid,
"txtNebula" ) );
1982 if (strcmp( str,
"btnZoomIn" ) == 0) {
1986 }
else if (strcmp( str,
"btnZoomOut" ) == 0) {
2008 wid =
window_create(
"wdwFindSystemsandSpobs", _(
"Find Systems and Spobs" ),
2040 int n, nspobs, nsystems;
2042 char **spobs, **systems;
2045 name = window_getInput( wid,
"inpFind" );
2055 found = malloc(
sizeof(
map_find_t ) * ( nspobs + nsystems ) );
2059 for (
int i = 0; i < nspobs; i++) {
2066 if (sysname == NULL)
2074 found[n].
spob = spob;
2078 snprintf( found[n].display,
sizeof( found[n].display ),
2079 _(
"%s (%s system)" ), spobs[i], system_name( sys ) );
2085 for (
int i = 0; i < nsystems; i++) {
2089 found[n].
spob = NULL;
2092 strncpy( found[n].display, sys->name,
sizeof( found[n].
display ) - 1 );
2121 str = malloc(
sizeof(
char * ) );
2122 str[0] = strdup( _(
"None" ) );
2127 str = malloc(
sizeof(
char * ) * n );
2128 for (
int i = 0; i < n; i++)
2129 str[i] = strdup( found[i].display );
2164 pos = toolkit_getListPos( wid,
"lstResults" );
2184 return strcasecmp( f1->
sys->name, f2->
sys->name );
2194 char buf[STRMAX_SHORT];
2205 _(
"Star System Property Editor" ), -1, -1,
2218 snprintf( buf,
sizeof( buf ),
"%s #n%s", _(
"Name:" ),
2221 window_addText( wid, x, y, 180, 15, 0,
"txtName", &
gl_smallFont, NULL, buf );
2222 window_addButton( wid, 200, y + 3,
BUTTON_WIDTH, 21,
"btnRename",
2231 window_addText( wid, x, y, l, 20, 1,
"txtRadius", NULL, NULL, s );
2232 window_addInput( wid, x += l + 7, y, 80, 20,
"inpRadius", 10, 1, NULL );
2233 window_setInputFilter( wid,
"inpRadius", INPUT_FILTER_NUMBER );
2235 s = _(
"(Scales spob positions)" );
2237 window_addText( wid, x, y, l, 20, 1,
"txtRadiusComment", NULL, NULL, s );
2245 window_addText( wid, x, y, l, 20, 1,
"txtDust", NULL, NULL, s );
2246 window_addInput( wid, x += l + 7, y, 50, 20,
"inpDust", 4, 1, NULL );
2247 window_setInputFilter( wid,
"inpDust", INPUT_FILTER_NUMBER );
2250 s = _(
"Interference" );
2252 window_addText( wid, x, y, l, 20, 1,
"txtInterference", NULL, NULL, s );
2253 window_addInput( wid, x += l + 7, y, 55, 20,
"inpInterference", 5, 1, NULL );
2254 window_setInputFilter( wid,
"inpInterference", INPUT_FILTER_NUMBER );
2262 window_addText( wid, x, y, l, 20, 1,
"txtNebula", NULL, NULL, s );
2263 window_addInput( wid, x += l + 7, y, 50, 20,
"inpNebula", 4, 1, NULL );
2264 window_setInputFilter( wid,
"inpNebula", INPUT_FILTER_NUMBER );
2267 s = _(
"Volatility" );
2269 window_addText( wid, x, y, l, 20, 1,
"txtVolatility", NULL, NULL, s );
2270 window_addInput( wid, x += l + 7, y, 50, 20,
"inpVolatility", 4, 1, NULL );
2271 window_setInputFilter( wid,
"inpVolatility", INPUT_FILTER_NUMBER );
2276 window_addText( wid, x, y, l, 20, 1,
"txtHue", NULL, NULL, s );
2277 window_addInput( wid, x += l + 7, y, 50, 20,
"inpHue", 4, 1, NULL );
2278 window_setInputFilter( wid,
"inpHue", INPUT_FILTER_NUMBER );
2285 s = _(
"No lanes" );
2286 window_addCheckbox( wid, x, y, 100,
gl_defFont.h,
"chkNolanes", s,
2287 uniedit_chkNolanes, sys_isFlag( sys, SYSTEM_NOLANES ) );
2292 l =
scnprintf( buf,
sizeof( buf ),
"#n%s#0", _(
"Tags: " ) );
2293 for (
int i = 0; i <
array_size( sys->tags ); i++)
2294 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s%s",
2295 ( i == 0 ) ?
"" :
", ", sys->tags[i] );
2300 snprintf( buf,
sizeof( buf ),
"%g", sys->radius );
2301 window_setInput( wid,
"inpRadius", buf );
2302 snprintf( buf,
sizeof( buf ),
"%d", sys->spacedust );
2303 window_setInput( wid,
"inpDust", buf );
2304 snprintf( buf,
sizeof( buf ),
"%g", sys->interference );
2305 window_setInput( wid,
"inpInterference", buf );
2306 snprintf( buf,
sizeof( buf ),
"%g", sys->nebu_density );
2307 window_setInput( wid,
"inpNebula", buf );
2308 snprintf( buf,
sizeof( buf ),
"%g", sys->nebu_volatility );
2309 window_setInput( wid,
"inpVolatility", buf );
2310 snprintf( buf,
sizeof( buf ),
"%g", sys->nebu_hue * 360. );
2311 window_setInput( wid,
"inpHue", buf );
2325 int y, h, has_spobs;
2340 str = malloc(
sizeof(
char * ) * ( n + 1 ) );
2343 for (
int i = 0; i < n; i++) {
2345 str[j++] = strdup( va->
name );
2348 str[j++] = strdup( _(
"None" ) );
2366 window_addButton( wid, -20 - ( 20 +
BUTTON_WIDTH ) * 2, y + 3,
2386 scale = atof( window_getInput( wid,
"inpRadius" ) ) / sys->radius;
2387 if (fabs( scale - 1. ) > 1e-5) {
2388 if (uniedit_diffMode)
2390 _(
"Changing system radius not supported in diff mode!" ) );
2395 data = atoi( window_getInput( wid,
"inpDust" ) );
2396 if (data != sys->spacedust) {
2397 if (uniedit_diffMode)
2398 uniedit_diffCreateSysInt( sys, HUNK_TYPE_SSYS_DUST, data );
2400 sys->spacedust = data;
2402 fdata = atof( window_getInput( wid,
"inpInterference" ) );
2403 if (fabs( sys->interference - fdata ) > 1e-5) {
2404 if (uniedit_diffMode)
2405 uniedit_diffCreateSysFloat( sys, HUNK_TYPE_SSYS_INTERFERENCE, fdata );
2407 sys->interference = fdata;
2409 fdata = atof( window_getInput( wid,
"inpNebula" ) );
2410 if (fabs( sys->nebu_density - fdata ) > 1e-5) {
2411 if (uniedit_diffMode)
2412 uniedit_diffCreateSysFloat( sys, HUNK_TYPE_SSYS_NEBU_DENSITY, fdata );
2414 sys->nebu_density = fdata;
2416 fdata = atof( window_getInput( wid,
"inpVolatility" ) );
2417 if (fabs( sys->nebu_volatility - fdata ) > 1e-5) {
2418 if (uniedit_diffMode)
2419 uniedit_diffCreateSysFloat( sys, HUNK_TYPE_SSYS_NEBU_VOLATILITY,
2422 sys->nebu_volatility = fdata;
2424 fdata = atof( window_getInput( wid,
"inpHue" ) ) / 360.;
2425 if (fabs( sys->nebu_hue - fdata ) > 1e-5) {
2426 if (uniedit_diffMode)
2427 uniedit_diffCreateSysFloat( sys, HUNK_TYPE_SSYS_NEBU_HUE, fdata );
2429 sys->nebu_hue = fdata;
2434 for (
int i = 0; i <
array_size( plt_stack ); i++)
2438 if (!uniedit_diffMode) {
2447 if (conf.devautosave) {
2449 uniedit_saveError();
2463 const char *selected = toolkit_getList( wid,
"lstSpobs" );
2466 if (( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ))
2469 if (uniedit_diffMode) {
2470 uniedit_diffCreateSysStr(
uniedit_sys[0], HUNK_TYPE_VSPOB_REMOVE,
2471 strdup( selected ) );
2476 dialogue_alert( _(
"Failed to remove virtual spob '%s'!" ), selected );
2503 dialogue_alert( _(
"No virtual spobs to add! Please add virtual spobs to "
2504 "the '%s' directory first." ),
2505 VIRTUALSPOB_DATA_PATH );
2510 wid =
window_create(
"wdwAddaVirtualSpob", _(
"Add a Virtual Spob" ), -1, -1,
2515 str = malloc(
sizeof(
char * ) *
array_size( va ) );
2517 str[i] = strdup( va[i].name );
2537 const char *selected;
2540 selected = toolkit_getList( wid,
"lstSpobs" );
2541 if (selected == NULL)
2544 if (uniedit_diffMode) {
2545 uniedit_diffCreateSysStr(
uniedit_sys[0], HUNK_TYPE_VSPOB_ADD,
2546 strdup( selected ) );
2551 dialogue_alert( _(
"Failed to add virtual spob '%s'!" ), selected );
2559 if (conf.devautosave) {
2561 uniedit_saveError();
2581 wid =
window_create(
"wdwSystemTagsEditor", _(
"System Tags Editor" ), -1,
2589 window_addButton( wid, -20, 20, bw,
BUTTON_HEIGHT,
"btnClose", _(
"Close" ),
2590 uniedit_btnTagsClose );
2594 window_addButton( wid, -20 - ( w + 15 ), y, w,
BUTTON_HEIGHT,
"btnRm",
2598 window_addButton( wid, -20, y, w,
BUTTON_HEIGHT,
"btnAdd", _(
"Add Tag" ),
2602 window_addButton( wid, -20 - ( w + 15 ), 20, w,
BUTTON_HEIGHT,
"btnNew",
2609 for (
int i = 0; i <
array_size( systems_all ); i++) {
2610 StarSystem *s = &systems_all[i];
2611 for (
int j = 0; j <
array_size( s->tags ); j++) {
2612 const char *t = s->tags[j];
2633static void uniedit_btnTagsClose(
unsigned int wid,
const char *unused )
2635 char buf[STRMAX_SHORT];
2637 int l =
scnprintf( buf,
sizeof( buf ),
"#n%s#0", _(
"Tags: " ) );
2638 for (
int i = 0; i <
array_size( s->tags ); i++)
2639 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s%s",
2640 ( ( i > 0 ) ?
", " :
"" ), s->tags[i] );
2652 char **have, **lack;
2653 int n, x, y, w, h, hpos, lpos, empty;
2660 hpos = toolkit_getListPos( wid,
"lstTagsHave" );
2661 lpos = toolkit_getListPos( wid,
"lstTagsLacked" );
2675 have = malloc( n *
sizeof(
char * ) );
2676 for (
int i = 0; i < n; i++)
2677 have[i] = strdup( s->tags[i] );
2680 have = malloc(
sizeof(
char * ) );
2681 have[n++] = strdup( _(
"None" ) );
2686 window_addList( wid, x, y, w, h,
"lstTagsHave", have, n, 0, NULL,
2696 lack[n++] = strdup( t );
2699 for (
int j = 0; j <
array_size( s->tags ); j++)
2700 if (strcmp( s->tags[j], t ) == 0) {
2705 lack[n++] = strdup( t );
2710 window_addList( wid, x, y, w, h,
"lstTagsLacked", lack, n, 0, NULL,
2714 if (hpos != -1 && lpos != -1) {
2715 toolkit_setListPos( wid,
"lstTagsHave", hpos );
2716 toolkit_setListPos( wid,
"lstTagsLacked", lpos );
2726 const char *selected = toolkit_getList( wid,
"lstTagsLacked" );
2727 if (( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ))
2730 if (uniedit_diffMode) {
2731 uniedit_diffCreateSysStr(
uniedit_sys[0], HUNK_TYPE_SSYS_TAG_ADD,
2732 strdup( selected ) );
2735 if (s->tags == NULL)
2750 const char *selected = toolkit_getList( wid,
"lstTagsHave" );
2751 if (( selected == NULL ) || ( strcmp( selected, _(
"None" ) ) == 0 ))
2754 if (uniedit_diffMode) {
2755 uniedit_diffCreateSysStr(
uniedit_sys[0], HUNK_TYPE_SSYS_TAG_REMOVE,
2756 strdup( selected ) );
2761 if (strcmp( selected, s->tags[i] ) == 0)
2766 array_erase( &s->tags, &s->tags[i], &s->tags[i + 1] );
2781 _(
"Please write the new tag to add to the system." ) );
2785 if (uniedit_diffMode) {
2786 uniedit_diffCreateSysStr(
uniedit_sys[0], HUNK_TYPE_SSYS_TAG_ADD,
2790 if (s->tags == NULL)
2808 char buf[STRMAX_SHORT];
2814 snprintf( buf,
sizeof( buf ),
"%s #n%s", _(
"Name:" ),
2817 window_modifyText( wid,
"txtName", buf );
2825 const char *selected;
2829 pos = toolkit_getListPos( wid,
"lstViewModes" );
2835 }
else if (pos == 1) {
2839 }
else if (pos == 2) {
2843 }
else if (pos == 3) {
2847 }
else if (pos == 4) {
2851 }
else if (pos == 5) {
2855 }
else if (pos == 6) {
2859 }
else if (pos == 7) {
2863 }
else if (pos == 8) {
2870 selected = toolkit_getList( wid,
"lstViewModes" );
2871 if (selected == NULL)
2881static void uniedit_chkNolanes(
unsigned int wid,
const char *wgtname )
2883 int s = window_checkboxState( wid, wgtname );
2885 if (uniedit_diffMode) {
2887 uniedit_diffCreateSysNone( sys, HUNK_TYPE_SSYS_NOLANES_ADD );
2889 uniedit_diffCreateSysNone( sys, HUNK_TYPE_SSYS_NOLANES_REMOVE );
2892 sys_setFlag( sys, SYSTEM_NOLANES );
2894 sys_rmFlag( sys, SYSTEM_NOLANES );
2898static void uniedit_diffClear(
void )
2901 for (
int i = 0; i <
array_size( uniedit_diff ); i++) {
2909 uniedit_diff = NULL;
2912static int uniedit_diff_cmp(
const void *p1,
const void *p2 )
2927void uniedit_diffCreateSysNone(
const StarSystem *sys, UniHunkType_t type )
2930 memset( &hunk, 0,
sizeof( hunk ) );
2934 hunk.
dtype = HUNK_DATA_NONE;
2935 uniedit_diffAdd( &hunk );
2938void uniedit_diffCreateSysStr(
const StarSystem *sys, UniHunkType_t type,
2941 uniedit_diffCreateSysStrAttr( sys, type, str, NULL );
2943void uniedit_diffCreateSysStrAttr(
const StarSystem *sys, UniHunkType_t type,
2947 memset( &hunk, 0,
sizeof( hunk ) );
2951 hunk.
dtype = HUNK_DATA_STRING;
2954 uniedit_diffAdd( &hunk );
2957void uniedit_diffCreateSysInt(
const StarSystem *sys, UniHunkType_t type,
2960 uniedit_diffCreateSysIntAttr( sys, type, data, NULL );
2962void uniedit_diffCreateSysIntAttr(
const StarSystem *sys, UniHunkType_t type,
2966 memset( &hunk, 0,
sizeof( hunk ) );
2970 hunk.
dtype = HUNK_DATA_INT;
2973 uniedit_diffAdd( &hunk );
2976void uniedit_diffCreateSysFloat(
const StarSystem *sys, UniHunkType_t type,
2979 uniedit_diffCreateSysFloatAttr( sys, type, fdata, NULL );
2981void uniedit_diffCreateSysFloatAttr(
const StarSystem *sys, UniHunkType_t type,
2985 memset( &hunk, 0,
sizeof( hunk ) );
2989 hunk.
dtype = HUNK_DATA_FLOAT;
2990 hunk.
u.fdata = fdata;
2992 uniedit_diffAdd( &hunk );
2997 uniedit_diffSaved = 0;
3001 for (
int i = 0; i <
array_size( uniedit_diff ); i++) {
3011 if (( hi->
attr != NULL ) && ( hunk->
attr != NULL )) {
3015 if (( strcmp( hi->
attr[j].name, hunk->
attr[k].name ) == 0 ) ||
3016 ( strcmp( hi->
attr[j].name, hunk->
attr[k].name ) == 0 )) {
3030 WARN( _(
"uniedit: failed to patch '%s'" ),
3033 memcpy( hi, hunk,
sizeof(
UniHunk_t ) );
3049static void uniedit_diffSsysPos( StarSystem *s,
double x,
double y )
3053 if (!uniedit_diffMode) {
3061 hunk.
type = HUNK_TYPE_SSYS_POS_X;
3062 hunk.
dtype = HUNK_DATA_FLOAT;
3064 uniedit_diffAdd( &hunk );
3067 hunk.
type = HUNK_TYPE_SSYS_POS_Y;
3069 uniedit_diffAdd( &hunk );
3072static void uniedit_diff_regenList(
unsigned int wid )
3080 p = toolkit_getListPos( wid,
"lstDiffs" );
3084 items = malloc(
sizeof(
char * ) *
array_size( uniedit_diff ) );
3085 for (
int i = 0; i <
array_size( uniedit_diff ); i++) {
3087 SDL_asprintf( &items[i],
"%s: %s", hi->
target.
u.
name,
3090 int y = -30 - 30 - 20;
3091 window_addList( wid, 20, y, w - 40, h + y -
BUTTON_HEIGHT - 40,
"lstDiffs",
3092 items,
array_size( uniedit_diff ), p, NULL, NULL );
3095static void uniedit_diffEditor(
unsigned int wid_unused,
const char *unused )
3103 window_create(
"wdwEditorDiffs", _(
"Diff Options" ), -1, -1, w, h );
3113 wid, 20, y, w - 40, 20,
"chkDiffMode",
3114 _(
"Diff Mode (creates a diff instead of direct modification)" ),
3115 uniedit_diff_toggle, uniedit_diffMode );
3119 window_addText( wid, 20, y, w - 40, 20, 0,
"txtSDiff", NULL, NULL,
3120 _(
"#nCurrent Diff Contents:" ) );
3122 uniedit_diff_regenList( wid );
3129 uniedit_diff_remove );
3132static void uniedit_diff_toggle(
unsigned int wid,
const char *wgt )
3134 if (uniedit_diffMode && !uniedit_diffSaved) {
3136 _(
"#rUnsaved Progress" ),
3137 _(
"You have #runsaved changes#0 to the universe diff. Are you "
3138 "sure you wish to disable diff mode and #rlose all your "
3140 window_checkboxSet( wid, wgt, 1 );
3144 uniedit_diffMode = window_checkboxState( wid, wgt );
3145 if (!uniedit_diffMode) {
3146 uniedit_diffClear();
3149 uniedit_diff_regenList( wid );
3153static void uniedit_diff_load_callback(
void *userdata,
3154 const char *
const *filelist,
3158 unsigned int wid = *(
unsigned int *)userdata;
3161 if (filelist == NULL) {
3162 WARN( _(
"Error calling %s: %s" ),
"SDL_ShowOpenFileDialog",
3165 }
else if (filelist[0] == NULL) {
3172 uniedit_diffClear();
3173 diff_parse( &data, strdup( filelist[0] ) );
3174 uniedit_diff = data.hunks;
3176 diff_freeData( &data );
3179 uniedit_diffMode = 1;
3180 window_checkboxSet( wid,
"chkDiffMode", 1 );
3184 for (
int i = 0; i <
array_size( uniedit_diff ); i++) {
3191 uniedit_diff_regenList( wid );
3194static void uniedit_diff_load(
unsigned int wid,
const char *wgt )
3198 { .name = _(
"Diff XML file" ), .pattern =
"xml" },
3202 SDL_ShowOpenFileDialog( uniedit_diff_load_callback, &wid,
gl_screen.window,
3203 filter, conf.dev_data_dir, 0 );
3206static void uniedit_diff_remove(
unsigned int wid,
const char *unused )
3209 int p = toolkit_getListPos( wid,
"lstDiffs" );
3218 array_erase( &uniedit_diff, &uniedit_diff[p], &uniedit_diff[p + 1] );
3221 uniedit_diff_regenList( wid );
3224static void uniedit_diff_close(
unsigned int wid,
const char *unused )
3227 uniedit_diffMode = window_checkboxState( wid,
"chkDiffMode" );
3229 uniedit_diffMode ? _(
"Save Diff" )
3230 : _(
"Save All" ) );
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_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’.
StarSystem * systems_stack
int dpl_saveAll(void)
Saves all the star spobs.
void sysedit_open(StarSystem *sys)
Opens the system editor interface.
void sysedit_sysScale(StarSystem *sys, double factor)
Scales a system.
int dsys_saveSystem(StarSystem *sys)
Saves a star system.
int dsys_saveAll(void)
Saves all the star systems.
static UniEditMode uniedit_mode
static void uniedit_btnOpen(unsigned int wid_unused, const char *unused)
Opens up a system.
static void uniedit_btnEditRename(unsigned int wid, const char *unused)
Renames the systems in the system editor.
static double uniedit_rotate
static int uniedit_checkName(const char *name)
Checks to see if a system name is already in use.
static void uniedit_renderOverlay(double bx, double by, double bw, double bh, void *data)
Renders the overlay.
static double uniedit_xpos
void uniedit_open(unsigned int wid_unused, const char *unused)
Opens the system editor interface.
static void uniedit_close(unsigned int wid, const char *wgt)
Closes the system editor widget.
#define UNIEDIT_CLICK_THRESHOLD
static double uniedit_dragSelX
static unsigned int uniedit_widFind
#define UNIEDIT_DOUBLECLICK_THRESHOLD
static map_find_t * found_cur
static void uniedit_btnEditAddSpobAdd(unsigned int wid, const char *unused)
Actually adds the virtual spob.
static void uniedit_btnNewTag(unsigned int wid, const char *unused)
Adds a tech to a system.
static void uniedit_deselect(void)
Deselects selected targets.
static void uniedit_btnAddTag(unsigned int wid, const char *unused)
Adds a tech to a spob.
static void uniedit_editSys(void)
Edits an individual system or group of systems.
#define UNIEDIT_FIND_WIDTH
static void uniedit_newSys(double x, double y)
Creates a new system.
static double uniedit_ypos
static void uniedit_btnNew(unsigned int wid_unused, const char *unused)
Enters the editor in new system mode.
static char ** uniedit_tagslist
#define UNIEDIT_ZOOM_STEP
static StarSystem ** uniedit_sys
#define UNIEDIT_EDIT_HEIGHT
static void uniedit_toggleJump(StarSystem *sys)
Toggles the jump point for the selected systems.
static void uniedit_editGenList(unsigned int wid)
Generates the virtual spob list.
static int uniedit_keys(unsigned int wid, SDL_Keycode key, SDL_Keymod mod, int isrepeat)
Handles keybindings.
static unsigned int uniedit_widEdit
static void uniedit_buttonZoom(unsigned int wid, const char *str)
Handles the button zoom clicks.
static void uniedit_renameSys(void)
Renames all the currently selected systems.
static void uniedit_findSys(void)
Finds systems and spobs.
static void uniedit_btnFind(unsigned int wid_unused, const char *unused)
Opens the system property editor.
static int uniedit_dragSys
#define UNIEDIT_FIND_HEIGHT
static void uniedit_findShowResults(unsigned int wid, map_find_t *found, int n)
Generates the virtual spob list.
static double uniedit_zoom
static unsigned int uniedit_lastClick
static double uniedit_dragSelY
static int uniedit_dragSel
static double uniedit_rotate_cx
static void uniedit_btnJump(unsigned int wid_unused, const char *unused)
Enters the editor in new jump mode.
static void uniedit_btnEdit(unsigned int wid_unused, const char *unused)
Opens the system property editor.
#define UNIEDIT_DRAG_THRESHOLD
static void uniedit_editSysClose(unsigned int wid, const char *name)
Closes the system property editor, saving the changes made.
static int uniedit_sortCompare(const void *p1, const void *p2)
qsort compare function for map finds.
static int uniedit_mouse(unsigned int wid, const SDL_Event *event, double mx, double my, double w, double h, double rx, double ry, void *data)
System editor custom widget mouse handling.
static void uniedit_btnEditAddSpob(unsigned int wid, const char *unused)
Adds a new virtual spob.
static double uniedit_rotate_cy
static void uniedit_btnViewModeSet(unsigned int wid, const char *unused)
Actually adds the virtual spob.
static void uniedit_btnView(unsigned int wid_unused, const char *unused)
Allows selecting the view.
static void uniedit_selectAdd(StarSystem *sys)
Adds a system to the selection.
static void uniedit_centerSystem(unsigned int wid, const char *unused)
Centers the selected system.
static void uniedit_findSysClose(unsigned int wid, const char *name)
Closes the search dialogue.
static UniEditViewMode uniedit_viewmode
static unsigned int uniedit_wid
static void uniedit_findSearch(unsigned int wid, const char *str)
Searches for spobs and systems.
#define UNIEDIT_EDIT_WIDTH
static int uniedit_view_faction
#define UNIEDIT_MOVE_THRESHOLD
void uniedit_selectText(void)
Sets the selected system text.
static void uniedit_btnRmTag(unsigned int wid, const char *unused)
Removes a tech from a spob.
static void uniedit_selectRm(StarSystem *sys)
Removes a system from the selection.
static void uniedit_focusLose(unsigned int wid, const char *wgtname)
Called when it's de-focused.
static void uniedit_btnEditRmSpob(unsigned int wid, const char *unused)
Removes a selected spob.
static void uniedit_btnEditTags(unsigned int wid, const char *unused)
Edits a spob's tags.
static void uniedit_render(double bx, double by, double w, double h, void *data)
System editor custom widget rendering.
static StarSystem * uniedit_tsys
static void uniedit_genTagsList(unsigned int wid)
Generates the spob tech list.
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.
int dialogue_YesNoRaw(const char *caption, const char *msg)
Runs a dialogue with both yes and no options.
void dialogue_alertRaw(const char *msg)
Displays an alert popup with only an ok button and a message.
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 FactionGenerator * faction_generators(int f)
Gets the faction's generators.
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.
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.
double naev_getrealdt(void)
Gets the last delta-tick.
Header file with generic functions and naev-specifics.
int nfile_dirMakeExist(const char *path)
Creates a directory if it doesn't exist.
int nfile_touch(const char *path)
Tries to create the file if it doesn't exist.
int nfile_dirExists(const char *path)
Checks to see if a directory exists.
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....
const char * num2strU(double n, int decimals)
Unsafe version of num2str that uses an internal buffer. Every call overwrites the return value.
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_renderCircle(double cx, double cy, double r, const glColour *c, int filled)
Draws a circle.
void pause_game(void)
Pauses the game.
void unpause_game(void)
Unpauses the game.
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
void pilot_clearTrails(Pilot *p)
Resets the trails for a pilot.
void safelanes_recalculate(void)
Update the safe lane locations in response to the universe changing (e.g., diff applied).
void space_reconstructPresences(void)
Reset the presence of all systems.
void systems_reconstructJumps(void)
Reconstructs the jumps.
int system_addJump(StarSystem *sys, StarSystem *target)
Adds a jump point between two star systems.
double system_getPresenceFull(const StarSystem *sys, int faction, double *base, double *bonus)
Get the presence of a faction in a system.
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
int system_addVirtualSpob(StarSystem *sys, const char *spobname)
Adds a virtual spob to a system.
StarSystem * system_getIndex(int id)
Get the system by its index.
StarSystem * system_new(void)
Creates a new star system.
StarSystem * system_getAll(void)
Gets an array (array.h) of all star systems.
char ** spob_searchFuzzyCase(const char *spobname, int *n)
Does a fuzzy case matching. Searches spob_name() but returns internal names.
char ** system_searchFuzzyCase(const char *sysname, int *n)
Does a fuzzy case matching. Searches translated names but returns internal names.
StarSystem * system_get(const char *sysname)
Get the system from its name.
double system_getPresence(const StarSystem *sys, int faction)
Get the presence of a faction in a system.
int system_rmVirtualSpob(StarSystem *sys, const char *spobname)
Removes a virtual spob from a system.
VirtualSpob * virtualspob_getAll(void)
Gets all the virtual spobs.
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
int system_rmJump(StarSystem *sys, StarSystem *target)
Removes a jump point from a star system.
Represents an asteroid field anchor.
AsteroidTypeGroup ** groups
The representation of an in-game pilot.
Represents the presence of a spob.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Represents presence in a system.
Universe diff filepath list.
union UniHunkTarget_t::@313272344000226026005312375073311105303321201365 u
Represents a single hunk in the diff.
union UniHunk_t::@304042144362124155373304222124203336037263233020 u
Basically modifies system parameters without creating any real objects.
Represents a found target.
char display[STRMAX_SHORT]
char ** tech_getItemNames(const tech_group_t *tech, int *n)
Gets the names of all techs within a given group.
void diff_end(void)
Cleans up after applying a set of diffs.
void diff_clear(void)
Removes all active diffs. (Call before economy_destroy().)
int diff_revertHunk(const UniHunk_t *hunk)
Reverts a hunk.
void diff_cleanupHunk(UniHunk_t *hunk)
Cleans up a hunk.
int diff_patchHunk(UniHunk_t *hunk)
Applies a hunk.
void diff_start(void)
Starts applying a set of diffs.
const char * diff_hunkName(UniHunkType_t t)
Gets the human readable name of a hunk.