From: Pasi Kallinen Date: Thu, 23 Jun 2016 06:44:07 +0000 (+0300) Subject: X11: Make statue tiles look like grayscale monsters X-Git-Tag: NetHack-3.6.1_RC01~655 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f35d4910530ea4bb75b87c3daa544717c566e8a;p=nethack X11: Make statue tiles look like grayscale monsters --- diff --git a/sys/unix/Makefile.dat b/sys/unix/Makefile.dat index f0566650c..535e7a808 100644 --- a/sys/unix/Makefile.dat +++ b/sys/unix/Makefile.dat @@ -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 \ diff --git a/win/X11/tile2x11.c b/win/X11/tile2x11.c index c9e410f46..8b7b455e1 100644 --- a/win/X11/tile2x11.c +++ b/win/X11/tile2x11.c @@ -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 */ diff --git a/win/share/tile.doc b/win/share/tile.doc index 8137f0f6e..1817982a7 100644 --- a/win/share/tile.doc +++ b/win/share/tile.doc @@ -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 diff --git a/win/share/tile.h b/win/share/tile.h index 566cc386c..db4f124f1 100644 --- a/win/share/tile.h +++ b/win/share/tile.h @@ -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); diff --git a/win/share/tilemap.c b/win/share/tilemap.c index f7acba0e8..cae25fdfb 100644 --- a/win/share/tilemap.c +++ b/win/share/tilemap.c @@ -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 diff --git a/win/share/tiletext.c b/win/share/tiletext.c index 5837ae422..fb6adb118 100644 --- a/win/share/tiletext.c +++ b/win/share/tiletext.c @@ -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 {