Mercurial > hg > batmud > maputils
changeset 1745:65e37d990069
Implement marker tags, used only for HTML output.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 18 Oct 2017 15:10:52 +0300 |
parents | 500eaef7bd7c |
children | 892d444fca65 |
files | colormap.c mkloc.c |
diffstat | 2 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/colormap.c Wed Oct 18 15:10:08 2017 +0300 +++ b/colormap.c Wed Oct 18 15:10:52 2017 +0300 @@ -15,6 +15,7 @@ char *fmtName; char *fmtDescription; BOOL supBackColor; + void (*putTagMarker) (FILE *, const char *, const int color, const int marker); void (*putTagLocation) (FILE *, const char *, const int color); void (*putTagLocationEnd) (FILE *, const char *); void (*putTagStart) (FILE *, const int color); @@ -155,6 +156,7 @@ * XHTML+CSS output format functions */ #define XHTML_LOCLABEL "label" +#define XHTML_LOCMARKER "marker" void putColorClassXHTML(FILE *outFile, const int color) { @@ -395,6 +397,36 @@ currColor = -1; } else + if (k == 0xfb) + { + char tmpStr[MAXSTR]; + int mch; + + // Location marker mode + checkEndTag(outFile, fmt, prevColor); + currColor = prevColor = -2; + + // Get location marker tag + if (!getTagStr(inFile, tmpStr, MAXSTR, 0xfc)) + return FALSE; + + // Get marker character + mch = fgetc(inFile); + k = fgetc(inFile); + + if (k != 0xfe) + { + THERR("Expected location tag '%s' end, but did not find one.\n", tmpStr); + return FALSE; + } + + currColor = muGetMapPieceColor(mch, optUseOldFormat, optCityFormat); + if (fmt->putTagMarker != NULL) + fmt->putTagMarker(outFile, tmpStr, currColor, mch); + else + fprintf(outFile, "%c", mch); + } + else if (k == 0xff) { char tmpStr[MAXSTR], tmpStr2[MAXSTR]; @@ -480,25 +512,27 @@ CMapOutFormat outputFormats[] = { { "xhtml", "XHTML+CSS", TRUE, + putTagMarkerXHTML, putTagLocationXHTML, putTagLocationEndXHTML, putTagStartXHTML, putTagEndXHTML, putEOLXHTML, putFileStartXHTML, putFileEndXHTML, fputse }, { "html5", "HTML5+CSS", TRUE, + putTagMarkerXHTML, putTagLocationXHTML, putTagLocationEndXHTML, putTagStartXHTML, putTagEndXHTML, putEOLXHTML, putFileStartHTML5, putFileEndXHTML, fputse }, { "ansi", "ANSI text", FALSE, - NULL, NULL, + NULL, NULL, NULL, putTagStartANSI, putTagEndANSI, putEOLANSI, putFileStartANSI, putFileEndANSI, NULL }, { "text", "Plain ASCII text", FALSE, - NULL, NULL, + NULL, NULL, NULL, putTagStartText, putTagEndText, putEOLText, putFileStartText, NULL, NULL },
--- a/mkloc.c Wed Oct 18 15:10:08 2017 +0300 +++ b/mkloc.c Wed Oct 18 15:10:52 2017 +0300 @@ -517,7 +517,11 @@ break; } + fputc(0xfb, outFile); + fprintf(outFile, "mloc%d_%d", tmp->ox + 1, tmp->oy + 1); + fputc(0xfc, outFile); fputc(chm, outFile); + fputc(0xfe, outFile); } else if (!optNoLabels && (n = locFindByCoords(l, x, y, FALSE)) >= 0)