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 
45 struct ADGameDescription;
46 
47 namespace Common {
48 class SeekableReadStream;
49 class PEResources;
50 class TranslationManager;
51 }
52 
53 namespace Graphics {
54 struct WinCursorGroup;
55 class MacCursor;
56 }
57 
58 namespace Hadesch {
59 
60 class VideoRoom;
61 
62 class Handler {
63 public:
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, Common::Point pnt) {}
79  virtual ~Handler() {}
80 };
81 
82 Common::SharedPtr<Hadesch::Handler> makeOlympusHandler();
83 Common::SharedPtr<Hadesch::Handler> makeWallOfFameHandler();
84 Common::SharedPtr<Hadesch::Handler> makeArgoHandler();
85 Common::SharedPtr<Hadesch::Handler> makeCreteHandler();
86 Common::SharedPtr<Hadesch::Handler> makeMinosHandler();
87 Common::SharedPtr<Hadesch::Handler> makeDaedalusHandler();
88 Common::SharedPtr<Hadesch::Handler> makeSeriphosHandler();
89 Common::SharedPtr<Hadesch::Handler> makeMedIsleHandler();
90 Common::SharedPtr<Hadesch::Handler> makeTroyHandler();
91 Common::SharedPtr<Hadesch::Handler> makeMinotaurHandler();
92 Common::SharedPtr<Hadesch::Handler> makeQuizHandler();
93 Common::SharedPtr<Hadesch::Handler> makeCatacombsHandler();
94 Common::SharedPtr<Hadesch::Handler> makePriamHandler();
95 Common::SharedPtr<Hadesch::Handler> makeAthenaHandler();
96 Common::SharedPtr<Hadesch::Handler> makeVolcanoHandler();
97 Common::SharedPtr<Hadesch::Handler> makeRiverStyxHandler();
98 Common::SharedPtr<Hadesch::Handler> makeHadesThroneHandler();
99 Common::SharedPtr<Hadesch::Handler> makeCreditsHandler(bool inOptions);
100 Common::SharedPtr<Hadesch::Handler> makeIntroHandler();
101 Common::SharedPtr<Hadesch::Handler> makeFerryHandler();
102 Common::SharedPtr<Hadesch::Handler> makeOptionsHandler();
103 Common::SharedPtr<Hadesch::Handler> makeMonsterHandler();
104 Common::SharedPtr<Hadesch::Handler> makeMedusaHandler();
105 Common::SharedPtr<Hadesch::Handler> makeTrojanHandler();
106 
108 public:
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; }
118  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
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 
184 private:
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;
218  Common::SharedPtr<PodFile> _wdPodFile;
219  Common::SharedPtr<HeroBelt> _heroBelt;
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
234  Common::TranslationManager *_transMan;
235 #endif
236 
237  // For freeing purposes
240 };
241 
242 extern HadeschEngine *g_vm;
243 
244 } // End of namespace Hadesch
245 
246 #endif
Definition: str.h:59
EngineFeature
Definition: engine.h:253
Definition: event.h:34
Definition: stream.h:77
Definition: error.h:84
Definition: persistent.h:50
Definition: ambient.h:30
Definition: array.h:52
Definition: advancedDetector.h:163
Definition: random.h:44
ErrorCode
Definition: error.h:47
Definition: stream.h:745
Definition: ptr.h:572
Definition: noncopyable.h:39
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hadesch.h:117
Definition: ustr.h:57
Definition: algorithm.h:29
Definition: translation.h:87
Definition: formatinfo.h:28
Definition: rect.h:45
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: hadesch.h:116
Definition: hadesch.h:107
Definition: system.h:161
Definition: hadesch.h:62
Definition: engine.h:144