15#include "dev_uniedit.h"
20#include "dev_sysedit.h"
21#include "dev_system.h"
32#include "tk/toolkit_priv.h"
36#define BUTTON_WIDTH 100
37#define BUTTON_HEIGHT 30
39#define UNIEDIT_EDIT_WIDTH 400
40#define UNIEDIT_EDIT_HEIGHT 450
42#define UNIEDIT_FIND_WIDTH 400
43#define UNIEDIT_FIND_HEIGHT 500
45#define UNIEDIT_DRAG_THRESHOLD 300
46#define UNIEDIT_MOVE_THRESHOLD 10
47#define UNIEDIT_CLICK_THRESHOLD 20.
48#define UNIEDIT_DOUBLECLICK_THRESHOLD 300
50#define UNIEDIT_ZOOM_STEP 1.2
51#define UNIEDIT_ZOOM_MAX 5.
52#define UNIEDIT_ZOOM_MIN -5.
57typedef enum UniEditMode_ {
63typedef enum UniEditViewMode_ {
65 UNIEDIT_VIEW_VIRTUALSPOBS,
67 UNIEDIT_VIEW_BACKGROUND,
68 UNIEDIT_VIEW_ASTEROIDS,
70 UNIEDIT_VIEW_PRESENCE_SUM,
71 UNIEDIT_VIEW_PRESENCE,
136static void uniedit_render(
double bx,
double by,
double w,
double h,
void *data );
139static int uniedit_mouse(
unsigned int wid, SDL_Event* event,
double mx,
double my,
140 double w,
double h,
double rx,
double ry,
void *data );
141static void uniedit_renderFactionDisks(
double x,
double y,
double r );
142static void uniedit_renderVirtualSpobs(
double x,
double y,
double r );
144static void uniedit_close(
unsigned int wid,
const char *wgt );
145static void uniedit_save(
unsigned int wid_unused,
const char *unused );
146static void uniedit_btnView(
unsigned int wid_unused,
const char *unused );
147static void uniedit_btnJump(
unsigned int wid_unused,
const char *unused );
149static void uniedit_btnEdit(
unsigned int wid_unused,
const char *unused );
150static void uniedit_btnNew(
unsigned int wid_unused,
const char *unused );
151static void uniedit_btnOpen(
unsigned int wid_unused,
const char *unused );
152static void uniedit_btnFind(
unsigned int wid_unused,
const char *unused );
154static int uniedit_keys(
unsigned int wid, SDL_Keycode key, SDL_Keymod mod );
165 const glColour cBG = { 0., 0., 0., 0.95 };
188 wid =
window_create(
"wdwUniverseEditor", _(
"Universe Editor"), -1, -1, -1, -1 );
194 window_addCust( wid, 0, 0, SCREEN_W, SCREEN_H,
199 window_addRect( wid, SCREEN_W-130, 0, 130, SCREEN_H,
"rctRCol", &cBG, 0 );
200 window_addRect( wid, 0, 0, SCREEN_W, 60,
"rctBBar", &cBG, 0 );
208 window_addCheckbox( wid, -150, 25, SCREEN_W/2 - 150, 20,
209 "chkEditAutoSave", _(
"Automatically save changes"), uniedit_autosave, conf.
devautosave );
213 "btnSave", _(
"Save All"), uniedit_save );
256 window_addText( wid, -20, -40, 100, 20, 0,
"txtSNebula",
258 window_addText( wid, -10, -40-
gl_smallFont.
h-5, 110, 60, 0,
"txtNebula",
262 window_addText( wid, -20, -100, 100, 20, 0,
"txtSPresence",
264 window_addText( wid, -10, -100-
gl_smallFont.
h-5, 110, 140, 0,
"txtPresence",
268 window_addText( wid, 140, 10, SCREEN_W/2 - 140, 30, 0,
278static int uniedit_keys(
unsigned int wid, SDL_Keycode key, SDL_Keymod mod )
315static void uniedit_save(
unsigned int wid_unused,
const char *unused )
327void uniedit_autosave(
unsigned int wid_unused,
const char *unused )
332 conf.
devautosave = window_checkboxState( wid_unused,
"chkEditAutoSave" );
338void uniedit_updateAutosave (
void)
343static int factionGenerates(
int f,
int tocheck,
double *w )
347 if (fg[i].
id==tocheck) {
377 if ((p->presence.faction != f) && !factionGenerates(p->presence.faction,f,NULL))
379 if (p->presence.base==0. && p->presence.bonus==0.)
393 str = malloc(
sizeof(
char*) * (
array_size(factions)+1) );
394 str[0]= strdup(_(
"Default"));
395 str[1]= strdup(_(
"Virtual Spobs"));
396 str[2]= strdup(_(
"System Radius"));
397 str[3]= strdup(_(
"Background"));
398 str[4]= strdup(_(
"Asteroids"));
399 str[5]= strdup(_(
"Tech"));
400 str[6]= strdup(_(
"Sum of Presences"));
408 qsort( &str[n], k-n,
sizeof(
char*),
strsort );
410 window_addList( wid, 20, -40,
UNIEDIT_EDIT_WIDTH-40, h,
"lstViewModes", str, k, 0, NULL,
uniedit_btnViewModeSet );
493static void uniedit_renderFactionDisks(
double x,
double y,
double r )
497 double tx, ty, sr, presence;
524static void uniedit_renderVirtualSpobs(
double x,
double y,
double r )
526 const glColour
c = { .r=1., .g=1., .b=1., .a=0.3 };
543static void uniedit_renderRadius(
double x,
double y,
double r )
545 const glColour
c = { .r=1., .g=1., .b=1., .a=0.3 };
562static void uniedit_renderBackground(
double x,
double y,
double r )
564 const glColour
c = { .r=1., .g=1., .b=1., .a=0.3 };
570 if (sys->background==NULL)
584static void uniedit_renderAsteroids(
double x,
double y,
double r )
586 const glColour
c = { .r=1., .g=1., .b=1., .a=0.3 };
591 double density = sys->asteroid_density;
606static void uniedit_renderTech(
double x,
double y,
double r )
608 const glColour
c = { .r=1., .g=1., .b=1., .a=0.3 };
615 for (
int j=0; j<
array_size(sys->spobs); j++) {
616 if (sys->spobs[j]->tech != NULL) {
634static void uniedit_renderPresenceSum(
double x,
double y,
double r )
636 const glColour
c = { .r=1., .g=1., .b=1., .a=0.3 };
643 for (
int j=0; j<
array_size(sys->presence); j++)
644 total +=
MAX( 0., sys->presence[j].value );
659void uniedit_renderMap(
double bx,
double by,
double w,
double h,
double x,
double y,
double zoom,
double r )
664 if (UNIEDIT_VIEW_DEFAULT)
665 map_renderDecorators( x, y, zoom, 1, 1. );
669 case UNIEDIT_VIEW_DEFAULT:
670 map_renderFactionDisks( x, y, zoom, r, 1, 1. );
671 map_renderSystemEnvironment( x, y, zoom, 1, 1. );
674 case UNIEDIT_VIEW_VIRTUALSPOBS:
675 uniedit_renderVirtualSpobs( x, y, r );
678 case UNIEDIT_VIEW_RADIUS:
679 uniedit_renderRadius( x, y, r );
682 case UNIEDIT_VIEW_BACKGROUND:
683 uniedit_renderBackground( x, y, r );
686 case UNIEDIT_VIEW_ASTEROIDS:
687 uniedit_renderAsteroids( x, y, r );
690 case UNIEDIT_VIEW_TECH:
691 uniedit_renderTech( x, y, r );
694 case UNIEDIT_VIEW_PRESENCE_SUM:
695 uniedit_renderPresenceSum( x, y, r );
698 case UNIEDIT_VIEW_PRESENCE:
700 uniedit_renderFactionDisks( x, y, r );
705 map_renderJumps( x, y, zoom, r, 1 );
708 map_renderSystems( bx, by, x, y, zoom, w, h, r, MAPMODE_EDITOR );
711 map_renderNames( bx, by, x, y, zoom, w, h, 1, 1. );
717static void uniedit_render(
double bx,
double by,
double w,
double h,
void *data )
728 uniedit_renderMap( bx, by, w, h, x, y,
uniedit_zoom, r );
733 glUseProgram( shaders.selectspob.program );
734 glUniform1f( shaders.selectspob.dt,
uniedit_dt );
736 1.5*r, 1.5*r, 0., &shaders.selectspob, &cWhite, 1 );
740static char getValCol(
double val )
748static int getPresenceVal(
int f,
SpobPresence *ap,
double *base,
double *bonus )
752 if ((ap->
faction!=f) && !(gf=factionGenerates(ap->
faction, f, &w)))
759 *base = ap->
base * w;
760 *bonus = ap->
bonus * w;
770 double x,y, mx,my, sx,sy;
771 double value, base, bonus;
772 char buf[STRMAX] = {
'\0'};
773 StarSystem *sys, *cur, *mousesys;
791 double l, r,
b, t, rx, ry;
792 const glColour col = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 0.5 };
807 if ((x > SCREEN_W-130) || (y < 60))
832 if (mousesys == NULL)
847 for (
int j=0; j<
array_size(sys->spobs_virtual); j++) {
849 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"%s%s", (l>0)?
"\n":
"", va->
name );
858 scnprintf( &buf[0],
sizeof(buf), _(
"System Radius: %s"),
num2strU( sys->radius, 0 ));
865 if (sys->background != NULL) {
866 scnprintf( &buf[0],
sizeof(buf), _(
"Background: %s"), sys->background );
876 l =
scnprintf( &buf[l],
sizeof(buf)-l, _(
"Density: %g"), sys->asteroid_density );
877 for (
int i=0; i<
array_size(sys->asteroids); i++) {
891 const int len =
sizeof(techlist) /
sizeof(
char*);
899 for (
int j=0; j<
array_size(sys->spobs); j++) {
900 Spob *spob = sys->spobs[j];
903 if (spob->
tech==NULL)
906 for (
int k=0; (k<n) && (ntechs<len-1) ; k++)
907 techlist[ ntechs++ ] = techs[k];
910 qsort( techlist, ntechs,
sizeof(
char*),
strsort );
911 for (
int k=0; k<ntechs; k++) {
912 if ((k>0) && (strcmp(techlist[k-1],techlist[k])==0))
914 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"%s%s", (l>0)?
"\n":
"", techlist[k] );
916 for (
int k=0; k<ntechs; k++)
931 for (
int j=0; j<
array_size(sys->presence); j++)
932 value +=
MAX( sys->presence[j].value, 0. );
935 l =
scnprintf( buf,
sizeof(buf), _(
"Total: %.0f"), value );
936 for (
int j=0; j<
array_size(sys->presence); j++) {
937 sp = &sys->presence[j];
955 l =
scnprintf( buf,
sizeof(buf),
"#%c%.0f#0 = #%c%.0f#0 + #%c%.0f#0 [%s - %s]",
956 getValCol(value), value, getValCol(base), base, getValCol(bonus), bonus,
960 for (
int j=0; j<
array_size(sys->spobs); j++) {
961 Spob *spob = sys->spobs[j];
962 if (!getPresenceVal( f, &spob->
presence, &base, &bonus ))
964 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n#%c%.0f#0 (#%c%+.0f#0) [%s]",
965 getValCol(base), base, getValCol(bonus), bonus,
spob_name(spob) );
967 for (
int j=0; j<
array_size(sys->spobs_virtual); j++) {
970 if (!getPresenceVal( f, &va->
presences[p], &base, &bonus ))
972 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n#%c%.0f#0 (#%c%+.0f#0) [%s]",
973 getValCol(base), base, getValCol(bonus), bonus, _(va->
name) );
978 for (
int k=0; k<
array_size(sys->jumps); k++) {
979 cur = sys->jumps[k].target;
980 for (
int j=0; j<
array_size(cur->spobs); j++) {
981 Spob *spob = cur->spobs[j];
982 if (!getPresenceVal( f, &spob->
presence, &base, &bonus ))
984 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n#%c%.0f#0 (#%c%+.0f#0) [%s (%s)]",
985 getValCol(base), base*0.5, getValCol(bonus), bonus*0.5,
spob_name(spob), _(cur->name) );
987 for (
int j=0; j<
array_size(cur->spobs_virtual); j++) {
990 if (!getPresenceVal( f, &va->
presences[p], &base, &bonus ))
992 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n#%c%.0f#0 (#%c%+.0f#0) [%s (%s)]",
993 getValCol(base), base*0.5, getValCol(bonus), bonus*0.5, _(va->
name), _(cur->name) );
1016static int uniedit_mouse(
unsigned int wid, SDL_Event* event,
double mx,
double my,
1017 double w,
double h,
double rx,
double ry,
void *data )
1020 unsigned int lastClick;
1021 StarSystem *clickedsys;
1026 mod = SDL_GetModState();
1028 switch (event->type) {
1030 case SDL_MOUSEWHEEL:
1032 if ((mx < 0.) || (mx > w) || (my < 0.) || (my > h))
1035 if (event->wheel.y > 0)
1037 else if (event->wheel.y < 0)
1042 case SDL_MOUSEBUTTONDOWN:
1044 if ((mx < 60.) || (mx > w) || (my < 0.) || (my > h-130))
1082 if (clickedsys != NULL) {
1104 if ((clickedsys != NULL) && inselection) {
1108 if (mod & (KMOD_LCTRL | KMOD_RCTRL))
1117 if (clickedsys != NULL) {
1119 if (!(mod & (KMOD_LCTRL | KMOD_RCTRL)))
1129 if (mod & (KMOD_LCTRL | KMOD_RCTRL | KMOD_LSHIFT | KMOD_RSHIFT)) {
1130 if (mod & (KMOD_LSHIFT | KMOD_RSHIFT))
1143 case SDL_MOUSEBUTTONUP:
1185 double x = sys->pos.x;
1186 double y = sys->pos.y;
1187 if ((x >= l) && (x <= r) && (y >= b) && (y <= t))
1195 case SDL_MOUSEMOTION:
1236 dialogue_alert( _(
"The Star System '%s' already exists!"), name );
1243char *uniedit_nameFilter(
const char *name )
1245 char *out = calloc( 1, (strlen(name)+1) );
1247 for (
int i=0; i<(int)strlen(name); i++) {
1248 if (!ispunct(name[i])) {
1252 out[pos] = tolower(name[i]);
1266 char *name, *oldName, *newName, *filtered;
1270 name =
dialogue_input( _(
"Rename Star System"), 1, 32, _(
"What do you want to rename #r%s#0?"), sys->name );
1284 filtered = uniedit_nameFilter(sys->name);
1285 asprintf(&oldName,
"dat/ssys/%s.xml", filtered);
1288 filtered = uniedit_nameFilter(name);
1289 asprintf(&newName,
"dat/ssys/%s.xml", filtered);
1292 rename(oldName, newName);
1316 name =
dialogue_inputRaw( _(
"New Star System Creation"), 1, 32, _(
"What do you want to name the new system?") );
1336 sys->stars = STARS_DENSITY_DEFAULT;
1337 sys->radius = RADIUS_DEFAULT;
1352 StarSystem *isys = NULL;
1356 for (
int j=0; j<
array_size(isys->jumps); j++) {
1357 StarSystem *target = isys->jumps[j].target;
1359 if (target == sys) {
1397 memset( jp, 0,
sizeof(JumpPoint) );
1401 jp->targetid = targ->id;
1403 jp->flags = JP_AUTOPOS;
1404 jp->hide = HIDE_DEFAULT_JUMP;
1416 if (sys->jumps[i].target == targ)
1421 WARN(_(
"Jump for system '%s' not found in system '%s' for removal."), targ->name, sys->name);
1426 array_erase( &sys->jumps, &sys->jumps[i], &sys->jumps[i+1] );
1442 window_modifyText(
uniedit_wid,
"txtSelected", _(
"No selection") );
1443 window_modifyText(
uniedit_wid,
"txtNebula", _(
"N/A") );
1444 window_modifyText(
uniedit_wid,
"txtPresence", _(
"N/A") );
1486 WARN(_(
"Trying to remove system '%s' from selection when not selected."), sys->name);
1505 window_modifyText(
uniedit_wid,
"txtSelected", buf );
1510 map_updateFactionPresence(
uniedit_wid,
"txtPresence", sys, 1 );
1512 if (sys->nebu_density<=0.)
1513 snprintf( buf,
sizeof(buf), _(
"None") );
1515 snprintf( buf,
sizeof(buf), _(
"%.0f Density\n%.1f Volatility"), sys->nebu_density, sys->nebu_volatility);
1516 window_modifyText(
uniedit_wid,
"txtNebula", buf );
1519 window_modifyText(
uniedit_wid,
"txtNebula", _(
"Multiple selected") );
1520 window_modifyText(
uniedit_wid,
"txtPresence", _(
"Multiple selected") );
1539 if (strcmp(str,
"btnZoomIn")==0) {
1543 else if (strcmp(str,
"btnZoomOut")==0) {
1576 "inpFind", 32, 1, NULL );
1595 int n, nspobs, nsystems;
1597 char **spobs, **systems;
1600 name = window_getInput( wid,
"inpFind" );
1610 found = malloc(
sizeof(
map_find_t) * (nspobs + nsystems) );
1614 for (
int i=0; i<nspobs; i++) {
1621 if (sysname == NULL)
1629 found[n].
spob = spob;
1633 snprintf( found[n].display,
sizeof(found[n].display),
1634 _(
"%s (%s system)"), spobs[i], sys->name );
1640 for (
int i=0; i<nsystems; i++) {
1644 found[n].
spob = NULL;
1647 strncpy(found[n].display, sys->name,
sizeof(found[n].
display)-1);
1675 str = malloc(
sizeof(
char*) );
1676 str[0] = strdup(_(
"None"));
1682 str = malloc(
sizeof(
char*) * n );
1683 for (
int i=0; i<n; i++)
1684 str[i] = strdup( found[i].display );
1719 pos = toolkit_getListPos( wid,
"lstResults" );
1742 return strcasecmp( f1->
sys->name, f2->
sys->name );
1752 char buf[STRMAX_SHORT];
1775 window_addText( wid, x, y, 180, 15, 0,
"txtName", &
gl_smallFont, NULL, buf );
1784 window_addText( wid, x, y, l, 20, 1,
"txtRadius",
1786 window_addInput( wid, x += l + 7, y, 80, 20,
"inpRadius", 10, 1, NULL );
1787 window_setInputFilter( wid,
"inpRadius", INPUT_FILTER_NUMBER );
1789 s = _(
"(Scales spob positions)");
1791 window_addText( wid, x, y, l, 20, 1,
"txtRadiusComment",
1800 window_addText( wid, x, y, l, 20, 1,
"txtStars",
1802 window_addInput( wid, x += l + 7, y, 50, 20,
"inpStars", 4, 1, NULL );
1803 window_setInputFilter( wid,
"inpStars", INPUT_FILTER_NUMBER );
1806 s = _(
"Interference");
1808 window_addText( wid, x, y, l, 20, 1,
"txtInterference",
1810 window_addInput( wid, x += l + 7, y, 55, 20,
"inpInterference", 5, 1, NULL );
1811 window_setInputFilter( wid,
"inpInterference", INPUT_FILTER_NUMBER );
1819 window_addText( wid, x, y, l, 20, 1,
"txtNebula",
1821 window_addInput( wid, x += l + 7, y, 50, 20,
"inpNebula", 4, 1, NULL );
1822 window_setInputFilter( wid,
"inpNebula", INPUT_FILTER_NUMBER );
1825 s = _(
"Volatility");
1827 window_addText( wid, x, y, l, 20, 1,
"txtVolatility",
1829 window_addInput( wid, x += l + 7, y, 50, 20,
"inpVolatility", 4, 1, NULL );
1830 window_setInputFilter( wid,
"inpVolatility", INPUT_FILTER_NUMBER );
1835 window_addText( wid, x, y, l, 20, 1,
"txtHue",
1837 window_addInput( wid, x += l + 7, y, 50, 20,
"inpHue", 4, 1, NULL );
1838 window_setInputFilter( wid,
"inpHue", INPUT_FILTER_NUMBER );
1842 snprintf( buf,
sizeof(buf),
"%g", sys->radius );
1843 window_setInput( wid,
"inpRadius", buf );
1844 snprintf( buf,
sizeof(buf),
"%d", sys->stars );
1845 window_setInput( wid,
"inpStars", buf );
1846 snprintf( buf,
sizeof(buf),
"%g", sys->interference );
1847 window_setInput( wid,
"inpInterference", buf );
1848 snprintf( buf,
sizeof(buf),
"%g", sys->nebu_density );
1849 window_setInput( wid,
"inpNebula", buf );
1850 snprintf( buf,
sizeof(buf),
"%g", sys->nebu_volatility );
1851 window_setInput( wid,
"inpVolatility", buf );
1852 snprintf( buf,
sizeof(buf),
"%g", sys->nebu_hue*360. );
1853 window_setInput( wid,
"inpHue", buf );
1868 int y, h, has_spobs;
1883 str = malloc(
sizeof(
char*) * (n+1) );
1886 for (
int i=0; i<n; i++) {
1887 va = sys->spobs_virtual[i];
1888 str[j++] = strdup( va->
name );
1892 str[j++] = strdup(_(
"None"));
1897 "lstSpobs", str, j, 0, NULL, NULL );
1921 scale = atof(window_getInput( wid,
"inpRadius" )) / sys->radius;
1924 sys->stars = atoi(window_getInput( wid,
"inpStars" ));
1925 sys->interference = atof(window_getInput( wid,
"inpInterference" ));
1926 sys->nebu_density = atof(window_getInput( wid,
"inpNebula" ));
1927 sys->nebu_volatility = atof(window_getInput( wid,
"inpVolatility" ));
1928 sys->nebu_hue = atof(window_getInput( wid,
"inpHue" )) / 360.;
1950 const char *selected;
1954 selected = toolkit_getList( wid,
"lstSpobs" );
1957 if ((selected==NULL) || (strcmp(selected,_(
"None"))==0))
1963 dialogue_alert( _(
"Failed to remove virtual spob '%s'!"), selected );
1988 dialogue_alert( _(
"No virtual spobs to add! Please add virtual spobs to the '%s' directory first."), VIRTUALSPOB_DATA_PATH );
1997 str = malloc(
sizeof(
char*) *
array_size(va) );
1999 str[i] = strdup( va[i].name );
2002 "lstSpobs", str,
array_size(va), 0, NULL, NULL );
2018 const char *selected;
2022 selected = toolkit_getList( wid,
"lstSpobs" );
2023 if (selected == NULL)
2029 dialogue_alert( _(
"Failed to add virtual spob '%s'!"), selected );
2052 char buf[STRMAX_SHORT];
2059 window_modifyText( wid,
"txtName", buf );
2067 const char *selected;
2071 pos = toolkit_getListPos( wid,
"lstViewModes" );
2110 selected = toolkit_getList( wid,
"lstViewModes" );
2111 if (selected == NULL)
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’.
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 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_deselect(void)
Deselects selected targets.
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 int uniedit_mouse(unsigned int wid, SDL_Event *event, double mx, double my, double w, double h, double rx, double ry, void *data)
System editor custom widget mouse handling.
#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)
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_jumpAdd(StarSystem *sys, StarSystem *targ)
Adds a new Star System jump.
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 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.
StarSystem * systems_stack
#define UNIEDIT_DRAG_THRESHOLD
static void uniedit_jumpRm(StarSystem *sys, StarSystem *targ)
Removes a Star System jump.
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 void uniedit_btnEditAddSpob(unsigned int wid, const char *unused)
Adds a new virtual spob.
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_btnRename(unsigned int wid_unused, const char *unused)
Renames selected systems.
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_render(double bx, double by, double w, double h, void *data)
System editor custom widget rendering.
static StarSystem * uniedit_tsys
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 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 asprintf(char **strp, const char *fmt,...)
Like sprintf(), but it allocates a large-enough string and returns the pointer in the first argument....
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.
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.
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.
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.
char * spob_getSystem(const char *spobname)
Get the name of a system from a spobname.
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_name(const Spob *p)
Gets the translated name of a spob.
Represents an asteroid field anchor.
AsteroidTypeGroup ** groups
Represents the presence of a spob.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Represents presence in a system.
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_clear(void)
Removes all active diffs. (Call before economy_destroy().)