]> granicus.if.org Git - nethack/commitdiff
black&white lava
authorPatR <rankin@nethack.org>
Sat, 28 May 2016 07:51:54 +0000 (00:51 -0700)
committerPatR <rankin@nethack.org>
Sat, 28 May 2016 07:51:54 +0000 (00:51 -0700)
Add MG_BW_LAVA to mapglyph() instead of hijacking MG_DETECT.  Used
to display lava in inverse video if color is disabled and lava is
using the same display character as water (which is the default).
(The use_inverse option must be enabled for tty to honor it.  X11's
text mode doesn't care.  Win32 does care but probably shouldn't--it's
not a case like tty where the hardware might not support it.)

This implements both MG_DETECT and MG_BW_LAVA for X11, but only if
the program is built with TEXTCOLOR enabled.  Those should work even
when color is not supported, but I suspect that configuration is
unlikely to ever be used so didn't want to spend the time to figure
out how to do it.  (The relevant data is overloaded on the color
data, so not available when TEXTCOLOR is disabled.)

The win32 revision is untested.

include/hack.h
src/mapglyph.c
win/X11/winmap.c
win/tty/wintty.c
win/win32/mhmap.c

index fb25a167286e6a8327223273bc2f109efa28c278..eeb5ce3e6a44406756d7239e766f5635353ba912 100644 (file)
 #define DISMOUNT_BYCHOICE 6
 
 /* Special returns from mapglyph() */
-#define MG_CORPSE 0x01
-#define MG_INVIS 0x02
-#define MG_DETECT 0x04
-#define MG_PET 0x08
-#define MG_RIDDEN 0x10
-#define MG_STATUE 0x20
+#define MG_CORPSE  0x01
+#define MG_INVIS   0x02
+#define MG_DETECT  0x04
+#define MG_PET     0x08
+#define MG_RIDDEN  0x10
+#define MG_STATUE  0x20
 #define MG_OBJPILE 0x40  /* more than one stack of objects */
+#define MG_BW_LAVA 0x80  /* 'black & white lava': highlight lava if it
+                            can't be distringuished from water by color */
 
 /* sellobj_state() states */
 #define SELL_NORMAL (0)
index c0c64016477b4a223154e61cefa2b91fc4456e88..dab688620b7cb7037d83c40f9dc3d55c82710238 100644 (file)
@@ -134,9 +134,7 @@ unsigned *ospecial;
         } else if (!iflags.use_color && offset == S_lava
                    && (showsyms[idx] == showsyms[S_pool + SYM_OFF_P]
                        || showsyms[idx] == showsyms[S_water + SYM_OFF_P])) {
-            /* temporary? hack; makes tty use inverse video if the
-               corresponding boolean option is enabled */
-            special |= MG_DETECT;
+            special |= MG_BW_LAVA;
         } else {
             cmap_color(offset);
         }
index bd7639e03000427ddd199eb09af50ff8e5c9fba9..ec5e5fa4a686eb5aa1fe0ace1dfd872443779287 100644 (file)
@@ -124,8 +124,9 @@ int bkglyph UNUSED;
         }
 #ifdef TEXTCOLOR
         co_ptr = &map_info->text_map.colors[y][x];
-        colordif = (((special & MG_PET) && iflags.hilite_pet)
-                    || ((special & MG_OBJPILE) && iflags.hilite_pile))
+        colordif = (((special & MG_PET) != 0 && iflags.hilite_pet)
+                    || ((special & MG_OBJPILE) != 0 && iflags.hilite_pile)
+                    || ((special & (MG_DETECT | MG_BW_LAVA)) != 0))
                       ? CLR_MAX : 0;
         if (*co_ptr != (uchar) (color + colordif)) {
             *co_ptr = (uchar) (color + colordif);
@@ -1223,7 +1224,7 @@ XtPointer widget_data; /* expose event from Window widget */
 /*
  * Do the actual work of the putting characters onto our X window.  This
  * is called from the expose event routine, the display window (flush)
- * routine, and the display cursor routine.  The later involves inverting
+ * routine, and the display cursor routine.  The last involves inverting
  * the foreground and background colors, which are also inverted when the
  * position's color is above CLR_MAX.
  *
@@ -1332,7 +1333,7 @@ boolean inverted;
         struct text_map_info_t *text_map = &map_info->text_map;
 
 #ifdef TEXTCOLOR
-        if (iflags.use_color) {
+        {
             register char *c_ptr;
             char *t_ptr;
             int cur_col, color, win_ystart;
@@ -1359,8 +1360,13 @@ boolean inverted;
                     }
 
                     XDrawImageString(XtDisplay(wp->w), XtWindow(wp->w),
-                                     cur_inv ? text_map->inv_color_gcs[color]
-                                             : text_map->color_gcs[color],
+                                     iflags.use_color
+                                        ? (cur_inv
+                                           ? text_map->inv_color_gcs[color]
+                                           : text_map->color_gcs[color])
+                                        : (cur_inv
+                                           ? text_map->inv_copy_gc
+                                           : text_map->copy_gc),
                                      text_map->square_lbearing
                                          + (text_map->square_width * cur_col),
                                      win_ystart, t_ptr, count);
@@ -1370,8 +1376,8 @@ boolean inverted;
                     cur_col += count;
                 } /* col loop */
             }     /* row loop */
-        } else
-#endif /* TEXTCOLOR */
+        }
+#else   /* !TEXTCOLOR */
         {
             int win_row, win_xstart;
 
@@ -1393,6 +1399,7 @@ boolean inverted;
                                  count);
             }
         }
+#endif  /* ?TEXTCOLOR */
     }
 }
 
index ed7eefd232c00f6812767d2967fbcd48f1756223..8ceb1dc4e132ba7bb479ee7d2a3ba72e42a1d404 100644 (file)
@@ -3220,7 +3220,8 @@ int bkglyph UNUSED;
     /* must be after color check; term_end_color may turn off inverse too */
     if (((special & MG_PET) && iflags.hilite_pet)
         || ((special & MG_OBJPILE) && iflags.hilite_pile)
-        || ((special & MG_DETECT) && iflags.use_inverse)) {
+        || ((special & MG_DETECT) && iflags.use_inverse)
+        || ((special & MG_BW_LAVA) && iflags.use_inverse)) {
         term_start_attr(ATR_INVERSE);
         reverse_on = TRUE;
     }
index 5e9ac26308e9c7032678ba78cbd515d6026b549f..821c91802993310bbea7c70c76ee80504228a196 100644 (file)
@@ -682,7 +682,7 @@ onPaint(HWND hWnd)
                                         &special, i, j);
                         ch = (char) mgch;
                         if (((special & MG_PET) && iflags.hilite_pet)
-                            || ((special & MG_DETECT)
+                            || ((special & (MG_DETECT | MG_BW_LAVA))
                                 && iflags.use_inverse)) {
                             back_brush =
                                 CreateSolidBrush(nhcolor_to_RGB(CLR_GRAY));