ScummVM API documentation
ultima8.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef ULTIMA8_ULTIMA8
24#define ULTIMA8_ULTIMA8
25
26#include "common/random.h"
27#include "common/stream.h"
28#include "graphics/screen.h"
29#include "ultima/detection.h"
30#include "ultima/ultima8/games/game_info.h"
31#include "ultima/ultima8/gfx/render_surface.h"
32#include "ultima/ultima8/metaengine.h"
33#include "ultima/ultima8/usecode/intrinsics.h"
34
35namespace Ultima {
36namespace Ultima8 {
37
38class Debugger;
39class Kernel;
40class UCMachine;
41class Game;
42class Gump;
43class GameMapGump;
44class MenuGump;
45class InverterGump;
46class RenderSurface;
47class PaletteManager;
48class GameData;
49class World;
50class ObjectManager;
51class FontManager;
52class Mouse;
53class AvatarMoverProcess;
54class Texture;
55class AudioMixer;
56class ConfigFileManager;
57
58#define GAME_IS_U8 (Ultima8Engine::get_instance()->getGameInfo()->_type == GameInfo::GAME_U8)
59#define GAME_IS_REMORSE (Ultima8Engine::get_instance()->getGameInfo()->_type == GameInfo::GAME_REMORSE)
60#define GAME_IS_REGRET (Ultima8Engine::get_instance()->getGameInfo()->_type == GameInfo::GAME_REGRET)
61#define GAME_IS_CRUSADER (GAME_IS_REMORSE || GAME_IS_REGRET)
62#define GAME_IS_DEMO (Ultima8Engine::get_instance()->getGameInfo()->_ucOffVariant == GameInfo::GAME_UC_DEMO)
63
64class Ultima8Engine : public Engine {
65 friend class Debugger;
66private:
67 Common::RandomSource _randomSource;
68
69 bool _isRunning;
70 GameInfo *_gameInfo;
71 const UltimaGameDescription *_gameDescription;
72
73 // minimal system
74 ConfigFileManager *_configFileMan;
75
76 static Ultima8Engine *_instance;
77
78 bool _fontOverride;
79 bool _fontAntialiasing;
80 // Audio Mixer
81 AudioMixer *_audioMixer;
82 uint32 _saveCount;
83
84 // full system
85 Game *_game;
86 Common::Error _lastError;
87
88 Kernel *_kernel;
89 ObjectManager *_objectManager;
90 UCMachine *_ucMachine;
91 RenderSurface *_screen;
92 Mouse *_mouse;
93 PaletteManager *_paletteManager;
94 GameData *_gameData;
95 World *_world;
96 FontManager *_fontManager;
97
98 Gump *_desktopGump;
99 GameMapGump *_gameMapGump;
100 InverterGump *_inverterGump;
101 AvatarMoverProcess *_avatarMoverProcess;
102
103 // Various dependency flags
104 // Timing stuff
105 int32 _lerpFactor;
106 bool _inBetweenFrame;
107 uint32 _priorFrameCounterTime;
108
109 bool _highRes;
110 bool _frameSkip;
111 bool _frameLimit;
112 bool _interpolate;
113 int32 _animationRate;
114
115 // Sort of Camera Related Stuff, move somewhere else
116
117 bool _avatarInStasis;
119 bool _showEditorItems;
120 bool _showTouching;
121 bool _hackMoverEnabled;
122 int32 _timeOffset;
123 bool _hasCheated;
124 bool _cheatsEnabled;
125 unsigned int _inversion;
126 bool _crusaderTeleporting;
127 uint32 _moveKeyFrame;
128 bool _cruStasis;
129private:
133 void showSplashScreen();
134
136 void writeSaveInfo(Common::WriteStream *ws);
137
139 void save(Common::WriteStream *ws);
140
142 bool load(Common::ReadStream *rs, uint32 version);
143
145 void resetEngine();
146
148 void setupCoreGumps();
149
151// void fullReset();
152
153 void handleDelayedEvents();
154
155 bool pollEvent(Common::Event &event);
156protected:
157 // Engine APIs
158 Common::Error run() override;
159
160 Common::Error initialize();
161 void deinitialize();
162
163 void pauseEngineIntern(bool pause) override;
164
165public:
167 ~Ultima8Engine() override;
168
169 void initializePath(const Common::FSNode &gamePath) override;
170
171 static Ultima8Engine *get_instance() {
172 return _instance;
173 }
174
175 bool hasFeature(EngineFeature f) const override;
176
177 Common::Language getLanguage() const;
178
179 bool setupGame();
180 Common::Error startupGame();
181
182 Common::Error changeVideoMode(int width, int height);
183
185 const GameInfo *getGameInfo() const {
186 return _gameInfo;
187 }
188
189 RenderSurface *getRenderScreen() {
190 return _screen;
191 }
192
193 Graphics::Screen *getScreen() const;
194
195 Common::Error runGame();
196 virtual void handleEvent(const Common::Event &event);
197
198 void handleActionDown(KeybindingAction action);
199 void handleActionUp(KeybindingAction action);
200
201 void paint();
202
203 static const int U8_DEFAULT_SCREEN_WIDTH = 320;
204 static const int U8_DEFAULT_SCREEN_HEIGHT = 200;
205 static const int CRUSADER_DEFAULT_SCREEN_WIDTH = 640;
206 static const int CRUSADER_DEFAULT_SCREEN_HEIGHT = 480;
207
208 static const int U8_HIRES_SCREEN_WIDTH = 640;
209 static const int U8_HIRES_SCREEN_HEIGHT = 400;
210 static const int CRUSADER_HIRES_SCREEN_WIDTH = 1024;
211 static const int CRUSADER_HIRES_SCREEN_HEIGHT = 768;
212
213 INTRINSIC(I_getCurrentTimerTick);
214 INTRINSIC(I_setAvatarInStasis);
215 INTRINSIC(I_getAvatarInStasis);
216 INTRINSIC(I_getTimeInGameHours);
217 INTRINSIC(I_getTimeInMinutes);
218 INTRINSIC(I_getTimeInSeconds);
219 INTRINSIC(I_setTimeInGameHours);
220 INTRINSIC(I_avatarCanCheat);
221 INTRINSIC(I_getCrusaderTeleporting);
222 INTRINSIC(I_setCrusaderTeleporting);
223 INTRINSIC(I_clrCrusaderTeleporting);
224 INTRINSIC(I_makeAvatarACheater);
225 INTRINSIC(I_closeItemGumps);
226 INTRINSIC(I_setCruStasis);
227 INTRINSIC(I_clrCruStasis);
228 INTRINSIC(I_moveKeyDownRecently);
229
230 void setAvatarInStasis(bool stat) {
231 _avatarInStasis = stat;
232 }
233 bool isAvatarInStasis() const {
234 return _avatarInStasis;
235 }
236 bool isAvatarControlled() const;
237 bool isShowEditorItems() const {
238 return _showEditorItems;
239 }
240 void setShowEditorItems(bool flag) {
241 _showEditorItems = flag;
242 }
243 bool isShowTouchingItems() const {
244 return _showTouching;
245 }
246 void setShowTouchingItems(bool flag) {
247 _showTouching = flag;
248 }
249
250 bool isHackMoverEnabled() const {
251 return _hackMoverEnabled;
252 }
253 void setHackMoverEnabled(bool flag) {
254 _hackMoverEnabled = flag;
255 }
256
257 bool isCrusaderTeleporting() const {
258 return _crusaderTeleporting;
259 }
260 void setCrusaderTeleporting(bool flag) {
261 _crusaderTeleporting = flag;
262 }
263 void setCruStasis(bool flag) {
264 _cruStasis = flag;
265 }
266 bool isCruStasis() const {
267 return _cruStasis;
268 }
269
270 void moveKeyEvent();
271 bool moveKeyDownRecently();
272
273 uint32 getGameTimeInSeconds();
274
275 GameMapGump *getGameMapGump() {
276 return _gameMapGump;
277 }
278 Gump *getDesktopGump() {
279 return _desktopGump;
280 }
281 Gump *getGump(uint16 gumpid);
282
285 void addGump(Gump *gump);
286
287 AvatarMoverProcess *getAvatarMoverProcess() {
288 return _avatarMoverProcess;
289 }
290
291 Common::RandomSource &getRandomSource() {
292 return _randomSource;
293 }
294
298 void syncSoundSettings() override;
299
303 void applyGameSettings() override;
304
309
313 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
314
318 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
319
323 Common::Error loadGameState(int slot) override;
324
328 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
329
334
338 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave) override;
339
342 bool newGame(int saveSlot = -1);
343
347public:
348 unsigned int getInversion() const {
349 return _inversion;
350 }
351 void setInversion(unsigned int i) {
352 _inversion = i & 0xFFFF;
353 }
354 bool isInverted() {
355 return (_inversion >= 0x4000 && _inversion < 0xC000);
356 }
357public:
358 bool areCheatsEnabled() const {
359 return _cheatsEnabled;
360 }
361 void setCheatMode(bool enabled) {
362 _cheatsEnabled = enabled;
363 }
364 bool hasCheated() const {
365 return _hasCheated;
366 }
367 void makeCheater() {
368 _hasCheated = true;
369 }
370 bool isInterpolationEnabled() const {
371 return _interpolate;
372 }
373};
374
375} // End of namespace Ultima8
376} // End of namespace Ultima
377
378#endif
Definition: error.h:81
Definition: fs.h:69
Definition: random.h:44
Definition: stream.h:385
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: screen.h:47
Definition: system.h:166
Definition: paletteman.h:47
Definition: audio_mixer.h:36
Definition: avatar_mover_process.h:36
Definition: config_file_manager.h:33
Definition: debugger.h:33
Definition: font_manager.h:41
Definition: game_data.h:51
Definition: game.h:32
Definition: game_map_gump.h:38
Definition: gump.h:46
Definition: inverter_gump.h:36
Definition: kernel.h:45
Definition: mouse.h:75
Definition: object_manager.h:42
Definition: palette_manager.h:39
Definition: render_surface.h:37
Definition: uc_machine.h:42
Definition: ultima8.h:64
Common::Error loadGameState(int slot) override
void setError(Common::Error &error)
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave) override
bool hasFeature(EngineFeature f) const override
void applyGameSettings() override
Common::Error run() override
void syncSoundSettings() override
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: ultima8.h:313
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
bool newGame(int saveSlot=-1)
void pauseEngineIntern(bool pause) override
void initializePath(const Common::FSNode &gamePath) override
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
const GameInfo * getGameInfo() const
Get current GameInfo struct.
Definition: ultima8.h:185
Definition: world.h:75
Language
Definition: language.h:45
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: events.h:218
GameInfo contains detailed information about the game.
Definition: game_info.h:38
Definition: detection.h:65