centralize the invert decision logic to avoid updates to 7 ports

This will make it easier to tinker for best results.
This commit is contained in:
nhmall
2019-12-23 21:44:34 -05:00
parent 8eca3a99ab
commit a034e8200c
10 changed files with 61 additions and 10 deletions

View File

@@ -438,4 +438,26 @@ const char *str;
putstr(window, attr, decode_mixed(buf, str));
}
/*
* Window port helper function for menu invert routines to move the decision
* logic into one place instead of 7 different window-port routines.
*/
boolean
menuitem_invert_test(mode, itemflags, is_selected)
int mode;
unsigned itemflags; /* The itemflags for the item */
boolean is_selected; /* The current selection status of the item */
{
boolean skipinvert = (itemflags & MENU_ITEMFLAGS_SKIPINVERT) != 0;
if ((iflags.menuinvertmode == 1 || iflags.menuinvertmode == 2)
&& !mode && skipinvert && !is_selected)
return FALSE;
else if (iflags.menuinvertmode == 2
&& !mode && skipinvert && is_selected)
return TRUE;
else
return TRUE;
}
/*mapglyph.c*/

View File

@@ -311,6 +311,7 @@ static struct Comp_Opt {
{ "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
PL_PSIZ, DISP_IN_GAME },
{ "map_mode", "map display mode under Windows", 20, DISP_IN_GAME }, /*WC*/
{ "menuinvertmode", "behaviour of menu iverts", 5, SET_IN_GAME },
{ "menustyle", "user interface for object selection", MENUTYPELEN,
SET_IN_GAME },
{ "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE },
@@ -2362,6 +2363,24 @@ boolean tinitial, tfrom_file;
return retval;
}
/* menuinvertmode=0 or 1 or 2 (2 is experimental) */
fullname = "menuinvertmode";
if (match_optname(opts, fullname, 5, TRUE)) {
if (negated) {
bad_negation(fullname, FALSE);
return FALSE;
} else {
int mode = atoi(op);
if (mode < 0 || mode > 2) {
config_error_add("Illegal %s parameter '%s'", fullname, op);
return FALSE;
}
iflags.menuinvertmode = mode;
}
return retval;
}
fullname = "msghistory";
if (match_optname(opts, fullname, 3, TRUE)) {
if (duplicate)
@@ -5614,7 +5633,9 @@ char *buf;
: (i == MAP_MODE_ASCII_FIT_TO_SCREEN)
? "fit_to_screen"
: defopt);
} else if (!strcmp(optname, "menustyle"))
} else if (!strcmp(optname, "menuinvertmode"))
Sprintf(buf, "%d", iflags.menuinvertmode);
else if (!strcmp(optname, "menustyle"))
Sprintf(buf, "%s", menutype[(int) flags.menu_style]);
else if (!strcmp(optname, "menu_deselect_all"))
Sprintf(buf, "%s", to_be_done);