summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/abl-show.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-11 20:01:06 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-11 20:01:06 +0000
commit4c540e1c4e99150305b9c5297928ed1794cec13c (patch)
tree3ce5ba4f11d96ba590256bdd446ae8204091a0a7 /crawl-ref/source/abl-show.cc
parentf792f9b19c0dcdbe4166ad0dc543f704822bfa29 (diff)
downloadcrawl-ref-4c540e1c4e99150305b9c5297928ed1794cec13c.tar.gz
crawl-ref-4c540e1c4e99150305b9c5297928ed1794cec13c.zip
Generalize the menu toggle from InvMenu to Menu and use it to properly
tie ability descriptions into the menu. Still haven't worked out how to update the titles, though. :( git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9412 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/abl-show.cc')
-rw-r--r--crawl-ref/source/abl-show.cc70
1 files changed, 34 insertions, 36 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 586b3145db..0e5b696c34 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -831,7 +831,7 @@ bool activate_ability()
}
std::vector<talent> talents = your_talents(false);
- if ( talents.empty() )
+ if (talents.empty())
{
// Give messages if the character cannot use innate talents right now.
// * Vampires can't turn into bats when full of blood.
@@ -867,8 +867,7 @@ bool activate_ability()
int selected = -1;
while (selected < 0)
{
- msg::streams(MSGCH_PROMPT) << "Use which ability? (? or * to list, ! "
- "for descriptions)"
+ msg::streams(MSGCH_PROMPT) << "Use which ability? (? or * to list)"
<< std::endl;
const int keyin = get_ch();
@@ -882,19 +881,6 @@ bool activate_ability()
return (false);
}
}
- else if (keyin == '!')
- {
- while (true)
- {
- selected = choose_ability_menu(talents, true);
- if (selected == -1)
- {
- canned_msg( MSG_OK );
- return (false);
- }
- _print_talent_description(talents[selected]);
- }
- }
else if (keyin == ESCAPE || keyin == ' ' || keyin == '\r'
|| keyin == '\n')
{
@@ -1959,25 +1945,33 @@ int choose_ability_menu(const std::vector<talent>& talents, bool describe)
abil_menu.set_highlighter(NULL);
abil_menu.set_title(
- new MenuEntry(" Ability "
+ new MenuEntry(" Ability "
"Cost Success"));
- if (describe)
- {
- abil_menu.set_more(formatted_string::parse_string(
- "Choose any ability to read its description, "
- "or exit the menu with Escape."));
- abil_menu.set_flags(MF_SINGLESELECT | MF_ANYPRINTABLE |
- MF_ALWAYS_SHOW_MORE);
- }
- else if (Options.tutorial_left)
+ abil_menu.set_flags(MF_SINGLESELECT | MF_ANYPRINTABLE
+ | MF_ALWAYS_SHOW_MORE);
+
+ if (Options.tutorial_left)
{
// XXX This could be buggy if you manage to pick up lots and lots
// of abilities during the tutorial.
abil_menu.set_more(tut_abilities_info());
- abil_menu.set_flags(MF_SINGLESELECT | MF_ANYPRINTABLE |
- MF_ALWAYS_SHOW_MORE);
}
+ else if (describe)
+ {
+ abil_menu.set_more(formatted_string::parse_string(
+ "Choose any ability to read its description, "
+ "or exit the menu with Escape."));
+ }
+ else
+ {
+ abil_menu.set_more(formatted_string::parse_string(
+ "Press '<w>!</w>' or '<w>?</w>' to toggle "
+ "between ability selection and description."));
+ }
+
+ abil_menu.allow_toggle = true;
+ abil_menu.menu_action = Menu::ACT_EXECUTE;
int numbers[52];
for (int i = 0; i < 52; ++i)
@@ -2014,17 +2008,21 @@ int choose_ability_menu(const std::vector<talent>& talents, bool describe)
}
}
- std::vector<MenuEntry*> sel = abil_menu.show(false);
- redraw_screen();
- if (sel.empty())
- {
- return -1;
- }
- else
+ while (true)
{
+ std::vector<MenuEntry*> sel = abil_menu.show(false);
+ redraw_screen();
+ if (sel.empty())
+ return -1;
+
ASSERT(sel.size() == 1);
ASSERT(sel[0]->hotkeys.size() == 1);
- return (*(reinterpret_cast<int*>(sel[0]->data)));
+ int selected = *(reinterpret_cast<int*>(sel[0]->data));
+
+ if (abil_menu.menu_action == Menu::ACT_EXAMINE)
+ _print_talent_description(talents[selected]);
+ else
+ return (*(reinterpret_cast<int*>(sel[0]->data)));
}
}