diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-09-10 15:58:46 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-09-10 15:58:46 +0000 |
commit | 1d23ad9eae6203fcabc6b1f9a933174bc907f2a9 (patch) | |
tree | 8182fbaccc51eecf655ed3feda605e4fff97ad67 /crawl-ref/source/tilereg.cc | |
parent | 383d392c17f076384fc37e631b6506739ca634fe (diff) | |
download | crawl-ref-1d23ad9eae6203fcabc6b1f9a933174bc907f2a9.tar.gz crawl-ref-1d23ad9eae6203fcabc6b1f9a933174bc907f2a9.zip |
Add an inventory-like region for the Tiles version to make spells
clickable. '_' toggles between inventory and spell display.
Actual tiles are still missing, but everything works as it should.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10648 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tilereg.cc')
-rw-r--r-- | crawl-ref/source/tilereg.cc | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 6b6d467761..dadf97d0e1 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -28,6 +28,8 @@ REVISION("$Rev$"); #include "player.h" #include "religion.h" #include "spells3.h" +#include "spl-cast.h" +#include "spl-util.h" #include "stuff.h" #include "terrain.h" #include "transfor.h" @@ -1616,7 +1618,11 @@ void InventoryRegion::render() const coord_def max_pos(ex, ey); std::string desc = ""; - if (floor && is_valid_item(mitm[idx])) + if (Options.tile_display_spells) + { + desc = spell_title((spell_type) idx); + } + else if (floor && is_valid_item(mitm[idx])) desc = mitm[idx].name(DESC_PLAIN); else if (!floor && is_valid_item(you.inv[idx])) desc = you.inv[idx].name(DESC_INVENTORY_EQUIP); @@ -1784,6 +1790,26 @@ void InventoryRegion::place_cursor(const coord_def &cursor) m_dirty = true; } +static int _handle_spells_mouse(MouseEvent &event, int idx, int item_idx) +{ + const spell_type spell = (spell_type) idx; + if (event.button == MouseEvent::LEFT) + { + you.last_clicked_item = item_idx; + if (!cast_a_spell(true, spell)) + flush_input_buffer( FLUSH_ON_FAILURE ); + return CK_MOUSE_CMD; + } + else if (event.button == MouseEvent::RIGHT) + { + you.last_clicked_item = item_idx; + describe_spell(spell); + redraw_screen(); + return CK_MOUSE_CMD; + } + return 0; +} + int InventoryRegion::handle_mouse(MouseEvent &event) { int cx, cy; @@ -1807,12 +1833,16 @@ int InventoryRegion::handle_mouse(MouseEvent &event) return 0; int idx = m_items[item_idx].idx; + + if (m_items[item_idx].key == 0 && Options.tile_display_spells) + return _handle_spells_mouse(event, idx, item_idx); + bool on_floor = m_items[item_idx].flag & TILEI_FLAG_FLOOR; ASSERT(idx >= 0); // TODO enne - this is all really only valid for the on-screen inventory - // Do we subclass inventoryregion for the onscreen and offscreen versions? + // Do we subclass InventoryRegion for the onscreen and offscreen versions? char key = m_items[item_idx].key; if (key) return key; @@ -1913,6 +1943,16 @@ static bool _can_use_item(const item_def &item, bool equipped) return (true); } +void _update_spell_tip_text(std::string& tip, int flag) +{ + if (flag & TILEI_FLAG_MELDED) + tip = "You cannot cast this spell right now."; + else + tip = "[L-Click] Cast (z)"; + + tip += "\n[R-Click] Describe (I)"; +} + bool InventoryRegion::update_tip_text(std::string& tip) { if (m_cursor == NO_CURSOR) @@ -1929,6 +1969,12 @@ bool InventoryRegion::update_tip_text(std::string& tip) bool display_actions = (m_items[item_idx].key == 0 && mouse_control::current_mode() == MOUSE_MODE_COMMAND); + if (display_actions && Options.tile_display_spells) + { + _update_spell_tip_text(tip, m_items[item_idx].flag); + return (true); + } + // TODO enne - should the command keys here respect keymaps? if (m_items[item_idx].flag & TILEI_FLAG_FLOOR) @@ -2153,6 +2199,19 @@ bool InventoryRegion::update_tip_text(std::string& tip) return (true); } +void _update_spell_alt_text(std::string &alt, int idx) +{ + const spell_type spell = (spell_type) idx; + + describe_info inf; + get_spell_desc(spell, inf); + + alt_desc_proc proc(crawl_view.msgsz.x, crawl_view.msgsz.y); + process_description<alt_desc_proc>(proc, inf); + + proc.get_string(alt); +} + bool InventoryRegion::update_alt_text(std::string &alt) { if (m_cursor == NO_CURSOR) @@ -2167,7 +2226,13 @@ bool InventoryRegion::update_alt_text(std::string &alt) { return (false); } + int idx = m_items[item_idx].idx; + if (m_items[item_idx].key == 0 && Options.tile_display_spells) + { + _update_spell_alt_text(alt, idx); + return (true); + } const item_def *item; if (m_items[item_idx].flag & TILEI_FLAG_FLOOR) |