[Scummvm-cvs-logs] SF.net SVN: scummvm:[41981] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Wed Jul 1 03:11:48 CEST 2009
Revision: 41981
http://scummvm.svn.sourceforge.net/scummvm/?rev=41981&view=rev
Author: dkasak13
Date: 2009-07-01 01:11:48 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
Added Text as a subclass of Drawable. Fixed syntax error in font.cpp
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/font.cpp
scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/font.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/font.cpp 2009-07-01 01:02:48 UTC (rev 41980)
+++ scummvm/branches/gsoc2009-draci/engines/draci/font.cpp 2009-07-01 01:11:48 UTC (rev 41981)
@@ -212,7 +212,7 @@
* @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 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);
}
/**
Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp 2009-07-01 01:02:48 UTC (rev 41980)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp 2009-07-01 01:11:48 UTC (rev 41981)
@@ -27,6 +27,7 @@
#include "draci/draci.h"
#include "draci/sprite.h"
+#include "draci/font.h"
namespace Draci {
@@ -124,7 +125,28 @@
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
Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h 2009-07-01 01:02:48 UTC (rev 41980)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h 2009-07-01 01:11:48 UTC (rev 41981)
@@ -27,6 +27,7 @@
#define DRACI_SPRITE_H
#include "draci/surface.h"
+#include "draci/font.h"
namespace Draci {
@@ -70,7 +71,21 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list