ScummVM API documentation
harvester.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 HARVESTER_H
23 #define HARVESTER_H
24 
25 #include "common/array.h"
26 #include "audio/mixer.h"
27 #include "common/error.h"
28 #include "common/random.h"
29 #include "common/serializer.h"
30 #include "engines/engine.h"
31 #include "graphics/screen.h"
32 #include "harvester/saveload.h"
33 #include "harvester/script.h"
34 
35 struct ADGameDescription;
36 
37 namespace Harvester {
38 
39 class ResourceManager;
40 class EntityManager;
41 class MediaManager;
42 class Script;
43 class Art;
44 class Text;
45 class Flow;
46 
47 class HarvesterEngine : public Engine {
48 public:
49  HarvesterEngine(OSystem *syst, const ADGameDescription *gameDesc);
50  ~HarvesterEngine() override;
51 
52  Common::Error run() override;
53  bool hasFeature(EngineFeature f) const override;
54 
58  Common::String getGameId() const;
59  bool isDemo() const;
60 
64  uint32 getRandomNumber(uint maxNum) {
65  return _randomSource.getRandomNumber(maxNum);
66  }
67 
68  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
69  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
70 
76  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
78 
79  ResourceManager *getResources() const { return _resources; }
80  MediaManager *getMedia() const { return _media; }
81  EntityManager *getRuntimeEntities() const;
82  Graphics::Screen *getScreen() const;
83  int getDisplayWidth() const;
84  int getDisplayHeight() const;
85  Script *getScript() const { return _script; }
86  Art *getArt() const;
87  Text *getText() const;
88  void setDisplayMode(int width, int height);
89  bool isGoreEnabled() const;
90  bool shouldShowCdChangePrompts() const;
91  int getFxVolumeLevel() const;
92  int getMusicVolumeLevel() const;
93  int getGammaLevel() const;
94  float getGammaBrightnessScale() const;
95  void setFxVolumeLevel(int level);
96  void setMusicVolumeLevel(int level);
97  void setGammaLevel(int level);
98  const Common::String &getMusicPath() const;
99  bool isMusicPlaying() const;
100  bool playMusic(const Common::String &path);
101  void pauseMusic(bool paused);
102  void stopMusic();
103  bool executeAudioCommand(const AudioCommand &command);
104  bool playSound(const Common::String &path);
105  bool playSingleSound(const Common::String &path);
106  void stopSingleSound();
107  bool isSingleSoundPlaying() const;
108  bool playSpeech(const Common::String &path);
109  void stopSpeech();
110  bool isSpeechPlaying() const;
111  bool loadSound(int slot, const Common::String &path);
112  bool playLoadedSound(int slot);
113  bool deleteLoadedSound(int slot);
114  void stopSound();
115  bool activateDisc(int discNumber);
116  bool isCombatDebugEnabled() const { return _combatDebugEnabled; }
117  bool toggleCombatDebugEnabled();
118  bool isRoomDebugEnabled() const { return _roomDebugEnabled; }
119  bool toggleRoomDebugEnabled();
120  bool isPathfindingDebugEnabled() const { return _pathfindingDebugEnabled; }
121  bool togglePathfindingDebugEnabled();
122  bool isTimerDebugEnabled() const { return _timerDebugEnabled; }
123  bool toggleTimerDebugEnabled();
124  bool requestDebugCommand(const CommandRecord &command);
125  bool requestDebugRoomChange(const Common::String &roomName);
126  void captureCurrentSaveRoomState(const Common::String &entranceName,
127  const Common::String &roomName, int playerX, int playerY, int playerZ,
128  int playerFacing, int discNumber, const Common::String &musicPath);
129  void clearCurrentSaveRoomState();
130  bool hasCurrentSaveRoomState() const { return _currentSaveRoomState.valid; }
131  const SaveRoomState &getCurrentSaveRoomState() const {
132  return _currentSaveRoomState;
133  }
134  bool hasPendingLoadedSaveRoomState() const { return _pendingLoadedSaveRoomState.valid; }
135  const SaveRoomState &getPendingLoadedSaveRoomState() const {
136  return _pendingLoadedSaveRoomState;
137  }
138  int getPendingLoadedDisc() const { return _pendingLoadedDisc; }
139  void clearPendingLoadedSaveRoomState();
140  bool hasPendingLoadedDialogueStateBlob() const { return !_pendingLoadedDialogueStateBlob.empty(); }
141  const Common::Array<byte> &getPendingLoadedDialogueStateBlob() const { return _pendingLoadedDialogueStateBlob; }
142  uint32 getPendingLoadedDialogueStateBlobVersion() const { return _pendingLoadedDialogueStateBlobVersion; }
143  void clearPendingLoadedDialogueStateBlob() {
144  _pendingLoadedDialogueStateBlob.clear();
145  _pendingLoadedDialogueStateBlobVersion = 0;
146  }
147 
148 private:
149  void applyMixerLevels();
150 
151  const ADGameDescription *const _gameDescription;
152  Common::RandomSource _randomSource;
153  ResourceManager *_resources = nullptr;
154  MediaManager *_media = nullptr;
155  Script *_script = nullptr;
156  SaveRoomState _currentSaveRoomState;
157  SaveRoomState _pendingLoadedSaveRoomState;
158  int _pendingLoadedDisc = 0;
159  Common::Array<byte> _pendingLoadedDialogueStateBlob;
160  uint32 _pendingLoadedDialogueStateBlobVersion = 0;
161  Flow *_activeFlow = nullptr;
162  bool _combatDebugEnabled = false;
163  bool _roomDebugEnabled = false;
164  bool _pathfindingDebugEnabled = false;
165  bool _timerDebugEnabled = false;
166  Common::String _emptyMusicPath;
167 };
168 
169 // Global engine hook used by existing Harvester helpers and macros.
170 // It is assigned in HarvesterEngine::HarvesterEngine() and cleared in
171 // HarvesterEngine::~HarvesterEngine() so restart-to-launcher resets it.
172 extern HarvesterEngine *g_engine;
173 #define SHOULD_QUIT ::Harvester::g_engine->shouldQuit()
174 
175 } // End of namespace Harvester
176 
177 #endif // HARVESTER_H
Definition: flow.h:46
Definition: str.h:59
Definition: art.h:31
Definition: saveload.h:29
EngineFeature
Definition: engine.h:282
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: stream.h:77
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: error.h:81
Definition: script.h:319
Definition: advancedDetector.h:164
void clear()
Definition: array.h:321
Definition: script.h:185
Definition: random.h:44
bool hasFeature(EngineFeature f) const override
uint getRandomNumber(uint max)
Common::Error run() override
Definition: stream.h:745
Definition: text.h:47
Definition: screen.h:47
Definition: media_manager.h:41
Engine * g_engine
Definition: serializer.h:80
Common::Error syncGame(Common::Serializer &s)
Definition: runtime_entity.h:180
bool empty() const
Definition: array.h:352
Definition: ustr.h:57
Definition: art.h:50
Common::String getGameId() const
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: script.h:231
Definition: resources.h:32
Definition: harvester.h:47
uint32 getRandomNumber(uint maxNum)
Definition: harvester.h:64
Definition: system.h:166
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: engine.h:149