reinstate 256 color

This commit is contained in:
nhmall
2024-03-24 23:47:24 -04:00
parent 4d453193cf
commit e3409fd4af
8 changed files with 25 additions and 32 deletions

View File

@@ -319,7 +319,7 @@ extern int count_menucolors(void);
extern int32 check_enhanced_colors(char *) NONNULLARG1;
extern const char *wc_color_name(int32) NONNULL;
extern int32_t rgbstr_to_int32(const char *rgbstr);
extern boolean closest_color(uint32_t lcolor, uint32_t *closecolor, int *clridx);
extern boolean closest_color(uint32_t lcolor, uint32_t *closecolor, uint16 *clridx);
extern int color_distance(uint32_t, uint32_t);
extern boolean onlyhexdigits(const char *buf);
extern uint32 get_nhcolor_from_256_index(int idx);
@@ -1098,7 +1098,7 @@ struct customization_detail *find_matching_customization(
const char *customization_name,
enum customization_types custtype,
enum graphics_sets which_set);
int set_map_nhcolor(glyph_map *gm, uint32 nhcolor) NONNULLARG1;
int set_map_customcolor(glyph_map *gm, uint32 nhcolor) NONNULLARG1;
extern int unicode_val(const char *);
extern int glyphrep(const char *) NONNULLARG1;
extern int match_glyph(char *) NONNULLARG1;

View File

