summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-14 15:18:04 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-14 15:18:04 +0000
commit56ec9dd2047b94176d719cbb06bb8361f4f4d166 (patch)
tree45a4f562b2c38a6bd61761cf6b5ee2620e29019c /crawl-ref/source
parent61b8176337742ccaa81d0bd1f45e3dde3c44223b (diff)
downloadcrawl-ref-56ec9dd2047b94176d719cbb06bb8361f4f4d166.tar.gz
crawl-ref-56ec9dd2047b94176d719cbb06bb8361f4f4d166.zip
Making tutorial and named monster tags consistent. Also, making tooltips not disappear until the mouse moves to another square, to address [2564067].
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9062 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/tilepick.cc11
-rw-r--r--crawl-ref/source/tilesdl.cc64
-rw-r--r--crawl-ref/source/tilesdl.h1
-rw-r--r--crawl-ref/source/tutorial.cc2
4 files changed, 63 insertions, 15 deletions
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index a034c7f3e2..7f23c07988 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -4426,16 +4426,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected)
if (mon->type == MONS_PANDEMONIUM_DEMON)
return;
- if (mon->type == MONS_PLAYER_GHOST)
- {
- // Beautification hack. "Foo's ghost" is a little bit
- // verbose as a tag. "Foo" on its own should be sufficient.
- tiles.add_text_tag(TAG_NAMED_MONSTER, mon->mname, gc);
- }
- else
- {
- tiles.add_text_tag(TAG_NAMED_MONSTER, mon->name(DESC_PLAIN), gc);
- }
+ tiles.add_text_tag(TAG_NAMED_MONSTER, mon);
}
else
{
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index c735f6f925..47967b1270 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -697,9 +697,29 @@ static unsigned int _timer_callback(unsigned int ticks)
return res;
}
+// Convenience struct for holding mouse location on screen.
+struct cursor_loc
+{
+ cursor_loc() { reset(); }
+ void reset() { reg = NULL; cx = cy = -1; }
+ bool operator==(const cursor_loc &rhs) const
+ {
+ return (rhs.reg == reg
+ && rhs.cx == cx
+ && rhs.cy == cy
+ && reg);
+ }
+
+ Region *reg;
+ int cx, cy;
+};
+
+
int TilesFramework::getch_ck()
{
SDL_Event event;
+ cursor_loc cur_loc;
+ cursor_loc tip_loc;
int key = 0;
@@ -778,6 +798,19 @@ int TilesFramework::getch_ck()
mouse_event.held = m_buttons_held;
mouse_event.mod = m_key_mod;
key = handle_mouse(mouse_event);
+
+ // find mouse location
+ for (unsigned int i = 0;
+ i < m_layers[m_active_layer].m_regions.size(); i++)
+ {
+ Region *reg = m_layers[m_active_layer].m_regions[i];
+ if (reg->mouse_pos(m_mouse.x, m_mouse.y,
+ cur_loc.cx, cur_loc.cy))
+ {
+ cur_loc.reg = reg;
+ break;
+ }
+ }
}
break;
@@ -817,11 +850,13 @@ int TilesFramework::getch_ck()
}
}
- bool show_tooltip = ((ticks - m_last_tick_moved
- > (unsigned int)Options.tile_tooltip_ms)
- && ticks > m_last_tick_moved);
+ bool timeout = ((ticks - m_last_tick_moved
+ > (unsigned int)Options.tile_tooltip_ms)
+ && ticks > m_last_tick_moved);
+ if (timeout)
+ tip_loc = cur_loc;
- if (show_tooltip)
+ if (tip_loc == cur_loc)
{
tiles.clear_text_tags(TAG_CELL_DESC);
if (m_tooltip.empty())
@@ -840,6 +875,7 @@ int TilesFramework::getch_ck()
else
{
m_tooltip.clear();
+ tip_loc.reset();
}
if (ticks - last_redraw_tick > ticks_per_redraw)
@@ -1476,6 +1512,26 @@ void TilesFramework::add_text_tag(text_tag_type type, const std::string &tag,
m_region_tile->add_text_tag(type, tag, gc);
}
+void TilesFramework::add_text_tag(text_tag_type type, const monsters* mon)
+{
+ // HACK. Names cover up pan demons in a weird way.
+ if (mon->type == MONS_PANDEMONIUM_DEMON)
+ return;
+
+ const coord_def &gc = mon->pos();
+
+ if (mon->type == MONS_PLAYER_GHOST)
+ {
+ // Beautification hack. "Foo's ghost" is a little bit
+ // verbose as a tag. "Foo" on its own should be sufficient.
+ tiles.add_text_tag(TAG_NAMED_MONSTER, mon->mname, gc);
+ }
+ else
+ {
+ tiles.add_text_tag(TAG_NAMED_MONSTER, mon->name(DESC_PLAIN), gc);
+ }
+}
+
bool TilesFramework::initialise_items()
{
return (m_image.load_item_texture());
diff --git a/crawl-ref/source/tilesdl.h b/crawl-ref/source/tilesdl.h
index 5a1f49419d..c8a211ed21 100644
--- a/crawl-ref/source/tilesdl.h
+++ b/crawl-ref/source/tilesdl.h
@@ -116,6 +116,7 @@ public:
void clear_text_tags(text_tag_type type);
void add_text_tag(text_tag_type type, const std::string &tag,
const coord_def &gc);
+ void add_text_tag(text_tag_type type, const monsters* mon);
bool initialise_items();
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 027635cae1..464327d37e 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -1220,7 +1220,7 @@ void tutorial_first_monster(const monsters &mon)
// need to highlight monster
const coord_def gc = mon.pos();
tiles.place_cursor(CURSOR_TUTORIAL, gc);
- tiles.add_text_tag(TAG_TUTORIAL, mon.name(DESC_CAP_A), gc);
+ tiles.add_text_tag(TAG_TUTORIAL, &mon);
text += "monster is a ";
text += mon.name(DESC_PLAIN).c_str();