diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/clua.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 25 | ||||
-rw-r--r-- | crawl-ref/source/invent.cc | 3 |
4 files changed, 27 insertions, 5 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 9885fc05d3..18d0a92af2 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1894,7 +1894,6 @@ static option_handler handlers[] = option_hboolean }, { "pickup_thrown", &Options.pickup_thrown, option_hboolean }, { "pickup_dropped", &Options.pickup_dropped, option_hboolean }, - { "sort_menus", &Options.sort_menus, option_hboolean }, { "show_waypoints", &Options.show_waypoints, option_hboolean }, { "item_colour", &Options.item_colour, option_hboolean }, { "target_zero_exp", &Options.target_zero_exp, option_hboolean }, diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 51288baa43..7ff9054ed6 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -813,7 +813,8 @@ public: std::vector<sound_mapping> sound_mappings; std::vector<colour_mapping> menu_colour_mappings; - bool sort_menus; + int sort_menus; // 0 = always, -1 = never, number = beyond + // that size. int dump_kill_places; // How to dump place information for kills. int dump_message_count; // How many old messages to dump diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index a797100754..61e05b9aa6 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -322,6 +322,27 @@ static bool read_bool( const std::string &field, bool def_value ) return (ret); } +// read a value which can be either a boolean (in which case return +// 0 for true, -1 for false), or a string of the form PREFIX:NUMBER +// (e.g., auto:7), in which case return NUMBER as an int. +static int read_bool_or_number( const std::string &field, int def_value, + const std::string& num_prefix) +{ + int ret = def_value; + + if (field == "true" || field == "1" || field == "yes") + ret = 0; + + if (field == "false" || field == "0" || field == "no") + ret = -1; + + if ( field.find(num_prefix) == 0 ) + ret = atoi(field.c_str() + num_prefix.size()); + + return (ret); +} + + static unsigned curses_attribute(const std::string &field) { if (field == "standout") // probably reverses @@ -547,7 +568,7 @@ void game_options::reset_options() travel_stair_cost = 500; travel_exclude_radius2 = 68; - sort_menus = false; + sort_menus = 5; tc_reachable = BLUE; tc_excluded = LIGHTMAGENTA; @@ -1643,7 +1664,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) #endif // WIZARD else if (key == "sort_menus") { - sort_menus = read_bool(field, sort_menus); + sort_menus = read_bool_or_number(field, sort_menus, "auto:"); } else if (key == "travel_delay") { diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index f8545bb11c..8302728722 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -291,7 +291,8 @@ void InvMenu::load_items(const std::vector<const item_def*> &mitems, items_in_class.push_back( new InvEntry(*mitems[j]) ); } - if (Options.sort_menus) + if (Options.sort_menus != -1 && + (int)items_in_class.size() >= Options.sort_menus) std::sort( items_in_class.begin(), items_in_class.end(), compare_menu_entries ); |