summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilereg.cc
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-10 16:23:13 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-10 16:23:13 +0000
commitabec3e39f39b3f598c90b645a45bb43097b8e5cb (patch)
tree6050a955d8385bd0c2d46d12776702c62d585b4e /crawl-ref/source/tilereg.cc
parent87616cef0d3617cd349edb6641d32d71cdd96b22 (diff)
downloadcrawl-ref-abec3e39f39b3f598c90b645a45bb43097b8e5cb.tar.gz
crawl-ref-abec3e39f39b3f598c90b645a45bb43097b8e5cb.zip
[2495836] Show names for friendly uniques during arena mode. Also, add a tile_tag_pref option.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8383 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tilereg.cc')
-rw-r--r--crawl-ref/source/tilereg.cc64
1 files changed, 57 insertions, 7 deletions
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 19a712cbbe..ecc065f66d 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -685,6 +685,15 @@ void DungeonRegion::pack_buffers()
}
}
+struct tag_def
+{
+ tag_def() { text = NULL; left = right = 0; }
+
+ const char* text;
+ char left, right;
+ char type;
+};
+
void DungeonRegion::render()
{
if (m_dirty)
@@ -698,24 +707,65 @@ void DungeonRegion::render()
m_buf_doll.draw();
m_buf_main.draw();
- // Draw text labels
- // TODO enne - add an option for this
- // TODO enne - be more intelligent about not covering stuff up
- for (unsigned int t = 0; t < TAG_MAX; t++)
+ FixedArray<tag_def, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER> tag_show;
+
+ int total_tags = 0;
+
+ for (int t = TAG_MAX - 1; t >= 0; t--)
{
for (unsigned int i = 0; i < m_tags[t].size(); i++)
{
- if (!on_screen(m_tags[t][i].gc))
+ if (!crawl_view.in_grid_los(m_tags[t][i].gc))
+ continue;
+
+ const coord_def ep = grid2show(m_tags[t][i].gc);
+
+ if (tag_show(ep).text)
+ continue;
+
+ const char *str = m_tags[t][i].tag.c_str();
+
+ int width = m_tag_font->string_width(str);
+ tag_def &def = tag_show(ep);
+
+ const int buffer = 2;
+
+ def.left = -width / 2 - buffer;
+ def.right = width / 2 + buffer;
+ def.text = str;
+ def.type = t;
+
+ total_tags++;
+ }
+
+ if (total_tags)
+ break;
+ }
+
+ if (!total_tags)
+ return;
+
+ // Draw text tags.
+ // TODO enne - be more intelligent about not covering stuff up
+ for (int y = 0; y < ENV_SHOW_DIAMETER; y++)
+ {
+ for (int x = 0; x < ENV_SHOW_DIAMETER; x++)
+ {
+ coord_def ep(x, y);
+ tag_def &def = tag_show(ep);
+
+ if (!def.text)
continue;
+ const coord_def gc = show2grid(ep);
coord_def pc;
- to_screen_coords(m_tags[t][i].gc, pc);
+ to_screen_coords(gc, pc);
// center this coord, which is at the top left of gc's cell
pc.x += dx / 2;
const coord_def min_pos(sx, sy);
const coord_def max_pos(ex, ey);
- m_tag_font->render_string(pc.x, pc.y, m_tags[t][i].tag.c_str(),
+ m_tag_font->render_string(pc.x, pc.y, def.text,
min_pos, max_pos, WHITE, false);
}
}