@@ -84,6 +84,7 @@ typedef struct glyph_map_entry {
unsigned glyphflags;
struct classic_representation sym;
uint32 customcolor;
uint16 color256idx;
short int tileidx;
#ifdef ENHANCED_SYMBOLS
struct unicode_representation *u;

View File

@@ -853,14 +853,20 @@ rgbstr_to_int32(const char *rgbstr)
}
int
set_map_nhcolor(glyph_map *gmap, uint32 nhcolor)
set_map_customcolor(glyph_map *gmap, uint32 nhcolor)
{
glyph_map *tmpgm = gmap;
uint32 closecolor = 0;
uint16 clridx = 0;
if (!tmpgm)
return 0;
gmap->customcolor = nhcolor;
if (closest_color(nhcolor, &closecolor, &clridx))
gmap->color256idx = clridx;
else
gmap->color256idx = 0;
return 1;
}
@@ -976,7 +982,7 @@ color_distance(uint32_t rgb1, uint32_t rgb2)
}
boolean
closest_color(uint32 lcolor, uint32 *closecolor, int *clridx)
closest_color(uint32 lcolor, uint32 *closecolor, uint16 *clridx)
{
int i, color_index = -1, similar = INT_MAX, current;
boolean retbool = FALSE;

View File

@@ -1566,12 +1566,12 @@ see_traps(void)
}
/* glyph, ttychar, framecolor,
{ glyphflags, { NO_COLOR, sym.symidx }, nhcolor, tileidx, u } */
{ glyphflags, { NO_COLOR, sym.symidx }, customcolor, color256idx, tileidx, u } */
static glyph_info no_ginfo = {
NO_GLYPH, ' ', NO_COLOR,
{ MG_BADXY, { NO_COLOR, 0 },
0,
0
0U, 0U
#ifdef ENHANCED_SYMBOLS
, 0
#endif
@@ -1602,7 +1602,7 @@ const glyph_info nul_glyphinfo = {
MG_UNEXPL,
{ NO_COLOR, SYM_UNEXPLORED + SYM_OFF_X },
0,
0
0U, 0U
#ifdef ENHANCED_SYMBOLS
, 0
#endif
@@ -1616,7 +1616,7 @@ extern glyph_map glyphmap[MAX_GLYPH]; /* from tile.c */
glyph_map glyphmap[MAX_GLYPH] = {
{ 0U, { NO_COLOR, 0 },
0,
0
0U, 0U
#ifdef ENHANCED_SYMBOLS
, 0
#endif
@@ -2029,7 +2029,7 @@ static gbuf_entry nul_gbuf = {
/* glyphinfo.gm */
{ MG_UNEXPL, { NO_COLOR, 0 },
0,
0
0U, 0U
#ifdef ENHANCED_SYMBOLS
, 0
#endif

View File

@@ -483,7 +483,7 @@ apply_customizations(
if (iflags.customcolors && do_colors) {
if (sc->custtype == custom_nhcolor) {
gmap = &glyphmap[details->content.ccolor.glyphidx];
(void) set_map_nhcolor(gmap,
(void) set_map_customcolor(gmap,
details->content.ccolor.nhcolor);
}
}
@@ -1051,6 +1051,7 @@ clear_all_glyphmap_colors(void)
for (glyph = 0; glyph < MAX_GLYPH; ++glyph) {
if (glyphmap[glyph].customcolor)
glyphmap[glyph].customcolor = 0;
glyphmap[glyph].color256idx = 0;
}
}

View File

@@ -139,17 +139,11 @@ X11_print_glyph(
if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) != 0) {
/* NH_BASIC_COLOR */
color = COLORVAL(glyphinfo->gm.customcolor);
#if 0
} else if (iflags.colorcount == 256
&& (X11_procs.wincap2 & WC2_EXTRACOLORS) != 0
&& (glyphinfo->gm.customcolor & NH_BASIC_COLOR) == 0) {
int clr256idx;
uint32 closecolor = 0;
if (closest_color(COLORVAL(glyphinfo->gm.customcolor),
&closecolor, &clr256idx))
nhcolor = COLORVAL(closecolor);
#endif
uint32 closecolor = get_nhcolor_from_256_index(glyphinfo->gm.color256idx);
nhcolor = COLORVAL(closecolor);
} else {
/* 24-bit color, NH_BASIC_COLOR == 0 */
nhcolor = COLORVAL(glyphinfo->gm.customcolor);

View File

@@ -1362,7 +1362,7 @@ main(int argc UNUSED, char *argv[] UNUSED)
Fprintf(ofp, "%smaxothtile = %d;\n\n", indent, lastothtile);
Fprintf(ofp, "#define NO_CUSTOMCOLOR (0U)\n\n");
Fprintf(ofp, "/* glyph, ttychar, { %s%s } */\n",
"glyphflags, { NO_COLOR, symidx }, NO_CUSTOMCOLOR, ovidx, tileidx", enhanced);
"glyphflags, { NO_COLOR, symidx }, NO_CUSTOMCOLOR, NO_CUSTOMCOLOR, ovidx, tileidx", enhanced);
#ifdef ENHANCED_SYMBOLS
enhanced = ", 0"; /* replace ", utf8rep" since we're done with that */
#endif
@@ -1370,7 +1370,7 @@ main(int argc UNUSED, char *argv[] UNUSED)
Fprintf(ofp, "%sNO_GLYPH, ' ', NO_COLOR,\n", indent);
Fprintf(ofp, "%s%s/* glyph_map */\n", indent, indent);
Fprintf(ofp, "%s%s{ %s, TILE_UNEXPLORED%s }\n", indent, indent,
"MG_UNEXPL, { NO_COLOR, SYM_UNEXPLORED + SYM_OFF_X }, NO_CUSTOMCOLOR",
"MG_UNEXPL, { NO_COLOR, SYM_UNEXPLORED + SYM_OFF_X }, NO_CUSTOMCOLOR, NO_CUSTOMCOLOR",
enhanced);
Fprintf(ofp, "};\n");
Fprintf(ofp, "\nglyph_map glyphmap[MAX_GLYPH] = {\n");
@@ -1385,7 +1385,7 @@ main(int argc UNUSED, char *argv[] UNUSED)
/*NOTREACHED*/
}
Fprintf(ofp,
" { 0U, { NO_COLOR, 0 }, NO_CUSTOMCOLOR, %4d%s }, /* [%04d] %s:%03d %s */\n",
" { 0U, { NO_COLOR, 0 }, NO_CUSTOMCOLOR, NO_CUSTOMCOLOR, %4d%s }, /* [%04d] %s:%03d %s */\n",
tilenum, enhanced, i,
tilesrc_texts[tilelist[tilenum]->src],
tilelist[tilenum]->file_entry,

View File

@@ -3849,18 +3849,9 @@ tty_print_glyph(
if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) != 0) {
/* don't set colordone or nhcolor */
color = COLORVAL(glyphinfo->gm.customcolor);
#if 0
} else if (iflags.colorcount == 256) {
if (closest_color(COLORVAL(glyphinfo->gm.customcolor),
&closecolor, &clridx)) {
if (ttyDisplay->color != NO_COLOR) {
term_end_color();
}
ttyDisplay->colorflags = 0;
term_start_256color(clridx);
colordone = TRUE;
}
#endif
ttyDisplay->colorflags = 0; /* not NH_BASIC_COLOR */
term_start_256color(glyphinfo->gm.color256idx);
} else {
nhcolor = COLORVAL(glyphinfo->gm.customcolor);
ttyDisplay->colorflags = 0;