scummvm/engines/grim/textobject.h

136 lines
3.2 KiB
C
Raw Normal View History

2012-01-06 23:29:45 +01:00
/* ResidualVM - A 3D game interpreter
*
2012-01-06 23:29:45 +01:00
* ResidualVM 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
* 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
*
*/
2009-05-26 09:39:42 +00:00
#ifndef GRIM_TEXTOBJECT_H
#define GRIM_TEXTOBJECT_H
#include "engines/grim/pool.h"
#include "engines/grim/color.h"
2005-01-01 12:27:57 +00:00
#include "common/endian.h"
2009-05-25 06:49:57 +00:00
namespace Grim {
2009-06-23 05:15:20 +00:00
class SaveGame;
2011-05-13 17:55:14 -07:00
class Font;
2009-06-23 05:15:20 +00:00
class TextObjectCommon {
public:
2012-01-24 08:34:34 -08:00
void setX(int x) { _x = x; _positioned = false; }
int getX() { return _x; }
2012-01-24 08:34:34 -08:00
void setY(int y) { _y = y; _positioned = false; }
int getY() { return _y; }
void setFont(Font *font) { _font = font; }
Font *getFont() { return _font; }
void setFGColor(const Color &fgColor) { _fgColor = fgColor; }
Color getFGColor() { return _fgColor; }
void setJustify(int justify) { _justify = justify; }
int getJustify() { return _justify; }
void setWidth(int width) { _width = width; }
int getWidth() { return _width; }
void setHeight(int height) { _height = height; }
int getHeight() { return _height; }
void setDuration(int duration) { _duration = duration; }
int getDuration() const { return _duration; }
protected:
TextObjectCommon();
Color _fgColor;
int _x, _y;
int _posX, _posY;
int _width, _height;
int _justify;
Font *_font;
int _duration;
2012-01-24 08:34:34 -08:00
bool _positioned;
};
class TextObjectDefaults : public TextObjectCommon {
};
class TextObject : public PoolObject<TextObject, MKTAG('T', 'E', 'X', 'T')>,
public TextObjectCommon {
public:
2009-11-16 18:09:51 +00:00
TextObject(bool blastDraw, bool isSpeech = false);
TextObject();
~TextObject();
void setDefaults(TextObjectDefaults *defaults);
void setText(const Common::String &text);
void reset();
int getBitmapWidth();
int getBitmapHeight();
2005-04-05 04:33:56 +00:00
int getTextCharPosition(int pos);
int getLineX(int line);
int getLineY(int line);
void *getUserData() { return _userData; }
void setUserData(void *data) { _userData = data; }
const Common::String *getLines() { return _lines; }
int getNumLines() { return _numberLines; }
const Common::String &getName() const { return _textID; }
void draw();
void update();
2011-06-07 09:20:10 -07:00
void destroy();
2012-01-24 08:34:34 -08:00
void reposition();
2011-06-07 09:20:10 -07:00
2011-03-21 17:18:04 +01:00
void saveState(SaveGame *state) const;
bool restoreState(SaveGame *state);
enum Justify {
NONE,
CENTER,
LJUSTIFY,
RJUSTIFY
};
protected:
bool _created;
void setupText();
int _numberLines;
bool _blastDraw;
2009-11-16 18:09:51 +00:00
bool _isSpeech;
Common::String _textID;
2011-05-23 16:28:05 +02:00
int _elapsedTime;
int _maxLineWidth;
Common::String *_lines;
void *_userData;
};
2009-05-25 06:49:57 +00:00
} // end of namespace Grim
#endif