February 2020 options.c overhaul
combine boolean and compound options into a single allopt[] array for
processing in options.c.
move the definitions of the options into new include/optlist.h file which
uses a set of macros to define them appropriately.
during compile of options.c each option described in include/optlist.h:
1. automatically results in a function prototype for an optfn called
optfn_xxxx (xxxx is the option name).
2. automatically results in an opt_xxxx enum value for referencing
its index throughout options.c (xxxx is the option name).
3. is used to initialize an element of the allopt[] array at index
opt_xxxx (xxxx is the option name) based on the settings in the
NHOPTB, NHOPTC, NHOPTP macros. Those macros only live during the
compilation of include/optlist.h.
each optfn_xxxx() function can be called with a req id of: do_init, do_set,
get_val or do_handler.
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 expects each optfn_xxxx() function to write the current
option value into the buffer it is passed.
req do_handler is called during doset() operations in response to player
selections most likely from the 'O' option-setting menu, but only if the
option is identified as having do_handler support in the allopts[]
'has_handler' boolean flag. Not every optfn_xxxx() does.
function special_handling() is eliminated. It's code has been redistributed
to individual handler functions for the option or purpose that they serve.
moved reglyph_darkroom() function from options.c to display.c
This commit is contained in:
@@ -1492,8 +1492,8 @@ char **argv;
|
||||
window_list[i].type = NHW_NONE;
|
||||
|
||||
/* add another option that can be set */
|
||||
set_wc_option_mod_status(WC_TILED_MAP, SET_IN_GAME);
|
||||
set_option_mod_status("mouse_support", SET_IN_GAME);
|
||||
set_wc_option_mod_status(WC_TILED_MAP, set_in_game);
|
||||
set_option_mod_status("mouse_support", set_in_game);
|
||||
|
||||
load_default_resources(); /* create default_resource_data[] */
|
||||
|
||||
|
||||
@@ -778,11 +778,11 @@ curses_character_dialog(const char **choices, const char *prompt)
|
||||
void
|
||||
curses_init_options()
|
||||
{
|
||||
/* change these from DISP_IN_GAME to SET_IN_GAME */
|
||||
set_wc_option_mod_status(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS, SET_IN_GAME);
|
||||
/* change these from set_gameview to set_in_game */
|
||||
set_wc_option_mod_status(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS, set_in_game);
|
||||
|
||||
/* Remove a few options that are irrelevant to this windowport */
|
||||
set_option_mod_status("eight_bit_tty", SET_IN_FILE);
|
||||
set_option_mod_status("eight_bit_tty", set_in_config);
|
||||
|
||||
/* If we don't have a symset defined, load the curses symset by default */
|
||||
if (!g.symset[PRIMARY].explicitly)
|
||||
|
||||
@@ -162,15 +162,15 @@ curses_init_nhwindows(int *argcp UNUSED,
|
||||
curses_init_nhcolors();
|
||||
} else {
|
||||
iflags.use_color = FALSE;
|
||||
set_option_mod_status("color", SET_IN_FILE);
|
||||
set_option_mod_status("color", set_in_config);
|
||||
iflags.wc2_guicolor = FALSE;
|
||||
set_wc2_option_mod_status(WC2_GUICOLOR, SET_IN_FILE);
|
||||
set_wc2_option_mod_status(WC2_GUICOLOR, set_in_config);
|
||||
}
|
||||
#else
|
||||
iflags.use_color = FALSE;
|
||||
set_option_mod_status("color", SET_IN_FILE);
|
||||
set_option_mod_status("color", set_in_config);
|
||||
iflags.wc2_guicolor = FALSE;
|
||||
set_wc2_option_mod_status(WC2_GUICOLOR, SET_IN_FILE);
|
||||
set_wc2_option_mod_status(WC2_GUICOLOR, set_in_config);
|
||||
#endif
|
||||
noecho();
|
||||
raw();
|
||||
|
||||
@@ -159,7 +159,7 @@ char **argv;
|
||||
| WC_FONT_STATUS | WC_FONT_MENU | WC_FONT_TEXT
|
||||
| WC_FONTSIZ_MESSAGE | WC_FONTSIZ_MAP | WC_FONTSIZ_STATUS
|
||||
| WC_FONTSIZ_MENU | WC_FONTSIZ_TEXT | WC_VARY_MSGCOUNT,
|
||||
SET_IN_GAME);
|
||||
set_in_game);
|
||||
if (iflags.wc_align_message == 0)
|
||||
iflags.wc_align_message = ALIGN_TOP;
|
||||
if (iflags.wc_align_status == 0)
|
||||
|
||||
@@ -440,14 +440,14 @@ char **argv UNUSED;
|
||||
tty_putstr(BASE_WINDOW, 0, "");
|
||||
tty_display_nhwindow(BASE_WINDOW, FALSE);
|
||||
|
||||
/* 'statuslines' defaults to SET_IN_FILE, allowed but invisible;
|
||||
/* 'statuslines' defaults to set_in_config, allowed but invisible;
|
||||
make it dynamically settable if feasible, otherwise visible */
|
||||
if (tty_procs.wincap2 & WC2_STATUSLINES)
|
||||
set_wc2_option_mod_status(WC2_STATUSLINES,
|
||||
#ifndef CLIPPING
|
||||
(LI < 1 + ROWNO + 2) ? DISP_IN_GAME :
|
||||
#endif
|
||||
SET_IN_GAME);
|
||||
set_in_game);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -213,16 +213,16 @@ mswin_init_nhwindows(int *argc, char **argv)
|
||||
* non-console applications
|
||||
*/
|
||||
iflags.toptenwin = 1;
|
||||
set_option_mod_status("toptenwin", SET_IN_FILE);
|
||||
//set_option_mod_status("perm_invent", SET_IN_FILE);
|
||||
set_option_mod_status("mouse_support", SET_IN_GAME);
|
||||
set_option_mod_status("toptenwin", set_in_config);
|
||||
//set_option_mod_status("perm_invent", set_in_config);
|
||||
set_option_mod_status("mouse_support", set_in_game);
|
||||
|
||||
/* initialize map tiles bitmap */
|
||||
initMapTiles();
|
||||
|
||||
/* set tile-related options to readonly */
|
||||
set_wc_option_mod_status(WC_TILE_WIDTH | WC_TILE_HEIGHT | WC_TILE_FILE,
|
||||
DISP_IN_GAME);
|
||||
set_gameview);
|
||||
|
||||
/* set font-related options to change in the game */
|
||||
set_wc_option_mod_status(
|
||||
@@ -231,7 +231,7 @@ mswin_init_nhwindows(int *argc, char **argv)
|
||||
| WC_FONT_STATUS | WC_FONT_MENU | WC_FONT_TEXT
|
||||
| WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS | WC_FONTSIZ_MENU
|
||||
| WC_FONTSIZ_TEXT | WC_VARY_MSGCOUNT,
|
||||
SET_IN_GAME);
|
||||
set_in_game);
|
||||
|
||||
mswin_color_from_string(iflags.wc_foregrnd_menu, &menu_fg_brush,
|
||||
&menu_fg_color);
|
||||
|
||||
Reference in New Issue
Block a user