summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-11-22 18:17:58 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-11-22 18:17:58 +0000
commit5f1be66956e19f339f4baef51bb11fef105a127f (patch)
treebc080f09d9493d53814b6dfdc28d02abef9f6d9f /crawl-ref/source/initfile.cc
parent83d3cb73a826d442277adf0814e3440fd9e70cae (diff)
downloadcrawl-ref-5f1be66956e19f339f4baef51bb11fef105a127f.tar.gz
crawl-ref-5f1be66956e19f339f4baef51bb11fef105a127f.zip
Implemented 1601230: sort_menus can now be of the form auto:5 (the default),
in which case categories with >= 5 items will be sorted. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@476 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r--crawl-ref/source/initfile.cc25
1 files changed, 23 insertions, 2 deletions
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")
{