From badc21cfcd7a35b56e3b61ba136315e5bd2930d1 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 18 Aug 2009 10:44:12 +0000 Subject: 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 --- crawl-ref/source/describe.cc | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/describe.cc') 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) -- cgit v1.2.3-54-g00ecf