2009-05-26 14:13:08 +00:00
|
|
|
/* Residual - A 3D game interpreter
|
2008-06-13 14:57:47 +00:00
|
|
|
*
|
|
|
|
* Residual is the legal property of its developers, whose names
|
2011-04-16 14:12:44 +02:00
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
2008-06-13 14:57:47 +00:00
|
|
|
* file distributed with this source distribution.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
2003-08-22 05:53:29 +00:00
|
|
|
|
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-04-10 11:24:03 +02:00
|
|
|
#include "engines/grim/colormap.h"
|
2011-05-13 17:55:14 -07:00
|
|
|
#include "engines/grim/font.h"
|
2003-08-22 05:53:29 +00:00
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
namespace Grim {
|
|
|
|
|
2009-05-10 15:48:40 +00:00
|
|
|
Common::String parseMsgText(const char *msg, char *msgId);
|
2005-03-19 21:48:23 +00:00
|
|
|
|
2011-05-18 09:03:17 +08:00
|
|
|
TextObjectCommon::TextObjectCommon() :
|
|
|
|
_x(0), _y(0), _fgColor(0), _justify(0), _width(0), _height(0),
|
2011-05-23 16:34:38 +02:00
|
|
|
_disabled(false), _font(NULL), _duration(0) {
|
2011-05-18 09:03:17 +08:00
|
|
|
}
|
|
|
|
|
2009-11-16 18:09:51 +00:00
|
|
|
TextObject::TextObject(bool blastDraw, bool isSpeech) :
|
2011-05-18 09:03:17 +08:00
|
|
|
Object(), TextObjectCommon(), _created(false), _numberLines(1),
|
|
|
|
_textBitmap(NULL),_bitmapWidthPtr(NULL), _textObjectHandle(NULL) {
|
2005-04-03 11:33:28 +00:00
|
|
|
memset(_textID, 0, sizeof(_textID));
|
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() :
|
2011-05-18 09:03:17 +08:00
|
|
|
Object(), TextObjectCommon(), _textObjectHandle(NULL),
|
|
|
|
_bitmapWidthPtr(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
|
|
|
|
2009-10-17 13:25:12 +00:00
|
|
|
void TextObject::setText(const char *text) {
|
2005-04-05 13:50:54 +00:00
|
|
|
if (strlen(text) < sizeof(_textID))
|
|
|
|
strcpy(_textID, text);
|
|
|
|
else {
|
2009-06-01 19:09:09 +00:00
|
|
|
error("Text ID exceeded maximum length (%d): %s", (int)sizeof(_textID), text);
|
2005-04-05 13:50:54 +00:00
|
|
|
// this should be good enough to still be unique
|
|
|
|
// but for debug purposes lets make this crash the program so we know about it
|
|
|
|
strncpy(_textID, text, sizeof(_textID));
|
2011-04-05 21:45:20 +02:00
|
|
|
_textID[sizeof(_textID) - 1] = 0;
|
2005-04-05 13:50:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-20 13:51:40 +00:00
|
|
|
TextObject::~TextObject() {
|
|
|
|
destroyBitmap();
|
|
|
|
}
|
|
|
|
|
2011-03-21 05:16:27 +08:00
|
|
|
void TextObject::saveState(SaveGame *state) const {
|
2011-05-02 03:50:09 +08:00
|
|
|
state->writeLEUint32(_fgColor->getId());
|
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
|
|
|
|
|
|
|
state->writeLESint32(_disabled);
|
|
|
|
state->writeLESint32(_blastDraw);
|
|
|
|
state->writeLESint32(_isSpeech);
|
2011-03-22 17:51:34 +01:00
|
|
|
state->writeLESint32(_created);
|
2011-05-23 16:28:05 +02:00
|
|
|
state->writeLESint32(_elapsedTime);
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2011-05-02 03:50:09 +08:00
|
|
|
state->writeLEUint32(_font->getId());
|
2011-03-21 05:16:27 +08:00
|
|
|
|
|
|
|
state->write(_textID, 256);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TextObject::restoreState(SaveGame *state) {
|
2011-03-22 17:51:34 +01:00
|
|
|
destroyBitmap();
|
|
|
|
|
2011-05-05 11:25:08 +02:00
|
|
|
_fgColor = g_grim->getColor(state->readLEUint32());
|
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
|
|
|
|
2011-05-23 16:28:05 +02:00
|
|
|
_disabled = state->readLESint32();
|
|
|
|
_blastDraw = state->readLESint32();
|
|
|
|
_isSpeech = state->readLESint32();
|
|
|
|
_created = state->readLESint32();
|
|
|
|
_elapsedTime = state->readLESint32();
|
2011-03-21 05:16:27 +08:00
|
|
|
|
2011-05-02 03:50:09 +08:00
|
|
|
_font = g_grim->getFont(state->readLEUint32());
|
2011-03-21 05:16:27 +08:00
|
|
|
|
|
|
|
state->read(_textID, 256);
|
|
|
|
|
|
|
|
_textBitmap = NULL;
|
|
|
|
_textObjectHandle = NULL;
|
|
|
|
_bitmapWidthPtr = NULL;
|
|
|
|
|
2011-03-22 17:51:34 +01:00
|
|
|
if (_created) {
|
|
|
|
_created = false;
|
|
|
|
createBitmap();
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
_disabled = defaults->getDisabled();
|
2005-03-20 13:51:40 +00:00
|
|
|
}
|
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
int TextObject::getBitmapWidth() {
|
2008-09-10 11:16:57 +00:00
|
|
|
if (!_bitmapWidthPtr)
|
2005-05-05 21:23:17 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
int width = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < _numberLines; i++) {
|
|
|
|
if (_bitmapWidthPtr[i] > width)
|
|
|
|
width = _bitmapWidthPtr[i];
|
|
|
|
}
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TextObject::getBitmapHeight() {
|
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;
|
2009-05-10 15:48:40 +00:00
|
|
|
Common::String msg = parseMsgText(_textID, 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;
|
|
|
|
}
|
|
|
|
|
2005-03-20 13:51:40 +00:00
|
|
|
void TextObject::createBitmap() {
|
|
|
|
if (_created)
|
|
|
|
destroyBitmap();
|
|
|
|
|
2009-05-10 15:48:40 +00:00
|
|
|
Common::String msg = parseMsgText(_textID, NULL);
|
|
|
|
Common::String message;
|
2009-10-17 13:25:12 +00:00
|
|
|
const char *c = msg.c_str();
|
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
|
2009-05-10 15:48:40 +00:00
|
|
|
for (int i = (int)msg.size() - 1; c[i] == TEXT_NULL; i--)
|
|
|
|
msg.deleteLastChar();
|
2005-08-21 13:59:38 +00:00
|
|
|
|
|
|
|
// remove char of id 13 from the end of the string,
|
2009-05-10 15:48:40 +00:00
|
|
|
for (int i = (int)msg.size() - 1; c[i] == 13; i--)
|
|
|
|
msg.deleteLastChar();
|
2005-04-05 13:50:54 +00: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){
|
|
|
|
if (_x < SCREEN_MARGIN) {
|
|
|
|
_x = SCREEN_MARGIN;
|
|
|
|
} else if (SCREEN_WIDTH - _x < SCREEN_MARGIN) {
|
|
|
|
_x = SCREEN_WIDTH - SCREEN_MARGIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
maxWidth = 2 * MIN(_x, SCREEN_WIDTH - _x);
|
|
|
|
} else if (_justify == LJUSTIFY) {
|
|
|
|
maxWidth = SCREEN_WIDTH - _x;
|
|
|
|
} else if (_justify == RJUSTIFY) {
|
|
|
|
maxWidth = _x;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We break the message to lines not longer than maxWidth
|
|
|
|
_numberLines = 1;
|
2009-08-04 14:44:48 +00:00
|
|
|
int lineWidth = 0;
|
|
|
|
int maxLineWidth = 0;
|
|
|
|
for (int i = 0; i < (int)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) {
|
2009-08-04 14:44:48 +00:00
|
|
|
if (message.contains(' ')) {
|
|
|
|
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 += '-';
|
|
|
|
}
|
2005-05-05 21:23:17 +00:00
|
|
|
message += '\n';
|
|
|
|
_numberLines++;
|
2009-08-04 14:44:48 +00:00
|
|
|
|
2009-11-16 18:09:51 +00:00
|
|
|
if (lineWidth > maxLineWidth) {
|
|
|
|
maxLineWidth = lineWidth;
|
|
|
|
}
|
|
|
|
lineWidth = 0;
|
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
continue; // don't add the space back
|
|
|
|
}
|
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];
|
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) {
|
|
|
|
_y -= _numberLines * _font->getHeight();
|
|
|
|
if (_y < SCREEN_TOP_MARGIN) {
|
|
|
|
_y = SCREEN_TOP_MARGIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-07 19:06:31 +00:00
|
|
|
_textObjectHandle = (GfxBase::TextObjectHandle **)malloc(sizeof(long) * _numberLines);
|
2008-03-10 23:06:07 +00:00
|
|
|
_bitmapWidthPtr = new int[_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;
|
|
|
|
const char *pos = strchr(message.c_str(), '\n');
|
|
|
|
if (pos) {
|
|
|
|
nextLinePos = pos - message.c_str();
|
|
|
|
cutLen = nextLinePos + 1;
|
|
|
|
} else {
|
|
|
|
nextLinePos = message.size();
|
|
|
|
cutLen = nextLinePos;
|
|
|
|
}
|
|
|
|
Common::String currentLine(message.c_str(), message.c_str() + nextLinePos);
|
2005-05-05 21:23:17 +00:00
|
|
|
|
|
|
|
_bitmapWidthPtr[j] = 0;
|
2009-05-10 15:48:40 +00:00
|
|
|
for (unsigned int i = 0; i < currentLine.size(); ++i) {
|
2008-09-28 15:23:15 +00:00
|
|
|
_bitmapWidthPtr[j] += MAX(_font->getCharWidth(currentLine[i]), _font->getCharDataWidth(currentLine[i]));
|
2005-05-05 21:23:17 +00:00
|
|
|
}
|
|
|
|
|
2007-01-29 18:42:58 +00:00
|
|
|
_textBitmap = new uint8[_font->getHeight() * (_bitmapWidthPtr[j] + 1)];
|
2009-04-07 12:58:30 +00:00
|
|
|
memset(_textBitmap, 0, _font->getHeight() * (_bitmapWidthPtr[j] + 1));
|
2005-05-05 21:23:17 +00:00
|
|
|
|
|
|
|
// Fill bitmap
|
2007-01-29 18:42:58 +00:00
|
|
|
int startOffset = 0;
|
2009-10-17 12:48:23 +00:00
|
|
|
for (unsigned int d = 0; d < currentLine.size(); d++) {
|
|
|
|
int ch = currentLine[d];
|
2007-01-29 18:42:58 +00:00
|
|
|
int8 startingLine = _font->getCharStartingLine(ch) + _font->getBaseOffsetY();
|
|
|
|
int32 charDataWidth = _font->getCharDataWidth(ch);
|
|
|
|
int32 charWidth = _font->getCharWidth(ch);
|
|
|
|
int8 startingCol = _font->getCharStartingCol(ch);
|
|
|
|
for (int line = 0; line < _font->getCharDataHeight(ch); line++) {
|
|
|
|
int offset = startOffset + ((_bitmapWidthPtr[j] + 1) * (line + startingLine));
|
|
|
|
for (int r = 0; r < charDataWidth; r++) {
|
|
|
|
const byte pixel = *(_font->getCharData(ch) + r + (charDataWidth * line));
|
|
|
|
byte *dst = _textBitmap + offset + startingCol + r;
|
2008-09-28 15:23:15 +00:00
|
|
|
if (*dst == 0 && pixel != 0)
|
2007-01-29 18:42:58 +00:00
|
|
|
_textBitmap[offset + startingCol + r] = pixel;
|
2005-05-05 21:23:17 +00:00
|
|
|
}
|
2007-01-29 18:42:58 +00:00
|
|
|
if (line + startingLine >= _font->getHeight())
|
|
|
|
break;
|
2005-03-19 21:48:23 +00:00
|
|
|
}
|
2007-01-29 18:42:58 +00:00
|
|
|
startOffset += charWidth;
|
2005-03-19 21:48:23 +00:00
|
|
|
}
|
2007-01-29 18:42:58 +00:00
|
|
|
|
2011-05-01 18:51:26 +02:00
|
|
|
_textObjectHandle[j] = g_driver->createTextBitmap(_textBitmap, _bitmapWidthPtr[j] + 1, _font->getHeight(), *_fgColor);
|
2005-05-05 21:23:17 +00:00
|
|
|
delete[] _textBitmap;
|
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
|
|
|
}
|
2005-03-20 13:51:40 +00:00
|
|
|
_created = true;
|
2011-05-23 16:28:05 +02:00
|
|
|
_elapsedTime = 0;
|
2003-08-22 05:53:29 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 17:55:14 -07:00
|
|
|
void TextObject::subBaseOffsetY() {
|
|
|
|
if (_font)
|
|
|
|
_y -= _font->getBaseOffsetY();
|
|
|
|
else
|
|
|
|
_y -= 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TextObject::getBaseOffsetY() {
|
|
|
|
if (_font)
|
|
|
|
return _font->getBaseOffsetY();
|
|
|
|
else
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
2005-03-20 13:51:40 +00:00
|
|
|
void TextObject::destroyBitmap() {
|
2005-04-05 13:50:54 +00:00
|
|
|
_created = false;
|
2005-03-20 13:51:40 +00:00
|
|
|
if (_textObjectHandle) {
|
2005-05-05 21:23:17 +00:00
|
|
|
for (int i = 0; i < _numberLines; i++) {
|
|
|
|
g_driver->destroyTextBitmap(_textObjectHandle[i]);
|
2008-07-13 15:42:45 +00:00
|
|
|
delete _textObjectHandle[i];
|
2005-05-05 21:23:17 +00:00
|
|
|
}
|
|
|
|
free(_textObjectHandle);
|
2005-03-20 13:51:40 +00:00
|
|
|
_textObjectHandle = NULL;
|
|
|
|
}
|
2005-05-05 21:23:17 +00:00
|
|
|
if (_bitmapWidthPtr) {
|
2008-03-10 23:06:07 +00:00
|
|
|
delete[] _bitmapWidthPtr;
|
2005-05-05 21:23:17 +00:00
|
|
|
_bitmapWidthPtr = NULL;
|
|
|
|
}
|
2005-03-19 21:48:23 +00:00
|
|
|
}
|
2005-01-02 13:34:50 +00:00
|
|
|
|
2003-08-22 05:53:29 +00:00
|
|
|
void TextObject::draw() {
|
2005-05-05 21:23:17 +00:00
|
|
|
int height = 0;
|
|
|
|
|
2009-05-24 19:44:47 +00:00
|
|
|
if (!_created || _disabled)
|
2005-04-05 13:50:54 +00:00
|
|
|
return;
|
2005-05-05 21:23:17 +00:00
|
|
|
// render multi-line (wrapped) text
|
|
|
|
for (int i = 0; i < _numberLines; i++) {
|
|
|
|
int y;
|
|
|
|
|
2008-09-10 08:10:06 +00:00
|
|
|
if (_blastDraw)
|
2009-04-07 12:01:07 +00:00
|
|
|
y = _y + 5;
|
|
|
|
else {
|
2009-04-08 09:14:31 +00:00
|
|
|
if (_font->getHeight() == 21) // talk_font,verb_font
|
2009-04-07 12:01:07 +00:00
|
|
|
y = _y - 6;
|
2009-04-08 09:14:31 +00:00
|
|
|
else if (_font->getHeight() == 26) // special_font
|
2009-04-07 12:01:07 +00:00
|
|
|
y = _y - 12;
|
2009-04-08 09:14:31 +00:00
|
|
|
else if (_font->getHeight() == 13) // computer_font
|
2009-04-07 12:01:07 +00:00
|
|
|
y = _y - 6;
|
2009-04-08 09:14:31 +00:00
|
|
|
else if (_font->getHeight() == 19) // pt_font
|
|
|
|
y = _y - 9;
|
2009-04-07 12:01:07 +00:00
|
|
|
else
|
|
|
|
y = _y;
|
|
|
|
}
|
2008-09-10 08:10:06 +00:00
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
2009-05-09 17:47:28 +00:00
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
if (_justify == LJUSTIFY || _justify == NONE)
|
|
|
|
g_driver->drawTextBitmap(_x, height + y, _textObjectHandle[i]);
|
|
|
|
else if (_justify == CENTER) {
|
2007-01-29 18:42:58 +00:00
|
|
|
int x = _x - (_bitmapWidthPtr[i] / 2);
|
2005-05-05 21:23:17 +00:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
|
|
|
|
g_driver->drawTextBitmap(x, height + y, _textObjectHandle[i]);
|
|
|
|
} else if (_justify == RJUSTIFY) {
|
2007-01-29 18:42:58 +00:00
|
|
|
int x = (_x - getBitmapWidth());
|
2005-05-05 21:23:17 +00:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
|
2007-01-29 18:42:58 +00:00
|
|
|
g_driver->drawTextBitmap(x, height + y, _textObjectHandle[i]);
|
2009-05-25 19:21:58 +00:00
|
|
|
} else if (gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL)
|
2009-05-31 07:33:18 +00:00
|
|
|
warning("TextObject::draw: Unknown justification code (%d)", _justify);
|
2005-05-05 21:23:17 +00:00
|
|
|
|
2007-01-29 18:42:58 +00:00
|
|
|
height += _font->getHeight();
|
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() {
|
|
|
|
if (!_created || _disabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-23 16:28:05 +02:00
|
|
|
_elapsedTime += g_grim->getFrameTime();
|
|
|
|
if (_elapsedTime > _duration) {
|
2011-05-22 19:46:59 +02:00
|
|
|
_disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
} // end of namespace Grim
|