1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ASYLUM_ASYLUM_H
#define ASYLUM_ASYLUM_H
#include "common/file.h"
#include "common/language.h"
#include "common/random.h"
#include "common/rect.h"
#include "common/scummsys.h"
#include "common/serializer.h"
#include "common/system.h"
#include "engines/advancedDetector.h"
#include "engines/engine.h"
#include "asylum/resources/data.h"
#include "asylum/detection.h"
#include "asylum/eventhandler.h"
#include "asylum/shared.h"
/**
* This is the namespace of the Asylum engine.
*
* Status of this engine: Complete
*
* Games using this engine:
* - Sanitarium
*/
struct ADGameDescription;
namespace Asylum {
class Cursor;
class Encounter;
class Menu;
class Puzzles;
class ResourceManager;
class Savegame;
class Scene;
class Screen;
class ScriptManager;
class Special;
class Speech;
class Sound;
class Text;
class VideoPlayer;
extern const char *const engineKeyMapId;
extern const char *const resviewerKeyMapId;
class AsylumEngine: public Engine, public Common::Serializable {
protected:
// Engine APIs
virtual Common::Error run() override;
virtual bool hasFeature(EngineFeature f) const override;
public:
enum StartGameType {
kStartGamePlayIntro,
kStartGameLoad,
kStartGameScene
};
AsylumEngine(OSystem *system, const ADGameDescription *gd);
virtual ~AsylumEngine();
/**
* Start a new the game
*/
bool startGame(ResourcePackId sceneId, StartGameType type);
/**
* Restarts the game
*/
void restart();
/**
* Run event loop
*/
void handleEvents();
/**
* Switch to a new scene
*
* @param sceneId ResourcePack for the scene
*/
void switchScene(ResourcePackId sceneId) { (void)startGame(sceneId, kStartGameScene); }
/**
* Get the number of engine ticks
*
* @return The tick.
*/
uint32 getTick() { return _system->getMillis() + _tickOffset; }
/**
* Sets the tick value
*
* @param offset The offset.
*/
void setTick(uint32 offset) { _tickOffset = offset - _system->getMillis(); }
/**
* Resets the game
*/
void reset();
/**
* This is the global tick counter.
*/
uint32 screenUpdateCount;
uint32 lastScreenUpdate;
// Game
Cursor *cursor() { return _cursor; }
Encounter *encounter() { return _encounter; }
Menu *menu() { return _menu; }
ResourceManager *resource() { return _resource; }
Savegame *savegame() { return _savegame; }
Scene *scene() { return _scene; }
Screen *screen() { return _screen; }
ScriptManager *script() { return _script; }
Special *special() { return _special; }
Speech *speech() { return _speech; }
Sound *sound() { return _sound; }
Text *text() { return _text; }
VideoPlayer *video() { return _video; }
SharedData *data() { return &_data; }
Puzzles *puzzles() { return _puzzles; }
// Flags
void setGameFlag(GameFlag flag);
void clearGameFlag(GameFlag flag);
void toggleGameFlag(GameFlag flag);
bool isGameFlagSet(GameFlag flag) const;
bool isGameFlagNotSet(GameFlag flag) const;
bool areGameFlagsSet(uint from, uint to) const;
void resetFlags() { memset(_gameFlags, 0, sizeof(_gameFlags)); }
// Misc
uint getRandom(uint max) { return max ? _rnd->getRandomNumber(max - 1) : 0; }
uint getRandomBit() { return _rnd->getRandomBit(); }
bool rectContains(const int16 (*rectPtr)[4], const Common::Point &p) const;
// Steam achievements
void unlockAchievement(const Common::String &id);
void checkAchievements();
/**
* Switch message handler.
*
* @param handler If non-null, a pointer to an EventHandler class.
*/
void switchEventHandler(EventHandler *handler);
/**
* Notifies the current event handler of an event
*
* @param type The event type.
*/
void notify(AsylumEventType type, int32 param1 = 0, int32 param2 = 0);
/**
* Updates the reverse stereo scene status from the config
*/
void updateReverseStereo();
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) override;
bool checkGameVersion(const char *version) { return !strcmp(_gameDescription->extra, version); }
bool isAltDemo() { return Common::File::exists("asylum.dat"); }
Common::Language getLanguage() { return _gameDescription->language; }
Common::String getTargetName() { return _targetName; }
Common::String getMoviesFileName() { return Common::String::format("%s.movies", _targetName.c_str()); }
bool isMenuVisible() { return _handler == (EventHandler *)_menu; }
EventHandler *getEventHandler() { return _handler; }
// Save/Load
int getAutosaveSlot() const override { return getMetaEngine()->getAutosaveSlot(); }
bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
Common::Error loadGameState(int slot) override;
bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
bool canSaveAutosaveCurrently() override;
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
private:
const ADGameDescription *_gameDescription;
// Misc
Common::RandomSource *_rnd;
// Game
Cursor *_cursor;
Encounter *_encounter;
Menu *_menu;
ResourceManager *_resource;
Savegame *_savegame;
Scene *_scene;
Screen *_screen;
ScriptManager *_script;
Special *_special;
Speech *_speech;
Sound *_sound;
Text *_text;
VideoPlayer *_video;
// Current EventHandler class instance
EventHandler *_handler;
// Game data
Puzzles *_puzzles;
SharedData _data;
uint32 _gameFlags[130];
bool _introPlayed;
int32 _tickOffset;
void updateMouseCursor();
void processDelayedEvents();
/**
* Play the intro
*/
void playIntro();
// Debug
friend class Console;
Scene *_previousScene;
ResourcePackId _delayedSceneIndex;
int32 _delayedVideoIndex;
};
} // namespace Asylum
#endif // ASYLUM_ASYLUM_H
|