--- /dev/null
+The definitition for each OPTIONS= option resides in include/optlish.h as of
+February 2020 in 3.7 WIP.
+
+Boolean and compound options are combined into a single allopt[] array.
+
+To add an option:
+
+ 1. Add an entry to include/optlist.h, using the NHOPTB macro for a
+ boolean on/off option, or NHOPTC macro for a compound option. The
+ list of options is kept in alphabetical order.
+ When the list of options is processed during the compile of options.c,
+ the following will be automatically generated and included in
+ options.c:
+
+ i) an optfn_xxxx function prototype (xxxx is the option name).
+ ii) an opt_xxxx enum value for referencing that option index by
+ name throughout options.c (xxxx is the option name).
+ iii) an initialization of an element in the allopt[] array, at
+ index opt_xxxx from step ii (xxxx is the option name).
+
+ 2. Create the optn_xxxx() function in options.c. Failure to do that will
+ result in a link error of "undefined function xxxx." The functions are
+ in options.c in alphabetical sequence by function name.
+
+ The skeletal template for an optn_xxxx() function is:
+
+ int
+ optfn_xxxx(optidx, req, negated, opts, op)
+ int optidx /* the index of this option opt_xxxx */
+ int req; /* the request ID from core functions */
+ boolean negated; /* will be true if opt was negated */
+ char *opts; /* points to the complete opt string */
+ char *op; /* points to value portion of opt string */
+ {
+ if (req == do_init) {
+ return optn_ok;
+ }
+ if (req == do_set) {
+ /* do option set processing for the option */
+ /* if successful, return optn_ok; */
+ /* if unsuccessful, return optn_err; */
+ }
+ if (req == get_val) {
+ /* return the current val of option in supplied opts buf */
+ if (!opts)
+ return optn_err;
+ Sprintf(opts, "%s", fakefunction to get xxxx value);
+ return optn_ok;
+ }
+ if (req == do_handler) {
+
+ /* this is optional. If the option needs its own
+ special handling after the doset menu, do it here
+ or call a function to do it. The naming convention
+ for such a function in options.c has been
+ handler_xxxx(), but the function does not need to
+ reside in options.c */
+
+ return optn_ok;
+ }
+ return optn_ok;
+ }
+
+ 3. NOTE: If you add (or delete) an option, please update the short
+ options help (option_help()), the long options help (dat/opthelp)
+ and also the Guidebooks.
+
+Here's some information about the req ID's passed to optn_xxxx() functions.
+Each optfn_xxxx() function can be called with a req id of: do_init, do_set,
+do_handler or get_val.
+
+req do_init is called from options_init, and if initialization or memory
+allocation or other initialization for that particular option is needed,
+it can be done in response to the init req
+
+req do_set is called from parseoptions() for each option it encounters
+and the optfn_xxxx() function is expected to react and set the option
+based on the string values that parseoptions() passes to it.
+
+req get_val is passed a buffer from its caller that the optfn_xxxx() is
+expected to fill with the current value of the opton.
+
+req do_handler is called during doset() operations processing in response
+to player selections, most likely from the 'O' option-setting menu. The
+do_handler req is only called for options that were marked as supporting
+do_handler in the option definition in include/optlist.h
&flags.mention_decor)
NHOPTB(mention_walls, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
&flags.mention_walls)
- NHOPTC(menu_deselect_all, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_deselect_all, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"deselect all items in a menu")
- NHOPTC(menu_deselect_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_deselect_page, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"deselect all items on this page of a menu")
- NHOPTC(menu_first_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_first_page, 4, opt_in, set_in_config, No, No, Yes, No, NoAlias,
"jump to the first page in a menu")
NHOPTC(menu_headings, 4, opt_in, set_in_game, No, Yes, No, Yes, NoAlias,
"display style for menu headings")
- NHOPTC(menu_invert_all, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_invert_all, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"invert all items in a menu")
- NHOPTC(menu_invert_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_invert_page, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"invert all items on this page of a menu")
- NHOPTC(menu_last_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_last_page, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"jump to the last page in a menu")
- NHOPTC(menu_next_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_next_page, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"goto the next menu page")
NHOPTB(menu_objsyms, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
&iflags.menu_head_objsym)
NHOPTB(menu_overlay, 0, opt_in, set_in_config, Off, No, No, No, NoAlias,
(boolean *) 0)
#endif
- NHOPTC(menu_previous_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_previous_page, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"goto the previous menu page")
- NHOPTC(menu_search, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_search, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"search for a menu item")
- NHOPTC(menu_select_all, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_select_all, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"select all items in a menu")
- NHOPTC(menu_select_page, 4, opt_in, set_in_config, No, No, No, No, NoAlias,
+ NHOPTC(menu_select_page, 4, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"select all items on this page of a menu")
NHOPTB(menu_tab_sep, 0, opt_in, set_wizonly, Off, Yes, No, No, NoAlias,
&iflags.menu_tab_sep)
static int FDECL(length_without_val, (const char *, int len));
static void NDECL(determine_ambiguities);
static int FDECL(check_misc_menu_command, (char *, char *));
-int FDECL(spcfn_misc_menu_cmd, (int, BOOLEAN_P, BOOLEAN_P, char *, char *));
+int FDECL(spcfn_misc_menu_cmd, (int, int, BOOLEAN_P, char *, char *));
static const char *FDECL(attr2attrname, (int));
static const char * FDECL(msgtype2name, (int));
if (optlen_wo_val < optlen) {
has_val = TRUE;
optlen = optlen_wo_val;
+ } else {
+ has_val = FALSE;
}
for (i = 0; i < OPTCOUNT; ++i) {
}
/*
- * Now call the option's associated function via the
- * function pointer for it in the allopt[] array.
+ * Now call the option's associated function via the function
+ * pointer for it in the allopt[] array, specifying a 'do_set' req.
*/
if (allopt[matchidx].optfn) {
op = string_for_opt(opts, TRUE);
if (g.program_state.in_parseoptions > 0)
g.program_state.in_parseoptions--;
+#if 0
+ /* This specialization shouldn't be needed any longer because each of
+ the individual options is part of the allopts[] list, thus already
+ taken care of in the for-loop above */
if (!got_match) {
int res = check_misc_menu_command(opts, op);
if (res >= 0)
- optresult = spcfn_misc_menu_cmd(res, FALSE, negated, opts, op);
+ optresult = spcfn_misc_menu_cmd(res, do_set, negated, opts, op);
if (optresult == optn_ok)
got_match = TRUE;
}
+#endif
if (!got_match) {
/* Is it a symbol? */
return optn_ok;
}
-#ifdef MAC_GRAPHICS_ENV
int
optfn_MACgraphics(optidx, req, negated, opts, op)
int optidx, req;
char *opts;
char *op;
{
+#if defined(MAC_GRAPHICS_ENV) && defined(BACKWARD_COMPAT)
+ boolean badflag = FALSE;
+
if (req == do_init) {
return optn_ok;
}
if (req == do_set) {
/* "MACgraphics" */
- iflags.MACgraphics = !negated;
+ if (!negated) {
+ if (g.symset[PRIMARY].name) {
+ badflag = TRUE;
+ } else {
+ g.symset[PRIMARY].name = dupstr(fullname);
+ if (!read_sym_file(PRIMARY)) {
+ badflag = TRUE;
+ clear_symsetentry(PRIMARY, TRUE);
+ }
+ }
+ if (badflag) {
+ config_error_add("Failure to load symbol set %s.", fullname);
+ return FALSE;
+ } else {
+ switch_symbols(TRUE);
+ if (!g.opt_initial && Is_rogue_level(&u.uz))
+ assign_graphics(ROGUESET);
+ }
+ }
return optn_ok;
}
if (req == get_val) {
opts[0] = '\0';
return optn_ok;
}
+#else
+ if (req == do_set) {
+ config_error_add("'%s' %s; use 'symset:%s' instead",
+ allopt[optidx].name,
+#ifdef MAC_GRAPHICS_ENV /* implies BACKWARD_COMPAT is not defined */
+ "no longer supported",
+#else
+ "is not supported",
+#endif
+ allopt[optidx].name);
+ }
+#endif
return optn_ok;
}
-#endif
int
optfn_map_mode(optidx, req, negated, opts, op)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
return optn_ok;
}
if (req == do_set) {
- return optn_ok;
+ int res = check_misc_menu_command(opts, op);
+
+ if (res < 0)
+ return optn_err;
+ return spcfn_misc_menu_cmd(res, req, negated, opts, op);
}
if (req == get_val) {
if (!opts)
char *opts;
char *op;
{
- int i;
-
if (req == do_init) {
return optn_ok;
}
if (!allopt[optidx].addr)
return optn_ok; /* silent retreat */
- if (optidx == opt_status_updates)
- i = 1;
-
/* option that must come from config file? */
if (!g.opt_initial && (allopt[optidx].setwhere == set_in_config))
return optn_err;
iflags.wc2_petattr = curses_read_attrs("I");
}
#endif
+ g.opt_need_redraw = TRUE;
break;
case opt_hitpointbar:
if (VIA_WINDOWPORT()) {
}
int spcfn_misc_menu_cmd(midx, req, negated, opts, op)
-int midx, req;
+int midx;
+int req;
boolean negated;
char *opts;
char *op;