diff options
-rw-r--r-- | crawl-ref/docs/crawl_options.txt | 24 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/macro.cc | 24 |
4 files changed, 41 insertions, 16 deletions
diff --git a/crawl-ref/docs/crawl_options.txt b/crawl-ref/docs/crawl_options.txt index dc8b997a39..d9cda57df2 100644 --- a/crawl-ref/docs/crawl_options.txt +++ b/crawl-ref/docs/crawl_options.txt @@ -73,7 +73,8 @@ The contents of this text are: 4-m Inscriptions. autoinscribe 4-n Macro related Options. - flush.failure, flush.command, flush.message + flush.failure, flush.command, flush.message, + macro_meta_entry, additional_macro_file 4-o Tiles Options. show_items, title_screen, tile_player_col, tile_monster_col, tile_friendly_col, tile_item_col, @@ -92,9 +93,10 @@ The contents of this text are: note_messages 6- Miscellaneous. 6-a All OS. - macro_meta_entry, mouse_input, wiz_mode, use_ascii, - classic_item_colours, colours, char_set, cset_ascii, - cset_ibm, cset_dec, cset_unicode, feature, mon_glyph + mouse_input, wiz_mode, use_ascii, classic_item_colours, + colours, char_set, cset_ascii, cset_ibm, cset_dec, + cset_unicode, feature, mon_glyph + 6-b DOS and Windows. dos_use_background_intensity 6-c Unix. @@ -1252,6 +1254,15 @@ flush.message = false command -- whenever the game is about to get the next command message -- whenever the game outputs a non-mute message +macro_meta_entry = true + macro_meta_entry lets you specify non-printable keycodes like + \{3} when creating a macro. For instance, if you want to keymap + 0 to Escape, you'd use a target keycode of \{27}. + +additional_macro_file = path/to/filename + Add an additional macro file to be loaded after macro.txt. + You can have multiple additional_macro_file lines. + 4-o Tiles Options. ---------------------- In non-tile games the tile options are ignored. @@ -1454,11 +1465,6 @@ note_messages = <regex list> 6-a All OS. --------------- -macro_meta_entry = true - macro_meta_entry lets you specify non-printable keycodes like - \{3} when creating a macro. For instance, if you want to keymap - 0 to Escape, you'd use a target keycode of \{27}. - mouse_input = false When enabled, the mouse_input option allows the game to use mouse input events on certain platforms (Windows and Unix). diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 2e98e3fc99..2fb110a339 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1524,6 +1524,7 @@ public: std::string macro_dir; // Directory containing macro.txt std::string morgue_dir; // Directory where character dumps and morgue // dumps are saved. Overrides crawl_dir. + std::vector<std::string> additional_macro_files; std::string player_name; diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 22fb404cfc..805d9d4312 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -598,6 +598,7 @@ void game_options::reset_options() #if !defined(SHORT_FILE_NAMES) && !defined(SAVE_DIR_PATH) morgue_dir = "morgue/"; #endif + additional_macro_files.clear(); player_name.clear(); @@ -1614,7 +1615,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) trim_string( field ); // Keep unlowercased field around - std::string orig_field = field; + const std::string orig_field = field; if (key != "name" && key != "crawl_dir" && key != "race" && key != "class" && key != "ban_pickup" @@ -2696,7 +2697,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) else pickup_mode = read_bool_or_number(field, pickup_mode, "auto:"); } - + else if (key == "additional_macro_file") + { + additional_macro_files.push_back(orig_field); + } #ifdef USE_TILE else if (key == "show_items") { diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 94b640db2b..29a2c7b242 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -825,11 +825,10 @@ void macro_add_query( void ) redraw_screen(); } - /* * Initializes the macros. */ -int macro_init( void ) +static void _read_macros_from(const char* filename) { std::string s; std::ifstream f; @@ -837,7 +836,7 @@ int macro_init( void ) bool keymap = false; KeymapContext keymc = KC_DEFAULT; - f.open( get_macro_file().c_str() ); + f.open( filename ); while (f >> s) { @@ -867,10 +866,25 @@ int macro_init( void ) macro_add( (keymap ? Keymaps[keymc] : Macros), key, action ); } } - - return (0); } +int macro_init( void ) +{ + _read_macros_from(get_macro_file().c_str()); + + const std::vector<std::string>& files = Options.additional_macro_files; + for (std::vector<std::string>::const_iterator it = files.begin(); + it != files.end(); + ++it) + { + _read_macros_from(it->c_str()); + } + + + return 0; +} + + void macro_userfn(const char *keys, const char *regname) { // TODO: Implement. |