2012-01-06 23:29:45 +01:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
2008-06-13 14:57:47 +00:00
|
|
|
*
|
2012-01-06 23:29:45 +01:00
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
2012-12-19 23:15:43 +01:00
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
2008-06-13 14:57:47 +00:00
|
|
|
* file distributed with this source distribution.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
2012-12-19 23:15:43 +01:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-04-02 14:20:45 +00:00
|
|
|
|
2012-12-19 23:15:43 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2006-04-02 14:20:45 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-19 23:15:43 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2006-04-02 14:20:45 +00:00
|
|
|
|
2012-12-19 23:15:43 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
|
|
|
*/
|
2003-08-22 05:53:29 +00:00
|
|
|
|
2011-07-23 15:37:14 +02:00
|
|
|
#include "engines/grim/debug.h"
|
2009-06-18 11:52:26 +00:00
|
|
|
#include "engines/grim/grim.h"
|
2009-05-24 19:13:58 +00:00
|
|
|
#include "engines/grim/textobject.h"
|
2009-06-23 05:15:20 +00:00
|
|
|
#include "engines/grim/savegame.h"
|
|
|
|
#include "engines/grim/lua.h"
|
2011-05-13 17:55:14 -07:00
|
|
|
#include "engines/grim/font.h"
|
2011-07-22 22:40:49 +02:00
|
|
|
#include "engines/grim/gfx_base.h"
|
2011-12-17 15:34:37 -08:00
|
|
|
#include "engines/grim/color.h"
|
2003-08-22 05:53:29 +00:00
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
namespace Grim {
|
|
|
|
|
2011-05-18 09:03:17 +08:00
|
|
|
TextObjectCommon::TextObjectCommon() :
|
|
|
|
_x(0), _y(0), _fgColor(0), _justify(0), _width(0), _height(0),
|
2012-01-24 08:34:34 -08:00
|
|
|
_font(NULL), _duration(0), _positioned(false) {
|
2011-05-18 09:03:17 +08:00
|
|
|
}
|
|
|
|
|
2009-11-16 18:09:51 +00:00
|
|
|
TextObject::TextObject(bool blastDraw, bool isSpeech) :
|
2012-04-05 15:20:30 -07:00
|
|
|
TextObjectCommon(), _numberLines(1),
|
2011-05-23 22:00:53 -07:00
|
|
|
_maxLineWidth(0), _lines(0), _userData(0), _created(false) {
|
2008-09-10 08:10:06 +00:00
|
|
|
_blastDraw = blastDraw;
|
2009-11-16 18:09:51 +00:00
|
|
|
_isSpeech = isSpeech;
|
2011-03-21 05:16:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextObject::TextObject() :
|
2012-04-05 15:20:30 -07:00
|
|
|
TextObjectCommon(), _maxLineWidth(0), _lines(NULL) {
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2005-03-20 13:51:40 +00:00
|
|
|
}
|
2005-03-19 21:48:23 +00:00
|
|
|
|
2011-05-22 22:31:27 -07:00
|
|
|
TextObject::~TextObject() {
|
|
|
|
delete[] _lines;
|
2011-12-21 12:16:11 -08:00
|
|
|
if (_created) {
|
|
|
|
g_driver->destroyTextObject(this);
|
|
|
|
}
|
2011-05-22 22:31:27 -07:00
|
|
|
}
|
|
|
|
|
2011-07-25 17:06:24 +02:00
|
|
|
void TextObject::setText(const Common::String &text) {
|
2011-06-11 22:33:55 -07:00
|
|
|
destroy();
|
2011-07-25 17:06:24 +02:00
|
|
|
_textID = text;
|
2011-05-22 22:31:27 -07:00
|
|
|
setupText();
|
2005-03-20 13:51:40 +00:00
|
|
|
}
|
|
|
|
|
2011-07-25 23:42:07 +02:00
|
|
|
void TextObject::reset() {
|
|
|
|
destroy();
|
|
|
|
setupText();
|
|
|
|
}
|
|
|
|
|
2011-03-21 05:16:27 +08:00
|
|
|
void TextObject::saveState(SaveGame *state) const {
|
2012-01-27 11:47:28 -08:00
|
|
|
state->writeColor(_fgColor);
|
2011-03-21 05:16:27 +08:00
|
|
|
|
|
|
|
state->writeLESint32(_x);
|
|
|
|
state->writeLESint32(_y);
|
|
|
|
state->writeLESint32(_width);
|
|
|
|
state->writeLESint32(_height);
|
|
|
|
state->writeLESint32(_justify);
|
|
|
|
state->writeLESint32(_numberLines);
|
2011-05-23 16:28:05 +02:00
|
|
|
state->writeLESint32(_duration);
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2012-01-27 15:09:13 -08:00
|
|
|
state->writeBool(_blastDraw);
|
|
|
|
state->writeBool(_isSpeech);
|
2011-05-23 16:28:05 +02:00
|
|
|
state->writeLESint32(_elapsedTime);
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2012-01-27 15:09:13 -08:00
|
|
|
state->writeLESint32(_font->getId());
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2011-07-25 17:06:24 +02:00
|
|
|
state->writeString(_textID);
|
2011-03-21 05:16:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TextObject::restoreState(SaveGame *state) {
|
2012-01-27 15:09:13 -08:00
|
|
|
_fgColor = state->readColor();
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2011-05-23 16:28:05 +02:00
|
|
|
_x = state->readLESint32();
|
|
|
|
_y = state->readLESint32();
|
|
|
|
_width = state->readLESint32();
|
|
|
|
_height = state->readLESint32();
|
|
|
|
_justify = state->readLESint32();
|
|
|
|
_numberLines = state->readLESint32();
|
|
|
|
_duration = state->readLESint32();
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2012-01-27 15:09:13 -08:00
|
|
|
_blastDraw = state->readBool();
|
|
|
|
_isSpeech = state->readBool();
|
2011-05-23 16:28:05 +02:00
|
|
|
_elapsedTime = state->readLESint32();
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2012-01-27 15:09:13 -08:00
|
|
|
_font = Font::getPool().getObject(state->readLESint32());
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2011-07-25 17:06:24 +02:00
|
|
|
_textID = state->readString();
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2011-06-07 18:25:37 +02:00
|
|
|
setupText();
|
|
|
|
_created = false;
|
|
|
|
_userData = NULL;
|
|
|
|
|
2011-03-21 05:16:27 +08:00
|
|
|
return true;
|
2009-06-23 05:15:20 +00:00
|
|
|
}
|
|
|
|
|
2005-03-20 16:48:26 +00:00
|
|
|
void TextObject::setDefaults(TextObjectDefaults *defaults) {
|
2011-05-18 09:03:17 +08:00
|
|
|
_x = defaults->getX();
|
|
|
|
_y = defaults->getY();
|
|
|
|
_font = defaults->getFont();
|
|
|
|
_fgColor = defaults->getFGColor();
|
|
|
|
_justify = defaults->getJustify();
|
2005-03-20 13:51:40 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 18:08:47 -07:00
|
|
|
int TextObject::getBitmapWidth() const {
|
2011-05-22 22:31:27 -07:00
|
|
|
return _maxLineWidth;
|
2005-05-05 21:23:17 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 18:08:47 -07:00
|
|
|
int TextObject::getBitmapHeight() const {
|
2009-11-16 18:09:51 +00:00
|
|
|
return _numberLines * _font->getHeight();
|
2005-05-05 21:23:17 +00:00
|
|
|
}
|
|
|
|
|
2005-04-05 04:33:56 +00:00
|
|
|
int TextObject::getTextCharPosition(int pos) {
|
|
|
|
int width = 0;
|
2011-10-12 17:42:40 +02:00
|
|
|
Common::String msg = LuaBase::instance()->parseMsgText(_textID.c_str(), NULL);
|
2005-04-05 04:33:56 +00:00
|
|
|
for (int i = 0; (msg[i] != '\0') && (i < pos); ++i) {
|
2007-01-29 18:42:58 +00:00
|
|
|
width += _font->getCharWidth(msg[i]);
|
2005-04-05 04:33:56 +00:00
|
|
|
}
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2011-06-07 09:20:10 -07:00
|
|
|
void TextObject::destroy() {
|
|
|
|
if (_created) {
|
|
|
|
g_driver->destroyTextObject(this);
|
|
|
|
_created = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-24 08:34:34 -08:00
|
|
|
void TextObject::reposition() {
|
2012-02-18 22:18:34 +01:00
|
|
|
if (_positioned)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_positioned = true;
|
|
|
|
_posX = _x;
|
|
|
|
_posY = _y;
|
|
|
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
2012-02-18 22:20:16 +01:00
|
|
|
if (_isSpeech || abs(_posX) >= 320 || abs(_posY) >= 240) {
|
|
|
|
_posY = _posY > 0 ? 480 - _posY : abs(_posY);
|
|
|
|
if (_posX < 0)
|
|
|
|
_posX = _posX + 640;
|
|
|
|
if (_justify == CENTER && _posX == 0)
|
|
|
|
_posX = 320;
|
2012-01-24 08:34:34 -08:00
|
|
|
} else {
|
2012-02-18 22:20:16 +01:00
|
|
|
_posX = 320 + _posX;
|
2012-09-25 23:15:14 +02:00
|
|
|
_posY = 240 - _posY;
|
2012-01-24 08:34:34 -08:00
|
|
|
}
|
2012-09-25 23:15:14 +02:00
|
|
|
|
2012-02-18 22:18:34 +01:00
|
|
|
Debug::debug(Debug::TextObjects, "Repositioning (%d, %d) -> (%d, %d)", _x, _y, _posX, _posY);
|
2012-02-18 22:19:28 +01:00
|
|
|
assert(0 <= _posX && _posX <= 640);
|
|
|
|
assert(0 <= _posY && _posY <= 480);
|
2012-01-24 08:34:34 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-22 22:31:27 -07:00
|
|
|
void TextObject::setupText() {
|
2011-10-12 17:42:40 +02:00
|
|
|
Common::String msg = LuaBase::instance()->parseMsgText(_textID.c_str(), NULL);
|
2009-05-10 15:48:40 +00:00
|
|
|
Common::String message;
|
2005-03-19 21:48:23 +00:00
|
|
|
|
2005-04-05 13:50:54 +00:00
|
|
|
// remove spaces (NULL_TEXT) from the end of the string,
|
|
|
|
// while this helps make the string unique it screws up
|
|
|
|
// text justification
|
2005-08-21 13:59:38 +00:00
|
|
|
// remove char of id 13 from the end of the string,
|
2011-05-26 11:35:11 -07:00
|
|
|
int pos = msg.size() - 1;
|
2011-05-26 14:01:29 -07:00
|
|
|
while (pos >= 0 && (msg[pos] == ' ' || msg[pos] == 13)) {
|
2009-05-10 15:48:40 +00:00
|
|
|
msg.deleteLastChar();
|
2011-05-26 11:35:11 -07:00
|
|
|
pos = msg.size() - 1;
|
|
|
|
}
|
2011-06-24 15:22:31 +02:00
|
|
|
delete[] _lines;
|
2011-05-26 11:16:11 -07:00
|
|
|
if (msg.size() == 0) {
|
2011-06-24 15:22:31 +02:00
|
|
|
_lines = NULL;
|
2011-05-26 11:16:11 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-24 08:34:34 -08:00
|
|
|
reposition();
|
2011-05-26 11:35:11 -07:00
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
// format the output message to incorporate line wrapping
|
|
|
|
// (if necessary) for the text object
|
2010-08-09 13:18:43 +00:00
|
|
|
const int SCREEN_WIDTH = _width ? _width : 640;
|
2009-11-16 18:09:51 +00:00
|
|
|
const int SCREEN_MARGIN = 75;
|
|
|
|
|
|
|
|
// If the speaker is too close to the edge of the screen we have to make
|
|
|
|
// some room for the subtitles.
|
|
|
|
if (_isSpeech){
|
2012-02-18 22:18:34 +01:00
|
|
|
if (_posX < SCREEN_MARGIN) {
|
|
|
|
_posX = SCREEN_MARGIN;
|
|
|
|
} else if (SCREEN_WIDTH - _posX < SCREEN_MARGIN) {
|
|
|
|
_posX = SCREEN_WIDTH - SCREEN_MARGIN;
|
2009-11-16 18:09:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The maximum width for any line of text is determined by the justification
|
|
|
|
// mode. Note that there are no left/right margins -- this is consistent
|
|
|
|
// with GrimE.
|
2011-04-17 12:34:22 +02:00
|
|
|
int maxWidth = 0;
|
2009-11-16 18:09:51 +00:00
|
|
|
if (_justify == CENTER) {
|
2012-02-18 22:18:34 +01:00
|
|
|
maxWidth = 2 * MIN(_posX, SCREEN_WIDTH - _posX);
|
2009-11-16 18:09:51 +00:00
|
|
|
} else if (_justify == LJUSTIFY) {
|
2012-02-18 22:18:34 +01:00
|
|
|
maxWidth = SCREEN_WIDTH - _posX;
|
2009-11-16 18:09:51 +00:00
|
|
|
} else if (_justify == RJUSTIFY) {
|
2012-02-18 22:18:34 +01:00
|
|
|
maxWidth = _posX;
|
2009-11-16 18:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We break the message to lines not longer than maxWidth
|
2011-07-12 12:20:53 +02:00
|
|
|
Common::String currLine;
|
2009-11-16 18:09:51 +00:00
|
|
|
_numberLines = 1;
|
2009-08-04 14:44:48 +00:00
|
|
|
int lineWidth = 0;
|
|
|
|
int maxLineWidth = 0;
|
2011-05-22 22:31:27 -07:00
|
|
|
for (uint i = 0; i < msg.size(); i++) {
|
2007-01-29 18:42:58 +00:00
|
|
|
lineWidth += MAX(_font->getCharWidth(msg[i]), _font->getCharDataWidth(msg[i]));
|
2009-11-16 18:09:51 +00:00
|
|
|
if (lineWidth > maxWidth) {
|
2011-07-12 12:20:53 +02:00
|
|
|
bool wordSplit = false;
|
|
|
|
if (currLine.contains(' ')) {
|
2009-08-04 14:44:48 +00:00
|
|
|
while (msg[i] != ' ' && i > 0) {
|
2009-11-16 18:09:51 +00:00
|
|
|
lineWidth -= MAX(_font->getCharWidth(msg[i]), _font->getCharDataWidth(msg[i]));
|
2009-08-04 14:44:48 +00:00
|
|
|
message.deleteLastChar();
|
|
|
|
--i;
|
2011-03-21 05:16:27 +08:00
|
|
|
}
|
2009-11-16 18:09:51 +00:00
|
|
|
} else if (msg[i] != ' ') { // if it is a unique word
|
|
|
|
int dashWidth = MAX(_font->getCharWidth('-'), _font->getCharDataWidth('-'));
|
|
|
|
while (lineWidth + dashWidth > maxWidth) {
|
|
|
|
lineWidth -= MAX(_font->getCharWidth(msg[i]), _font->getCharDataWidth(msg[i]));
|
|
|
|
message.deleteLastChar();
|
|
|
|
--i;
|
|
|
|
}
|
2009-08-04 14:44:48 +00:00
|
|
|
message += '-';
|
2011-07-12 12:20:53 +02:00
|
|
|
wordSplit = true;
|
2009-08-04 14:44:48 +00:00
|
|
|
}
|
2005-05-05 21:23:17 +00:00
|
|
|
message += '\n';
|
2011-07-12 12:20:53 +02:00
|
|
|
currLine.clear();
|
2005-05-05 21:23:17 +00:00
|
|
|
_numberLines++;
|
2009-08-04 14:44:48 +00:00
|
|
|
|
2009-11-16 18:09:51 +00:00
|
|
|
if (lineWidth > maxLineWidth) {
|
|
|
|
maxLineWidth = lineWidth;
|
|
|
|
}
|
|
|
|
lineWidth = 0;
|
|
|
|
|
2011-07-12 12:20:53 +02:00
|
|
|
if (wordSplit) {
|
|
|
|
lineWidth += MAX(_font->getCharWidth(msg[i]), _font->getCharDataWidth(msg[i]));
|
|
|
|
} else {
|
|
|
|
continue; // don't add the space back
|
|
|
|
}
|
2005-05-05 21:23:17 +00:00
|
|
|
}
|
2009-08-04 14:44:48 +00:00
|
|
|
|
|
|
|
if (lineWidth > maxLineWidth)
|
|
|
|
maxLineWidth = lineWidth;
|
2009-11-16 18:09:51 +00:00
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
message += msg[i];
|
2011-07-12 12:20:53 +02:00
|
|
|
currLine += msg[i];
|
2005-03-19 21:48:23 +00:00
|
|
|
}
|
2009-08-04 14:44:48 +00:00
|
|
|
|
2009-11-16 18:09:51 +00:00
|
|
|
// If the text object is a speech subtitle, the y parameter is the
|
|
|
|
// coordinate of the bottom of the text block (instead of the top). It means
|
|
|
|
// that every extra line pushes the previous lines up, instead of being
|
|
|
|
// printed further down the screen.
|
|
|
|
const int SCREEN_TOP_MARGIN = 16;
|
|
|
|
if (_isSpeech) {
|
2012-02-18 22:18:34 +01:00
|
|
|
_posY -= _numberLines * _font->getHeight();
|
|
|
|
if (_posY < SCREEN_TOP_MARGIN) {
|
|
|
|
_posY = SCREEN_TOP_MARGIN;
|
2009-11-16 18:09:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-22 22:31:27 -07:00
|
|
|
_lines = new Common::String[_numberLines];
|
2005-05-05 21:23:17 +00:00
|
|
|
|
|
|
|
for (int j = 0; j < _numberLines; j++) {
|
2009-05-10 15:48:40 +00:00
|
|
|
int nextLinePos, cutLen;
|
2011-07-04 12:13:48 +02:00
|
|
|
const char *breakPos = strchr(message.c_str(), '\n');
|
|
|
|
if (breakPos) {
|
|
|
|
nextLinePos = breakPos - message.c_str();
|
2009-05-10 15:48:40 +00:00
|
|
|
cutLen = nextLinePos + 1;
|
|
|
|
} else {
|
|
|
|
nextLinePos = message.size();
|
|
|
|
cutLen = nextLinePos;
|
|
|
|
}
|
|
|
|
Common::String currentLine(message.c_str(), message.c_str() + nextLinePos);
|
2011-05-22 22:31:27 -07:00
|
|
|
_lines[j] = currentLine;
|
|
|
|
int width = _font->getStringLength(currentLine);
|
|
|
|
if (width > _maxLineWidth)
|
|
|
|
_maxLineWidth = width;
|
2009-05-10 15:48:40 +00:00
|
|
|
for (int count = 0; count < cutLen; count++)
|
|
|
|
message.deleteChar(0);
|
2005-03-19 21:48:23 +00:00
|
|
|
}
|
2011-05-23 16:28:05 +02:00
|
|
|
_elapsedTime = 0;
|
2003-08-22 05:53:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 18:08:47 -07:00
|
|
|
int TextObject::getLineX(int line) const {
|
2012-02-18 22:18:34 +01:00
|
|
|
int x = _posX;
|
2011-05-23 16:19:47 -07:00
|
|
|
if (_justify == CENTER)
|
2012-02-18 22:18:34 +01:00
|
|
|
x = _posX - (_font->getStringLength(_lines[line]) / 2);
|
2011-05-23 16:19:47 -07:00
|
|
|
else if (_justify == RJUSTIFY)
|
2012-02-18 22:18:34 +01:00
|
|
|
x = _posX - getBitmapWidth();
|
2011-05-23 16:19:47 -07:00
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
return x;
|
|
|
|
}
|
2008-09-10 08:10:06 +00:00
|
|
|
|
2012-05-05 18:08:47 -07:00
|
|
|
int TextObject::getLineY(int line) const {
|
2012-02-18 22:18:34 +01:00
|
|
|
int y = _posY;
|
2011-05-23 16:19:47 -07:00
|
|
|
if (_blastDraw)
|
2012-02-18 22:18:34 +01:00
|
|
|
y = _posY + 5;
|
2011-05-23 16:19:47 -07:00
|
|
|
else {
|
|
|
|
if (_font->getHeight() == 21) // talk_font,verb_font
|
2012-02-18 22:18:34 +01:00
|
|
|
y = _posY - 6;
|
2011-05-23 16:19:47 -07:00
|
|
|
else if (_font->getHeight() == 26) // special_font
|
2012-02-18 22:18:34 +01:00
|
|
|
y = _posY - 12;
|
2011-05-23 16:19:47 -07:00
|
|
|
else if (_font->getHeight() == 13) // computer_font
|
2012-02-18 22:18:34 +01:00
|
|
|
y = _posY - 6;
|
2011-05-23 16:19:47 -07:00
|
|
|
else if (_font->getHeight() == 19) // pt_font
|
2012-02-18 22:18:34 +01:00
|
|
|
y = _posY - 9;
|
2011-05-23 16:19:47 -07:00
|
|
|
else
|
2012-02-18 22:18:34 +01:00
|
|
|
y = _posY;
|
2011-05-23 16:19:47 -07:00
|
|
|
}
|
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
|
|
|
y += _font->getHeight()*line;
|
2009-05-09 17:47:28 +00:00
|
|
|
|
2011-05-23 16:19:47 -07:00
|
|
|
return y;
|
|
|
|
}
|
2011-05-22 20:43:28 -07:00
|
|
|
|
2011-05-23 16:19:47 -07:00
|
|
|
void TextObject::draw() {
|
2012-01-11 19:06:19 -08:00
|
|
|
if (!_lines)
|
2011-05-23 16:19:47 -07:00
|
|
|
return;
|
2005-05-05 21:23:17 +00:00
|
|
|
|
2011-05-23 22:00:53 -07:00
|
|
|
if (!_created) {
|
|
|
|
g_driver->createTextObject(this);
|
|
|
|
_created = true;
|
|
|
|
}
|
|
|
|
|
2011-10-07 23:05:20 +02:00
|
|
|
if (_justify > 3 || _justify < 0)
|
2011-05-23 16:19:47 -07:00
|
|
|
warning("TextObject::draw: Unknown justification code (%d)", _justify);
|
2005-05-05 21:23:17 +00:00
|
|
|
|
2011-05-23 16:19:47 -07:00
|
|
|
g_driver->drawTextObject(this);
|
2005-05-05 21:23:17 +00:00
|
|
|
|
2003-08-22 05:53:29 +00:00
|
|
|
}
|
2009-05-25 06:49:57 +00:00
|
|
|
|
2011-05-22 19:46:59 +02:00
|
|
|
void TextObject::update() {
|
2012-01-11 19:06:19 -08:00
|
|
|
if (!_duration || !_created) {
|
2011-05-22 19:46:59 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-23 16:28:05 +02:00
|
|
|
_elapsedTime += g_grim->getFrameTime();
|
|
|
|
if (_elapsedTime > _duration) {
|
2012-01-11 19:06:19 -08:00
|
|
|
delete this;
|
2011-05-22 19:46:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
} // end of namespace Grim
|