generic feature_toggle
This adds a generic feature_toggle mechanism to the game. Code that wants to offer two different ways of doing something can add an entry to feature_toggles[] (in decl.c), and create a preprocessor macro for its array index in decl.h. Then the code can test it using if (feature_toggle(FEATURE_NAME)) ..do_this.. else ..do_that.. The player can toggle the alternate code path on using OPTIONS=feature_toggle:feature_name_1 feature_name_2 ... This seems better than creating brand new options for controlling features (ala prayconfirm, which could switch to this single option feature_toggle mechanism as well) My first use of it is to allow toggling of the selectors on the loot menu, which I'm hesitant to just change back because now people are actively using the new selectors and the complaints would be really loud if the interface were to just switch back after they adjusted. The default behaviour is the new behaviour "iob", but with an OPTIONS=feature_toggle:loot_menu_selectors in your config file, it will revert to using "abc" as it did in 3.3.1. I'll add a Guidebook page of "features/behaviour that can be toggled" later. The toggles can only be done in defaults.nh, and are not saved with the game.
This commit is contained in:
@@ -370,6 +370,28 @@ E char *fqn_prefix[PREFIX_COUNT];
|
||||
E char *fqn_prefix_names[PREFIX_COUNT];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Feature toggles
|
||||
*
|
||||
* The following provide a way to offer two different
|
||||
* behaviours for a game interface feature, and allow
|
||||
* the player to toggle the alternate behaviour on.
|
||||
* The feature_name fields stored in the feature_toggles[]
|
||||
* array can be specified in an OPTIONS=feature_toggle:value1 value2
|
||||
* statement in the config file.
|
||||
*/
|
||||
|
||||
E unsigned long toggled_features;
|
||||
|
||||
E struct features_that_toggle {
|
||||
char *feature_name;
|
||||
unsigned long feature_bit;
|
||||
} feature_toggles[];
|
||||
|
||||
#define TOGGLE_INVALID 0
|
||||
#define TOGGLE_LOOT_MENU_SELECTORS 1 /* index in feature_toogle_list[] */
|
||||
#define LAST_FEATURE_TOGGLE 1
|
||||
|
||||
#undef E
|
||||
|
||||
#endif /* DECL_H */
|
||||
|
||||
@@ -1353,6 +1353,7 @@ E char *FDECL(nh_getenv, (const char *));
|
||||
E void FDECL(set_duplicate_opt_detection, (int));
|
||||
E void FDECL(set_wc_option_mod_status, (unsigned long, int));
|
||||
E void FDECL(set_option_mod_status, (char *, int));
|
||||
E boolean FDECL(feature_toggle, (int));
|
||||
|
||||
/* ### pager.c ### */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user