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 
25 namespace 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 
76 class TextMgr {
77 private:
78  Words *_words;
79  GfxMgr *_gfx;
80  AgiEngine *_vm;
81  SystemUI *_systemUI;
82 
83 public:
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 displayText(const char *textPtr, bool disabledLook = false);
124  void displayCharacter(byte character, bool disabledLook = false);
125 
126  void displayTextInsideWindow(const char *textPtr, int16 windowRow, int16 windowColumn);
127 
128  MessageState_Struct _messageState;
129 
130  void printAt(int16 textNr, int16 textPos_Row, int16 textPos_Column, int16 text_Width);
131  void print(int16 textNr);
132 
133  bool messageBox(const char *textPtr);
134  void messageBox_KeyPress(uint16 newKey);
135 
136  bool _messageBoxCancelled;
137 
138  void drawMessageBox(const char *textPtr, int16 forcedHeight = 0, int16 wantedWidth = 0, bool forcedWidth = false);
139  void getMessageBoxInnerDisplayDimensions(int16 &x, int16 &y, int16 &width, int16 &height);
140  bool isMouseWithinMessageBox();
141  void closeWindow();
142 
143  void statusRow_Set(int16 row);
144  int16 statusRow_Get();
145 
146  void statusEnable();
147  void statusDisable();
148  bool statusEnabled();
149 
150  void statusDraw();
151  void statusClear();
152 
153  bool _statusEnabled;
154  int16 _statusRow;
155 
156  void clearLine(int16 row, byte color);
157  void clearLines(int16 row_Upper, int16 row_Lower, byte color);
158  void clearBlock(int16 row_Upper, int16 column_Upper, int16 row_Lower, int16 column_Lower, byte color);
159 
160  void clearBlockInsideWindow(int16 windowRow, int16 windowColumn, int16 width, byte color);
161 
162  bool _inputEditEnabled;
163  byte _inputCursorChar;
164 
165  bool _optionCommandPromptWindow;
166 
167  bool _promptEnabled;
168  int16 _promptRow;
169  int16 _promptCursorPos;
170  byte _prompt[42];
171  byte _promptPrevious[42];
172 
173  bool inputGetEditStatus();
174  void inputEditOn();
175  void inputEditOff();
176  void inputSetCursorChar(int16 cursorChar);
177  byte inputGetCursorChar();
178 
179  void promptReset();
180  void promptEnable();
181  void promptDisable();
182  bool promptIsEnabled();
183 
184  void promptRow_Set(int16 row);
185  int16 promptRow_Get();
186  void promptKeyPress(uint16 newKey);
187  void promptCancelLine();
188  void promptEchoLine();
189  void promptRedraw();
190  void promptClear(); // for AGI1
191  void promptRememberForAutoComplete(bool entered = false); // for auto-completion
192 
193  void promptCommandWindow(bool recallLastCommand, uint16 newKey);
194 
195  int16 _inputStringRow;
196  int16 _inputStringColumn;
197  bool _inputStringEntered;
198  int16 _inputStringMaxLen;
199  int16 _inputStringCursorPos;
200  byte _inputString[42];
201 
202  bool stringWasEntered();
203  void stringPos_Get(int16 &row, int16 &column);
204  int16 stringGetMaxLen();
205  void stringSet(const char *text);
206  void stringEdit(int16 stringMaxLen);
207  void stringKeyPress(uint16 newKey);
208  void stringRememberForAutoComplete(bool entered = false); // for auto-completion
209 
210  char *stringPrintf(const char *originalText);
211  char *stringWordWrap(const char *originalText, int16 maxWidth, int16 *calculatedWidthPtr = nullptr, int16 *calculatedHeightPtr = nullptr);
212 };
213 
214 Common::String rightAlign(Common::String line, va_list args);
215 
216 } // End of namespace Agi
217 
218 #endif /* AGI_TEXT_H */
Definition: str.h:59
Definition: text.h:27
Definition: systemui.h:51
Definition: text.h:34
Definition: graphics.h:58
Definition: agi.h:839
Definition: text.h:43
Definition: words.h:35
Definition: agi.h:63
Definition: text.h:76