]> granicus.if.org Git - nethack/commitdiff
X11: Make statue tiles look like grayscale monsters
authorPasi Kallinen <paxed@alt.org>
Thu, 23 Jun 2016 06:44:07 +0000 (09:44 +0300)
committerPasi Kallinen <paxed@alt.org>
Thu, 23 Jun 2016 06:44:07 +0000 (09:44 +0300)
sys/unix/Makefile.dat
win/X11/tile2x11.c
win/share/tile.doc
win/share/tile.h
win/share/tilemap.c
win/share/tiletext.c

index f0566650ce65981483b43ba438fabda16c91f09a..535e7a8089a95225803cb53bd998f225572214d6 100644 (file)
@@ -31,9 +31,11 @@ all: $(VARDAT) spec_levs quest_levs dungeon
        (cd ../util ; $(MAKE) tile2bmp)
 
 x11tiles: ../util/tile2x11 ../win/share/monsters.txt ../win/share/objects.txt \
-                               ../win/share/other.txt
+                               ../win/share/other.txt \
+                                ../win/share/monsters.txt
        ../util/tile2x11 ../win/share/monsters.txt ../win/share/objects.txt \
-                               ../win/share/other.txt
+                               ../win/share/other.txt \
+                                -grayscale ../win/share/monsters.txt
 
 beostiles: ../util/tile2beos ../win/share/monsters.txt \
                                ../win/share/objects.txt \
index c9e410f4648ee3c9ec04149e99b4c4d960144255..8b7b455e104b479c55ee579380071934b680827d 100644 (file)
@@ -177,7 +177,7 @@ char **argv;
     header.per_row = TILES_PER_ROW;
 
     if (argc == 1) {
-        Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...]\n", argv[0]);
+        Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...] [-grayscale txt_fileN]\n", argv[0]);
         exit(1);
     }
 
@@ -190,8 +190,15 @@ char **argv;
     /* don't leave garbage at end of partial row */
     (void) memset((genericptr_t) tile_bytes, 0, sizeof(tile_bytes));
 
-    for (i = 1; i < argc; i++)
+    for (i = 1; i < argc; i++) {
+        if (!strncmp(argv[i], "-grayscale", 10)) {
+            set_grayscale(TRUE);
+            if (i < (argc - 1)) i++;
+        } else {
+            set_grayscale(FALSE);
+        }
         process_file(argv[i]);
+    }
     Fprintf(stderr, "Total tiles: %ld\n", header.ntiles);
 
     /* round size up to the end of the row */
index 8137f0f6ed36b16201c9d324bb0792812a87ccfd..1817982a7f26e8a3c82f956ed4e95f0529255742 100644 (file)
@@ -57,8 +57,10 @@ boolean read_text_tile(pixel[TILE_Y][TILE_X]);
 boolean write_text_tile(pixel[TILE_Y][TILE_X]);
        writes tile
 
-There are two additional shared routines provided for writers:
+There are some additional shared routines provided for writers:
 
+void set_grayscale(boolean g);
+       do grayscale color substitutions when reading the tile text file
 void init_colormap();
        initialize the output colormap from the input one
        must be called before opening output file as colormap is part of header
index 566cc386c6ddbb9fcafccd8d8eb0e22260f9bf46..db4f124f186848c954694d0fa732c2f8a275c182 100644 (file)
@@ -35,6 +35,7 @@ extern boolean FDECL(read_text_tile, (pixel(*) [TILE_X]));
 extern boolean FDECL(write_text_tile, (pixel(*) [TILE_X]));
 extern int NDECL(fclose_text_file);
 
+extern void FDECL(set_grayscale, (boolean));
 extern void NDECL(init_colormap);
 extern void NDECL(merge_colormap);
 
index f7acba0e84faae268aa17625bd2572da5887b270..cae25fdfbc7a1d05a6559c6077328319c13ba643 100644 (file)
@@ -21,7 +21,7 @@ extern void FDECL(exit, (int));
 #endif
 #endif
 
-#if defined(MSDOS) || defined(WIN32)
+#if defined(MSDOS) || defined(WIN32) || defined(X11_GRAPHICS)
 #define STATUES_LOOK_LIKE_MONSTERS
 #endif
 
index 5837ae422d582f2cc032fdf690df3e17c15ecf3e..fb6adb118cfe83792dd995448471195ac15dc145 100644 (file)
@@ -37,6 +37,20 @@ static void FDECL(write_txttile, (FILE *, pixel (*)[TILE_X]));
     "%[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.] = " \
     "(%d, %d, %d) "
 
+static boolean grayscale = FALSE;
+/* grayscale color mapping */
+static const int graymappings[] = {
+ /* .  A  B   C   D   E   F   G   H   I   J   K   L   M   N   O   P */
+    0, 1, 17, 18, 19, 20, 27, 22, 23, 24, 25, 26, 21, 15, 13, 14, 14
+};
+
+void
+set_grayscale(g)
+boolean g;
+{
+    grayscale = g;
+}
+
 static void
 read_text_colormap(txtfile)
 FILE *txtfile;
@@ -135,6 +149,13 @@ pixel (*pixels)[TILE_X];
                 return FALSE;
             }
             k = color_index[(int) c[0]];
+            if (grayscale) {
+                if (k > (SIZE(graymappings) - 1))
+                    Fprintf(stderr, "Gray mapping issue %d > %d.\n", k,
+                            SIZE(graymappings) - 1);
+                else
+                    k = graymappings[k];
+            }
             if (k == -1)
                 Fprintf(stderr, "color %c not in colormap!\n", c[0]);
             else {