1 /* ResidualVM - A 3D game interpreter 2 * 3 * ResidualVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the AUTHORS 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GRIM_TEXTOBJECT_H 24 #define GRIM_TEXTOBJECT_H 25 26 #include "engines/grim/pool.h" 27 #include "engines/grim/color.h" 28 29 #include "common/endian.h" 30 31 namespace Grim { 32 33 class SaveGame; 34 class Font; 35 36 class TextObjectCommon { 37 public: setX(int x)38 void setX(int x) { _x = x; } getX()39 int getX() const { return _x; } 40 setY(int y)41 void setY(int y) { _y = y; } getY()42 int getY() const { return _y; } 43 setFont(const Font * font)44 void setFont(const Font *font) { _font = font; } getFont()45 const Font *getFont() const { return _font; } 46 setFGColor(const Color & fgColor)47 void setFGColor(const Color &fgColor) { _fgColor = fgColor; } getFGColor()48 Color getFGColor() const { return _fgColor; } 49 setJustify(int justify)50 void setJustify(int justify) { _justify = justify; } getJustify()51 int getJustify() const { return _justify; } 52 setWidth(int width)53 void setWidth(int width) { _width = width; } getWidth()54 int getWidth() const { return _width; } 55 setHeight(int height)56 void setHeight(int height) { _height = height; } getHeight()57 int getHeight() const { return _height; } 58 setDuration(int duration)59 void setDuration(int duration) { _duration = duration; } getDuration()60 int getDuration() const { return _duration; } 61 62 void setLayer(int layer); getLayer()63 int getLayer() const { return _layer; } 64 setCoords(int coords)65 void setCoords(int coords) { _coords = coords; } getCoords()66 int getCoords() const { return _coords; } 67 68 protected: 69 TextObjectCommon(); 70 71 const Font *_font; 72 int _x, _y; 73 int _width, _height; 74 int _justify; 75 int _duration; 76 int _layer; 77 int _coords; 78 Color _fgColor; 79 }; 80 81 class TextObjectDefaults : public TextObjectCommon { 82 83 }; 84 85 class TextObject : public PoolObject<TextObject>, 86 public TextObjectCommon { 87 public: 88 TextObject(); 89 ~TextObject(); 90 getStaticTag()91 static int32 getStaticTag() { return MKTAG('T', 'E', 'X', 'T'); } 92 93 void setDefaults(const TextObjectDefaults *defaults); 94 void setText(const Common::String &text, bool delaySetup); 95 void reset(); 96 97 int getBitmapWidth() const; 98 int getBitmapHeight() const; 99 int getTextCharPosition(int pos); 100 101 int getLineX(int line) const; 102 int getLineY(int line) const; 103 setIsSpeech()104 void setIsSpeech() { _isSpeech = true; } setBlastDraw()105 void setBlastDraw() { _blastDraw = true; } isBlastDraw()106 bool isBlastDraw() { return _blastDraw; } 107 getUserData()108 const void *getUserData() const { return _userData; } setUserData(void * data)109 void setUserData(void *data) { _userData = data; } 110 getLines()111 const Common::String *getLines() const { return _lines; } getNumLines()112 int getNumLines() const { return _numberLines; } 113 getName()114 const Common::String &getName() const { return _textID; } 115 void draw(); 116 void update(); 117 118 void destroy(); 119 120 void saveState(SaveGame *state) const; 121 bool restoreState(SaveGame *state); 122 getStackLevel()123 int getStackLevel() { return _stackLevel; } incStackLevel()124 void incStackLevel() { _stackLevel++; } decStackLevel()125 void decStackLevel() { assert(_stackLevel > 0); _stackLevel--; } 126 127 enum Justify { 128 NONE, 129 CENTER, 130 LJUSTIFY, 131 RJUSTIFY 132 }; 133 134 protected: 135 void setupText(); 136 137 Common::String _textID; 138 139 Common::String *_lines; 140 141 void *_userData; 142 143 int _numberLines; 144 int _elapsedTime; 145 int _maxLineWidth; 146 147 bool _blastDraw; 148 bool _isSpeech; 149 bool _created; 150 151 int _stackLevel; 152 }; 153 154 } // end of namespace Grim 155 156 #endif 157