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/core/game.h"
27 #include "mads/core/font.h"
28 #include "mads/core/msurface.h"
29 
30 namespace MADS {
31 
32 #define DIALOG_TOP 22
33 #define POPUP_CENTER 0x8000
34 
35 class RexNebularEngine;
36 
37 class Dialog {
38 private:
39  void setDialogPalette();
40 protected:
41  RexNebularEngine *_vm;
42  MSurface *_savedSurface;
43  Common::Point _position;
44  int _width;
45  int _height;
46  byte _dialogPalette[8 * 3];
47 
48  int TEXTDIALOG_CONTENT1;
49  int TEXTDIALOG_CONTENT2;
50  int TEXTDIALOG_EDGE;
51  int TEXTDIALOG_BACKGROUND;
52  int TEXTDIALOG_FC;
53  int TEXTDIALOG_FD;
54  int TEXTDIALOG_FE;
55  int TEXTDIALOG_BLACK;
56 protected:
60  virtual void draw();
61 
65  virtual void calculateBounds();
66 
70  virtual void save();
71 
75  virtual void restore();
76 
80  void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
81 public:
86 
90  virtual ~Dialog();
91 
96  return Common::Rect(_position.x, _position.y,
97  _position.x + _width, _position.y + _height);
98  }
99 };
100 
101 #define TEXT_DIALOG_MAX_LINES 20
102 
103 class TextDialog : protected Dialog {
104 private:
108  void appendLine(const Common::String &line);
109 
113  void restorePalette();
114 
118  void init(int maxTextChars);
119 protected:
120  Font *_font;
121  int _innerWidth;
122  int _lineWidth;
123  int _currentX;
124  int _numLines;
125  int _lineSize;
126  int _askXp;
127  int _askLineNum;
128  Common::String _lines[TEXT_DIALOG_MAX_LINES];
129  int _lineXp[TEXT_DIALOG_MAX_LINES];
130  SpriteAsset *_edgeSeries;
131  MSurface *_portrait;
132  int _piecesPerCenter;
133  int _fontSpacing;
134 
138  void calculateBounds() override;
139 public:
147  TextDialog(RexNebularEngine *vm, const Common::String &fontName,
148  const Common::Point &pos, int maxChars);
149 
158  TextDialog(RexNebularEngine *vm, const Common::String &fontName, const Common::Point &pos,
159  MSurface *portrait, int maxTextChars);
160 
164  ~TextDialog() override;
165 
169  void draw() override;
170 
174  void drawWithInput();
175 
179  void addLine(const Common::String &line, bool underline = false);
180 
184  void wordWrap(const Common::String &line);
185 
189  void incNumLines();
190 
194  void addInput();
195 
199  void addBarLine();
200 
204  void underlineLine();
205 
206  void downPixelLine();
207 
211  void setLineXp(int xp);
212 
216  int estimatePieces(int maxLen);
217 
221  virtual void show();
222 };
223 
224 class MessageDialog : public TextDialog {
225 public:
226  MessageDialog(RexNebularEngine *vm, int lines, ...);
227 
228  ~MessageDialog() override {}
229 };
230 
231 enum DialogId {
232  DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
233  DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6,
234  DIALOG_MAIN_MENU = 7, DIALOG_TEXTVIEW = 8, DIALOG_ANIMVIEW = 9,
235  DIALOG_ADVERT = 10
236 };
237 
238 class Dialogs {
239 protected:
240  RexNebularEngine *_vm;
241 
243 public:
244  static Dialogs *init(RexNebularEngine *vm);
245 public:
246  Common::Point _defaultPosition;
247  DialogId _pendingDialog;
248  int _indexList[10];
249 
250  virtual ~Dialogs() {}
251 
252  virtual void showDialog() = 0;
253  virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
254  virtual Common::String getVocab(int vocabId) = 0;
255  virtual bool show(int messageId, int objectId = -1) = 0;
256 
260  virtual void spinObject(int idx) { warning("TODO: spinObject"); }
261 };
262 
264 protected:
269 
274 
278  bool _palFlag;
279 
283  virtual void display();
284 public:
289 
290  ~FullScreenDialog() override;
291 };
292 
293 } // namespace MADS
294 
295 #endif /* MADS_DIALOGS_H */
bool _palFlag
Definition: dialogs.h:278
Definition: events.h:41
Definition: dialogs.h:103
virtual ~Dialog()
Definition: str.h:59
virtual void draw()
virtual void restore()
int _screenId
Definition: dialogs.h:273
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:238
Definition: rect.h:524
Dialog(RexNebularEngine *vm)
Definition: nebular.h:50
virtual void spinObject(int idx)
Definition: dialogs.h:260
T y
Definition: rect.h:49
T x
Definition: rect.h:48
Definition: rect.h:144
RexNebularEngine * _vm
Definition: dialogs.h:268
virtual void calculateBounds()
Definition: dialogs.h:224
Definition: font.h:47
Definition: assets.h:62
virtual void save()
Definition: action.h:28
Definition: msurface.h:172
Definition: dialogs.h:37
Common::Rect getBounds() const
Definition: dialogs.h:95
Definition: dialogs.h:263