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