From 4c540e1c4e99150305b9c5297928ed1794cec13c Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 11 Mar 2009 20:01:06 +0000 Subject: 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 --- crawl-ref/source/abl-show.cc | 70 +++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'crawl-ref/source/abl-show.cc') 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 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& 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 '!' or '?' 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& talents, bool describe) } } - std::vector sel = abil_menu.show(false); - redraw_screen(); - if (sel.empty()) - { - return -1; - } - else + while (true) { + std::vector 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(sel[0]->data))); + int selected = *(reinterpret_cast(sel[0]->data)); + + if (abil_menu.menu_action == Menu::ACT_EXAMINE) + _print_talent_description(talents[selected]); + else + return (*(reinterpret_cast(sel[0]->data))); } } -- cgit v1.2.3-54-g00ecf