summaryrefslogtreecommitdiff
path: root/src/render.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-11-07 18:33:03 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-11-07 18:33:03 +0100
commit5186351345d43801ac45acde8b7e30734eea0349 (patch)
tree7c331bb3c34de2ce31a791f79e7bf783534870d0 /src/render.cpp
parentd0be87d32929c42502fb842aa2b0ab0233313b93 (diff)
Better unit say.
Diffstat (limited to 'src/render.cpp')
-rw-r--r--src/render.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/render.cpp b/src/render.cpp
index 80ed2b6..259d898 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -181,6 +181,32 @@ void state_t::render(oriented_sprite_t *sprite, rectf_t bounds, float angle)
render(sprite->textures + index, bounds, mirror);
}
+void state_t::render_text(v2f_t x, float height, const wchar_t *wstr,
+ text_align_t align, sf::Color color)
+{
+ sf::Text text(wstr, font, 20);
+ sf::FloatRect rect;
+ float scale;
+ v2f_t offset;
+
+ rect = text.getGlobalBounds();
+ scale = height / 20.0f;
+
+ switch (align) {
+ case ALIGN_CENTER_BOTTOM:
+ offset[0] = -rect.width / 2;
+ offset[1] = -rect.height;
+ break;
+ }
+
+ offset *= scale;
+
+ text.setScale(scale, scale);
+ text.setPosition(x + offset);
+ text.setFillColor(color);
+ window->draw(text);
+}
+
void state_t::render_hlrect(rectf_t rect, sf::Color color)
{
sf::Color fill;