Mercurial > hg > batmud > maputils
changeset 36:ec00fb30b147
Updates
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 11 Dec 2006 07:46:31 +0000 |
parents | ffd7a5124e9f |
children | a1a1d64382de |
files | Makefile.gen colormap.c maputils.c maputils.h th_args.c |
diffstat | 5 files changed, 90 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.gen Mon Dec 11 05:50:48 2006 +0000 +++ b/Makefile.gen Mon Dec 11 07:46:31 2006 +0000 @@ -15,12 +15,14 @@ MKMAP_BIN=$(BINPATH)mkmap$(EXEEXT) MKSPECIAL_BIN=$(BINPATH)mkspecial$(EXEEXT) COLORMAP_BIN=$(BINPATH)colormap$(EXEEXT) +COLORANSI_BIN=$(BINPATH)coloransi$(EXEEXT) MAKEBCMAP_BIN=$(BINPATH)mkbcmap$(EXEEXT) DIFFMAP_BIN=$(BINPATH)diffmap$(EXEEXT) +MKLOC_BIN=$(BINPATH)mkloc$(EXEEXT) -TARGETS=$(MKMAP_BIN) $(COLORMAP_BIN) $(MKSPECIAL_BIN) \ - $(MAKEBCMAP_BIN) $(DIFFMAP_BIN) \ - votk.html lanzia.html +TARGETS=$(MKMAP_BIN) $(COLORMAP_BIN) $(MKSPECIAL_BIN) \ + $(MAKEBCMAP_BIN) $(DIFFMAP_BIN) $(COLORANSI_BIN) \ + $(MKLOC_BIN) votk.html lanzia.html MAPFILES=tooltip.js votk.html votk.map lanzia.html lanzia.map @@ -39,9 +41,15 @@ $(MKSPECIAL_BIN): mkspecial.c maputils.o th_args.o th_util.o th_string.o $(COMP) -o $@ $+ $(LDFLAGS) +$(MKLOC_BIN): mkloc.c maputils.o th_args.o th_util.o th_string.o + $(COMP) -o $@ $+ $(LDFLAGS) + $(COLORMAP_BIN): colormap.c maputils.o th_util.o $(COMP) -o $@ $+ $(LDFLAGS) +$(COLORANSI_BIN): coloransi.c maputils.o th_util.o + $(COMP) -o $@ $+ $(LDFLAGS) + $(MAKEBCMAP_BIN): mkbcmap.c maputils.o th_util.o th_string.o $(COMP) -o $@ $+ $(LDFLAGS)
--- a/colormap.c Mon Dec 11 05:50:48 2006 +0000 +++ b/colormap.c Mon Dec 11 07:46:31 2006 +0000 @@ -6,6 +6,14 @@ #include "maputils.h" #include <string.h> +/* If defined, the code will be compiled with following + * "optimizations", which make the HTML output smaller, at + * cost of strict spec-compatibility + * + * - Omit '' from class='' arguments (non-spec) + */ +#define CHEATMODE + void processNormal(FILE *inFile, FILE *outFile) { @@ -15,16 +23,33 @@ while ((k = fgetc(inFile)) != EOF) { if (k == '\n') { fprintf(outFile, "\n"); + } else if (k == 0xff) { + /* Location title mode */ + c = col_light_white; + if (p != -1) fprintf(outFile, "</i>"); + + fprintf(outFile, "<i class='%c'>", 'a'+c); + + while ((k = fgetc(inFile)) != EOF) { + if (k == 0xfe) + break; + else + fprintf(outFile, "%c", k); + } + } else { c = mcGetColor(k); if (c != p) { - if (p != -1) { - fprintf(outFile, "</span>"); - } + if (p != -1) fprintf(outFile, "</i>"); if (k > 0) { +#ifdef CHEATMODE fprintf(outFile, - "<span class='%c'>%c", 'a'+c, k); + "<i class=%c>%c", 'a'+c, k); +#else + fprintf(outFile, + "<i class='%c'>%c", 'a'+c, k); +#endif } } else fprintf(outFile, "%c", k); @@ -46,20 +71,24 @@ } else { if (c != p) { if (p != -1) { - fprintf(outFile, "</span>"); + fprintf(outFile, "</i>"); } if (c >= 0) { DINT t = (c / 64), q = (c % 64); if (t > 0) { fprintf(outFile, - "<span style='color:%s;background:%s'>", + "<i style='color:%s;background:%s'>", mapColors[mapPieces[q].col].css, mapColors[t].css); } else { - fprintf(outFile, - "<span class='%c'>", +#ifdef CHEATMODE + fprintf(outFile, "<i class=%c>", 'a'+mapPieces[q].col); +#else + fprintf(outFile, "<i class='%c'>", + 'a'+mapPieces[q].col); +#endif } fprintf(outFile, "%c", mapPieces[q].c); @@ -98,14 +127,21 @@ fprintf(outFile, " <style type=\"text/css\">\n" " body { background: black; color: white; }\n" + " i { text-decoration: none; font-style: normal; }\n" ); - mcXHTMLcolors(outFile); - + mcXHTMLcolors(outFile, "i"); + fprintf(outFile, " </style>\n" "</head>\n" "<body>\n" + ); + + if (argc >= 2) + fprintf(outFile, "<h2>%s</h2>\n", argv[1]); + + fprintf(outFile, "<pre>\n" );
--- a/maputils.c Mon Dec 11 05:50:48 2006 +0000 +++ b/maputils.c Mon Dec 11 07:46:31 2006 +0000 @@ -6,24 +6,25 @@ #include "maputils.h" #include "th_util.h" + color_t mapColors[] = { -{ "#000000", 0 }, -{ "#0000bb", 1 }, -{ "#bb0000", 2 }, -{ "#bbbb00", 3 }, -{ "#00bb00", 4 }, -{ "#bbbbbb", 5 }, -{ "#00ffff", 6 }, -{ "#770077", 7 }, +{ "#000000", 30, ANSI_OFF }, +{ "#0000bb", 34, ANSI_OFF }, +{ "#bb0000", 31, ANSI_OFF }, +{ "#bbbb00", 33, ANSI_OFF }, +{ "#00bb00", 32, ANSI_OFF }, +{ "#bbbbbb", 37, ANSI_OFF }, +{ "#00ffff", 36, ANSI_OFF }, +{ "#770077", 35, ANSI_OFF }, -{ "#777777", 8 }, -{ "#0000ff", 9 }, -{ "#ff0000", 10 }, -{ "#ffff00", 11 }, -{ "#00ff00", 12 }, -{ "#ffffff", 13 }, -{ "#00ffff", 14 }, -{ "#ff00ff", 15 }, +{ "#777777", 30, ANSI_BOLD }, +{ "#0000ff", 34, ANSI_BOLD }, +{ "#ff0000", 31, ANSI_BOLD }, +{ "#ffff00", 33, ANSI_BOLD }, +{ "#00ff00", 32, ANSI_BOLD }, +{ "#ffffff", 37, ANSI_BOLD }, +{ "#00ffff", 36, ANSI_BOLD }, +{ "#ff00ff", 35, ANSI_BOLD }, }; const DINT nmapColors = (sizeof(mapColors) / sizeof(color_t));
--- a/maputils.h Mon Dec 11 05:50:48 2006 +0000 +++ b/maputils.h Mon Dec 11 07:46:31 2006 +0000 @@ -23,10 +23,21 @@ typedef struct { DCHAR *css; DINT ansi; + DINT ansi_attr; } color_t; enum { + ANSI_OFF = 0, + ANSI_BOLD = 1, + ANSI_UNDERSCORE = 4, + ANSI_BLINK = 5, + ANSI_REVERSE = 7, + ANSI_CONCEALED = 8 +}; + + +enum { col_black = 0, col_blue, col_red,