- Implemented "fill colour" command
- Added icon (for minimised windows) - Added windows executable - Changed behaviour of "foreground colour" command - RMB now selects colour - Added "fillcol" attribute to mapobject_t - Changed file save routine to include 8 byte version string - Chagned file load routine to cope with old format maps
This commit is contained in:
parent
c1e00f9fdd
commit
84bda8c74d
|
@ -1,5 +1,5 @@
|
||||||
netmapr: netmapr.c constants.h netmapr.h Makefile
|
netmapr: netmapr.c constants.h netmapr.h Makefile
|
||||||
gcc -Wall -g netmapr.c -I/usr/local/include -onetmapr -lmingw32 -L/usr/local/lib -lSDLmain -lSDL -mwindows
|
gcc -mwindows -mno-cygwin -Wall -onetmapr.exe -g netmapr.c windows_files/attachicon.res -I/usr/local/include -lmingw32 -L/usr/local/lib -lSDLmain -lSDL -lSDL_ttf
|
||||||
|
|
||||||
convert: convert.c convert.h Makefile
|
convert: convert.c convert.h Makefile
|
||||||
gcc -Wall -g convert.c -I/usr/local/include -oconvert -lmingw32 -L/usr/local/lib -lSDLmain -lSDL
|
gcc -Wall -g convert.c -I/usr/local/include -oconvert -lmingw32 -L/usr/local/lib -lSDLmain -lSDL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define VERSION "0.99a"
|
#define VERSION "0.99b"
|
||||||
|
|
||||||
#define BUFLEN 512
|
#define BUFLEN 512
|
||||||
|
|
||||||
|
@ -47,6 +47,10 @@
|
||||||
#define LINESELHANDLESIZE (5)
|
#define LINESELHANDLESIZE (5)
|
||||||
#define OBJSELHANDLEPCT (15)
|
#define OBJSELHANDLEPCT (15)
|
||||||
|
|
||||||
|
/* used as a NULL value for colours */
|
||||||
|
#define NOCOLOUR (99)
|
||||||
|
#define USECOLOUR (100)
|
||||||
|
|
||||||
#define GRIDBRIGHTNESS 100
|
#define GRIDBRIGHTNESS 100
|
||||||
|
|
||||||
#define T_EMPTY (0)
|
#define T_EMPTY (0)
|
||||||
|
@ -91,6 +95,7 @@
|
||||||
#define S_MATCHY (19)
|
#define S_MATCHY (19)
|
||||||
#define S_CREATETELE (20)
|
#define S_CREATETELE (20)
|
||||||
#define S_REALLYQUIT (21)
|
#define S_REALLYQUIT (21)
|
||||||
|
#define S_FILLCOL (22)
|
||||||
|
|
||||||
|
|
||||||
#define TB_POINTER (0)
|
#define TB_POINTER (0)
|
||||||
|
|
9
dist.sh
9
dist.sh
|
@ -3,12 +3,15 @@ VERSION=`cat constants.h | grep VERSION | awk '{ v=$3; gsub("\"","",v); print v
|
||||||
|
|
||||||
FULLNAME=netmapr-${VERSION}
|
FULLNAME=netmapr-${VERSION}
|
||||||
TARFILE=${FULLNAME}.tar.gz
|
TARFILE=${FULLNAME}.tar.gz
|
||||||
|
WINFILE=${FULLNAME}-win32.zip
|
||||||
|
|
||||||
mkdir ${FULLNAME}
|
mkdir ${FULLNAME}
|
||||||
cp Makefile.linux Makefile.freebsd Makefile.windows objects.dat buttons.dat netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map ${FULLNAME}/
|
cp Makefile.linux Makefile.freebsd Makefile.windows objects.dat buttons.dat netmapr.c netmapr.h constants.h convert.c convert.h icon.bmp verdana.ttf example.map ${FULLNAME}/
|
||||||
|
|
||||||
tar zcvf ${TARFILE} ${FULLNAME}
|
tar zcvf ${TARFILE} ${FULLNAME}
|
||||||
|
|
||||||
rm -rf ${FULLNAME}
|
rm -rf ${FULLNAME}
|
||||||
|
|
||||||
|
|
||||||
|
mkdir ${FULLNAME}
|
||||||
|
cp objects.dat buttons.dat netmapr.exe netmapr.c netmapr.h constants.h convert.c convert.h verdana.ttf example.map icon.bmp windows_files/*.dll ${FULLNAME}/
|
||||||
|
zip -r ${WINFILE} ${FULLNAME}
|
||||||
|
rm -rf ${FULLNAME}
|
||||||
|
|
298
netmapr.c
298
netmapr.c
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
SDL_Surface *screen, *buffer;
|
SDL_Surface *screen, *buffer;
|
||||||
SDL_Surface *emptyimg;
|
SDL_Surface *emptyimg;
|
||||||
|
SDL_Surface *icon;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
TTF_Font *font[MAXLETTERHEIGHT];
|
TTF_Font *font[MAXLETTERHEIGHT];
|
||||||
|
@ -425,6 +426,22 @@ int main (int argc, char **argv) {
|
||||||
updatetextcursor();
|
updatetextcursor();
|
||||||
|
|
||||||
changestate(S_TYPETEXT);
|
changestate(S_TYPETEXT);
|
||||||
|
} else if (state == S_FILLCOL) {
|
||||||
|
getcolor(screen, event.button.x, event.button.y, &objfillcol);
|
||||||
|
objfillcol.unused = USECOLOUR; /* clear NOCOLOUR flag */
|
||||||
|
if (map[curmap].selecteditem != -1) {
|
||||||
|
if (map[curmap].selecteditemtype == T_OBJECT) {
|
||||||
|
map[curmap].obj[map[curmap].selecteditem].fillcol = objfillcol;
|
||||||
|
map[curmap].obj[map[curmap].selecteditem].fillcol.unused = USECOLOUR;
|
||||||
|
sprintf(statustext, "Fill colour of object #%d changed to R=%d,G=%d,B=%d",map[curmap].selecteditem, objfillcol.r,objfillcol.g,objfillcol.b);
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "Fill colour selected: R=%d,G=%d,B=%d",objfillcol.r,objfillcol.g,objfillcol.b);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "Fill colour selected: R=%d,G=%d,B=%d",objfillcol.r,objfillcol.g,objfillcol.b);
|
||||||
|
}
|
||||||
|
changestate(S_NONE);
|
||||||
|
drawmap();
|
||||||
} else if (state == S_FGCOL) {
|
} else if (state == S_FGCOL) {
|
||||||
getcolor(screen, event.button.x, event.button.y, &fgcol);
|
getcolor(screen, event.button.x, event.button.y, &fgcol);
|
||||||
if (map[curmap].selecteditem != -1) {
|
if (map[curmap].selecteditem != -1) {
|
||||||
|
@ -520,6 +537,32 @@ int main (int argc, char **argv) {
|
||||||
|
|
||||||
tempx = (event.button.x - toolbox.x) / (toolbox.gridsize+3);
|
tempx = (event.button.x - toolbox.x) / (toolbox.gridsize+3);
|
||||||
tempy = (event.button.y - toolbox.y) / (toolbox.gridsize+3);
|
tempy = (event.button.y - toolbox.y) / (toolbox.gridsize+3);
|
||||||
|
|
||||||
|
/* are we in a colour selection state? */
|
||||||
|
if (state == S_FGCOL) {
|
||||||
|
changestate(S_NONE);
|
||||||
|
drawmap();
|
||||||
|
break;
|
||||||
|
} else if (state == S_FILLCOL) {
|
||||||
|
/* set bgcol to 'nothing' */
|
||||||
|
objfillcol = black;
|
||||||
|
objfillcol.unused = NOCOLOUR;
|
||||||
|
if (map[curmap].selecteditem != -1) {
|
||||||
|
if (map[curmap].selecteditemtype == T_OBJECT) {
|
||||||
|
map[curmap].obj[map[curmap].selecteditem].fillcol = black;
|
||||||
|
map[curmap].obj[map[curmap].selecteditem].fillcol.unused = NOCOLOUR;
|
||||||
|
sprintf(statustext, "Fill colour of object #%d removed.", map[curmap].selecteditem);
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "Fill colour removed.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "Fill colour removed.");
|
||||||
|
}
|
||||||
|
changestate(S_NONE);
|
||||||
|
drawmap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
selection = tempy*toolbox.gridrowlen + tempx;
|
selection = tempy*toolbox.gridrowlen + tempx;
|
||||||
switch (selection) {
|
switch (selection) {
|
||||||
case TB_POINTER:
|
case TB_POINTER:
|
||||||
|
@ -566,12 +609,39 @@ int main (int argc, char **argv) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TB_FGCOL:
|
case TB_FGCOL:
|
||||||
changestate(S_FGCOL);
|
/* change selected item to match fgcol */
|
||||||
|
if (map[curmap].selecteditem != -1) {
|
||||||
|
if (map[curmap].selecteditemtype == T_LINK) {
|
||||||
|
map[curmap].olink[map[curmap].selecteditem].col = fgcol;
|
||||||
|
sprintf(statustext, "Colour of link #%d changed to R=%d,G=%d,B=%d",map[curmap].selecteditem, fgcol.r,fgcol.g,fgcol.b);
|
||||||
|
} else if (map[curmap].selecteditemtype == T_TEXT) {
|
||||||
|
map[curmap].textob[map[curmap].selecteditem].c = fgcol;
|
||||||
|
sprintf(statustext, "Colour of text item #%d changed to R=%d,G=%d,B=%d",map[curmap].selecteditem, fgcol.r,fgcol.g,fgcol.b);
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "No object selected! (use RMB to select new foreground colour)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "No object selected! (use RMB to select new foreground colour)");
|
||||||
|
}
|
||||||
drawmap();
|
drawmap();
|
||||||
break;
|
break;
|
||||||
case TB_FILLCOL:
|
case TB_FILLCOL:
|
||||||
sprintf(statustext, "Select Fill Colour feature not yet implemented.");
|
if (map[curmap].selecteditem != -1) {
|
||||||
drawstatusbar();
|
if (map[curmap].selecteditemtype == T_OBJECT) {
|
||||||
|
map[curmap].obj[map[curmap].selecteditem].fillcol = objfillcol;
|
||||||
|
map[curmap].obj[map[curmap].selecteditem].fillcol.unused = objfillcol.unused;
|
||||||
|
if (objfillcol.unused == USECOLOUR) {
|
||||||
|
sprintf(statustext, "Fill colour of object #%d changed to R=%d,G=%d,B=%d",map[curmap].selecteditem, objfillcol.r,objfillcol.g,objfillcol.b);
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "Fill colour of object #%d removed.",map[curmap].selecteditem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "No object selected! (use RMB to select new fill colour)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sprintf(statustext, "No object selected! (use RMB to select new fill colour)");
|
||||||
|
}
|
||||||
|
drawmap();
|
||||||
break;
|
break;
|
||||||
case TB_LINESTYLE:
|
case TB_LINESTYLE:
|
||||||
sprintf(statustext, "Select Line Style feature not yet implemented.");
|
sprintf(statustext, "Select Line Style feature not yet implemented.");
|
||||||
|
@ -659,6 +729,24 @@ int main (int argc, char **argv) {
|
||||||
endtextresize(event.button.x, event.button.y);
|
endtextresize(event.button.x, event.button.y);
|
||||||
changestate(S_NONE);
|
changestate(S_NONE);
|
||||||
}
|
}
|
||||||
|
/* check for right click on toolbox */
|
||||||
|
if (isontoolbox(event.button.x, event.button.y)) {
|
||||||
|
int tempx,tempy, selection;
|
||||||
|
|
||||||
|
tempx = (event.button.x - toolbox.x) / (toolbox.gridsize+3);
|
||||||
|
tempy = (event.button.y - toolbox.y) / (toolbox.gridsize+3);
|
||||||
|
selection = tempy*toolbox.gridrowlen + tempx;
|
||||||
|
switch (selection) {
|
||||||
|
case TB_FGCOL:
|
||||||
|
changestate(S_FGCOL);
|
||||||
|
drawmap();
|
||||||
|
break;
|
||||||
|
case TB_FILLCOL:
|
||||||
|
changestate(S_FILLCOL);
|
||||||
|
drawmap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
@ -1362,7 +1450,7 @@ int drawletter(SDL_Surface *dest,int x, int y, int w, int h, char let, SDL_Color
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawvector(dest, &letter[let-FIRSTLET].vect, x, y, w,h, &col);
|
drawvector(dest, &letter[let-FIRSTLET].vect, x, y, w,h, &col, NULL);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1505,7 +1593,11 @@ void drawobject(SDL_Surface *dest, mapobject_t *o) {
|
||||||
printf("About to drawvector ...");
|
printf("About to drawvector ...");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
drawvector(temps, &objtype[o->type].vimg, 0, 0, o->w, o->h, NULL);
|
if (o->fillcol.unused == USECOLOUR) {
|
||||||
|
drawvector(temps, &objtype[o->type].vimg, 0, 0, o->w, o->h, NULL, &o->fillcol);
|
||||||
|
} else {
|
||||||
|
drawvector(temps, &objtype[o->type].vimg, 0, 0, o->w, o->h, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* set transparent colour on temp surface */
|
/* set transparent colour on temp surface */
|
||||||
if (testing) {
|
if (testing) {
|
||||||
|
@ -1604,7 +1696,7 @@ void drawmap(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == S_FGCOL) {
|
if ((state == S_FGCOL) || (state == S_FILLCOL)) {
|
||||||
drawcolorchart(screen);
|
drawcolorchart(screen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2264,7 +2356,13 @@ void drawtoolbox(void) {
|
||||||
floodfill(screen, area.x + 5, area.y + 5, fgcol);
|
floodfill(screen, area.x + 5, area.y + 5, fgcol);
|
||||||
}
|
}
|
||||||
if (i == TB_FILLCOL) {
|
if (i == TB_FILLCOL) {
|
||||||
floodfill(screen, area.x + 5, area.y + 5, objfillcol);
|
if (objfillcol.unused != NOCOLOUR) {
|
||||||
|
floodfill(screen, area.x + 5, area.y + 5, objfillcol);
|
||||||
|
} else {
|
||||||
|
floodfill(screen, area.x + 5, area.y + 5, black);
|
||||||
|
drawline(screen, area.x+(area.w/2)-3, area.y+(area.h/2)-3-4, area.x+(area.w/2)+3, area.y+(area.h/2)+3-4,white);
|
||||||
|
drawline(screen, area.x+(area.w/2)+3, area.y+(area.h/2)-3-4, area.x+(area.w/2)-3, area.y+(area.h/2)+3-4,white);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UpdateRect(screen, x, y, toolbox.gridsize+3,toolbox.gridsize+3);
|
SDL_UpdateRect(screen, x, y, toolbox.gridsize+3,toolbox.gridsize+3);
|
||||||
|
@ -2309,7 +2407,7 @@ void drawtoolboxselector(int buttonid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *overridefg) {
|
void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *overridefg, SDL_Color *overridebg) {
|
||||||
float xscale,yscale;
|
float xscale,yscale;
|
||||||
int realx1, realy1;
|
int realx1, realy1;
|
||||||
int realx2, realy2;
|
int realx2, realy2;
|
||||||
|
@ -2333,10 +2431,15 @@ void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h
|
||||||
linecol = *overridefg;
|
linecol = *overridefg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vimg->vector[i].c.unused == 255) {
|
if (overridebg == NULL) {
|
||||||
fillcol = objfillcol;
|
if (vimg->vector[i].c.unused == 255) {
|
||||||
|
/* used to display current colour in foreground/background buttons */
|
||||||
|
fillcol = objfillcol;
|
||||||
|
} else {
|
||||||
|
fillcol = vimg->vector[i].c;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fillcol = vimg->vector[i].c;
|
fillcol = *overridebg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale the coords of this vector
|
// scale the coords of this vector
|
||||||
|
@ -2674,7 +2777,12 @@ int loadmap(void) {
|
||||||
char filename[BUFLEN];
|
char filename[BUFLEN];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int namelen;
|
int namelen;
|
||||||
int i;
|
int i,n;
|
||||||
|
char vers[8], *p;
|
||||||
|
|
||||||
|
mapobject099a_t tempmapobjects[MAXOBJECTS];
|
||||||
|
|
||||||
|
|
||||||
/* TODO: validate */
|
/* TODO: validate */
|
||||||
strcpy(filename, text);
|
strcpy(filename, text);
|
||||||
|
|
||||||
|
@ -2690,41 +2798,109 @@ int loadmap(void) {
|
||||||
|
|
||||||
/* TODO: free() variables! */
|
/* TODO: free() variables! */
|
||||||
|
|
||||||
|
/* TODO: read version string */
|
||||||
|
fread(&vers, 8, 1, f);
|
||||||
|
/* if no version string, then this is an old version */
|
||||||
|
if (vers[0] != 'V') {
|
||||||
|
strcpy(vers, "OLD");
|
||||||
|
/* go back to start of file */
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
} else {
|
||||||
|
/* if we found a version string, remove trailling spaces */
|
||||||
|
for (p = vers; *p != '\0' ; p++) {
|
||||||
|
if (*p == ' ') {
|
||||||
|
*p = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* read in number maps */
|
/* current version(s) */
|
||||||
fread(&nummaps, sizeof(int), 1, f);
|
if (!strcmp(vers, "V0.99b")) {
|
||||||
|
/* read in number maps */
|
||||||
|
fread(&nummaps, sizeof(int), 1, f);
|
||||||
|
|
||||||
for (i = 0; i < nummaps; i++) {
|
for (i = 0; i < nummaps; i++) {
|
||||||
fread(&map[i].width, sizeof(int), 1, f);
|
fread(&map[i].width, sizeof(int), 1, f);
|
||||||
fread(&map[i].height, sizeof(int), 1, f);
|
fread(&map[i].height, sizeof(int), 1, f);
|
||||||
fread(&map[i].bpp, sizeof(int), 1, f);
|
fread(&map[i].bpp, sizeof(int), 1, f);
|
||||||
fread(&map[i].bgcol, sizeof(SDL_Color), 1, f);
|
fread(&map[i].bgcol, sizeof(SDL_Color), 1, f);
|
||||||
fread(&map[i].boxcol, sizeof(SDL_Color), 1, f);
|
fread(&map[i].boxcol, sizeof(SDL_Color), 1, f);
|
||||||
fread(&map[i].numthings, sizeof(int), 1, f);
|
fread(&map[i].numthings, sizeof(int), 1, f);
|
||||||
fread(&map[i].numobjects, sizeof(int), 1, f);
|
fread(&map[i].numobjects, sizeof(int), 1, f);
|
||||||
fread(&map[i].numlinks, sizeof(int), 1, f);
|
fread(&map[i].numlinks, sizeof(int), 1, f);
|
||||||
fread(&map[i].numtext, sizeof(int), 1, f);
|
fread(&map[i].numtext, sizeof(int), 1, f);
|
||||||
map[i].selecteditem = -1;
|
map[i].selecteditem = -1;
|
||||||
map[i].selecteditemtype = -1;
|
map[i].selecteditemtype = -1;
|
||||||
map[i].selectedlinkpoint = -1;
|
map[i].selectedlinkpoint = -1;
|
||||||
map[i].selectedtype = 0;
|
map[i].selectedtype = 0;
|
||||||
map[i].curobj = -1;
|
map[i].curobj = -1;
|
||||||
map[i].curlink = -1;
|
map[i].curlink = -1;
|
||||||
map[i].curlinkpoint = -1;
|
map[i].curlinkpoint = -1;
|
||||||
map[i].curtext = -1;
|
map[i].curtext = -1;
|
||||||
map[i].startx = -1;
|
map[i].startx = -1;
|
||||||
map[i].starty = -1;
|
map[i].starty = -1;
|
||||||
map[i].textanchor = -1;
|
map[i].textanchor = -1;
|
||||||
strcpy(map[i].text, "");
|
strcpy(map[i].text, "");
|
||||||
|
|
||||||
fread(&namelen, sizeof(int), 1, f);
|
fread(&namelen, sizeof(int), 1, f);
|
||||||
fread(&map[i].name, (namelen+1) * sizeof(char), 1, f);
|
fread(&map[i].name, (namelen+1) * sizeof(char), 1, f);
|
||||||
|
|
||||||
/* read objects */
|
/* read objects */
|
||||||
fread(&map[i].thing, sizeof(thing_t), map[i].numthings, f);
|
fread(&map[i].thing, sizeof(thing_t), map[i].numthings, f);
|
||||||
fread(&map[i].olink, sizeof(link_t), map[i].numlinks, f);
|
fread(&map[i].olink, sizeof(link_t), map[i].numlinks, f);
|
||||||
fread(&map[i].obj, sizeof(mapobject_t), map[i].numobjects, f);
|
fread(&map[i].obj, sizeof(mapobject_t), map[i].numobjects, f);
|
||||||
fread(&map[i].textob, sizeof(text_t), map[i].numtext, f);
|
fread(&map[i].textob, sizeof(text_t), map[i].numtext, f);
|
||||||
|
}
|
||||||
|
} else { /* old versions without version string */
|
||||||
|
/* 0.99a didn't have the fillcol field in mapobject_t */
|
||||||
|
|
||||||
|
/* read in number maps */
|
||||||
|
fread(&nummaps, sizeof(int), 1, f);
|
||||||
|
|
||||||
|
for (i = 0; i < nummaps; i++) {
|
||||||
|
fread(&map[i].width, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].height, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].bpp, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].bgcol, sizeof(SDL_Color), 1, f);
|
||||||
|
fread(&map[i].boxcol, sizeof(SDL_Color), 1, f);
|
||||||
|
fread(&map[i].numthings, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].numobjects, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].numlinks, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].numtext, sizeof(int), 1, f);
|
||||||
|
map[i].selecteditem = -1;
|
||||||
|
map[i].selecteditemtype = -1;
|
||||||
|
map[i].selectedlinkpoint = -1;
|
||||||
|
map[i].selectedtype = 0;
|
||||||
|
map[i].curobj = -1;
|
||||||
|
map[i].curlink = -1;
|
||||||
|
map[i].curlinkpoint = -1;
|
||||||
|
map[i].curtext = -1;
|
||||||
|
map[i].startx = -1;
|
||||||
|
map[i].starty = -1;
|
||||||
|
map[i].textanchor = -1;
|
||||||
|
strcpy(map[i].text, "");
|
||||||
|
|
||||||
|
fread(&namelen, sizeof(int), 1, f);
|
||||||
|
fread(&map[i].name, (namelen+1) * sizeof(char), 1, f);
|
||||||
|
|
||||||
|
/* read objects */
|
||||||
|
fread(&map[i].thing, sizeof(thing_t), map[i].numthings, f);
|
||||||
|
fread(&map[i].olink, sizeof(link_t), map[i].numlinks, f);
|
||||||
|
/* read into temp area, then copy to real structure */
|
||||||
|
fread(&tempmapobjects, sizeof(mapobject099a_t), map[i].numobjects, f);
|
||||||
|
for (n = 0; n < map[i].numobjects; n++) {
|
||||||
|
map[i].obj[n].type = tempmapobjects[n].type;
|
||||||
|
map[i].obj[n].x = tempmapobjects[n].x;
|
||||||
|
map[i].obj[n].y = tempmapobjects[n].y;
|
||||||
|
map[i].obj[n].w = tempmapobjects[n].w;
|
||||||
|
map[i].obj[n].h = tempmapobjects[n].h;
|
||||||
|
map[i].obj[n].child = tempmapobjects[n].child;
|
||||||
|
map[i].obj[n].fillcol = black;
|
||||||
|
map[i].obj[n].fillcol.unused = NOCOLOUR;
|
||||||
|
}
|
||||||
|
fread(&map[i].textob, sizeof(text_t), map[i].numtext, f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -2732,7 +2908,7 @@ int loadmap(void) {
|
||||||
curmap = 0;
|
curmap = 0;
|
||||||
|
|
||||||
modified = FALSE;
|
modified = FALSE;
|
||||||
sprintf(statustext,"Successfully loaded map from '%s' (%d maps).\n",filename,nummaps); fflush(stdout);
|
sprintf(statustext,"Successfully loaded map from '%s' (%d maps). [file version: '%s']\n",filename,nummaps, vers);
|
||||||
strcpy(currentfilename, filename);
|
strcpy(currentfilename, filename);
|
||||||
|
|
||||||
drawmap();
|
drawmap();
|
||||||
|
@ -2914,8 +3090,30 @@ int initgraphics(void) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initvars();
|
initvars();
|
||||||
|
|
||||||
|
/* set up icon */
|
||||||
|
sprintf(file, "icon.bmp");
|
||||||
|
for (i = 1; i < MAXLETTERHEIGHT; i++) {
|
||||||
|
icon = SDL_LoadBMP("icon.bmp");
|
||||||
|
if (!icon) {
|
||||||
|
sprintf(file, "/usr/local/share/netmapr/icon.bmp");
|
||||||
|
icon = SDL_LoadBMP(file);
|
||||||
|
}
|
||||||
|
if (!icon) {
|
||||||
|
sprintf(file, "%s/icon.bmp",progdir);
|
||||||
|
icon = SDL_LoadBMP(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!icon) {
|
||||||
|
printf("Error opening icon.bmp: %s\n", TTF_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_WM_SetIcon(icon, NULL);
|
||||||
|
|
||||||
|
|
||||||
/* load fonts */
|
/* load fonts */
|
||||||
TTF_Init();
|
TTF_Init();
|
||||||
sprintf(file, "verdana.ttf");
|
sprintf(file, "verdana.ttf");
|
||||||
|
@ -3327,7 +3525,7 @@ int initgraphics(void) {
|
||||||
}
|
}
|
||||||
} else if (!strcmp(p, "end")) {
|
} else if (!strcmp(p, "end")) {
|
||||||
/* draw vector image into button's bitmap field */
|
/* draw vector image into button's bitmap field */
|
||||||
drawvector(button[numbuttons].img, &tempv, 1, 1, toolbox.gridsize-2,toolbox.gridsize-2, NULL);
|
drawvector(button[numbuttons].img, &tempv, 1, 1, toolbox.gridsize-2,toolbox.gridsize-2, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
//printf("Adding button: '%s' (vnum = %d).\n",button[numbuttons].name,tempv.vnum);
|
//printf("Adding button: '%s' (vnum = %d).\n",button[numbuttons].name,tempv.vnum);
|
||||||
|
@ -3357,7 +3555,7 @@ int initgraphics(void) {
|
||||||
int lw,lh;
|
int lw,lh;
|
||||||
lw = 8;
|
lw = 8;
|
||||||
lh = 10;
|
lh = 10;
|
||||||
drawvector(screen, &letter[i].vect, x, y, lw,lh);
|
drawvector(screen, &letter[i].vect, x, y, lw,lh, NULL, NULL);
|
||||||
x = x + lw + 2;
|
x = x + lw + 2;
|
||||||
if (x >= (map[curmap].width - lw)) {
|
if (x >= (map[curmap].width - lw)) {
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -3784,7 +3982,8 @@ void initvars(void) {
|
||||||
|
|
||||||
|
|
||||||
fgcol = black;
|
fgcol = black;
|
||||||
objfillcol = yellow;
|
objfillcol = black;
|
||||||
|
objfillcol.unused = NOCOLOUR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3823,6 +4022,7 @@ int savemap(void) {
|
||||||
int eoff;
|
int eoff;
|
||||||
SDL_Surface *exportmap;
|
SDL_Surface *exportmap;
|
||||||
SDL_Rect area;
|
SDL_Rect area;
|
||||||
|
char vers[8];
|
||||||
|
|
||||||
/* TODO: validate */
|
/* TODO: validate */
|
||||||
strcpy(filename, text);
|
strcpy(filename, text);
|
||||||
|
@ -3870,6 +4070,10 @@ int savemap(void) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* dump version, 8 bytes, right padded with 0s */
|
||||||
|
sprintf(vers, "V%-7s", VERSION);
|
||||||
|
fwrite(vers, 8, 1, f);
|
||||||
|
|
||||||
/* dump out numbers of map[curmap].objects */
|
/* dump out numbers of map[curmap].objects */
|
||||||
fwrite(&nummaps, sizeof(int), 1, f);
|
fwrite(&nummaps, sizeof(int), 1, f);
|
||||||
|
|
||||||
|
|
Binary file not shown.
14
netmapr.h
14
netmapr.h
|
@ -104,8 +104,20 @@ typedef struct {
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
int child;
|
int child;
|
||||||
|
/* fillcol.unused = 1 means to fill with this colour */
|
||||||
|
/* fillcol.unused = NOCOLOUR means to ignore this*/
|
||||||
|
SDL_Color fillcol;
|
||||||
} mapobject_t;
|
} mapobject_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int type; /* index into objtype[] */
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
|
int child;
|
||||||
|
} mapobject099a_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[BUFLEN];
|
char name[BUFLEN];
|
||||||
SDL_Surface *img;
|
SDL_Surface *img;
|
||||||
|
@ -175,7 +187,7 @@ void drawstatusbar(void);
|
||||||
void drawtext(SDL_Surface *dest, text_t *t);
|
void drawtext(SDL_Surface *dest, text_t *t);
|
||||||
void drawtoolbox(void);
|
void drawtoolbox(void);
|
||||||
void drawtoolboxselector(int buttonid);
|
void drawtoolboxselector(int buttonid);
|
||||||
void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h,SDL_Color *overridefg );
|
void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h,SDL_Color *overridefg, SDL_Color *overridebg );
|
||||||
void drillto(int mapnum);
|
void drillto(int mapnum);
|
||||||
int endobjmove(int x, int y);
|
int endobjmove(int x, int y);
|
||||||
int endresize(int x, int y);
|
int endresize(int x, int y);
|
||||||
|
|
Loading…
Reference in New Issue