summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/command.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-25 11:13:18 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-25 11:13:18 +0000
commit137d900672cf15df2d5f3cf5988aff20d33620f7 (patch)
treeee5e26fe0d672f0cfa3c1faf5a4fda4d31ff5840 /crawl-ref/source/command.cc
parentc5ab08484a85c0f7f25bd8199d0e1c688e08eba3 (diff)
downloadcrawl-ref-137d900672cf15df2d5f3cf5988aff20d33620f7.tar.gz
crawl-ref-137d900672cf15df2d5f3cf5988aff20d33620f7.zip
[1801838] Use a menu to show mutation list so long lists don't scroll off the end of the terminal.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3331 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/command.cc')
-rw-r--r--crawl-ref/source/command.cc44
1 files changed, 42 insertions, 2 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index c8ef7a641b..d94af8de8d 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1318,19 +1318,58 @@ static int keyhelp_keyfilter(int ch)
return ch;
}
+///////////////////////////////////////////////////////////////////////////
+// Manual menu highlighter.
+
+class help_highlighter : public MenuHighlighter
+{
+public:
+ help_highlighter();
+ int entry_colour(const MenuEntry *entry) const;
+private:
+ text_pattern pattern;
+ std::string get_species_key() const;
+};
+
+help_highlighter::help_highlighter()
+ : pattern(get_species_key())
+{
+}
+
+int help_highlighter::entry_colour(const MenuEntry *entry) const
+{
+ return !pattern.empty() && pattern.matches(entry->text)? WHITE : -1;
+}
+
+// to highlight species in aptitudes list ('?%')
+std::string help_highlighter::get_species_key() const
+{
+ if (player_genus(GENPC_DRACONIAN) && you.experience_level < 7)
+ return "";
+
+ std::string result = species_name(you.species, you.experience_level);
+ if (player_genus(GENPC_DRACONIAN))
+ strip_tag(result,
+ species_name(you.species, you.experience_level, true));
+
+ result += " ";
+ return (result);
+}
+////////////////////////////////////////////////////////////////////////////
+
static void show_keyhelp_menu(const std::vector<formatted_string> &lines,
bool with_manual, bool easy_exit = false,
int hotkey = 0)
{
formatted_scroller cmd_help;
-
+
// Set flags, and use easy exit if necessary.
int flags = MF_NOSELECT | MF_ALWAYS_SHOW_MORE | MF_NOWRAP;
if (easy_exit)
flags |= MF_EASY_EXIT;
cmd_help.set_flags(flags, false);
cmd_help.set_tag("help");
-
+
// FIXME: Allow for hiding Page down when at the end of the listing, ditto
// for page up at start of listing.
cmd_help.set_more( formatted_string::parse_string(
@@ -1339,6 +1378,7 @@ static void show_keyhelp_menu(const std::vector<formatted_string> &lines,
if ( with_manual )
{
+ cmd_help.set_highlighter(new help_highlighter);
cmd_help.f_keyfilter = keyhelp_keyfilter;
column_composer cols(2, 40);