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