changeset 2170:afad5e1b347d

Refactor mkcitymap and how the city maps are generated. Improve the cosmetic looks and hopefully also the usability of the generated HTML maps.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 Oct 2019 19:00:45 +0300
parents 0de42c8fc5b1
children ebd97df1c19a
files Makefile.gen misc/calythien.opts misc/dortlewall.opts misc/esiris.opts misc/lorenchia.opts misc/misc.css misc/misc.html misc/rilynttar.opts misc/tyr_farwyn.opts mkcitymap.c
diffstat 10 files changed, 154 insertions(+), 194 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.gen	Sat Oct 12 18:34:34 2019 +0300
+++ b/Makefile.gen	Sat Oct 12 19:00:45 2019 +0300
@@ -91,8 +91,8 @@
 $(MAP_PATH)%.html: $(MAP_PATH)%.map $(MAP_PATH)%.name $(COLORMAP_BIN)
 	$(COLORMAP_BIN) $(COLORMAP_OPTS) `cat $(patsubst %.map,%.opts,$<)` $(COLORMAP_HTML) -t "`cat $(patsubst %.map,%.name,$<)`" -o $@ $<
 
-$(MAP_PATH)%.html: $(MAP_PATH)%.map $(MAP_PATH)%.loc $(MAP_PATH)%.desc $(MKCITYMAP_BIN) tooltip.js
-	$(MKCITYMAP_BIN) $(MKCITYMAP_OPTS) -t "`cat $(patsubst %.map,%.desc,$<)`" $< $(patsubst %.map,%.loc,$<) `cat $(patsubst %.map,%.opts,$<)` -o "$@"
+$(MAP_PATH)%.html: $(MAP_PATH)%.map $(MAP_PATH)%.loc $(MAP_PATH)%.desc $(MKCITYMAP_BIN) tooltip.js $(MAP_PATH)misc.html
+	$(MKCITYMAP_BIN) $(MKCITYMAP_OPTS) -h $(MAP_PATH)misc.html -t "`cat $(patsubst %.map,%.desc,$<)`" $< $(patsubst %.map,%.loc,$<) `cat $(patsubst %.map,%.opts,$<)` -o "$@"
 
 
 ###
