sever extracolors from utf8map and ENHANCED_SYMBOLS

move the custom color data into its own field in the glyphmap
and disassociate it from the unicode/utf8 stuff.

move the glyphcache stuff during options processing and parsing
into new file glyphs.c and out of utf8map.c, and make it
general, and not part of ENHANCED_SYMBOLS.

Do the groundwork for allowing glyph color customizations to
work when any symset is loaded and not restrict it only to
the enhanced1 H_UTF8 symsets.

The customizations in effect are still affiliated with a particular
symset.

Also closes #1224, but the PR itself references a data structure
made obsolete by this commit. The curses comment from the PR was
added into the code.

The PR also made several suggestions, but only the first
one has been included in this commit (and no longer based on
the handler), that being:
"allow defining colors if other symbol handling modes are used
(possibly limited to the standard 16 colors)."

FredrIQ also wrote the following suggestions in PR#1224:

Something I was also contemplating, unrelated to implementation of this
support in curses, would be the ability for the following:

allow defining colors if other symbol handling modes are used (possibly limited to the standard 16 colors)
allow defining attributes (for example: glyph:G_pet_female_kitten:U+0066/red/underline)
allow specifying glyphs as wildcards for defining global color/attribute changes

Something I also want to see are keywords for "don't change the current defined data". If this
were to be added, you could for example do this:
OPTIONS=glyph:G_*_fox:U+0064/blue
OPTIONS=glyph:G_statue_*:basechar/gray/underline
for "make all foxes use a blue color, make all statues gray with underline" without needing
to specify the relevant character for every statue. This ("basechar", "basefg", etc)
should perhaps also be added for MENUCOLORS and statushilites, so that you can, for
example, underline all items being worn without needing to specify a bunch of
near-duplicate rules for combining BUC colors + underline worn items
as per #1064
This commit is contained in:
nhmall
2024-03-23 15:33:00 -04:00
parent ef17c7ac2b
commit ba00dc9066
36 changed files with 1799 additions and 1589 deletions

View File

@@ -63,6 +63,7 @@ struct window_procs curses_procs = {
#ifdef CURSES_UNICODE
| WC2_U_UTF8STR
#endif
| WC2_EXTRACOLORS
#ifdef SELECTSAVED
| WC2_SELECTSAVED
#endif
@@ -912,6 +913,7 @@ curses_print_glyph(
int glyph;
int ch;
int color;
uint32 nhcolor = 0;
unsigned int special;
int attr = -1;
@@ -919,6 +921,22 @@ curses_print_glyph(
special = glyphinfo->gm.glyphflags;
ch = glyphinfo->ttychar;
color = glyphinfo->gm.sym.color;
/* Extra color handling
* FIQ: The curses library does not support truecolor, only the more limited 256
* color mode. On top of this, the windowport only supports 16 color mode.
* Thus, we only allow users to customize glyph colors to the basic NetHack
* colors. */
if (glyphinfo->gm.nhcolor != 0
&& (curses_procs.wincap2 & WC2_EXTRACOLORS) != 0) {
if ((glyphinfo->gm.nhcolor & NH_BASIC_COLOR) != 0) {
color = COLORVAL(glyphinfo->gm.nhcolor);
#if 0
} else {
/* 24-bit color, NH_BASIC_COLOR == 0 */
nhcolor = COLORVAL(glyphinfo->gm.nhcolor);
#endif
}
}
if ((special & MG_PET) && iflags.hilite_pet) {
attr = curses_convert_attr(iflags.wc2_petattr);
}
@@ -955,20 +973,15 @@ curses_print_glyph(
}
}
curses_putch(wid, x, y, ch,
#ifdef ENHANCED_SYMBOLS
if (SYMHANDLING(H_UTF8)
&& glyphinfo->gm.u
&& glyphinfo->gm.u->utf8str) {
curses_putch(wid, x, y, ch, glyphinfo->gm.u, color,
bkglyphinfo->framecolor, attr);
} else {
curses_putch(wid, x, y, ch, NULL, color,
bkglyphinfo->framecolor, attr);
}
#else
curses_putch(wid, x, y, ch, color,
bkglyphinfo->framecolor, attr);
(SYMHANDLING(H_UTF8)
&& glyphinfo->gm.u && glyphinfo->gm.u->utf8str)
? glyphinfo->gm.u : NULL,
#endif
(nhcolor != 0) ? nhcolor : color,
bkglyphinfo->framecolor, attr);
}
/*