#include <config.h>
-#include "text_object.h"
-#include "resources.h"
-#include "video/drawing_context.h"
+#include "text_object.hpp"
+#include "resources.hpp"
+#include "video/drawing_context.hpp"
TextObject::TextObject()
: fading(0), fadetime(0), visible(false)
{
font = blue_text;
+ centered = false;
}
TextObject::~TextObject()
}
void
+TextObject::set_centered(bool centered)
+{
+ this->centered = centered;
+}
+
+void
TextObject::draw(DrawingContext& context)
{
context.push_transform();
context.draw_filled_rect(Vector(125, 50), Vector(550, 120),
Color(150, 180, 200, 125), LAYER_GUI-50);
- context.draw_text(font, text, Vector(125+35, 50+35), LEFT_ALLIGN, LAYER_GUI-40);
+ if (centered) {
+ context.draw_center_text(font, text, Vector(0, 50+35), LAYER_GUI-40);
+ }
+ else context.draw_text(font, text, Vector(125+35, 50+35), LEFT_ALLIGN, LAYER_GUI-40);
context.pop_transform();
}