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>2008-06-18 20:21:53 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-18 20:21:53 +0000
commit341258b95e2dde491b2b8aef794e5fd6ac3156ee (patch)
tree260ca53fb36d35627b441d400b26b4beb8404135 /crawl-ref/source/abl-show.cc
parentc64b21cdfddbb84b459273e7990bd80a1e91d970 (diff)
downloadcrawl-ref-341258b95e2dde491b2b8aef794e5fd6ac3156ee.tar.gz
crawl-ref-341258b95e2dde491b2b8aef794e5fd6ac3156ee.zip
Add the framework for descriptions for abilities to be read from the
ability menu (a!) Currently only contains descriptions for Zin, TSO and "Renounce Religion". Also, now I'm worried that players might accidentally press '?' instead of '!' and then apply an ability when they only wanted to read its description. (Of course, with some of them you can opt out, e.g. because they need targeting, but for others it's a real problem.) There must be a good solution around somewhere. Abilities are not (yet) searchable in the database. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5958 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/abl-show.cc')
-rw-r--r--crawl-ref/source/abl-show.cc84
1 files changed, 69 insertions, 15 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 8bd24d35a2..12e09d2be3 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -38,8 +38,10 @@
#include "abyss.h"
#include "beam.h"
+#include "database.h"
#include "decks.h"
#include "delay.h"
+#include "describe.h"
#include "effects.h"
#include "food.h"
#include "it_use2.h"
@@ -208,7 +210,7 @@ static const ability_def Ability_List[] =
// as exhaustion's only (and designed) effect is preventing Berserk. -- bwr
{ ABIL_FLY_II, "Fly", 0, 0, 25, 0, ABFLAG_NONE },
{ ABIL_DELAYED_FIREBALL, "Release Delayed Fireball", 0, 0, 0, 0, ABFLAG_INSTANT },
- { ABIL_MUMMY_RESTORATION, "Restoration", 1, 0, 0, 0, ABFLAG_PERMANENT_MP },
+ { ABIL_MUMMY_RESTORATION, "Self-Restoration", 1, 0, 0, 0, ABFLAG_PERMANENT_MP },
// EVOKE abilities use Evocations and come from items:
// Mapping, Teleportation, and Blink can also come from mutations
@@ -321,7 +323,6 @@ static const ability_def Ability_List[] =
{ ABIL_RENOUNCE_RELIGION, "Renounce Religion", 0, 0, 0, 0, ABFLAG_NONE },
};
-
const struct ability_def & get_ability_def( ability_type abil )
{
for (unsigned int i = 0;
@@ -810,6 +811,35 @@ std::vector<const char*> get_ability_names()
return result;
}
+static void _print_talent_description(talent tal)
+{
+ clrscr();
+
+ std::string name = get_ability_def(tal.which).name;
+
+ // The suffix is necessary to distinguish between similarly named spells.
+ // Yes, this is a hack. (XXX)
+ std::string lookup = getLongDescription(name + "ability");
+ if (lookup.empty())
+ {
+ // Try again without the suffix.
+ lookup = getLongDescription(name);
+ }
+
+ if (lookup.empty()) // Still nothing found?
+ cprintf("No description found.");
+ else
+ {
+ std::ostringstream data;
+ data << name << "$$" << lookup;
+ print_description(data.str());
+ }
+ if (getch() == 0)
+ getch();
+
+ clrscr();
+}
+
bool activate_ability()
{
if (you.duration[DUR_BERSERKER])
@@ -855,7 +885,8 @@ bool activate_ability()
int selected = -1;
while (selected < 0)
{
- msg::streams(MSGCH_PROMPT) << "Use which ability? (? or * to list)"
+ msg::streams(MSGCH_PROMPT) << "Use which ability? (? or * to list, ! "
+ "for descriptions)"
<< std::endl;
const int keyin = get_ch();
@@ -869,15 +900,28 @@ bool activate_ability()
return (false);
}
}
- else if (keyin == ESCAPE || keyin == ' '
- || keyin == '\r' || keyin == '\n')
+ 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')
{
canned_msg( MSG_OK );
return (false);
}
else if ( isalpha(keyin) )
{
- // try to find the hotkey
+ // Try to find the hotkey.
for (unsigned int i = 0; i < talents.size(); ++i)
{
if (talents[i].hotkey == keyin)
@@ -887,7 +931,7 @@ bool activate_ability()
}
}
- // if we can't, cancel out
+ // If we can't, cancel out.
if (selected < 0)
{
mpr("You can't do that.");
@@ -1902,24 +1946,34 @@ static void _pay_ability_costs(const ability_def& abil)
lose_piety( piety_cost );
}
-int choose_ability_menu(const std::vector<talent>& talents)
+int choose_ability_menu(const std::vector<talent>& talents, bool describe)
{
Menu abil_menu(MF_SINGLESELECT | MF_ANYPRINTABLE, "ability");
+
abil_menu.set_highlighter(NULL);
abil_menu.set_title(
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);
+ }
+
int numbers[52];
- for ( int i = 0; i < 52; ++i )
+ for (int i = 0; i < 52; ++i)
numbers[i] = i;
bool found_invocations = false;
- // first add all non-invocations
- for ( unsigned int i = 0; i < talents.size(); ++i )
+ // First add all non-invocations.
+ for (unsigned int i = 0; i < talents.size(); ++i)
{
- if ( talents[i].is_invocation )
+ if (talents[i].is_invocation)
found_invocations = true;
else
{
@@ -1930,12 +1984,12 @@ int choose_ability_menu(const std::vector<talent>& talents)
}
}
- if ( found_invocations )
+ if (found_invocations)
{
abil_menu.add_entry(new MenuEntry(" Invocations - ", MEL_SUBTITLE));
- for ( unsigned int i = 0; i < talents.size(); ++i )
+ for (unsigned int i = 0; i < talents.size(); ++i)
{
- if ( talents[i].is_invocation )
+ if (talents[i].is_invocation)
{
MenuEntry* me = new MenuEntry(_describe_talent(talents[i]),
MEL_ITEM, 1, talents[i].hotkey);