runtime toggle of ENHANCED_SYMBOLS customsymbols

This commit is contained in:
nhmall
2024-03-24 19:39:36 -04:00
parent 780d0912ee
commit 29495f77f7
10 changed files with 72 additions and 30 deletions

View File

@@ -752,7 +752,8 @@ struct instance_globals_o {
boolean opt_need_redraw; /* for doset() */
boolean opt_need_glyph_reset;
boolean opt_need_promptstyle;
boolean opt_reset_customizations;
boolean opt_reset_customcolors;
boolean opt_reset_customsymbols;
/* pickup.c */
int oldcap; /* last encumbrance */

View File

@@ -1106,12 +1106,13 @@ extern void dump_all_glyphids(FILE *fp) NONNULLARG1;
extern void fill_glyphid_cache(void);
extern void free_glyphid_cache(void);
extern boolean glyphid_cache_status(void);
extern void apply_customizations(enum graphics_sets which_set);
extern void apply_customizations(enum graphics_sets which_set,
enum do_customizations docustomize);
extern void purge_custom_entries(enum graphics_sets which_set);
extern void purge_all_custom_entries(void);
extern void dump_glyphids(void);
extern void clear_all_glyphmap_colors(void);
extern void reset_customizations(void);
extern void reset_customcolors(void);
/* ### hack.c ### */
@@ -3383,6 +3384,7 @@ extern char *mixed_to_utf8(char *buf, size_t bufsz, const char *str,
void free_all_glyphmap_u(void);
int set_map_u(glyph_map *gm, uint32 utf32ch, const uint8 *utf8str) NONNULLPTRS;
#endif /* ENHANCED_SYMBOLS */
extern void reset_customsymbols(void);
/* ### vault.c ### */

View File

@@ -376,6 +376,7 @@ struct instance_flags {
boolean wizweight; /* display weight of everything in wizard mode */
boolean wizmgender; /* test gender info from core in window port */
boolean customcolors; /* support customcolors defined in glyphmap */
boolean customsymbols; /* support customsymbols defined in glyphmap */
/*
* Window capability support.
*/

View File

@@ -253,6 +253,9 @@ static int optfn_##a(int, int, boolean, char *, char *);
NHOPTB(customcolors, Map, 0, opt_out, set_in_game,
On, Yes, No, No, "customcolours", &iflags.customcolors,
Term_False, "use custom colors in map")
NHOPTB(customsymbols, Map, 0, opt_out, set_in_game,
On, Yes, No, No, "customsymbols", &iflags.customsymbols,
Term_False, "use custom utf8 symbols in map")
NHOPTB(dark_room, Advanced, 0, opt_out, set_in_game,
On, Yes, No, No, NoAlias, &flags.dark_room, Term_False,
"show floor outside line of sight differently")

View File

@@ -129,6 +129,12 @@ enum graphics_sets {
UNICODESET = NUM_GRAPHICS
};
enum do_customizations {
do_custom_none,
do_custom_colors,
do_custom_symbols
};
enum customization_types { custom_none, custom_symbols,
custom_ureps, custom_nhcolor, custom_count };

View File

@@ -655,7 +655,8 @@ static const struct instance_globals_o g_init_o = {
FALSE, /* opt_need_redraw */
FALSE, /* opt_need_glyph_reset */
FALSE, /* opt_need_promptstyle */
FALSE, /* opt_reset_customizations */
FALSE, /* opt_reset_customcolors */
FALSE, /* opt_reset_customsymbols */
/* pickup.c */
0, /* oldcap */
/* restore.c */

View File

@@ -449,12 +449,16 @@ add_custom_nhcolor_entry(
}
void
apply_customizations(enum graphics_sets which_set)
apply_customizations(
enum graphics_sets which_set,
enum do_customizations docustomize)
{
glyph_map *gmap;
struct customization_detail *details;
struct symset_customization *sc;
boolean at_least_one = FALSE;
boolean at_least_one = FALSE,
do_colors = ((docustomize & do_custom_colors) != 0),
do_symbols = ((docustomize & do_custom_symbols) != 0);
int custs;
for (custs = 0; custs < (int) custom_count; ++custs) {
@@ -466,15 +470,17 @@ apply_customizations(enum graphics_sets which_set)
details = sc->details;
while (details) {
#ifdef ENHANCED_SYMBOLS
if (sc->custtype == custom_ureps) {
gmap = &glyphmap[details->content.urep.glyphidx];
if (gs.symset[which_set].handling == H_UTF8)
(void) set_map_u(gmap,
details->content.urep.u.utf32ch,
details->content.urep.u.utf8str);
if (iflags.customsymbols && do_symbols) {
if (sc->custtype == custom_ureps) {
gmap = &glyphmap[details->content.urep.glyphidx];
if (gs.symset[which_set].handling == H_UTF8)
(void) set_map_u(gmap,
details->content.urep.u.utf32ch,
details->content.urep.u.utf8str);
}
}
#endif
if (iflags.customcolors) {
if (iflags.customcolors && do_colors) {
if (sc->custtype == custom_nhcolor) {
gmap = &glyphmap[details->content.ccolor.glyphidx];
(void) set_map_nhcolor(gmap,
@@ -1048,10 +1054,10 @@ clear_all_glyphmap_colors(void)
}
}
void reset_customizations(void)
void reset_customcolors(void)
{
clear_all_glyphmap_colors();
apply_customizations(gc.currentgraphics);
apply_customizations(gc.currentgraphics, do_custom_colors);
}
/* not used yet */

View File

@@ -4078,7 +4078,8 @@ optfn_symset(
reslt = handler_symset(optidx);
if (glyphid_cache_status())
free_glyphid_cache();
/* apply_customizations(gc.currentgraphics); */
/* apply_customizations(gc.currentgraphics,
(do_custom_colors | do_custom_symbols)); */
return reslt;
}
return optn_ok;
@@ -5230,7 +5231,10 @@ optfn_boolean(
go.opt_need_glyph_reset = TRUE;
break;
case opt_customcolors:
go.opt_reset_customizations = TRUE;
go.opt_reset_customcolors = TRUE;
break;
case opt_customsymbols:
go.opt_reset_customsymbols = TRUE;
break;
case opt_menucolors:
case opt_guicolor:
@@ -7193,7 +7197,8 @@ initoptions_finish(void)
if (glyphid_cache_status())
free_glyphid_cache();
apply_customizations(gc.currentgraphics);
apply_customizations(gc.currentgraphics,
(do_custom_colors | do_custom_symbols));
go.opt_initial = FALSE;
/*
@@ -8392,7 +8397,8 @@ doset_simple_menu(void)
go.opt_need_redraw = FALSE;
go.opt_need_glyph_reset = FALSE;
go.opt_reset_customizations = FALSE;
go.opt_reset_customcolors = FALSE;
go.opt_reset_customsymbols = FALSE;
pick_cnt = select_menu(tmpwin, PICK_ONE, &pick_list);
/* note: without the complication of a preselected entry, a PICK_ONE
menu returning pick_cnt > 0 implies exactly 1 */
@@ -8483,8 +8489,11 @@ doset_simple(void)
}
if (go.opt_need_promptstyle)
adjust_menu_promptstyle(WIN_INVEN, &iflags.menu_headings);
if (go.opt_reset_customizations) {
reset_customizations();
if (go.opt_reset_customcolors || go.opt_reset_customsymbols) {
if (go.opt_reset_customcolors)
reset_customcolors();
if (go.opt_reset_customsymbols)
reset_customsymbols();
docrt_flags(opt_crt_flags);
}
@@ -8738,13 +8747,16 @@ doset(void) /* changing options via menu by Per Liboriussen */
if (go.opt_need_glyph_reset) {
reset_glyphmap(gm_optionchange);
}
if (go.opt_reset_customizations) {
reset_customizations();
docrt();
}
if (go.opt_need_redraw) {
check_gold_symbol();
reglyph_darkroom();
if (go.opt_reset_customcolors
|| go.opt_reset_customsymbols || go.opt_need_redraw) {
if (go.opt_reset_customcolors)
reset_customcolors();
if (go.opt_reset_customsymbols)
reset_customsymbols();
if (go.opt_need_redraw) {
check_gold_symbol();
reglyph_darkroom();
}
docrt();
}
if (go.opt_need_promptstyle) {

View File

@@ -680,7 +680,8 @@ load_symset(const char *s, int which_set)
if (read_sym_file(which_set)) {
switch_symbols(TRUE);
apply_customizations(gc.currentgraphics);
apply_customizations(gc.currentgraphics,
do_custom_symbols | do_custom_colors);
} else {
clear_symsetentry(which_set, TRUE);
return 0;
@@ -1089,7 +1090,8 @@ do_symset(boolean rogueflag)
assign_graphics(ROGUESET);
} else if (!rogueflag)
assign_graphics(PRIMARYSET);
apply_customizations(rogueflag ? ROGUESET : PRIMARYSET);
apply_customizations(rogueflag ? ROGUESET : PRIMARYSET,
(do_custom_symbols | do_custom_colors));
preference_update("symset");
return TRUE;
}

View File

@@ -208,6 +208,14 @@ add_custom_urep_entry(
}
#endif /* ENHANCED_SYMBOLS */
void reset_customsymbols(void)
{
#ifdef ENHANCED_SYMBOLS
free_all_glyphmap_u();
apply_customizations(gc.currentgraphics, do_custom_symbols);
#endif
}
/* utf8map.c */