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:
@@ -691,8 +691,8 @@ Two things control whether any preference setting appears in the
|
||||
'O' command options menu during the game:
|
||||
1. The option must be marked as being supported by having its
|
||||
bit set in the window_procs wincap or wincap2 mask.
|
||||
2. The option must have its optflag field set to SET_IN_GAME in order
|
||||
to be able to set the option, or marked DISP_IN_GAME if you just
|
||||
2. The option must have its optflag field set to set_in_game in order
|
||||
to be able to set the option, or marked set_gameview if you just
|
||||
want to reveal what the option is set to.
|
||||
Both conditions must be true to be able to see or set the option from
|
||||
within NetHack.
|
||||
@@ -703,8 +703,8 @@ the wc_ options can be altered by calling
|
||||
set_wc_option_mod_status(optmask, status)
|
||||
The default value for the wc2_ options can be altered by calling
|
||||
set_wc2_option_mod_status(optmask, status)
|
||||
In each case, set the option modification status to one of SET_IN_FILE,
|
||||
DISP_IN_GAME, or SET_IN_GAME.
|
||||
In each case, set the option modification status to one of set_in_config,
|
||||
set_gameview, or set_in_game.
|
||||
|
||||
The setting of any wincap or wincap2 option is handled by the NetHack
|
||||
core option processing code. You do not have to provide a parser in
|
||||
@@ -874,7 +874,7 @@ the option's bit in the port's wincap mask. The port can choose to adjust
|
||||
for the change to an option that it receives notification about, or ignore it.
|
||||
The former approach is recommended. If you don't want to deal with a
|
||||
user-initiated setting change, then the port should call
|
||||
set_wc_option_mod_status(mask, SET_IN_FILE) to make the option invisible to
|
||||
set_wc_option_mod_status(mask, set_in_config) to make the option invisible to
|
||||
the user.
|
||||
|
||||
Functions available for the window port to call:
|
||||
@@ -883,16 +883,16 @@ set_wc_option_mod_status(optmask, status)
|
||||
-- Adjust the optflag field for a set of wincap options to
|
||||
specify whether the port wants the option to appear
|
||||
in the 'O' command options menu, The second parameter,
|
||||
"status" can be set to SET_IN_FILE, DISP_IN_GAME,
|
||||
or SET_IN_GAME (SET_IN_FILE implies that the option
|
||||
"status" can be set to set_in_config, set_gameview,
|
||||
or set_in_game (set_in_config implies that the option
|
||||
is completely hidden during the game).
|
||||
|
||||
set_wc2_option_mod_status(optmask, status)
|
||||
-- Adjust the optflag field for a set of wincap2 options to
|
||||
specify whether the port wants the option to appear
|
||||
in the 'O' command options menu, The second parameter,
|
||||
"status" can be set to SET_IN_FILE, DISP_IN_GAME,
|
||||
or SET_IN_GAME (SET_IN_FILE implies that the option
|
||||
"status" can be set to set_in_config, set_gameview,
|
||||
or set_in_game (set_in_config implies that the option
|
||||
is completely hidden during the game).
|
||||
|
||||
set_option_mod_status(optnam, status)
|
||||
|
||||
Reference in New Issue
Block a user