summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/describe.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-08-18 10:44:12 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-08-18 10:44:12 +0000
commitbadc21cfcd7a35b56e3b61ba136315e5bd2930d1 (patch)
tree1bf5cc209bd55aa118b8fbb446b837b2fb8aaf34 /crawl-ref/source/describe.cc
parent2a67f62a9a071d355878ae4ea8bde19f87162d34 (diff)
downloadcrawl-ref-badc21cfcd7a35b56e3b61ba136315e5bd2930d1.tar.gz
crawl-ref-badc21cfcd7a35b56e3b61ba136315e5bd2930d1.zip
FR 2810959: If a player reads a spellbook which is in inventory, then looks at
a spell's description, pressing 'M' will try to memorise that spell from that particular book. FR 2815575: Instead of moving "spell levels left" to the top of the spell memorisation menu, make it light-green in color. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10558 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r--crawl-ref/source/describe.cc36
1 files changed, 31 insertions, 5 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index ca8c6e66b4..68b2a77587 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -32,6 +32,7 @@ REVISION("$Rev$");
#include "fight.h"
#include "food.h"
#include "ghost.h"
+#include "invent.h"
#include "it_use2.h"
#include "itemname.h"
#include "itemprop.h"
@@ -2184,7 +2185,7 @@ static bool _describe_spells(const item_def &item)
if (nthing == SPELL_NO_SPELL)
return (false);
- describe_spell( nthing );
+ describe_spell( nthing, &item );
return (true);
}
@@ -2202,13 +2203,23 @@ void describe_item( item_def &item, bool allow_inscribe )
while (true)
{
+ // Memorised spell while reading a spellbook.
+ if (you.turn_is_over)
+ return;
+
const bool spells_shown = _show_item_description(item);
if (spells_shown)
{
cgotoxy(1, wherey());
textcolor(LIGHTGREY);
- cprintf("Select a spell to read its description.");
+
+ if (item.base_type == OBJ_BOOKS && in_inventory(item))
+ cprintf("Select a spell to read its description or to "
+ "memorize it.");
+ else
+ cprintf("Select a spell to read its description.");
+
if (_describe_spells(item))
continue;
return;
@@ -2383,7 +2394,7 @@ void inscribe_item(item_def &item, bool proper_prompt)
// Describes (most) every spell in the game.
//
//---------------------------------------------------------------
-void describe_spell(spell_type spelled)
+void describe_spell(spell_type spelled, const item_def* item)
{
std::string description;
@@ -2405,6 +2416,7 @@ void describe_spell(spell_type spelled)
#endif
}
+ bool can_mem = false;
if (you_cannot_memorise(spelled))
{
description += "$$";
@@ -2413,13 +2425,27 @@ void describe_spell(spell_type spelled)
description += lowercase_string(species_name(you.species, 0));
description += ".";
}
+ else if (item && item->base_type == OBJ_BOOKS && in_inventory(*item))
+ {
+ can_mem = true;
+ description += "$$";
+ description += "(M)emorise this spell.";
+ }
print_description(description);
mouse_control mc(MOUSE_MODE_MORE);
- if (getch() == 0)
- getch();
+ char ch;
+ if ((ch = getch()) == 0)
+ ch = getch();
+
+ if (can_mem && toupper(ch) == 'M')
+ {
+ if (!learn_spell(spelled, *item, false) || !you.turn_is_over)
+ more();
+ redraw_screen();
+ }
}
static std::string _describe_draconian_role(const monsters *mon)