diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-31 01:07:33 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-31 01:07:33 +0000 |
commit | 51cf2e590f33e894236ab640f2ffa58aff3a92ec (patch) | |
tree | a4867edae9afa6041faf53de9fe32ccfc066fd1e /crawl-ref/source | |
parent | c6f2e85b44fe574cff0a59607fe1b5a366954b62 (diff) | |
download | crawl-ref-51cf2e590f33e894236ab640f2ffa58aff3a92ec.tar.gz crawl-ref-51cf2e590f33e894236ab640f2ffa58aff3a92ec.zip |
drop_filter can now match against the same keywords as menu_colour, minus the
identification status and chunk/corpse information.
drop_filter now defaults to useless_item
You can prevent an init file variable from being changed by turning it into a
constant.
Clear variables and aliases when resetting the game options.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8043 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/externs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 24 | ||||
-rw-r--r-- | crawl-ref/source/invent.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/invent.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/itemname.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/menu.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/menu.h | 5 |
8 files changed, 63 insertions, 6 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 41885c7f7a..97c91451fb 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -2221,6 +2221,7 @@ private: typedef std::map<std::string, std::string> string_map; string_map aliases; string_map variables; + std::set<std::string> constants; // Variables that can't be changed std::set<std::string> included; // Files we've included already. public: diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index bbd6dcdc4f..5032753e8b 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -933,6 +933,11 @@ void game_options::reset_options() // Forget any files we remembered as included. included.clear(); + + // Forget variables and such. + aliases.clear(); + variables.clear(); + constants.clear(); } void game_options::clear_cset_overrides() @@ -1561,7 +1566,13 @@ int game_options::read_explore_stop_conditions(const std::string &field) const void game_options::add_alias(const std::string &key, const std::string &val) { if (key[0] == '$') - variables[key.substr(1)] = val; + { + std::string name = key.substr(1); + // Don't alter if it's a constant. + if (constants.find(name) != constants.end()) + return; + variables[name] = val; + } else aliases[key] = val; } @@ -3043,6 +3054,17 @@ void game_options::read_option_line(const std::string &str, bool runscript) { _bindkey(field); } + else if (key == "constant") + { + if (variables.find(field) == variables.end()) + report_error(make_stringf("No variable named '%s' to make " + "constant", field.c_str())); + else if (constants.find(field) != constants.end()) + report_error(make_stringf("'%s' is already a constant", + field.c_str())); + else + constants.insert(field); + } // Catch-all else, copies option into map else if (runscript) diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index d91d2512b7..fa03f8b291 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -173,6 +173,11 @@ void InvEntry::select(int qty) MenuEntry::select(qty); } +std::string InvEntry::get_filter_text() const +{ + return (filtering_item_prefix(*item) + " " + get_text()); +} + std::string InvEntry::get_text() const { std::ostringstream tstr; diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h index 844cbeadf6..079d15ff1e 100644 --- a/crawl-ref/source/invent.h +++ b/crawl-ref/source/invent.h @@ -99,6 +99,8 @@ public: virtual void select( int qty = -1 ); + virtual std::string get_filter_text() const; + #ifdef USE_TILE virtual bool tile(int &tile, TextureID &tex) const; #endif diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 58356b012e..99554a5023 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -2508,11 +2508,16 @@ bool is_useless_item(const item_def &item, bool temp) } } -const std::string menu_colour_item_prefix(const item_def &item, bool temp) +static const std::string _item_prefix(const item_def &item, bool temp, + bool filter) { std::vector<std::string> prefixes; - if (item_ident(item, ISFLAG_KNOW_TYPE)) + // No identified/unidentified for filtering, since the user might + // want to filter on "ident" to find scrolls of identify. + if (filter) + ; + else if (item_ident(item, ISFLAG_KNOW_TYPE)) prefixes.push_back("identified"); else { @@ -2584,7 +2589,12 @@ const std::string menu_colour_item_prefix(const item_def &item, bool temp) else if (is_preferred_food(item)) prefixes.push_back("preferred"); - if (is_poisonous(item)) + // Don't include these for filtering, since the user might want + // to use "muta" to search for "potion of cure mutation", and + // similar. + if (filter) + ; + else if (is_poisonous(item)) prefixes.push_back("poisonous"); else if (is_mutagenic(item)) prefixes.push_back("mutagenic"); @@ -2622,7 +2632,7 @@ const std::string menu_colour_item_prefix(const item_def &item, bool temp) break; } - if (Options.menu_colour_prefix_class) + if (Options.menu_colour_prefix_class && !filter) prefixes.push_back(item_class_name(item.base_type, true)); std::string result = comma_separated_line(prefixes.begin(), prefixes.end(), @@ -2631,6 +2641,16 @@ const std::string menu_colour_item_prefix(const item_def &item, bool temp) return result; } +const std::string menu_colour_item_prefix(const item_def &item, bool temp) +{ + return _item_prefix(item, temp, false); +} + +const std::string filtering_item_prefix(const item_def &item, bool temp) +{ + return _item_prefix(item, temp, true); +} + const std::string get_menu_colour_prefix_tags(item_def &item, description_level_type desc) { diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h index baab01e6b7..d735708246 100644 --- a/crawl-ref/source/itemname.h +++ b/crawl-ref/source/itemname.h @@ -128,6 +128,8 @@ void set_ident_type( object_class_type basetype, int subtype, * *********************************************************************** */ const std::string menu_colour_item_prefix(const item_def &item, bool temp = true); +const std::string filtering_item_prefix(const item_def &item, + bool temp = true); const std::string get_menu_colour_prefix_tags(item_def &item, description_level_type desc); const std::string get_message_colour_tags(item_def &item, diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 74507803e2..6daa92f940 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -675,7 +675,7 @@ bool Menu::is_selectable(int item) const if (select_filter.empty()) return (true); - std::string text = items[item]->get_text(); + std::string text = items[item]->get_filter_text(); for (int i = 0, count = select_filter.size(); i < count; ++i) { if (select_filter[i].matches(text)) diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h index 407c41210e..9ddc336e65 100644 --- a/crawl-ref/source/menu.h +++ b/crawl-ref/source/menu.h @@ -138,6 +138,11 @@ struct MenuEntry selected_qty = (qty == -1? quantity : qty); } + virtual std::string get_filter_text() const + { + return get_text(); + } + #ifdef USE_TILE virtual bool tile(int &idx, TextureID &tex) const { |