ScummVM API documentation
dialogs.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 MADS_DIALOGS_H
23 #define MADS_DIALOGS_H
24 
25 #include "common/scummsys.h"
26 #include "mads/game.h"
27 #include "mads/font.h"
28 #include "mads/msurface.h"
29 
30 namespace MADS {
31 
32 #define DIALOG_TOP 22
33 #define POPUP_CENTER 0x8000
34 
35 class Dialog {
36 private:
37  void setDialogPalette();
38 protected:
39  MADSEngine *_vm;
40  MSurface *_savedSurface;
41  Common::Point _position;
42  int _width;
43  int _height;
44  byte _dialogPalette[8 * 3];
45 
46  int TEXTDIALOG_CONTENT1;
47  int TEXTDIALOG_CONTENT2;
48  int TEXTDIALOG_EDGE;
49  int TEXTDIALOG_BACKGROUND;
50  int TEXTDIALOG_FC;
51  int TEXTDIALOG_FD;
52  int TEXTDIALOG_FE;
53  int TEXTDIALOG_BLACK;
54 protected:
58  virtual void draw();
59 
63  virtual void calculateBounds();
64 
68  virtual void save();
69 
73  virtual void restore();
74 
78  void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
79 public:
83  Dialog(MADSEngine *vm);
84 
88  virtual ~Dialog();
89 
94  return Common::Rect(_position.x, _position.y,
95  _position.x + _width, _position.y + _height);
96  }
97 };
98 
99 #define TEXT_DIALOG_MAX_LINES 20
100 
101 class TextDialog : protected Dialog {
102 private:
106  void appendLine(const Common::String &line);
107 
111  void restorePalette();
112 
116  void init(int maxTextChars);
117 protected:
118  Font *_font;
119  int _innerWidth;
120  int _lineWidth;
121  int _currentX;
122  int _numLines;
123  int _lineSize;
124  int _askXp;
125  int _askLineNum;
126  Common::String _lines[TEXT_DIALOG_MAX_LINES];
127  int _lineXp[TEXT_DIALOG_MAX_LINES];
128  SpriteAsset *_edgeSeries;
129  MSurface *_portrait;
130  int _piecesPerCenter;
131  int _fontSpacing;
132 
136  void calculateBounds() override;
137 public:
145  TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos,
146  int maxChars);
147 
156  TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos,
157  MSurface *portrait, int maxTextChars);
158 
162  ~TextDialog() override;
163 
167  void draw() override;
168 
172  void drawWithInput();
173 
177  void addLine(const Common::String &line, bool underline = false);
178 
182  void wordWrap(const Common::String &line);
183 
187  void incNumLines();
188 
192  void addInput();
193 
197  void addBarLine();
198 
202  void underlineLine();
203 
204  void downPixelLine();
205 
209  void setLineXp(int xp);
210 
214  int estimatePieces(int maxLen);
215 
219  virtual void show();
220 };
221 
222 class MessageDialog : public TextDialog {
223 public:
224  MessageDialog(MADSEngine *vm, int lines, ...);
225 
226  ~MessageDialog() override {}
227 };
228 
229 enum DialogId {
230  DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
231  DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6,
232  DIALOG_MAIN_MENU = 7, DIALOG_TEXTVIEW = 8, DIALOG_ANIMVIEW = 9,
233  DIALOG_ADVERT = 10
234 };
235 
236 class Dialogs {
237 protected:
238  MADSEngine *_vm;
239 
240  Dialogs(MADSEngine *vm);
241 public:
242  static Dialogs *init(MADSEngine *vm);
243 public:
244  Common::Point _defaultPosition;
245  DialogId _pendingDialog;
246  int _indexList[10];
247 
248  virtual ~Dialogs() {}
249 
250  virtual void showDialog() = 0;
251  virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
252  virtual Common::String getVocab(int vocabId) = 0;
253  virtual bool show(int messageId, int objectId = -1) = 0;
254 
258  virtual void spinObject(int idx) { warning("TODO: spinObject"); }
259 };
260 
262 protected:
267 
272 
276  bool _palFlag;
277 
281  virtual void display();
282 public:
287 
288  ~FullScreenDialog() override;
289 };
290 
291 } // End of namespace MADS
292 
293 #endif /* MADS_DIALOGS_H */
bool _palFlag
Definition: dialogs.h:276
Definition: events.h:41
Definition: dialogs.h:101
virtual ~Dialog()
MADSEngine * _vm
Definition: dialogs.h:266
Definition: str.h:59
virtual void draw()
Dialog(MADSEngine *vm)
virtual void restore()
int _screenId
Definition: dialogs.h:271
void drawContent(const Common::Rect &r, int seed, byte color1, byte color2)
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: dialogs.h:236
Definition: rect.h:144
virtual void spinObject(int idx)
Definition: dialogs.h:258
Definition: rect.h:45
virtual void calculateBounds()
Definition: mads.h:87
Definition: dialogs.h:222
Definition: font.h:47
Definition: assets.h:61
virtual void save()
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Definition: action.h:28
Definition: msurface.h:172
Definition: dialogs.h:35
Common::Rect getBounds() const
Definition: dialogs.h:93
Definition: dialogs.h:261