diff options
author | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2010-12-27 16:38:31 +0100 |
---|---|---|
committer | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2010-12-27 17:04:54 +0100 |
commit | e837e7eadd852ea034c2f4dacfce5b98e6711d16 (patch) | |
tree | 2553790cad76933534536b60fdb35dfc958f3ab3 /crawl-ref/source/tilereg-cmd.cc | |
parent | 81d9087f1ef5b8032bcd4ba140bebecd1f862a94 (diff) | |
download | crawl-ref-e837e7eadd852ea034c2f4dacfce5b98e6711d16.tar.gz crawl-ref-e837e7eadd852ea034c2f4dacfce5b98e6711d16.zip |
Add descriptions for common commands.
This is currently only used for the command tab in Tiles, but could
be useful for the console version as well.
Diffstat (limited to 'crawl-ref/source/tilereg-cmd.cc')
-rw-r--r-- | crawl-ref/source/tilereg-cmd.cc | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/crawl-ref/source/tilereg-cmd.cc b/crawl-ref/source/tilereg-cmd.cc index fdea7e093a..6347758bba 100644 --- a/crawl-ref/source/tilereg-cmd.cc +++ b/crawl-ref/source/tilereg-cmd.cc @@ -9,15 +9,19 @@ #include "tilereg-cmd.h" +#include "abl-show.h" #include "cio.h" #include "command.h" #include "enum.h" +#include "env.h" #include "libutil.h" #include "macro.h" #include "misc.h" +#include "terrain.h" #include "tiledef-dngn.h" #include "tiledef-icons.h" #include "tilepick.h" +#include "viewgeom.h" CommandRegion::CommandRegion(const TileRegionInit &init) : GridRegion(init) { @@ -41,7 +45,7 @@ void CommandRegion::draw_tag() const command_type cmd = (command_type) idx; - draw_desc(command_to_name(cmd).c_str()); + draw_desc(get_command_description(cmd, true).c_str()); } int CommandRegion::handle_mouse(MouseEvent &event) @@ -79,10 +83,9 @@ bool CommandRegion::update_tip_text(std::string& tip) if (item_idx >= m_items.size() || m_items[item_idx].empty()) return (false); - // TODO: Map command -> action description. const command_type cmd = (command_type) m_items[item_idx].idx; tip = make_stringf("[L-Click] %s (%%)", - command_to_name(cmd).c_str()); + get_command_description(cmd, true).c_str()); insert_commands(tip, cmd); // tip += "\n[R-Click] Describe"; @@ -90,10 +93,37 @@ bool CommandRegion::update_tip_text(std::string& tip) return (true); } -// There are no command descriptions. bool CommandRegion::update_alt_text(std::string &alt) { - return (false); + if (m_cursor == NO_CURSOR) + return (false); + + unsigned int item_idx = cursor_index(); + if (item_idx >= m_items.size() || m_items[item_idx].empty()) + return (false); + + if (m_last_clicked_item >= 0 + && item_idx == (unsigned int) m_last_clicked_item) + { + return (false); + } + + int idx = m_items[item_idx].idx; + + const command_type cmd = (command_type) idx; + + const std::string desc = get_command_description(cmd, false); + if (desc.empty()) + return (false); + + describe_info inf; + inf.body << desc; + + alt_desc_proc proc(crawl_view.msgsz.x, crawl_view.msgsz.y); + process_description<alt_desc_proc>(proc, inf); + proc.get_string(alt); + + return (true); } void CommandRegion::pack_buffers() @@ -134,6 +164,11 @@ static bool _command_not_applicable(const command_type cmd) return (!i_feel_safe(false)); case CMD_DISPLAY_RELIGION: return (you.religion == GOD_NO_GOD); + case CMD_PRAY: + return (you.religion == GOD_NO_GOD + && !feat_is_altar(grd(you.pos()))); + case CMD_USE_ABILITY: + return (your_talents(false).empty()); default: return (false); } |