diff --git a/Makefile b/Makefile index 503c5bd..b291354 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,11 @@ netmapr: netmapr.c constants.h netmapr.h Makefile gcc -Wall -g netmapr.c -onetmapr `sdl-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf + ln -f netmapr netmapr-viewer install: netmapr - cp -f netmapr /usr/local/bin ; [ ! -d ~/.netmapr ] && mkdir ~/.netmapr ; cp -f *.dat ~/.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 diff --git a/Makefile.freebsd b/Makefile.freebsd index 66ffd36..bd2d52e 100644 --- a/Makefile.freebsd +++ b/Makefile.freebsd @@ -1,2 +1,10 @@ netmapr: netmapr.c constants.h netmapr.h Makefile - gcc -Wall -g netmapr.c -onetmapr `sdl11-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext + gcc -Wall -g netmapr.c -onetmapr `sdl11-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf + +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 diff --git a/Makefile.linux b/Makefile.linux index 503c5bd..b291354 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,5 +1,11 @@ netmapr: netmapr.c constants.h netmapr.h Makefile gcc -Wall -g netmapr.c -onetmapr `sdl-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf + ln -f netmapr netmapr-viewer install: netmapr - cp -f netmapr /usr/local/bin ; [ ! -d ~/.netmapr ] && mkdir ~/.netmapr ; cp -f *.dat ~/.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 diff --git a/constants.h b/constants.h index 083dda7..9c9a37a 100644 --- a/constants.h +++ b/constants.h @@ -1,4 +1,4 @@ -#define VERSION "0.99c" +#define VERSION "0.99d" #define BUFLEN 512 diff --git a/icon.bmp b/icon.bmp index e5c1195..70316ea 100644 Binary files a/icon.bmp and b/icon.bmp differ diff --git a/netmapr.c b/netmapr.c index e6fae0c..1a4dcd7 100644 --- a/netmapr.c +++ b/netmapr.c @@ -47,6 +47,8 @@ SDL_Color objfillcol; int modified = FALSE; +int readonly = FALSE; + int numobjtypes = 0; int numletters = 0; int numbuttons = 0; @@ -102,7 +104,15 @@ int main (int argc, char **argv) { strcpy(progdir, "/usr/local/share/netmapr"); } - printf("Starting netmapr v%s...\n", VERSION); + if (strstr(argv[0], "view")) { + readonly = TRUE; + } + + if (readonly) { + printf("Starting netmapr viewer v%s...\n", VERSION); + } else { + printf("Starting netmapr v%s...\n", VERSION); + } @@ -1060,8 +1070,19 @@ int addvector(vectorimg_t *vimg, int type, int x1, int y1, int x2, int y2, SDL_C } void changestate(int newstate) { + /* can't do most things in readonly mode */ + if (readonly) { + switch (newstate) { + case S_NONE: + case S_LOADING: + case S_REALLYQUIT: + break; + default: + newstate = S_NONE; + break; + } + } if (newstate != state) { - if ((state == S_ADDOBJ) || (state == S_ADDTEXT)) { /* change mouse back to normal */ SDL_SetCursor(normalmouse); @@ -2014,6 +2035,23 @@ void drawstatusbar(void) { drawbox(screen, temp.x-3,temp.y-1,temp.x+tw+1,temp.y+th,blue); drawtext(screen, &temp); } + /* show readonly status */ + if (readonly) { + int tw,th; + + /* same place as 'mod' box, as in readonly mode map can't be modified */ + temp.x = map[curmap].width - 30; + temp.y = map[curmap].height+2; + temp.h = DEFTEXTH-1; + + TTF_SizeText(font[temp.h], "RO", &tw, &th); + temp.w = tw; + temp.c = blue; + temp.anchor = -1; + strcpy(temp.text, "RO"); + drawbox(screen, temp.x-3,temp.y-1,temp.x+tw+1,temp.y+th,blue); + drawtext(screen, &temp); + } SDL_UpdateRect(screen, area.x, area.y, area.w, area.h); } @@ -2258,7 +2296,11 @@ void drawobox(void) { } void drawscreen(void){ - sprintf(statustext, "Welcome to netmapr v%s.", VERSION); + if (readonly) { + sprintf(statustext, "Welcome to netmapr viewer v%s.", VERSION); + } else { + sprintf(statustext, "Welcome to netmapr v%s.", VERSION); + } drawmap(); drawtoolbox(); drawobox(); @@ -2883,45 +2925,8 @@ int loadmap(void) { } } } - - /* current version(s) */ - if (!strcmp(vers, "V0.99b") || !strcmp(vers, "V0.99c")) { - /* 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); - fread(&map[i].obj, sizeof(mapobject_t), map[i].numobjects, f); - fread(&map[i].textob, sizeof(text_t), map[i].numtext, f); - } - } else { /* old versions without version string */ + if (!strcmp(vers, "OLD")) { + /* old versions without version string */ /* 0.99a didn't have the fillcol field in mapobject_t */ /* read in number maps */ @@ -2970,6 +2975,42 @@ int loadmap(void) { } fread(&map[i].textob, sizeof(text_t), map[i].numtext, f); } + } else { + /* 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); + fread(&map[i].obj, sizeof(mapobject_t), map[i].numobjects, f); + fread(&map[i].textob, sizeof(text_t), map[i].numtext, f); + } } fclose(f); @@ -3290,8 +3331,13 @@ int initgraphics(void) { printf("Doublebuf set ok.\n"); fflush(stdout); } - sprintf(verstring, "netmapr v%s, by rpearce 2005", VERSION); - SDL_WM_SetCaption(verstring,"netmapr"); + if (readonly) { + sprintf(verstring, "netmapr viewer v%s, by rpearce 2005", VERSION); + SDL_WM_SetCaption(verstring,"netmapr viewer"); + } else { + sprintf(verstring, "netmapr v%s, by rpearce 2005", VERSION); + SDL_WM_SetCaption(verstring,"netmapr"); + } /* initialise buffer */ buffer = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].width,map[curmap].height,