ScummVM API documentation
text.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 TWINE_TEXT_H
23#define TWINE_TEXT_H
24
25#include "common/scummsys.h"
26#include "common/str.h"
27#include "common/rect.h"
28#include "twine/shared.h"
29
30namespace TwinE {
31
32class TextEntry;
33
34// MAX_CAR
35#define TEXT_MAX_FADE_IN_CHR 32
36#define INTER_LINE 38
37#define INTER_SPACE 7
38#define INTER_LEAVE 2
39
40enum class ProgressiveTextState {
41 End = 0,
42 ContinueRunning = 1,
43 NextPage = 2
44};
45
46class TwinEEngine;
47
48class Text {
49private:
50 TwinEEngine *_engine;
51 void initVoxBank(TextBankId bankIdx);
58 void drawCharacter(int32 x, int32 y, uint16 character);
66 void drawCharacterShadow(int32 x, int32 y, uint16 character, int32 color, Common::Rect& dirtyRect);
67 void initEndPage();
68 struct WordSize {
69 int32 lenWord = 0;
70 int32 sizeWord = 0;
71 };
72 struct LineCharacter {
73 int16 chr = 0;
74 int16 width = 0;
75 };
76 WordSize getNextWord(const char *completeText, char *wordBuf, int32 wordBufSize);
77 uint16 getNextChar(const char *&dialogue);
78 void getNextLine();
79 void appendText(const char *s, uint &i);
80 // draw next page arrow polygon
81 void renderContinueReadingTriangle();
85 void pushChar(int16 baseX, int16 y, const LineCharacter &chr); // PushCar
91 void fadeInCharacters(int32 counter, int32 fontColor);
92
93 TextBankId _currentBankIdx = TextBankId::None;
94
95 LineCharacter _bufLine[256];
96 const char *_ptDial = nullptr;
97
98 int32 _xDial = 0;
99 int32 _yDial = 0;
100
102 const LineCharacter *_ptLine = nullptr;
103
104 int32 _nbLineDial = 0;
105 struct BlendInCharacter { // T_STACKCAR
106 int16 chr = 0;
107 int16 x = 0;
108 int16 y = 0;
109 };
110 BlendInCharacter _stackChar[TEXT_MAX_FADE_IN_CHR]; // StackCar
111 int32 _nbChar = 0; // NbCar
112 int32 _sizeLine = 0;
113 int32 _nbSpace = 0;
114 int32 _nbBigSpace = 0;
115 int32 _sizeSpace = 0;
116
118 const char *_ptText = nullptr;
120 int32 _currDialTextSize = 0;
121
122 char _currMenuTextBuffer[256];
123 TextBankId _currMenuTextBank = TextBankId::None;
124 TextId _currMenuTextIndex = TextId::kNone;
125
127 int32 _interLeave = 0;
129 int32 _interSpace = 0;
131 int32 _dialTextColor = 0;
132
134 int32 _maxDegrade = 0;
136 int32 _minDegrade = 0;
142 int32 _stepDegrade = 0;
144 int32 _nbDegrade = 0;
145
146 int32 _maxLineDial = 0;
147 int32 _dialMaxSize = 0;
148
149 bool _isShiftJIS = false;
150 bool _isVisualRTL = false;
151
152public:
153 Text(TwinEEngine *engine);
154 ~Text();
155
156 // Dial_X1, Dial_Y1
157 Common::Rect _dialTextBox { 0, 0, 0, 0};
158 bool displayText(TextId index, bool showText, bool playVox, bool loop); // MyDial
159
160 static const int32 lineHeight = INTER_LINE;
161
162 bool _flagRunningDial = false;
163 bool _flagEndDial = false;
164 bool _flagEnd3Line = false;
165 // renders a triangle if the next side of the text can get activated
166 bool _renderTextTriangle = false;
167 bool _flagMessageShade = false;
168 bool _hasHiddenVox = false;
169 int32 _voxHiddenIndex = 0;
170 // ---
171
172 const TextEntry *_currDialTextEntry = nullptr; // ordered entry
173 Common::String _currentVoxBankFile;
174 // used for the android version (dotemu)
175 Common::String _currentOggBaseFile;
176
177 bool _showDialogueBubble = true;
178
183 void initDial(TextBankId bankIdx);
184 void initSceneTextBank();
185 inline TextBankId textBank() const {
186 return _currentBankIdx;
187 }
188 void closeDial();
195 void drawText(int32 x, int32 y, const char *dialogue, bool shadow = false);
196
197 bool drawTextProgressive(TextId index, bool playVox = true, bool loop = true);
198
203 int32 sizeFont(const char *dialogue);
204 int32 getCharWidth(uint16 chr) const;
205 int32 getCharHeight(uint16 chr) const;
206
207 void initDialWindow();
208 void secondInitDialWindow();
209
210 void commonOpenDial(TextId index);
211 void initLine();
212 void initInventoryText(InventoryItems index);
213 void initItemFoundText(InventoryItems index);
214 void fadeInRemainingChars();
215 ProgressiveTextState nextDialChar();
216
222 void setFont(int32 interLeave, int32 interSpace);
223
228 void setFontCrossColor(int32 color);
229
234 void setFontColor(int32 color);
235
242 void setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize);
243
249 bool getText(TextId index);
250
257 bool getMenuText(TextId index, char *text, uint32 textSize);
258
259 void bigWinDial();
260 void normalWinDial();
261
262 void drawAskQuestion(TextId index);
263 void drawHolomapLocation(TextId index);
264
265 bool playVox(const TextEntry *text);
266 bool playVoxSimple(const TextEntry *text);
267 bool stopVox(const TextEntry *text);
268 bool initVoxToPlay(const TextEntry *text);
269 bool initVoxToPlayTextId(TextId index);
270};
271
272} // namespace TwinE
273
274#endif
Definition: str.h:59
Definition: text.h:33
Definition: text.h:48
int32 sizeFont(const char *dialogue)
void initDial(TextBankId bankIdx)
bool getText(TextId index)
void setFontColor(int32 color)
void drawText(int32 x, int32 y, const char *dialogue, bool shadow=false)
bool getMenuText(TextId index, char *text, uint32 textSize)
void setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize)
void setFontCrossColor(int32 color)
void setFont(int32 interLeave, int32 interSpace)
Definition: twine.h:207
Definition: rect.h:536