--- a/misc/calythien.opts	Sat Oct 12 18:34:34 2019 +0300
+++ b/misc/calythien.opts	Sat Oct 12 19:00:45 2019 +0300
@@ -1,1 +0,0 @@
--T
--- a/misc/dortlewall.opts	Sat Oct 12 18:34:34 2019 +0300
+++ b/misc/dortlewall.opts	Sat Oct 12 19:00:45 2019 +0300
@@ -1,1 +0,0 @@
--T
--- a/misc/esiris.opts	Sat Oct 12 18:34:34 2019 +0300
+++ b/misc/esiris.opts	Sat Oct 12 19:00:45 2019 +0300
@@ -1,1 +0,0 @@
--T
--- a/misc/lorenchia.opts	Sat Oct 12 18:34:34 2019 +0300
+++ b/misc/lorenchia.opts	Sat Oct 12 19:00:45 2019 +0300
@@ -1,1 +0,0 @@
--T
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/misc.css	Sat Oct 12 19:00:45 2019 +0300
@@ -0,0 +1,102 @@
+body {
+  background: black;
+  color: white;
+  font-family: Arial, Verdana, sans-serif;
+  height: 100%;
+  padding: 0;
+  margin: 0;
+}
+
+.holder {
+  display: block;
+  color: #000;
+}
+
+* html .tooltip {
+  border-right: 400px solid #fff;
+}
+
+* html .holder {
+  display: inline-block;
+  position: relative;
+  margin-right: -400px;
+}
+
+a.loc {
+  background: black;
+  color: red;
+  text-decoration: none;
+}
+
+a.loc:hover {
+  background: white;
+  color: red;
+}
+
+body > h1 {
+  margin: 0;
+  font-size: 1.5em;
+  background: #222;
+  padding: 0.3em;
+}
+
+div.tooltip {
+  position: absolute;
+  display: none;
+
+  min-width: 200px;
+  max-width: 500px;
+  padding: 0.5em;
+  border: 0.2em solid gray;
+
+  background: white;
+  color: black;
+  border-radius: 0.5em;
+  font-size: 0.75em;
+
+  z-index: 15;
+}
+
+div.tooltip h1 {
+  font-size: 1.1em;
+  margin: 0;
+  padding: 0;
+}
+
+pre.map {
+}
+
+div.map {
+  font-weight: bold;
+  position: absolute;
+  left: 0;
+  right: 20%;
+  top: 2.5em;
+  bottom: 0;
+  margin: 0;
+  padding: 0;
+  overflow: auto;
+  text-align: center;
+}
+
+div.loctab {
+  background: black;
+  color: white;
+  position: absolute;
+  right: 0;
+  bottom: 0;
+  top: 0;
+  width: 19%;
+  padding: 0.5em;
+  z-index: 10;
+  border-left: 0.2em solid gray;
+  overflow: auto;
+  font-size: 0.75em;
+  padding: 0.5em;
+  padding-bottom: 1em;
+  padding-top: 1em;
+}
+
+div.loctab a {
+  display: block;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/misc.html	Sat Oct 12 19:00:45 2019 +0300
@@ -0,0 +1,2 @@
+ <script type="text/javascript" src="tooltip.js"></script>
+ <link rel="stylesheet" href="misc.css" type="text/css" />
--- a/misc/rilynttar.opts	Sat Oct 12 18:34:34 2019 +0300
+++ b/misc/rilynttar.opts	Sat Oct 12 19:00:45 2019 +0300
@@ -1,1 +0,0 @@
--T
--- a/misc/tyr_farwyn.opts	Sat Oct 12 18:34:34 2019 +0300
+++ b/misc/tyr_farwyn.opts	Sat Oct 12 19:00:45 2019 +0300
@@ -1,1 +0,0 @@
--T
--- a/mkcitymap.c	Sat Oct 12 18:34:34 2019 +0300
+++ b/mkcitymap.c	Sat Oct 12 19:00:45 2019 +0300
@@ -12,11 +12,9 @@
 char    *optDestFilename = NULL,
         *optMapFilename = NULL,
         *optLocFilename = NULL,
-        *optUrchinFile = NULL,
+        *optHeadFilename = NULL,
         *optMapTitle = NULL;
 
-BOOL    optUseTable = FALSE;
-
 
 /* Arguments
  */
@@ -25,9 +23,8 @@
     { 0, '?', "help",           "Show this help", OPT_NONE },
     { 1, 'v', "verbose",        "Be more verbose", OPT_NONE },
     { 2, 'o', "output",         "Output filename", OPT_ARGREQ },
-    { 4, 'T', "table",          "Use HTML table", OPT_NONE },
-    { 5, 't', "title",          "Map title", OPT_ARGREQ },
-    { 6, 'u', "urchin-file",    "Specify urchin file", OPT_ARGREQ },
+    { 3, 't', "title",          "Map title", OPT_ARGREQ },
+    { 4, 'h', "header-file",    "Specify extra <head> data in file", OPT_ARGREQ },
 };
 
 const int optListN = sizeof(optList) / sizeof(optList[0]);
@@ -60,19 +57,14 @@
         THMSG(2, "Output file set to '%s'.\n", optDestFilename);
         break;
 
-    case 4:
-        optUseTable = TRUE;
-        THMSG(2, "Using HTML table formatting.\n");
-        break;
-
-    case 5:
+    case 3:
         optMapTitle = optArg;
         THMSG(2, "Map title string set to '%s'.\n", optMapTitle);
         break;
 
-    case 6:
-        optUrchinFile = optArg;
-        THMSG(2, "Urchin filename set to '%s'.\n", optUrchinFile);
+    case 4:
+        optHeadFilename = optArg;
+        THMSG(2, "Head filename set to '%s'.\n", optHeadFilename);
         break;
 
     default:
@@ -101,206 +93,76 @@
 }
 
 
