ScummVM API documentation
lab.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 /*
23 * This code is based on Labyrinth of Time code with assistance of
24 *
25 * Copyright (c) 1993 Terra Nova Development
26 * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
27 *
28 */
29
30#ifndef LAB_LAB_H
31#define LAB_LAB_H
32
33#include "common/system.h"
34#include "common/random.h"
35#include "common/rect.h"
36#include "common/savefile.h"
37#include "engines/engine.h"
38#include "engines/savestate.h"
39
40#include "lab/console.h"
41#include "lab/image.h"
42#include "lab/labsets.h"
43#include "lab/detection.h"
44
46
47namespace Lab {
48
49struct MapData;
50struct Action;
51struct CloseData;
52struct Button;
53struct IntuiMessage;
54struct InventoryData;
55struct RoomData;
56struct Rule;
57struct TextFont;
58struct ViewData;
59
60class Anim;
61class DisplayMan;
62class EventManager;
63class Interface;
64class Image;
65class Music;
66class Resource;
67class SpecialLocks;
68class Utils;
69
71 byte _version;
73 uint16 _roomNumber;
74 uint16 _direction;
75};
76
78
79struct CrumbData {
80 uint16 _crumbRoomNum;
81 uint16 _crumbDirection;
82};
83
84#define MAX_CRUMBS 128
85
90
91enum Direction {
92 kDirectionNorth,
93 kDirectionSouth,
94 kDirectionEast,
95 kDirectionWest
96};
97
98enum MainButton {
99 kButtonNone = -1,
100 kButtonPickup,
101 kButtonUse,
102 kButtonOpen,
103 kButtonClose,
104 kButtonLook,
105 kButtonInventory,
106 kButtonLeft,
107 kButtonForward,
108 kButtonRight,
109 kButtonMap
110};
111
112enum MessageClass {
113 kMessageLeftClick,
114 kMessageRightClick,
115 kMessageButtonUp,
116 kMessageAction
117};
118
119enum LABActions {
120 kActionNone,
121 kActionQuit,
122 kActionSkipIntro,
123 kActionSoundRaise,
124 kActionSoundLower,
125 kActionInteract,
126 kActionTake,
127 kActionMove,
128 kActionOpen,
129 kActionClose,
130 kActionLook,
131 kActionInv,
132 kActionForward,
133 kActionLeft,
134 kActionRight,
135 kActionMap,
136 kActionFocusOnNextInteractiveItem,
137 kActionExit,
138 kActionMainDisplay,
139 kActionSaveLoad,
140 kActionUse,
141 kActionInvLook,
142 kActionPrev,
143 kActionNext,
144 kActionDropBreadcrumb,
145 kActionFollowBreadcrumbs,
146 kActionRunWhileFollowingBreadcrumbs,
147 kActionMapExit,
148 kActionUpperFloor,
149 kActionLowerFloor,
150 kActionQuitDialogYes,
151 kActionQuitDialogNo,
152 kActionJournalBack,
153 kActionJournalExit,
154 kActionJournalForward,
155 kActionDummy,
156};
157
158class LabEngine : public Engine {
159 friend class Console;
160
161private:
162 bool _isCrumbWaiting;
163 bool _lastTooLong;
164 bool _lastPage;
165 bool _mainDisplay;
166 bool _noUpdateDiff;
167 bool _quitLab;
168
169 byte *_blankJournal;
170
171 int _lastWaitTOFTicks;
172
173 uint16 _direction;
174 uint16 _highPalette[20];
175 uint16 _journalPage;
176 uint16 _maxRooms;
177 uint16 _monitorPage;
178 uint16 _monitorButtonHeight;
179
180 uint32 _extraGameFeatures;
181
182 Common::String _journalText;
183 Common::String _journalTextTitle;
184 Common::String _nextFileName;
185 Common::String _newFileName;
186 Common::String _monitorTextFilename;
187
188 const CloseData *_closeDataPtr;
189 ButtonList _journalButtonList;
190 ButtonList _mapButtonList;
191 Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
192 Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath;
193 Image *_imgMapX[4];
194 InventoryData *_inventory;
195 MapData *_maps;
196 Image *_monitorButton;
197 Image *_journalBackImage;
198 TextFont *_journalFont;
199 bool _introPlaying;
200
201public:
202 bool _alternate;
203 bool _droppingCrumbs;
204 bool _followingCrumbs;
205 bool _followCrumbsFast;
206 bool _isCrumbTurning;
207 bool _isHiRes;
208
209 int _roomNum;
210
211 uint16 _highestCondition;
212 uint16 _manyRooms;
213 uint16 _numCrumbs;
214 uint16 _numInv;
215
216 uint32 _crumbTimestamp;
217
218 Common::String _curFileName;
219
220 Anim *_anim;
221 CrumbData _breadCrumbs[MAX_CRUMBS];
222 DisplayMan *_graphics;
223 EventManager *_event;
224 Interface *_interface;
225 ButtonList _invButtonList;
226 ButtonList _moveButtonList;
227 Image *_invImages[10];
228 Image *_moveImages[20];
229 LargeSet *_conditions, *_roomsFound;
230 Music *_music;
231 Resource *_resource;
232 RoomData *_rooms;
233 TextFont *_msgFont;
234 SpecialLocks *_specialLocks;
235 Utils *_utils;
236
237public:
238 LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
239 ~LabEngine() override;
240
241 Common::Error run() override;
242 void go();
243
244 const ADGameDescription *_gameDescription;
245 Common::Platform getPlatform() const;
246 uint32 getFeatures() const;
247
248 bool hasFeature(EngineFeature f) const override;
249
250 void changeVolume(int delta);
251 uint16 getDirection() { return _direction; }
252
257 uint16 getQuarters();
258 void setQuarters(uint16 quarters);
259 void updateEvents();
260 void waitTOF();
261
262 Common::Error loadGameState(int slot) override;
263 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
264 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
265 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
266
267 bool isMainDisplay() const { return _mainDisplay; }
268
269private:
273 bool checkConditions(const Common::Array<int16> &cond);
274
278 void decIncInv(uint16 *CurInv, bool dec);
279
283 void doActions(const ActionList &actionList);
284
288 bool doActionRule(Common::Point pos, int16 action, int16 roomNum);
289
293 bool doActionRuleSub(int16 action, int16 roomNum, const CloseData *closePtr, bool allowDefaults);
294
298 void handleMonitorCloseup();
299
303 bool doGoForward();
304
308 void doJournal();
309
313 bool doMainView();
314
318 void doMap();
319
323 void doMonitor(const Common::String &background, const Common::String &textfile, bool isinteractive, Common::Rect textRect);
324
328 void doNotes();
329
333 bool doOperateRuleSub(int16 itemNum, int16 roomNum, const CloseData *closePtr, bool allowDefaults);
334
338 bool doOperateRule(Common::Point pos, int16 ItemNum);
339
343 bool doTurn(uint16 from, uint16 to);
344
348 bool doUse(uint16 curInv);
349
354 void doWestPaper();
355
359 void drawDirection(const CloseData *closePtr);
360
364 void drawJournal(uint16 wipenum, bool needFade);
365
369 void drawJournalText();
370
374 void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeIn);
375
379 void drawMonText(const char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive);
380
384 void drawRoomMap(uint16 curRoom, bool drawMarkFl);
385
389 void drawRoomMessage(uint16 curInv, const CloseData *closePtr);
390 void drawStaticMessage(byte index);
391
395 void eatMessages();
396
403 const CloseData *findClosePtrMatch(const CloseData *closePtr, const CloseDataList &list);
404
408 bool floorVisited(uint16 floorNum);
409
413 MainButton followCrumbs();
414 void freeMapData();
415 void freeScreens();
416 bool processEvent(MessageClass tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
417 uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
418
422 Common::String getInvName(uint16 curInv);
423
428 uint16 getLowerFloor(uint16 floorNum);
429
433 const CloseData *getObject(Common::Point pos, const CloseData *closePtr);
434
439 uint16 getUpperFloor(uint16 floorNum);
440
444 ViewData *getViewData(uint16 roomNum, uint16 direction);
445
449 void interfaceOff();
450
454 void interfaceOn();
455
459 void loadJournalData();
460
464 void loadMapData();
465
469 void mainGameLoop();
470 void showLab2Teaser();
471
475 void perFlipButton(uint16 buttonId);
476
480 uint16 processArrow(uint16 curDirection, uint16 arrow);
481
485 void processJournal();
486
490 void processMap(uint16 curRoom);
491
495 void processMonitor(const Common::String &ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
496
500 Common::Rect roomCoords(uint16 curRoom);
501 bool saveRestoreGame();
502
506 void setCurrentClose(Common::Point pos, const CloseData **closePtrList, bool useAbsoluteCoords, bool next=false);
507
511 bool takeItem(Common::Point pos);
512
516 void turnPage(bool fromLeft);
517 bool processKey(IntuiMessage *curMsg, uint32 msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
518 void processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
519 void processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode);
520 void performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv);
521
525 bool saveGame(int slot, const Common::String &desc);
526
530 bool loadGame(int slot);
531 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
532
533 void handleTrialWarning();
534};
535
536WARN_UNUSED_RESULT bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header, bool skipThumbnail = true);
537
538} // End of namespace Lab
539
540#endif // LAB_LAB_H
Definition: input.h:69
Definition: error.h:81
Definition: savefile.h:54
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: anim.h:45
Definition: console.h:31
Definition: dispman.h:57
Definition: eventman.h:47
Definition: image.h:41
Definition: interface.h:49
Definition: lab.h:158
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature f) const override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Common::Error loadGameState(int slot) override
Common::String getPictName(bool useClose)
Common::Error run() override
Definition: labsets.h:41
Definition: music.h:49
Definition: resource.h:94
Definition: speciallocks.h:39
Definition: utils.h:35
Definition: system.h:166
Definition: savestate.h:56
Platform
Definition: platform.h:93
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: advancedDetector.h:164
Definition: rect.h:144
Definition: rect.h:536
Definition: processroom.h:136
Definition: lab.h:79
Definition: eventman.h:40
Definition: processroom.h:175
Definition: processroom.h:181
Definition: processroom.h:167
Definition: lab.h:70
Definition: dispman.h:38
Definition: processroom.h:145