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 AGI_TEXT_H
23#define AGI_TEXT_H
24
25namespace Agi {
26
28 int16 row;
29 int16 column;
30};
31
32#define TEXTPOSARRAY_MAX 5
33
35 byte foreground;
36 byte background;
37 byte combinedForeground;
38 byte combinedBackground;
39};
40
41#define TEXTATTRIBARRAY_MAX 5
42
44 uint8 type;
45 int16 wanted_Text_Width;
46 TextPos_Struct wanted_TextPos;
47 bool dialogue_Open;
48 uint8 newline_Char;
49 bool window_Active;
50 TextPos_Struct textPos;
51 TextPos_Struct textPos_Edge;
52 int16 textSize_Width;
53 int16 textSize_Height;
54 uint16 printed_Height;
55
56 int16 backgroundPos_x;
57 int16 backgroundPos_y; // original AGI used lowerY here, we use upperY so that upscaling is easier
58 int16 backgroundSize_Width;
59 int16 backgroundSize_Height;
60};
61
62// this defines here are for calculating character-size inside the visual-screen!
63#define FONT_VISUAL_WIDTH 4
64#define FONT_VISUAL_HEIGHT 8
65
66#define FONT_DISPLAY_WIDTH 8
67#define FONT_DISPLAY_HEIGHT 8
68#define FONT_ROW_CHARACTERS 25
69#define FONT_COLUMN_CHARACTERS 40
70#define FONT_BYTES_PER_CHARACTER 8
71
72#define HEIGHT_MAX 20
73
74#define TEXT_STRING_MAX_SIZE 40
75
76class TextMgr {
77private:
78 Words *_words;
79 GfxMgr *_gfx;
80 AgiEngine *_vm;
81 SystemUI *_systemUI;
82
83public:
84 TextMgr(AgiEngine *vm, Words *words, GfxMgr *gfx);
85 ~TextMgr();
86
87 void init(SystemUI *systemUI);
88
89 TextPos_Struct _textPos;
90 int16 _textPosArrayCount;
91 TextPos_Struct _textPosArray[TEXTPOSARRAY_MAX];
92
93 TextAttrib_Struct _textAttrib;
94 int16 _textAttribArrayCount;
95 TextAttrib_Struct _textAttribArray[TEXTATTRIBARRAY_MAX];
96
97 uint16 _window_Row_Min;
98 uint16 _window_Row_Max;
99 int16 _reset_Column;
100
101 void configureScreen(uint16 gameRow);
102 uint16 getWindowRowMin();
103
104 void dialogueOpen();
105 void dialogueClose();
106
107 void charPos_Clip(int16 &row, int16 &column);
108 void charPos_Set(int16 row, int16 column);
109 void charPos_Set(TextPos_Struct *posPtr);
110 void charPos_Get(int16 &row, int16 &column);
111 void charPos_Get(TextPos_Struct *posPtr);
112 void charPos_Push();
113 void charPos_Pop();
114 void charPos_SetInsideWindow(int16 windowRow, int16 windowColumn);
115 void charAttrib_Set(byte foreground, byte background);
116 byte charAttrib_GetForeground();
117 byte charAttrib_GetBackground();
118 void charAttrib_Push();
119 void charAttrib_Pop();
120 byte calculateTextBackground(byte background);
121
122 void display(int16 textNr, int16 textRow, int16 textColumn);
123 void displayAdjustRTL(int16 textRow, int16 textColumn, char *text, int16 calculatedWidth);
124 void displayText(const char *textPtr, bool disabledLook = false);
125 void displayCharacter(byte character, bool disabledLook = false);
126
127 void displayTextInsideWindow(const char *textPtr, int16 windowRow, int16 windowColumn);
128
129 MessageState_Struct _messageState;
130
131 void printAt(int16 textNr, int16 textPos_Row, int16 textPos_Column, int16 text_Width);
132 void print(int16 textNr);
133
134 bool messageBox(const char *textPtr);
135 void messageBox_KeyPress(uint16 newKey);
136
137 bool _messageBoxCancelled;
138
139 void drawMessageBox(const char *textPtr, int16 forcedHeight = 0, int16 wantedWidth = 0, bool forcedWidth = false);
140 void getMessageBoxInnerDisplayDimensions(int16 &x, int16 &y, int16 &width, int16 &height);
141 bool isMouseWithinMessageBox();
142 void closeWindow(bool ttsStopSpeech = true);
143
144 void statusRow_Set(int16 row);
145 int16 statusRow_Get();
146
147 void statusEnable();
148 void statusDisable();
149 bool statusEnabled();
150
151 void statusDraw(bool ttsVoiceScore = false, bool ttsVoiceSound = false);
152 void statusClear();
153
154 bool _statusEnabled;
155 int16 _statusRow;
156
157 void clearLine(int16 row, byte color);
158 void clearLines(int16 row_Upper, int16 row_Lower, byte color);
159 void clearBlock(int16 row_Upper, int16 column_Upper, int16 row_Lower, int16 column_Lower, byte color);
160
161 void clearBlockInsideWindow(int16 windowRow, int16 windowColumn, int16 width, byte color);
162
163 bool _inputEditEnabled;
164 byte _inputCursorChar;
165
166 bool _optionCommandPromptWindow;
167
168 bool _promptEnabled;
169 int16 _promptRow;
170 int16 _promptCursorPos;
171 byte _prompt[42];
172 byte _promptPrevious[42];
173
174 bool inputGetEditStatus();
175 void inputEditOn();
176 void inputEditOff();
177 void inputSetCursorChar(int16 cursorChar);
178 byte inputGetCursorChar();
179
180 void promptReset();
181 void promptEnable();
182 void promptDisable();
183 bool promptIsEnabled();
184
185 void promptRow_Set(int16 row);
186 int16 promptRow_Get();
187 void promptKeyPress(uint16 newKey);
188 void promptCancelLine();
189 void promptEchoLine();
190 void promptRedraw();
191 void promptClear(); // for AGI1
192 void promptRememberForAutoComplete(bool entered = false); // for auto-completion
193
194 void promptCommandWindow(bool recallLastCommand, uint16 newKey);
195
196 int16 _inputStringRow;
197 int16 _inputStringColumn;
198 bool _inputStringEntered;
199 int16 _inputStringMaxLen;
200 int16 _inputStringCursorPos;
201 byte _inputString[42];
202
203 bool stringWasEntered();
204 void stringPos_Get(int16 &row, int16 &column);
205 int16 stringGetMaxLen();
206 void stringSet(const char *text);
207 void stringEdit(int16 stringMaxLen);
208 void stringKeyPress(uint16 newKey);
209 void stringRememberForAutoComplete(bool entered = false); // for auto-completion
210
211 char *stringPrintf(const char *originalText);
212 char *stringWordWrap(const char *originalText, int16 maxWidth, int16 *calculatedWidthPtr = nullptr, int16 *calculatedHeightPtr = nullptr);
213};
214
215Common::String rightAlign(Common::String line, va_list args);
216
217} // End of namespace Agi
218
219#endif /* AGI_TEXT_H */
Definition: agi.h:699
Definition: graphics.h:58
Definition: systemui.h:51
Definition: text.h:76
Definition: words.h:37
Definition: str.h:59
Definition: agi.h:64
Definition: text.h:43
Definition: text.h:34
Definition: text.h:27