ScummVM API documentation
hadesch.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 * Copyright 2020 Google
21 *
22 */
23#ifndef HADESCH_HADESCH_H
24#define HADESCH_HADESCH_H
25
26#include "common/random.h"
27#include "common/stream.h"
28#include "common/savefile.h"
29#include "common/list.h"
30
31#include "engines/engine.h"
32#include "engines/savestate.h"
33
34#include "gui/debugger.h"
35#include "graphics/cursor.h"
36#include "hadesch/pod_file.h"
37#include "hadesch/video.h"
38#include "hadesch/enums.h"
39#include "hadesch/event.h"
40#include "hadesch/herobelt.h"
41#include "hadesch/persistent.h"
42
43#define _hs(x) (x)
44
46
47namespace Common {
48class SeekableReadStream;
49class PEResources;
50class TranslationManager;
51}
52
53namespace Graphics {
54struct WinCursorGroup;
55class MacCursor;
56}
57
58namespace Hadesch {
59
60class VideoRoom;
61
62class Handler {
63public:
64 virtual void handleClick(const Common::String &name) = 0;
65 virtual void handleAbsoluteClick(Common::Point pnt) {}
66 virtual bool handleClickWithItem(const Common::String &name, InventoryItem item) {
67 return false;
68 }
69 virtual void handleEvent(int eventId) = 0;
70 virtual void handleMouseOver(const Common::String &name) {}
71 virtual void handleMouseOut(const Common::String &name) {}
72 virtual void frameCallback() {}
73 virtual void handleKeypress(uint32 ucode) {}
74 virtual void prepareRoom() = 0;
75 virtual bool handleCheat(const Common::String &cheat) {
76 return false;
77 }
78 virtual void handleUnclick(const Common::String &name, const Common::Point &pnt) {}
79 virtual ~Handler() {}
80};
81
82Common::SharedPtr<Hadesch::Handler> makeOlympusHandler();
83Common::SharedPtr<Hadesch::Handler> makeWallOfFameHandler();
87Common::SharedPtr<Hadesch::Handler> makeDaedalusHandler();
88Common::SharedPtr<Hadesch::Handler> makeSeriphosHandler();
89Common::SharedPtr<Hadesch::Handler> makeMedIsleHandler();
91Common::SharedPtr<Hadesch::Handler> makeMinotaurHandler();
93Common::SharedPtr<Hadesch::Handler> makeCatacombsHandler();
95Common::SharedPtr<Hadesch::Handler> makeAthenaHandler();
96Common::SharedPtr<Hadesch::Handler> makeVolcanoHandler();
97Common::SharedPtr<Hadesch::Handler> makeRiverStyxHandler();
98Common::SharedPtr<Hadesch::Handler> makeHadesThroneHandler();
99Common::SharedPtr<Hadesch::Handler> makeCreditsHandler(bool inOptions);
100Common::SharedPtr<Hadesch::Handler> makeIntroHandler();
101Common::SharedPtr<Hadesch::Handler> makeFerryHandler();
102Common::SharedPtr<Hadesch::Handler> makeOptionsHandler();
103Common::SharedPtr<Hadesch::Handler> makeMonsterHandler();
104Common::SharedPtr<Hadesch::Handler> makeMedusaHandler();
105Common::SharedPtr<Hadesch::Handler> makeTrojanHandler();
106
108public:
109 HadeschEngine(OSystem *syst, const ADGameDescription *desc);
110 ~HadeschEngine() override;
111
112 Common::Error run() override;
113
114 bool hasFeature(EngineFeature f) const override;
115
116 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
117 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _persistent._currentRoomId != 0; }
119 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
120
121 Common::SeekableReadStream *openFile(const Common::String &name, bool addCurrentPath);
122
123 Common::RandomSource &getRnd();
124
125 const Common::String &getCDScenesPath() const;
126
127 Common::SharedPtr<VideoRoom> getVideoRoom();
128
129 void moveToRoom(RoomId id) {
130 _nextRoom.push_back(id);
131 _heroBelt->clearHold();
132 }
133
134 void handleEvent(EventHandlerWrapper event);
135 int32 getCurrentTime() {
136 return _currentTime;
137 }
138 Common::Point getMousePos();
139
140 void addTimer(EventHandlerWrapper event, int period, int repeat = 1);
141 void addSkippableTimer(EventHandlerWrapper event, int period, int repeat = 1);
142 void cancelTimer(int eventId);
143
144 Common::SharedPtr<PodFile> getWdPodFile() {
145 return _wdPodFile;
146 }
147
148 RoomId getPreviousRoomId() const {
149 return _persistent._previousRoomId;
150 }
151
152 bool isRoomVisited(RoomId id) const {
153 return _persistent._roomVisited[id];
154 }
155
156 Persistent *getPersistent() {
157 return &_persistent;
158 }
159
160 Common::SharedPtr<Handler> getCurrentHandler();
161
162 Common::SharedPtr<HeroBelt> getHeroBelt() {
163 return _heroBelt;
164 }
165
166 int firstAvailableSlot();
167
168 void newGame();
169 void enterOptions();
170 void resetOptionsRoom();
171 void exitOptions();
172 void enterOptionsCredits();
173 void quit();
174 bool hasAnySaves();
175
176 Common::Array<HadeschSaveDescriptor> getHadeschSavesList();
177 void deleteSave(int slot);
178 int genSubtitleID();
179 uint32 getSubtitleDelayPerChar() const;
180 void wrapSubtitles(const Common::U32String &str, Common::Array<Common::U32String> &lines);
181 Common::U32String translate(const Common::String &str);
182 void fallbackClick();
183
184private:
185 void addTimer(EventHandlerWrapper event, int32 start_time, int period,
186 int repeat, bool skippable);
187 void moveToRoomReal(RoomId id);
188 void setVideoRoom(Common::SharedPtr<VideoRoom> scene,
190 RoomId roomId);
191 Common::ErrorCode loadCursors();
192 bool handleGenericCheat(const Common::String &cheat);
193 Common::ErrorCode loadWindowsCursors(const Common::ScopedPtr<Common::PEResources>& exe);
194
195 struct Timer {
196 int32 next_time;
197 int32 period;
198 int32 period_count;
199 EventHandlerWrapper event;
200 bool skippable;
201 };
202 const ADGameDescription *_desc;
203
205
206 Common::String _cdScenesPath;
207
208 Common::SharedPtr<VideoRoom> _sceneVideoRoom;
209 Common::SharedPtr<Handler> _sceneHandler;
210 Common::SharedPtr<VideoRoom> _optionsRoom;
211 Common::SharedPtr<Handler> _optionsHandler;
212 bool _isInOptions;
213 uint32 _optionsEnterTime;
214 uint32 _sceneStartTime;
215 int32 _currentTime;
217 Common::List<Timer> _sceneTimers;
220 Common::String _cheat;
222 bool _cheatsEnabled;
223 Common::Point _mousePos;
224
225 Persistent _persistent;
226 Common::Array<RoomId> _nextRoom;
227 bool _isRestoring;
228 bool _isQuitting;
229 int _subtitleID;
230 int _subtitleDelayPerChar;
231 int _lastFallbackSound;
232
233#ifdef USE_TRANSLATION
235#endif
236
237 // For freeing purposes
240};
241
242extern HadeschEngine *g_vm;
243
244} // End of namespace Hadesch
245
246#endif
Definition: array.h:52
void push_back(const T &element)
Definition: array.h:181
Definition: error.h:81
Definition: noncopyable.h:39
Definition: random.h:44
Definition: ptr.h:572
Definition: stream.h:745
Definition: str.h:59
Definition: translation.h:87
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:155
EngineFeature
Definition: engine.h:293
Definition: event.h:34
Definition: hadesch.h:107
Common::Error run() override
bool hasFeature(EngineFeature f) const override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hadesch.h:117
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hadesch.h:116
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: hadesch.h:62
Definition: system.h:166
ErrorCode
Definition: error.h:47
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: advancedDetector.h:164
Definition: rect.h:144