some options handling cleanup

Hide 'altkeyhandling' from the 'O' menu for !WIN32 builds.  If
present in run-time config file it will be parsed and then ignored.

Instead of showing "unknown" for the value of the 'hilite_status'
compound option, show "none" if there are no highlighting rules, or
a pointer to other option "status highlight rules" when there are.

Deal with a few function parameters that are used for some
combination of build-time config settings and unused for others.
This commit is contained in:
PatR
2022-04-06 12:08:58 -07:00
parent 6d490de39c
commit 9da36fb03e
2 changed files with 51 additions and 16 deletions

View File

@@ -96,8 +96,13 @@ opt_##a,
"message window alignment")
NHOPTC(align_status, 20, opt_in, set_gameview, No, Yes, No, Yes, NoAlias,
"status window alignment")
#ifdef WIN32
NHOPTC(altkeyhandling, 20, opt_in, set_in_game, No, Yes, No, Yes,
"altkeyhandler", "alternative key handling")
#else
NHOPTC(altkeyhandling, 20, opt_in, set_in_config, No, Yes, No, Yes,
"altkeyhandler", "(not applicable)")
#endif
#ifdef ALTMETA
NHOPTB(altmeta, 0, opt_out, set_in_game, Off, Yes, No, No, NoAlias,
&iflags.altmeta)
@@ -229,6 +234,9 @@ opt_##a,
#ifdef STATUS_HILITES
NHOPTC(hilite_status, 13, opt_out, set_in_game, Yes, Yes, Yes, No, NoAlias,
"a status highlighting rule (can occur multiple times)")
#else
NHOPTC(hilite_status, 13, opt_out, set_in_config, Yes, Yes, Yes, No,
NoAlias, "(not available)")
#endif
NHOPTB(hitpointbar, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
&iflags.wc2_hitpointbar)

View File

@@ -667,8 +667,12 @@ optfn_align_status(int optidx, int req, boolean negated, char *opts, char *op)
}
static int
optfn_altkeyhandling(int optidx UNUSED, int req, boolean negated UNUSED,
char *opts, char *op UNUSED)
optfn_altkeyhandling(
int optidx UNUSED,
int req,
boolean negated,
char *opts,
char *op)
{
if (req == do_init) {
return optn_ok;
@@ -677,11 +681,12 @@ optfn_altkeyhandling(int optidx UNUSED, int req, boolean negated UNUSED,
/* altkeyhandling:string */
#if defined(WIN32) && defined(TTY_GRAPHICS)
if (op != empty_optstr) {
set_altkeyhandling(op);
} else {
if (op == empty_optstr || negated)
return optn_err;
}
set_altkeyhandling(op);
#else
nhUse(negated);
nhUse(op);
#endif
return optn_ok;
}
@@ -1276,8 +1281,12 @@ optfn_gender(int optidx, int req, boolean negated, char *opts, char *op)
}
static int
optfn_hilite_status(int optidx UNUSED, int req, boolean negated,
char *opts, char *op)
optfn_hilite_status(
int optidx UNUSED,
int req,
boolean negated,
char *opts,
char *op)
{
if (req == do_init) {
return optn_ok;
@@ -1297,6 +1306,8 @@ optfn_hilite_status(int optidx UNUSED, int req, boolean negated,
return optn_err;
return optn_ok;
#else
nhUse(negated);
nhUse(op);
config_error_add("'%s' is not supported", allopt[optidx].name);
return optn_err;
#endif
@@ -1304,7 +1315,13 @@ optfn_hilite_status(int optidx UNUSED, int req, boolean negated,
if (req == get_val) {
if (!opts)
return optn_err;
#ifdef STATUS_HILITES
Strcpy(opts, count_status_hilites()
? "(see \"status highlight rules\" below)"
: "(none)");
#else
opts[0] = '\0';
#endif
return optn_ok;
}
return optn_ok;
@@ -3028,23 +3045,27 @@ optfn_sortloot(int optidx, int req, boolean negated UNUSED,
}
static int
optfn_statushilites(int optidx UNUSED, int req, boolean negated,
char *opts, char *op)
optfn_statushilites(
int optidx UNUSED,
int req,
boolean negated,
char *opts,
char *op)
{
if (req == do_init) {
return optn_ok;
}
if (req == do_set) {
/* control over whether highlights should be displayed, and for
* how long */
/* control over whether highlights should be displayed (non-zero), and
also for how long to show temporary ones (N turns; default 3) */
#ifdef STATUS_HILITES
if (negated) {
iflags.hilite_delta = 0L;
} else {
op = string_for_opt(opts, TRUE);
iflags.hilite_delta =
(op == empty_optstr || !*op) ? 3L : atol(op);
iflags.hilite_delta = (op == empty_optstr || !*op) ? 3L
: atol(op);
if (iflags.hilite_delta < 0L)
iflags.hilite_delta = 1L;
}
@@ -3052,6 +3073,8 @@ optfn_statushilites(int optidx UNUSED, int req, boolean negated,
reset_status_hilites();
return optn_ok;
#else
nhUse(negated);
nhUse(op);
config_error_add("'%s' is not supported", allopt[optidx].name);
return optn_err;
#endif
@@ -7328,8 +7351,12 @@ optfn_o_status_cond(int optidx UNUSED, int req, boolean negated UNUSED,
#ifdef STATUS_HILITES
static int
optfn_o_status_hilites(int optidx UNUSED, int req, boolean negated UNUSED,
char *opts, char *op UNUSED)
optfn_o_status_hilites(
int optidx UNUSED,
int req,
boolean negated UNUSED,
char *opts,
char *op UNUSED)
{
if (req == do_init) {
return optn_ok;