aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/font.cpp4
-rw-r--r--engines/draci/sprite.cpp24
-rw-r--r--engines/draci/sprite.h15
3 files changed, 40 insertions, 3 deletions
diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp
index cfc09cb5ef..b3c5768b51 100644
--- a/engines/draci/font.cpp
+++ b/engines/draci/font.cpp
@@ -212,7 +212,7 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty) const {
* @param spacing Space to leave between individual characters. Defaults to 0.
*/
-void Font::drawString(Surface *dst, const byte *str, uint len
+void Font::drawString(Surface *dst, const byte *str, uint len,
int x, int y, int spacing) const {
assert(dst != NULL);
assert(x >= 0);
@@ -245,7 +245,7 @@ void Font::drawString(Surface *dst, const byte *str, uint len
void Font::drawString(Surface *dst, const Common::String &str,
int x, int y, int spacing) const {
- drawString(dst, str, str.size(), x, y, spacing);
+ drawString(dst, (byte *) str.c_str(), str.size(), x, y, spacing);
}
/**
diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp
index cce3f51cfa..14d2e905c9 100644
--- a/engines/draci/sprite.cpp
+++ b/engines/draci/sprite.cpp
@@ -27,6 +27,7 @@
#include "draci/draci.h"
#include "draci/sprite.h"
+#include "draci/font.h"
namespace Draci {
@@ -124,7 +125,28 @@ void Sprite::draw(Surface *surface) const {
Common::Rect r(_x, _y, _x + _width, _y + _height);
surface->markDirtyRect(r);
}
-
+
+Text::Text(const Common::String &str, Font *font, byte fontColour, uint spacing) {
+ uint len = str.size();
+
+ _text = new byte[len];
+ memcpy(_text, str.c_str(), len);
+ _length = len;
+
+ _spacing = spacing;
+ _colour = fontColour;
+
+ _font = font;
+}
+
+Text::~Text() {
+ delete _text;
+}
+
+void Text::draw(Surface *surface) const {
+ _font->setColour(_colour);
+ _font->drawString(surface, _text, _length, _x, _y, _spacing);
+}
} // End of namespace Draci
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index c9591514e3..68f823512a 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -27,6 +27,7 @@
#define DRACI_SPRITE_H
#include "draci/surface.h"
+#include "draci/font.h"
namespace Draci {
@@ -70,7 +71,21 @@ public:
byte *_data; //!< Pointer to a buffer containing raw sprite data (row-wise)
};
+class Text : public Drawable {
+public:
+ Text(const Common::String &str, Font *font, byte fontColour, uint spacing = 0);
+ ~Text();
+
+ void draw(Surface *surface) const;
+
+ byte *_text;
+ uint _length;
+ uint8 _colour;
+ uint _spacing;
+ Font *_font;
+};
+
} // End of namespace Draci
#endif // DRACI_SPRITE_H