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/nebular/core/game.h"
27 #include "mads/nebular/core/font.h"
28 #include "mads/nebular/core/msurface.h"
29 
30 namespace MADS {
31 namespace Nebular {
32 
33 #define DIALOG_TOP 22
34 #define POPUP_CENTER 0x8000
35 
36 class RexNebularEngine;
37 
38 class Dialog {
39 private:
40  void setDialogPalette();
41 protected:
42  RexNebularEngine *_vm;
43  MSurface *_savedSurface;
44  Common::Point _position;
45  int _width;
46  int _height;
47  byte _dialogPalette[8 * 3];
48 
49  int TEXTDIALOG_CONTENT1;
50  int TEXTDIALOG_CONTENT2;
51  int TEXTDIALOG_EDGE;
52  int TEXTDIALOG_BACKGROUND;
53  int TEXTDIALOG_FC;
54  int TEXTDIALOG_FD;
55  int TEXTDIALOG_FE;
56  int TEXTDIALOG_BLACK;
57 protected:
61  virtual void draw();
62 
66  virtual void calculateBounds();
67 
71  virtual void save();
72 
76  virtual void restore();
77 
81  void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
82 public:
87 
91  virtual ~Dialog();
92 
97  return Common::Rect(_position.x, _position.y,
98  _position.x + _width, _position.y + _height);
99  }
100 };
101 
102 #define TEXT_DIALOG_MAX_LINES 20
103 
104 class TextDialog : protected Dialog {
105 private:
109  void appendLine(const Common::String &line);
110 
114  void restorePalette();
115 
119  void init(int maxTextChars);
120 protected:
121  Font *_font;
122  int _innerWidth;
123  int _lineWidth;
124  int _currentX;
125  int _numLines;
126  int _lineSize;
127  int _askXp;
128  int _askLineNum;
129  Common::String _lines[TEXT_DIALOG_MAX_LINES];
130  int _lineXp[TEXT_DIALOG_MAX_LINES];
131  SpriteAsset *_edgeSeries;
132  MSurface *_portrait;
133  int _piecesPerCenter;
134  int _fontSpacing;
135 
139  void calculateBounds() override;
140 public:
148  TextDialog(RexNebularEngine *vm, const Common::String &fontName,
149  const Common::Point &pos, int maxChars);
150 
159  TextDialog(RexNebularEngine *vm, const Common::String &fontName, const Common::Point &pos,
160  MSurface *portrait, int maxTextChars);
161 
165  ~TextDialog() override;
166 
170  void draw() override;
171 
175  void drawWithInput();
176 
180  void addLine(const Common::String &line, bool underline = false);
181 
185  void wordWrap(const Common::String &line);
186 
190  void incNumLines();
191 
195  void addInput();
196 
200  void addBarLine();
201 
205  void underlineLine();
206 
207  void downPixelLine();
208 
212  void setLineXp(int xp);
213 
217  int estimatePieces(int maxLen);
218 
222  virtual void show();
223 };
224 
225 class MessageDialog : public TextDialog {
226 public:
227  MessageDialog(RexNebularEngine *vm, int lines, ...);
228 
229  ~MessageDialog() override {
230  }
231 };
232 
233 enum DialogId {
234  DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
235  DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6,
236  DIALOG_MAIN_MENU = 7, DIALOG_TEXTVIEW = 8, DIALOG_ANIMVIEW = 9,
237  DIALOG_ADVERT = 10
238 };
239 
240 class Dialogs {
241 protected:
242  RexNebularEngine *_vm;
243 
245 public:
246  static Dialogs *init(RexNebularEngine *vm);
247 public:
248  Common::Point _defaultPosition;
249  DialogId _pendingDialog;
250  int _indexList[10];
251 
252  virtual ~Dialogs() {
253  }
254 
255  virtual void showDialog() = 0;
256  virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
257  virtual Common::String getVocab(int vocabId) = 0;
258  virtual bool show(int messageId, int objectId = -1) = 0;
259 
263  virtual void spinObject(int idx) {
264  warning("TODO: spinObject");
265  }
266 };
267 
269 protected:
274 
279 
283  bool _palFlag;
284 
288  virtual void display();
289 public:
294 
295  ~FullScreenDialog() override;
296 };
297 
298 } // namespace Nebular
299 } // namespace MADS
300 
301 #endif
virtual void restore()
Definition: str.h:59
Definition: nebular.h:51
virtual void calculateBounds()
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: rect.h:524
Definition: events.h:44
RexNebularEngine * _vm
Definition: dialogs.h:273
Dialog(RexNebularEngine *vm)
bool _palFlag
Definition: dialogs.h:283
virtual void draw()
int _screenId
Definition: dialogs.h:278
Definition: dialogs.h:225
Definition: font.h:48
T y
Definition: rect.h:49
Definition: dialogs.h:240
Definition: dialogs.h:38
T x
Definition: rect.h:48
Definition: rect.h:144
Definition: dialogs.h:104
virtual void spinObject(int idx)
Definition: dialogs.h:263
Common::Rect getBounds() const
Definition: dialogs.h:96
Definition: assets.h:63
Definition: sound_manager.h:38
Definition: dialogs.h:268
Definition: msurface.h:188
virtual void save()
void drawContent(const Common::Rect &r, int seed, byte color1, byte color2)