ScummVM API documentation
pegasus.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 * Additional copyright for this file:
8 * Copyright (C) 1995-1997 Presto Studios, Inc.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef PEGASUS_PEGASUS_H
26#define PEGASUS_PEGASUS_H
27
28#include "common/list.h"
29#include "common/macresman.h"
30#include "common/rect.h"
31#include "common/scummsys.h"
32#include "common/str-array.h"
33#include "common/system.h"
34#include "common/util.h"
35
36#include "engines/engine.h"
37
38#include "pegasus/graphics.h"
39#include "pegasus/hotspot.h"
40#include "pegasus/input.h"
41#include "pegasus/notification.h"
42#include "pegasus/timers.h"
43#include "pegasus/items/autodragger.h"
44#include "pegasus/items/inventory.h"
45#include "pegasus/items/itemdragger.h"
46#include "pegasus/neighborhood/neighborhood.h"
47
48namespace Common {
49 class RandomSource;
50}
51
52namespace Video {
53 class VideoDecoder;
54}
55
56namespace Pegasus {
57
58class PegasusConsole;
59struct PegasusGameDescription;
60class SoundManager;
61class GraphicsManager;
62class Idler;
63class Cursor;
64class TimeBase;
65class GameMenu;
66class InventoryItem;
67class BiochipItem;
68class Neighborhood;
69
71friend class InputHandler;
72
73public:
74 PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc);
75 ~PegasusEngine() override;
76
77 // Engine stuff
78 const PegasusGameDescription *_gameDescription;
79 bool hasFeature(EngineFeature f) const override;
80 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
81 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
82 Common::Error loadGameState(int slot) override;
83 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
84
85 static Common::Array<Common::Keymap *> initKeymaps();
86
87 // Base classes
88 GraphicsManager *_gfx;
89 Common::MacResManager *_resFork;
90 Cursor *_cursor;
91
92 // Menu
93 void useMenu(GameMenu *menu);
94 bool checkGameMenu();
95
96 // Misc.
97 bool isDemo() const;
98 bool isDVD() const;
99 bool isDVDDemo() const;
100 bool isOldDemo() const;
101 bool isWindows() const;
102 bool isLinux() const;
103 void addIdler(Idler *idler);
104 void removeIdler(Idler *idler);
105 void addTimeBase(TimeBase *timeBase);
106 void removeTimeBase(TimeBase *timeBase);
107 void delayShell(TimeValue time, TimeScale scale);
108 void resetIntroTimer();
109 void introTimerExpired();
110 void refreshDisplay();
111 bool playerAlive();
112 void processShell();
113 void checkCallBacks();
114 void createInterface();
115 void setGameMode(const GameMode);
116 GameMode getGameMode() const { return _gameMode; }
117 uint getRandomBit();
118 uint getRandomNumber(uint max);
119 void shuffleArray(int32 *arr, int32 count);
120 void drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y);
121 HotspotList &getAllHotspots() { return _allHotspots; }
122
123 // Energy
124 void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
125 int32 getSavedEnergyValue() { return _savedEnergyValue; }
126
127 // Death
128 Sound &getDeathSound() { return _deathSound; }
129 void setEnergyDeathReason(const DeathReason reason) { _deathReason = reason; }
130 DeathReason getEnergyDeathReason() { return _deathReason; }
131 void resetEnergyDeathReason();
132 void die(const DeathReason);
133 DeathReason getDeathReason() { return _deathReason; }
134 void playEndMessage();
135
136 // Volume
137 uint16 getSoundFXLevel() { return _FXLevel; }
138 void setSoundFXLevel(uint16);
139 uint16 getAmbienceLevel() { return _ambientLevel; }
140 void setAmbienceLevel(uint16);
141
142 // Items
143 ItemList &getAllItems() { return _allItems; }
144 bool playerHasItem(const Item *);
145 bool playerHasItemID(const ItemID);
146 void checkFlashlight();
147 bool itemInLocation(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
148
149 // Inventory Items
150 InventoryItem *getCurrentInventoryItem();
151 bool itemInInventory(InventoryItem *);
152 bool itemInInventory(ItemID);
153 Inventory *getItemsInventory() { return &_items; }
154 InventoryResult addItemToInventory(InventoryItem *);
155 void removeAllItemsFromInventory();
156 InventoryResult removeItemFromInventory(InventoryItem *);
157 uint32 countInventoryItems() { return _items.getNumItems(); }
158
159 // Biochips
160 BiochipItem *getCurrentBiochip();
161 bool itemInBiochips(BiochipItem *);
162 bool itemInBiochips(ItemID);
163 Inventory *getBiochipsInventory() { return &_biochips; }
164 void removeAllItemsFromBiochips();
165 InventoryResult addItemToBiochips(BiochipItem *);
166
167 // AI
168 Common::Path getBriefingMovie();
169 Common::Path getEnvScanMovie();
170 uint getNumHints();
171 Common::Path getHintMovie(uint);
172 bool canSolve();
173 void prepareForAIHint(const Common::Path &);
174 void cleanUpAfterAIHint(const Common::Path &);
175 void requestToggle(bool request = true) { _toggleRequested = request; }
176 bool toggleRequested() const { return _toggleRequested; }
177 bool isChattyAI() { return _chattyAI; }
178 void setChattyAI(bool);
179 bool isChattyArthur() { return _chattyArthur; }
180 void setChattyArthur(bool);
181 Common::SeekableReadStream *_aiSaveStream;
182
183 // Neighborhood
184 void jumpToNewEnvironment(const NeighborhoodID, const RoomID, const DirectionConstant);
185 NeighborhoodID getCurrentNeighborhoodID() const;
186
187 // Dragging
188 void dragItem(const Input &, Item *, DragType);
189 bool isDragging() const { return _dragType != kDragNoDrag; }
190 DragType getDragType() const { return _dragType; }
191 Item *getDraggingItem() const { return _draggingItem; }
192 void dragTerminated(const Input &);
193 void autoDragItemIntoRoom(Item *, Sprite *);
194 void autoDragItemIntoInventory(Item *, Sprite*);
195
196 // Save/Load
197 void makeContinuePoint();
198 bool swapSaveAllowed(bool allow) {
199 bool old = _saveAllowed;
200 _saveAllowed = allow;
201 return old;
202 }
203 bool swapLoadAllowed(bool allow) {
204 bool old = _loadAllowed;
205 _loadAllowed = allow;
206 return old;
207 }
208 void requestSave() { _saveRequested = true; }
209 bool saveRequested() const { return _saveRequested; }
210 void requestLoad() { _loadRequested = true; }
211 bool loadRequested() const { return _loadRequested; }
212 static Common::StringArray listSaveFiles();
213
214protected:
215 Common::Error run() override;
216 void pauseEngineIntern(bool pause) override;
217
218 Notification _shellNotification;
219 void receiveNotification(Notification *notification, const NotificationFlags flags) override;
220
221 void handleInput(const Input &input, const Hotspot *cursorSpot) override;
222 bool isClickInput(const Input &, const Hotspot *) override;
223 InputBits getClickFilter() override;
224
225 void clickInHotspot(const Input &, const Hotspot *) override;
226 void activateHotspots(void) override;
227
228 void updateCursor(const Common::Point &, const Hotspot *) override;
229 bool wantsCursor() override;
230
231private:
232 // Intro
233 void runIntro();
234 void stopIntroTimer();
235 bool detectOpeningClosingDirectory();
236 Common::Path _introDirectory;
237 FuseFunction *_introTimer;
238
239 // Idlers
240 Idler *_idlerHead;
241 void giveIdleTime();
242
243 // Items
244 ItemList _allItems;
245 void createItems();
246 void createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction);
247 Inventory _items;
248 Inventory _biochips;
249 ItemID _currentItemID;
250 ItemID _currentBiochipID;
251 void destroyInventoryItem(const ItemID itemID);
252 ItemID pickItemToDestroy();
253
254 // TimeBases
255 Common::List<TimeBase *> _timeBases;
256
257 // Save/Load
258 bool loadFromStream(Common::SeekableReadStream *stream);
259 bool writeToStream(Common::WriteStream *stream, int saveType);
260 void loadFromContinuePoint();
261 void writeContinueStream(Common::WriteStream *stream);
262 Common::SeekableReadStream *_continuePoint;
263 bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
264 Common::Error showLoadDialog();
265 Common::Error showSaveDialog();
266 void showSaveFailedDialog(const Common::Error &status);
267 bool _saveRequested, _loadRequested;
268
269 // Misc.
270 Hotspot _returnHotspot;
271 HotspotList _allHotspots;
272 InputHandler *_savedHandler;
273 void showTempScreen(const Common::Path &fileName);
274 bool playMovieScaled(Video::VideoDecoder *video, uint16 x, uint16 y);
275 void throwAwayEverything();
276 void shellGameInput(const Input &input, const Hotspot *cursorSpot);
278 void doSubChase();
279 uint getNeighborhoodCD(const NeighborhoodID neighborhood) const;
280 uint _currentCD;
281 InputBits getInputFilter() override;
282
283 // Menu
284 GameMenu *_gameMenu;
285 void doGameMenuCommand(const GameMenuCommand);
286 void doInterfaceOverview();
287 ScreenDimmer _screenDimmer;
288 void pauseMenu(bool menuUp);
289 PauseToken _menuPauseToken;
290 bool _heardOverviewVoice;
291
292 // Energy
293 int32 _savedEnergyValue;
294
295 // Death
296 DeathReason _deathReason;
297 Sound _deathSound;
298 void doDeath();
299
300 // AI
301 bool _toggleRequested;
302 bool _chattyAI;
303 bool _chattyArthur;
304
305 // Neighborhood
306 Neighborhood *_neighborhood;
307 void useNeighborhood(Neighborhood *neighborhood);
308 void performJump(NeighborhoodID start);
309 void startNewGame();
310 void startNeighborhood();
311 void makeNeighborhood(NeighborhoodID, Neighborhood *&);
312
313 // Sound
314 uint16 _ambientLevel;
315 uint16 _FXLevel;
316
317 // Game Mode
318 GameMode _gameMode;
319 bool _switchModesSync;
320 void switchGameMode(const GameMode, const GameMode);
321 bool canSwitchGameMode(const GameMode, const GameMode);
322
323 // Dragging
324 ItemDragger _itemDragger;
325 Item *_draggingItem;
326 Sprite *_draggingSprite;
327 DragType _dragType;
328 AutoDragger _autoDragger;
329
330 // Interface
331 void toggleInventoryDisplay();
332 void toggleBiochipDisplay();
333 void raiseInventoryDrawer();
334 void raiseBiochipDrawer();
335 void lowerInventoryDrawer();
336 void lowerBiochipDrawer();
337 void raiseInventoryDrawerSync();
338 void raiseBiochipDrawerSync();
339 void lowerInventoryDrawerSync();
340 void lowerBiochipDrawerSync();
341 void showInfoScreen();
342 void hideInfoScreen();
343 void toggleInfo();
344 Movie _bigInfoMovie, _smallInfoMovie;
345};
346
347extern PegasusEngine *g_vm;
348
349} // End of namespace Pegasus
350
351#endif
Definition: array.h:52
Definition: error.h:81
Definition: list.h:44
Definition: macresman.h:126
Definition: path.h:52
Definition: random.h:44
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: graphics.h:38
Definition: system.h:166
Definition: engine.h:110
Definition: autodragger.h:34
Definition: cursor.h:44
Definition: timers.h:239
Definition: menu.h:38
Definition: graphics.h:44
Definition: hotspot.h:85
Definition: hotspot.h:119
Definition: timers.h:37
Definition: input.h:410
Definition: input.h:322
Definition: inventory.h:41
Definition: itemdragger.h:72
Definition: item.h:294
Definition: itemlist.h:41
Definition: movie.h:40
Definition: neighborhood.h:111
Definition: notification.h:53
Definition: notification.h:103
Definition: pegasus.h:70
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
bool hasFeature(EngineFeature f) const override
void pauseEngineIntern(bool pause) override
Common::Error loadGameState(int slot) override
Common::Error run() override
Definition: elements.h:226
Definition: sound.h:50
Definition: elements.h:168
Definition: timers.h:63
Definition: video_decoder.h:53
Definition: algorithm.h:29
Definition: rect.h:144
Definition: atari-cursor.h:35
Definition: surface.h:67
Definition: detection.h:29