ScummVM API documentation
window.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 HDB_WINDOW_H
23 #define HDB_WINDOW_H
24 
25 namespace HDB {
26 
27 enum {
28  kMaxMsgQueue = 10,
29  kPanicZoneFaceY = 5,
30  kNumCrazy = 37
31 };
32 
33 enum PZValue {
34  PANICZONE_TIMER,
35  PANICZONE_START,
36  PANICZONE_TITLESTOP,
37  PANICZONE_BLASTOFF,
38  PANICZONE_COUNTDOWN,
39 
40  PANICZONE_END
41 };
42 
43 struct DialogInfo {
44  char title[64]; // TITLE string
45  int tileIndex; // this is for a character picture
46  char string[160]; // actual text in the dialog
47 
48  bool active; // is it drawing or not?
49  int x, y; // where to draw dialog
50  int width, height; // size of the dialog itself
51  int titleWidth;
52  Picture *gfx; // character tile (picture)
53  int more; // whether we want to draw the MORE icon or not
54  int el, er, et, eb; // saves the text edges
55  char luaMore[64]; // the name of the function to call after clicking the MORE button
56 
57  DialogInfo() : tileIndex(0), active(false), x(0), y(0),
58  width(0), height(0), titleWidth(0), gfx(nullptr), more(0), el(0), er(0), et(0),
59  eb(0) {
60  title[0] = 0;
61  string[0] = 0;
62  luaMore[0] = 0;
63  }
64 };
65 
67  char title[64]; // TITLE string
68  char text[160]; // actual text in the dialog
69  char func[64]; // function to call with result
70 
71  bool active; // is it drawing or not?
72  int x, y; // where to draw dialog
73  int width, height; // size of the dialog itself
74  int textHeight; // height of everything above choices
75  int titleWidth;
76  int el, er, et, eb; // saves the text edges
77  uint32 timeout; // timeout value!
78 
79  int selection; // which choice we've made
80  int numChoices; // how many choices possible
81  char choices[10][64]; // ptrs to choice text
82 
83  DialogChoiceInfo() : active(false), x(0), y(0),
84  width(0), height(0), textHeight(0), titleWidth(0), el(0), er(0), et(0),
85  eb(0), timeout(0), selection(0), numChoices(0) {
86  title[0] = 0;
87  text[0] = 0;
88  func[0] = 0;
89  for (int i = 0; i < 10; i++)
90  choices[i][0] = 0;
91  }
92 };
93 
94 struct MessageInfo {
95  bool active;
96  char title[128];
97  int timer;
98  int x, y;
99  int width, height;
100 
101  MessageInfo() : active(false), timer(0), x(0), y(0), width(0), height(0) {
102  title[0] = 0;
103  }
104 };
105 
106 struct InvWinInfo {
107  int x, y;
108  int width, height;
109  int selection;
110  bool active;
111 
112  InvWinInfo() : x(0), y(0), width(0), height(0), selection(0), active(false) {}
113 };
114 
115 struct DlvsInfo {
116  int x, y;
117  int width, height;
118  bool active;
119  int selected;
120  bool animate;
121  uint32 delay1, delay2, delay3;
122  bool go1, go2, go3;
123 
124  DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0),
125  animate(false), delay1(0), delay2(0), delay3(0), go1(false), go2(false), go3(false) {}
126 };
127 
128 struct PanicZone {
129  bool active;
130  int sequence;
131  int timer;
132  int x1, y1;
133  int x2, y2;
134  int xv, yv; // for both
135  int numberTime;
136  int numberTimeMaster;
137  int numberValue;
138  Picture *gfxPanic, *gfxZone;
139  Picture *gfxFace[2];
140  Picture *gfxNumber[10];
141 
142  PanicZone() : active(false), sequence(0), timer(0), x1(0), y1(0), x2(0), y2(0), xv(0), yv(0),
143  numberTime(0), numberTimeMaster(0), numberValue(0), gfxPanic(nullptr), gfxZone(nullptr) {
144  memset(&gfxFace, 0, sizeof(gfxFace));
145  memset(&gfxNumber, 0, sizeof(gfxNumber));
146  }
147 };
148 
149 struct TryAgainInfo {
150  double y1, y2;
151  double yv1, yv2;
152  double yv1v, yv2v;
153  double x1, x2;
154 
155  TryAgainInfo() : y1(0), y2(0), yv1(0), yv2(0), yv1v(0), yv2v(0), x1(0), x2(0) {}
156 };
157 
158 struct TOut {
159  char text[128];
160  int x, y;
161  uint32 timer;
162 
163  TOut() : x(0), y(0), timer(0) {
164  text[0] = 0;
165  }
166 };
167 
168 class Window {
169 public:
170  Window();
171  ~Window();
172 
173  void init();
174  void save(Common::OutSaveFile *out);
175  void loadSaveFile(Common::InSaveFile *in);
176  void restartSystem();
177  void setInfobarDark(int value);
178 
179  void closeAll();
180 
181  // Pause Functions
182  void drawPause();
183  void checkPause(int x, int y);
184 
185  // Weapon Functions
186  void drawWeapon();
187  void chooseWeapon(AIType wType);
188 
189  // Dialog Functions
190 
191  void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
192  void drawDialog();
193  void closeDialog();
194  bool checkDialogClose(int x, int y);
195  void drawBorder(int x, int y, int width, int height, bool guyTalking);
196  void setDialogDelay(int delay);
197  uint32 getDialogDelay() {
198  return _dialogDelay;
199  }
200  bool dialogActive() {
201  return _dialogInfo.active;
202  }
203 
204  // Dialog Choice Functions
205 
206  void openDialogChoice(const char *title, const char *text, const char *func, int numChoices, const char *choices[10]);
207  void drawDialogChoice();
208  void closeDialogChoice();
209  bool checkDialogChoiceClose(int x, int y);
210  void dialogChoiceMoveup();
211  void dialogChoiceMovedown();
212  bool dialogChoiceActive() {
213  return _dialogChoiceInfo.active;
214  }
215 
216  // MessageBar Functions
217  void openMessageBar(const char *title, int time);
218  void drawMessageBar();
219  bool checkMsgClose(int x, int y);
220  void nextMsgQueued();
221  void closeMsg();
222  bool msgBarActive() {
223  return _msgInfo.active;
224  }
225 
226  // Inventory Functions
227  void drawInventory();
228  void setInvSelect(int status) {
229  _invWinInfo.selection = status;
230  }
231  int getInvSelect() {
232  return _invWinInfo.selection;
233  }
234  void checkInvSelect(int x, int y);
235  bool inventoryActive() {
236  return _invWinInfo.active;
237  }
238  // PPC Inventory
239  void openInventory();
240  bool checkInvClose(int x, int y);
241  void closeInv();
242 
243  // Deliveries Functions
244  void openDeliveries(bool animate);
245  void drawDeliveries();
246  void setSelectedDelivery(int which);
247  int getSelectedDelivery() {
248  return _dlvsInfo.selected;
249  }
250  bool animatingDelivery() {
251  return _dlvsInfo.animate;
252  }
253  void checkDlvSelect(int x, int y);
254  // PPC Deliveries
255  bool checkDlvsClose(int x, int y);
256  void closeDlvs();
257  bool deliveriesActive() {
258  return _dlvsInfo.active;
259  }
260 
261  // Try Again Functions
262  void drawTryAgain();
263  void clearTryAgain();
264 
265  // Panic Zone Functions
266  void loadPanicZoneGfx();
267  void drawPanicZone();
268  void startPanicZone();
269  void stopPanicZone();
270  bool inPanicZone() {
271  return _pzInfo.active;
272  }
273 
274  // TextOut functions
275  void textOut(const char *text, int x, int y, int timer);
276  void centerTextOut(const char *text, int y, int timer);
277  void drawTextOut();
278  int textOutActive() {
279  return (_textOutList.size());
280  }
281  void closeTextOut();
282 
283  // Platform-specific Constants
284  int _weaponX, _weaponY;
285  int _invItemSpace, _invItemSpaceX, _invItemSpaceY;
286  int _invItemPerLine;
287  int _dlvItemSpaceX;
288  int _dlvItemSpaceY;
289  int _dlvItemPerLine;
290  int _dlvItemTextY;
291  int _dialogTextLeft;
292  int _dialogTextRight;
293  int _openDialogTextLeft;
294  int _openDialogTextRight;
295  int _textOutCenterX;
296  int _pauseY;
297  int _tryY1; // TRY
298  int _tryY2; // AGAIN
299  int _tryRestartY; // (ok)
300  int _panicXStop;
301  int _panicZoneFaceX;
302 
303  Tile *getGemGfx() {
304  return _gemGfx;
305  }
306 
307  PanicZone _pzInfo, _tempPzInfo;
308 
309 private:
310 
311  DialogInfo _dialogInfo;
312  uint32 _dialogDelay; // Used for Cinematics
313 
314  DialogChoiceInfo _dialogChoiceInfo;
315 
316  MessageInfo _msgInfo;
317 
318  InvWinInfo _invWinInfo;
319  Common::Array<TOut *> _textOutList;
320  DlvsInfo _dlvsInfo;
321 
322  TryAgainInfo _tryAgainInfo;
323 
324  char _msgQueueStr[kMaxMsgQueue][128];
325  int _msgQueueWait[kMaxMsgQueue];
326  int _numMsgQueue;
327 
328  // Windows GFX
329  Picture *_gfxTL, *_gfxTM, *_gfxTR;
330  Picture *_gfxL, *_gfxM, *_gfxR;
331  Picture *_gfxBL, *_gfxBM, *_gfxBR;
332  Picture *_gfxTitleL, *_gfxTitleM, *_gfxTitleR;
333  Picture *_gGfxTL, *_gGfxTM, *_gGfxTR;
334  Picture *_gGfxL, *_gGfxM, *_gGfxR;
335  Picture *_gGfxBL, *_gGfxBM, *_gGfxBR;
336  Picture *_gGfxTitleL, *_gGfxTitleM, *_gGfxTitleR;
337  Picture *_gfxIndent, *_gfxArrowTo, *_gfxHandright;
338  Picture *_gfxTry, *_gfxAgain, *_gfxInvSelect;
339  Picture *_gfxLevelRestart, *_gfxPausePlaque;
340  Tile *_gemGfx;
341  Picture *_mstoneGfx;
342 
343  // Info Bar
344  Picture *_gfxResources, *_gfxDeliveries;
345  Picture *_gfxInfobar, *_gfxDarken;
346  int _infobarDimmed;
347 };
348 
349 } // End of Namespace
350 
351 #endif // !HDB_WINDOW_H
Definition: ai-player.h:25
Definition: window.h:158
Definition: savefile.h:54
Definition: array.h:52
Definition: window.h:43
Definition: stream.h:745
Definition: window.h:66
Definition: window.h:168
Definition: window.h:115
Definition: gfx.h:256
Definition: window.h:149
Definition: window.h:94
Definition: window.h:106
Definition: window.h:128
Definition: gfx.h:234