summaryrefslogtreecommitdiff
path: root/src/render.cpp
diff options
context:
space:
mode:
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;