-void outputLocationHTML(FILE *outFile, const LocMarker *marker, const int nname)
-{
-    fprintf(outFile,
-        "<a class=\"loc\" id=\"listloc%d_%d\" href=\"?%d_%d\" "
-        "onmouseover=\"%s('%d_%d');\" onmouseout=\"qn();\">",
-        marker->xc, marker->yc,
-        marker->xc, marker->yc,
-        (marker->freeform || marker->nnames > 1) ? "sttq" : "qh",
-        marker->xc, marker->yc);
-
-    if (marker->names[nname].name != NULL)
-    {
-        fprintf(outFile,
-        " <span class=\"desc\">%s</span>",
-        marker->names[nname].name);
-    }
-
-    fprintf(outFile, "</a><br />\n");
-}
-
-
-void outputLocationBlockHTML(FILE *outFile, const MapLocations *locs, int start, int end)
-{
-    if (start >= locs->nlocations || start < 0 || start > end)
-        return;
-
-    if (end >= locs->nlocations)
-        end = locs->nlocations - 1;
-
-    fprintf(outFile, "<td>\n");
-
-    for (int n = start; n <= end; n++)
-    {
-        const LocMarker *marker = locs->locations[n];
-        if (marker->flags & LOCF_INVIS) continue;
-
-        for (int i = 0; i < marker->nnames; i++)
-            outputLocationHTML(outFile, marker, i);
-    }
-
-    fprintf(outFile, "</td>\n");
-}
-
-
 void outputHTMLHeader(FILE *outFile, const MapLocations *locs)
 {
     (void) locs;
 
     muPrintHTMLhead(outFile, optMapTitle, TRUE);
 
-    fprintf(outFile,
-    " <script type=\"text/javascript\" src=\"tooltip.js\"></script>\n"
-    " <style type=\"text/css\">\n"
-    "  body { background: black; color: white; font-family: Arial, Verdana, sans-serif; %s }\n"
-    "  a.loc { background: black; color: red; text-decoration: none; }\n"
-    "  a.loc:hover { background: white; color: red; }\n"
-    "  pre.map { font-size: 9pt; %s }\n",
-    optUseTable ? "" : "height: 100%; padding: 0; margin: 0;",
-    optUseTable ? "" : "overflow: auto;"
-    );
+    if (optHeadFilename != NULL &&
+        muCopyFileToStream(outFile, optHeadFilename) < 0)
+    {
+        THERR("Error copying urchin file '%s' to output.\n", optHeadFilename);
+    }
+
+    fprintf(outFile, " <style type=\"text/css\">\n");
+    muPrintHTMLcolors(outFile, "span", NULL, NULL);
+    fprintf(outFile, " </style>\n");
+
 
     fprintf(outFile,
-    "  .tooltip {\n"
-    "    position: absolute;\n"
-    "    display: none;\n"
-    "    min-width: 200px; max-width: 500px;\n"
-    "    background: white; color: black;\n"
-    "    padding: 5px;\n"
-    "    border: 2px solid gray;\n"
-    "    -moz-border-radius: 5px;\n"
-    "    border-radius: 5px;\n"
-    "    font-size: 8pt;\n"
-    "    z-index: 15;\n"
-    "  }\n"
-    "  .holder { display: block; color: #000; }\n"
-    "  * html .tooltip { border-right: 400px solid #fff; }\n"
-    "  * html .holder { display: inline-block; position: relative; margin-right: -400px; }\n"
-    "  div.loctab table tr { vertical-align: top; }\n"
-    );
+        "</head>\n"
+        "<body onload=\"httOnLoad();\">\n"
+        );
 
