From d15155a03c2ec8c2be240d791f011eba2eef9509 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Mon, 31 Oct 2005 02:20:14 +0000 Subject: [PATCH] - Made map box scrollable. --- INSTALL | 9 ----- INSTALL.txt | 16 ++++++++ Makefile.freebsd | 8 ++-- Makefile.linux | 8 ++-- README => README.txt | 0 constants.h | 12 +++--- netmapr.c | 96 ++++++++++++++++++++++++++++++++++++-------- netmapr.h | 1 + 8 files changed, 111 insertions(+), 39 deletions(-) delete mode 100644 INSTALL create mode 100644 INSTALL.txt rename README => README.txt (100%) diff --git a/INSTALL b/INSTALL deleted file mode 100644 index e285312..0000000 --- a/INSTALL +++ /dev/null @@ -1,9 +0,0 @@ -UNIX: - -1. cp Makefile.whatever Makefile -2. make -3. make install -4. Add the following to your profile: - NETMAPRDIR=/usr/local/share/netmapr - export NETMAPRDIR - diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 0000000..19bc878 --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,16 @@ +UNIX: + +1. cp Makefile.whatever Makefile +2. make +3. make install +4. Add the following to your profile: + NETMAPRDIR=/usr/local/share/netmapr + export NETMAPRDIR + +WINDOWS: +1. Unzip to C:\program files (or anywhere else) +2. Add the following environment variable + (my computer->properties->advanced->environment settings) + + Name: NETMAPRDIR + Value: C:\program files\netmapr-1.0 (or wherever you unzipped it) diff --git a/Makefile.freebsd b/Makefile.freebsd index bd2d52e..7629103 100644 --- a/Makefile.freebsd +++ b/Makefile.freebsd @@ -4,7 +4,7 @@ netmapr: netmapr.c constants.h netmapr.h Makefile install: netmapr install -C -D -o root -m 755 netmapr /usr/local/bin/netmapr ln -f /usr/local/bin/netmapr /usr/local/bin/netmapr-viewer - install -C -D -o root -m 644 buttons.dat /usr/local/share/buttons.dat - install -C -D -o root -m 644 objects.dat /usr/local/share/objects.dat - install -C -D -o root -m 644 verdana.ttf /usr/local/share/verdana.ttf - install -C -D -o root -m 644 icon.bmp /usr/local/share/icon.bmp + install -C -D -o root -m 644 buttons.dat /usr/local/share/netmapr/buttons.dat + install -C -D -o root -m 644 objects.dat /usr/local/share/netmapr/objects.dat + install -C -D -o root -m 644 verdana.ttf /usr/local/share/netmapr/verdana.ttf + install -C -D -o root -m 644 icon.bmp /usr/local/share/netmapr/icon.bmp diff --git a/Makefile.linux b/Makefile.linux index b291354..ff1a3ef 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -5,7 +5,7 @@ netmapr: netmapr.c constants.h netmapr.h Makefile install: netmapr install -C -D -o root -m 755 netmapr /usr/local/bin/netmapr ln -f /usr/local/bin/netmapr /usr/local/bin/netmapr-viewer - install -C -D -o root -m 644 buttons.dat /usr/local/share/buttons.dat - install -C -D -o root -m 644 objects.dat /usr/local/share/objects.dat - install -C -D -o root -m 644 verdana.ttf /usr/local/share/verdana.ttf - install -C -D -o root -m 644 icon.bmp /usr/local/share/icon.bmp + install -C -D -o root -m 644 buttons.dat /usr/local/share/netmapr/buttons.dat + install -C -D -o root -m 644 objects.dat /usr/local/share/netmapr/objects.dat + install -C -D -o root -m 644 verdana.ttf /usr/local/share/netmapr/verdana.ttf + install -C -D -o root -m 644 icon.bmp /usr/local/share/netmapr/icon.bmp diff --git a/README b/README.txt similarity index 100% rename from README rename to README.txt diff --git a/constants.h b/constants.h index a0cd673..ad6ad2b 100644 --- a/constants.h +++ b/constants.h @@ -1,4 +1,4 @@ -#define VERSION "0.99e" +#define VERSION "1.0" #define BUFLEN 512 @@ -10,10 +10,10 @@ #define MAXPOINTS 20 #define MAXBUTTONS 40 -#define MAXMAPS 20 +#define MAXMAPS 60 #define MAXHISTORY 50 -#define MAXCHILDREN 10 +#define MAXCHILDREN 30 #define MAXOBJTYPES 30 #define MAXOBJECTS 512 @@ -146,5 +146,7 @@ #define LA_DEST (2) #define LA_BOTH (3) -#define LM_ARROW () -#define THICKNESS +#define C_NONE (-1) +#define C_SCROLLUP (-2) +#define C_SCROLLDOWN (-3) + diff --git a/netmapr.c b/netmapr.c index 9b5892d..397d109 100644 --- a/netmapr.c +++ b/netmapr.c @@ -550,6 +550,8 @@ int main (int argc, char **argv) { th = TTF_FontHeight(font[MAPBOXTEXTHEIGHT]); /* change to child */ pos = (event.button.y - (mapbox.y+(th*2)+1)) / th; + /* adjust for offset if not a special value */ + pos += mapbox.offset; if (pos >= numchildren) { sprintf(statustext, "ERROR: Invalid child map %d (max is %d).",pos,numchildren); drawstatusbar(); @@ -2551,7 +2553,7 @@ void drawmapbox(void) { /* show .. */ if (numhistory >= 1) { - /* draw arrow */ + /* draw back arrow */ drawline(screen, x+5,y+(lh/2),x+mapbox.width-15,y+(lh/2),white,1); drawline(screen, x+5,y+(lh/2),x+15,y+1,white,1); drawline(screen, x+5,y+(lh/2),x+15,y+(lh-1),white,1); @@ -2560,8 +2562,11 @@ void drawmapbox(void) { y += th; /* children ... */ - + + /* first generate list of children */ + numchildren = 0; + for (i = 0; i < map[curmap].numobjects; i++) { if (map[curmap].obj[i].child != -1) { /* make sure we haven't already drawn this name */ @@ -2573,26 +2578,75 @@ void drawmapbox(void) { } } if (!found) { - sprintf(temp.text, map[map[curmap].obj[i].child].name); - //temp.x = x+DEFTEXTW; - temp.x = x; - temp.y = y; - temp.h = lh; - TTF_SizeText(font[lh], temp.text, &tw,&th); - temp.w = tw; - temp.anchor = -1; - temp.c = white; - - drawtext(screen, &temp); - children[numchildren] = map[curmap].obj[i].child; numchildren++; - - y += th; } } } + /* now draw all children, starting at mapbox.offset */ + for (i = mapbox.offset; i < numchildren; i++) { + if ((i == mapbox.offset) && (mapbox.offset > 0)) { + /* replace this entry with an arrow */ + children[i] = C_SCROLLUP; + /* draw an up arrow */ + TTF_SizeText(font[lh], "unused", &tw,&th); + drawline(screen, x + (mapbox.width / 2)-3, y+th-4, + x + (mapbox.width / 2), y+th-7, + white, 1); + drawline(screen, x + (mapbox.width / 2)+3, y+th-4, + x + (mapbox.width / 2), y+th-7, + white, 1); + } else { + /* get its name */ + sprintf(temp.text, "*Unknown*"); /* default, shouldn't actually ever be used */ + for (n = 0; n < map[curmap].numobjects; n++) { + if (map[curmap].obj[n].child == children[i]) { + sprintf(temp.text, map[map[curmap].obj[n].child].name); + break; + } + } + + temp.x = x; + temp.y = y; + temp.h = lh; + TTF_SizeText(font[lh], temp.text, &tw,&th); + temp.w = tw; + temp.anchor = -1; + temp.c = white; + + if (temp.y + temp.h >= (mapbox.y + mapbox.height)) { + SDL_Rect ar; + /* off the bottom of the page - replace previous item with an arrow */ + + printf("showing arrow\n"); fflush(stdout); + + y = y - th - 1; /* go back one line */ + /* clear previous text */ + ar.x = x; + ar.y = y; + ar.w = mapbox.width - 3; + ar.h = th; + SDL_FillRect(screen, &ar, fillcol); + + /* draw arrow */ + drawline(screen, x + (mapbox.width / 2)-3, y+th-7, + x + (mapbox.width / 2), y+th-4, + white, 1); + drawline(screen, x + (mapbox.width / 2)+3, y+th-7, + x + (mapbox.width / 2), y+th-4, + white, 1); + + children[i-1] = C_SCROLLDOWN; + break; + } + + drawtext(screen, &temp); + } + + y += th; + } + SDL_UpdateRect(screen, mapbox.x, mapbox.y, screen->w - mapbox.x,mapbox.height+2); //SDL_Flip(screen); } @@ -4589,6 +4643,7 @@ void initvars(void) { mapbox.y = toolbox.y+toolbox.height+1; mapbox.width = SIDEBARW; mapbox.height = obox.y - mapbox.y - 20; + mapbox.offset = 0; fgcol = black; @@ -5768,7 +5823,8 @@ int endlinkmove(int x, int y) { } void drillto(int mapnum) { - if (mapnum == -1) { +printf("drilling to: %d\n",mapnum); + if (mapnum == C_NONE) { if (nummaps < (MAXMAPS-1)) { /* push current map */ history[numhistory] = curmap; @@ -5797,6 +5853,12 @@ void drillto(int mapnum) { sprintf(statustext, "ERROR: Maximum number of maps reached."); drawstatusbar(); } + } else if (mapnum == C_SCROLLUP) { + mapbox.offset--; + drawmapbox(); + } else if (mapnum == C_SCROLLDOWN) { + mapbox.offset++; + drawmapbox(); } else { /* push current map */ history[numhistory] = curmap; diff --git a/netmapr.h b/netmapr.h index a1e17b6..1a7de22 100644 --- a/netmapr.h +++ b/netmapr.h @@ -34,6 +34,7 @@ struct { int y; int width; int height; + int offset; } mapbox;