black&white lava

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.
This commit is contained in:
PatR
2016-05-28 00:51:54 -07:00
parent 4341be8c89
commit 6459b5d301
5 changed files with 27 additions and 19 deletions

View File

@@ -57,13 +57,15 @@
#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)

View 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);
}

View 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 */
}
}

View 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;
}

View 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));