aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDenis Kasak2009-07-01 01:43:20 +0000
committerDenis Kasak2009-07-01 01:43:20 +0000
commit48959935880a991d14768dac66f41c183eb0dd44 (patch)
tree1d2eaf2aaa72d9872cc9d62827c30ca1874d6f0c /engines
parent4c86646db67d8f7d66f96e633af0bd1ca8e14f25 (diff)
downloadscummvm-rg350-48959935880a991d14768dac66f41c183eb0dd44.tar.gz
scummvm-rg350-48959935880a991d14768dac66f41c183eb0dd44.tar.bz2
scummvm-rg350-48959935880a991d14768dac66f41c183eb0dd44.zip
Added Text::setText() and Text::setColour() methods. Changed demo animation to use them.
svn-id: r41984
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/draci.cpp26
-rw-r--r--engines/draci/sprite.cpp18
-rw-r--r--engines/draci/sprite.h3
3 files changed, 36 insertions, 11 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index da81074655..3d8a6cc4f9 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -129,26 +129,30 @@ int DraciEngine::go() {
Common::String testString = "Testing, testing, read all about it!";
xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
ypos = 130;
- Text txt1(testString, _font, kFontColour1, xpos, ypos, 1);
+ Text txt(testString, _font, kFontColour1, xpos, ypos, 1);
- txt1.draw(surf);
+ txt.draw(surf);
// Draw small string
_font->setFont(kFontSmall);
testString = "I'm smaller than the font above me.";
xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
ypos += 20;
- Text txt2(testString, _font, kFontColour1, xpos, ypos, 1);
+ txt.setText(testString);
+ txt._x = xpos;
+ txt._y = ypos;
- txt2.draw(surf);
+ txt.draw(surf);
// Overflow handling test
testString = "Checking overflooooooooooooooooooooooooow...";
xpos = 50;
ypos += 20;
- Text txt3(testString, _font, kFontColour1, xpos, ypos, 1);
+ txt.setText(testString);
+ txt._x = xpos;
+ txt._y = ypos;
- txt3.draw(surf);
+ txt.draw(surf);
_screen->copyToScreen();
@@ -162,6 +166,12 @@ int DraciEngine::go() {
}
testString = "I'm transparent";
+ xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
+ ypos = 80;
+ txt.setText(testString);
+ txt.setColour(kDefaultTransparent);
+ txt._x = xpos;
+ txt._y = ypos;
for (unsigned int t = 0; t < 25; ++t) {
debugC(5, kDraciGeneralDebugLevel, "Drawing frame %d...", t);
@@ -177,9 +187,7 @@ int DraciEngine::go() {
sp.draw(surf);
// Draw transparent text over dragon
- _font->setColour(kDefaultTransparent);
- _font->drawString(surf, testString,
- (kScreenWidth - _font->getStringWidth(testString, 1)) / 2, 80, 1);
+ txt.draw(surf);
_screen->copyToScreen();
_system->delayMillis(100);
diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp
index 062499471d..b56727e15c 100644
--- a/engines/draci/sprite.cpp
+++ b/engines/draci/sprite.cpp
@@ -129,13 +129,13 @@ void Sprite::draw(Surface *surface) const {
Text::Text(const Common::String &str, Font *font, byte fontColour,
uint16 x, uint16 y, uint spacing) {
uint len = str.size();
+ _length = len;
_x = x;
_y = y;
_text = new byte[len];
memcpy(_text, str.c_str(), len);
- _length = len;
_spacing = spacing;
_colour = fontColour;
@@ -144,7 +144,21 @@ Text::Text(const Common::String &str, Font *font, byte fontColour,
}
Text::~Text() {
- delete _text;
+ delete[] _text;
+}
+
+void Text::setText(const Common::String &str) {
+ delete[] _text;
+
+ uint len = str.size();
+ _length = len;
+
+ _text = new byte[len];
+ memcpy(_text, str.c_str(), len);
+}
+
+void Text::setColour(byte fontColour) {
+ _colour = fontColour;
}
void Text::draw(Surface *surface) const {
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index 50b091e3d5..84c38527d4 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -78,6 +78,9 @@ public:
uint16 x = 0, uint16 y = 0, uint spacing = 0);
~Text();
+ void setText(const Common::String &str);
+ void setColour(byte fontColour);
+
void draw(Surface *surface) const;
byte *_text;