ScummVM API documentation
textobject.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRIM_TEXTOBJECT_H
23 #define GRIM_TEXTOBJECT_H
24 
25 #include "engines/grim/pool.h"
26 #include "engines/grim/color.h"
27 
28 #include "common/endian.h"
29 
30 namespace Grim {
31 
32 class SaveGame;
33 class Font;
34 
36 public:
37  void setX(int x) { _x = x; }
38  int getX() const { return _x; }
39 
40  void setY(int y) { _y = y; }
41  int getY() const { return _y; }
42 
43  void setFont(const Font *font) { _font = font; }
44  const Font *getFont() const { return _font; }
45 
46  void setFGColor(const Color &fgColor) { _fgColor = fgColor; }
47  Color getFGColor() const { return _fgColor; }
48 
49  void setJustify(int justify) { _justify = justify; }
50  int getJustify() const { return _justify; }
51 
52  void setWidth(int width) { _width = width; }
53  int getWidth() const { return _width; }
54 
55  void setHeight(int height) { _height = height; }
56  int getHeight() const { return _height; }
57 
58  void setDuration(int duration) { _duration = duration; }
59  int getDuration() const { return _duration; }
60 
61  void setLayer(int layer);
62  int getLayer() const { return _layer; }
63 
64  void setCoords(int coords) { _coords = coords; }
65  int getCoords() const { return _coords; }
66 
67 protected:
69 
70  const Font *_font;
71  int _x, _y;
72  int _width, _height;
73  int _justify;
74  int _duration;
75  int _layer;
76  int _coords;
77  Color _fgColor;
78 };
79 
81 
82 };
83 
84 class TextObject : public PoolObject<TextObject>, public TextObjectCommon {
85 public:
86  TextObject();
87  ~TextObject();
88 
89  static int32 getStaticTag() { return MKTAG('T', 'E', 'X', 'T'); }
90 
91  void setDefaults(const TextObjectDefaults *defaults);
92  void setText(const Common::String &text, bool delaySetup);
93  void reset();
94 
95  int getBitmapWidth() const;
96  int getBitmapHeight() const;
97  int getTextCharPosition(int pos);
98 
99  int getLineX(int line) const;
100  int getLineY(int line) const;
101 
102  void setIsSpeech() { _isSpeech = true; }
103  void setBlastDraw() { _blastDraw = true; }
104  bool isBlastDraw() { return _blastDraw; }
105 
106  const void *getUserData() const { return _userData; }
107  void setUserData(void *data) { _userData = data; }
108 
109  const Common::String *getLines() const { return _lines; }
110  int getNumLines() const { return _numberLines; }
111 
112  const Common::String &getName() const { return _textID; }
113  void draw();
114  void update();
115 
116  void destroy();
117 
118  void saveState(SaveGame *state) const;
119  bool restoreState(SaveGame *state);
120 
121  int getStackLevel() { return _stackLevel; }
122  void incStackLevel() { _stackLevel++; }
123  void decStackLevel() { assert(_stackLevel > 0); _stackLevel--; }
124 
125  enum Justify {
126  NONE,
127  CENTER,
128  LJUSTIFY,
129  RJUSTIFY
130  };
131 
132 protected:
133  void setupText();
134 
135  Common::String _textID;
136 
137  Common::String *_lines;
138 
139  void *_userData;
140 
141  int _numberLines;
142  int _elapsedTime;
143  int _maxLineWidth;
144 
145  bool _blastDraw;
146  bool _isSpeech;
147  bool _created;
148 
149  int _stackLevel;
150 
151 private:
152  template <typename S>
153  void setupTextReal(S msg, Common::String (*convert)(const S &s));
154 };
155 
156 } // end of namespace Grim
157 
158 #endif
Definition: str.h:59
Definition: savegame.h:33
Definition: actor.h:33
Definition: textobject.h:84
Definition: textobject.h:35
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: pool.h:42
Definition: font.h:38
Definition: textobject.h:80
Definition: color.h:29