-    if (!optUseTable)
+    if (optMapTitle)
     {
-    fprintf(outFile,
-    "  div.map {\n"
-    "    font-weight: bold;\n"
-    "    position: absolute;\n"
-    "    left: 0;\n"
-    "    right: 0;\n"
-    "    top: 0;\n"
-    "    margin: 0;\n"
-    "    padding: 0;\n"
-    "    height: 75%%;\n"
-    "    overflow: auto;\n"
-    "    text-align: center;\n"
-    "  }\n"
-    "  div.loctab {\n"
-    "    background: black;\n"
-    "    color: white;\n"
-    "    position: absolute;\n"
-    "    right: 0;\n"
-    "    left: 0;\n"
-    "    height: 20%%;\n"
-    "    bottom: 0;\n"
-    "    padding: 4px;\n"
-    "    z-index: 10;\n"
-    "    border-top: 4px solid gray;\n"
-    "    font-size: 10pt;\n"
-    "    overflow: auto;\n"
-    "  }\n"
-    "  div.loctab table { width: 95%%; }\n"
-    );
-    }
-
-    muPrintHTMLcolors(outFile, "span", NULL, NULL);
-
-    fprintf(outFile,
-    " </style>\n"
-    );
-
-    if (optUrchinFile && muCopyFileToStream(outFile, optUrchinFile) < 0)
-    {
-        THERR("Error copying urchin file '%s' to output.\n", optUrchinFile);
+        fprintf(outFile, "<h1>");
+        fputse(optMapTitle, outFile);
+        fprintf(outFile, "</h1>\n");
     }
 
     fprintf(outFile,
-    "</head>\n"
-    "<body onload=\"httOnLoad();\">\n"
-    );
-
-    if (optUseTable && optMapTitle)
-    {
-      fprintf(outFile, "<h3>");
-      fputse(optMapTitle, outFile);
-      fprintf(outFile, "</h3>\n");
-    }
-
-    if (optUseTable)
-    {
-    fprintf(outFile,
-    "<table>\n"
-    " <tr>\n"
-    "  <td>\n"
-    );
-    }
-
-    fprintf(outFile,
-    "<div class=\"map\">"
-    "<pre class=\"map\">"
-    );
+        "<div class=\"map\">"
+        "<pre class=\"map\">"
+        );
 }
 
 
 void outputHTMLFooter(FILE *outFile, const MapLocations *locs)
 {
-    int n, k, num;
-
     fprintf(outFile,
     "</pre>"
     "</div>\n"
+    "<div class=\"loctab\">\n"
     );
 
-    if (optUseTable)
+    for (int n = 0; n < locs->nlocations; n++)
     {
-    fprintf(outFile,
-    "  </td>\n"
-    "  <td>\n"
-    );
+        const LocMarker *marker = locs->locations[n];
+        if (marker->flags & LOCF_INVIS) continue;
+
+        for (int i = 0; i < marker->nnames; i++)
+        {
+            fprintf(outFile,
+                "<a class=\"loc\" id=\"listloc%d_%d\" href=\"?%d_%d\" "
+                "onmouseover=\"%s('%d_%d');\" onmouseout=\"qn();\">",
+                marker->xc, marker->yc,
+                marker->xc, marker->yc,
+                (marker->freeform || marker->nnames > 1) ? "sttq" : "qh",
+                marker->xc, marker->yc);
+
+            fputse(marker->names[i].name, outFile);
+
+            fprintf(outFile, "</a>\n");
+        }
     }
 
     fprintf(outFile,
-    "<div class=\"loctab\">\n"
-    "<table><tr>\n"
-    );
-
-    for (num = n = 0; n < locs->nlocations; n++)
-    {
-        const LocMarker *marker = locs->locations[n];
-        if ((marker->flags & LOCF_INVIS) == 0)
-            num++;
-    }
-
-    k = (num / (optUseTable ? 2 : 4)) + 1;
-    for (n = 0; n < locs->nlocations; n += k)
-      outputLocationBlockHTML(outFile, locs, n, n + k - 1);
-
-    fprintf(outFile,
-    "</tr></table>\n"
     "</div>\n"
     );
 
-    if (optUseTable)
-    {
-    fprintf(outFile,
-    "  </td>\n"
-    " </tr>\n"
-    "</table>\n"
-    );
-    }
-
-    for (n = 0; n < locs->nlocations; n++)
+    for (int n = 0; n < locs->nlocations; n++)
     {
         const LocMarker *marker = locs->locations[n];
         if (marker->flags & LOCF_INVIS) continue;
@@ -312,7 +174,7 @@
 
         if (marker->names[0].name != NULL)
         {
-            fprintf(outFile, "<b>%s</b>", marker->names[0].name);
+            fprintf(outFile, "<h1>%s</h1>", marker->names[0].name);
         }
 
         if (marker->nnames > 1)