/* 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 2 * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright 2020 Google * */ #ifndef HADESCH_HADESCH_H #define HADESCH_HADESCH_H #include "common/random.h" #include "common/stream.h" #include "common/savefile.h" #include "common/list.h" #include "engines/engine.h" #include "engines/savestate.h" #include "gui/debugger.h" #include "graphics/cursor.h" #include "hadesch/pod_file.h" #include "hadesch/video.h" #include "hadesch/enums.h" #include "hadesch/event.h" #include "hadesch/herobelt.h" #include "hadesch/persistent.h" #include "common/translation.h" struct ADGameDescription; namespace Common { class SeekableReadStream; class PEResources; } namespace Graphics { struct WinCursorGroup; class MacCursor; } namespace Hadesch { class VideoRoom; class Handler { public: virtual void handleClick(const Common::String &name) = 0; virtual void handleAbsoluteClick(Common::Point pnt) {} virtual bool handleClickWithItem(const Common::String &name, InventoryItem item) { return false; } virtual void handleEvent(int eventId) = 0; virtual void handleMouseOver(const Common::String &name) {} virtual void handleMouseOut(const Common::String &name) {} virtual void frameCallback() {} virtual void handleKeypress(uint32 ucode) {} virtual void prepareRoom() = 0; virtual bool handleCheat(const Common::String &cheat) { return false; } virtual void handleUnclick(const Common::String &name, Common::Point pnt) {} virtual ~Handler() {} }; Common::SharedPtr makeOlympusHandler(); Common::SharedPtr makeWallOfFameHandler(); Common::SharedPtr makeArgoHandler(); Common::SharedPtr makeCreteHandler(); Common::SharedPtr makeMinosHandler(); Common::SharedPtr makeDaedalusHandler(); Common::SharedPtr makeSeriphosHandler(); Common::SharedPtr makeMedIsleHandler(); Common::SharedPtr makeTroyHandler(); Common::SharedPtr makeMinotaurHandler(); Common::SharedPtr makeQuizHandler(); Common::SharedPtr makeCatacombsHandler(); Common::SharedPtr makePriamHandler(); Common::SharedPtr makeAthenaHandler(); Common::SharedPtr makeVolcanoHandler(); Common::SharedPtr makeRiverStyxHandler(); Common::SharedPtr makeHadesThroneHandler(); Common::SharedPtr makeCreditsHandler(bool inOptions); Common::SharedPtr makeIntroHandler(); Common::SharedPtr makeFerryHandler(); Common::SharedPtr makeOptionsHandler(); Common::SharedPtr makeMonsterHandler(); Common::SharedPtr makeMedusaHandler(); Common::SharedPtr makeTrojanHandler(); class HadeschEngine : public Engine, Common::NonCopyable { public: HadeschEngine(OSystem *syst, const ADGameDescription *desc); ~HadeschEngine() override; Common::Error run() override; bool hasFeature(EngineFeature f) const override; bool canLoadGameStateCurrently() override { return true; } bool canSaveGameStateCurrently() override { return _persistent._currentRoomId != 0; } Common::Error loadGameStream(Common::SeekableReadStream *stream) override; Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override; Common::SeekableReadStream *openFile(const Common::String &name, bool addCurrentPath); Common::RandomSource &getRnd(); const Common::String &getCDScenesPath() const; Common::SharedPtr getVideoRoom(); void moveToRoom(RoomId id) { _nextRoom.push_back(id); _heroBelt->clearHold(); } void handleEvent(EventHandlerWrapper event); int32 getCurrentTime() { return _currentTime; } Common::Point getMousePos(); void addTimer(EventHandlerWrapper event, int period, int repeat = 1); void addSkippableTimer(EventHandlerWrapper event, int period, int repeat = 1); void cancelTimer(int eventId); Common::SharedPtr getWdPodFile() { return _wdPodFile; } RoomId getPreviousRoomId() const { return _persistent._previousRoomId; } bool isRoomVisited(RoomId id) const { return _persistent._roomVisited[id]; } Persistent *getPersistent() { return &_persistent; } Common::SharedPtr getCurrentHandler(); Common::SharedPtr getHeroBelt() { return _heroBelt; } int firstAvailableSlot(); void newGame(); void enterOptions(); void resetOptionsRoom(); void exitOptions(); void enterOptionsCredits(); void quit(); bool hasAnySaves(); Common::Array getHadeschSavesList(); void deleteSave(int slot); int genSubtitleID(); uint32 getSubtitleDelayPerChar() const; void wrapSubtitles(const Common::U32String &str, Common::Array &lines); Common::U32String translate(const Common::String &str); private: void addTimer(EventHandlerWrapper event, int32 start_time, int period, int repeat, bool skippable); void moveToRoomReal(RoomId id); void setVideoRoom(Common::SharedPtr scene, Common::SharedPtr handler, RoomId roomId); Common::ErrorCode loadCursors(); bool handleGenericCheat(const Common::String &cheat); Common::ErrorCode loadWindowsCursors(Common::PEResources &exe); struct Timer { int32 next_time; int32 period; int32 period_count; EventHandlerWrapper event; bool skippable; }; const ADGameDescription *_desc; Common::RandomSource _rnd; Common::String _cdScenesPath; Common::SharedPtr _sceneVideoRoom; Common::SharedPtr _sceneHandler; Common::SharedPtr _optionsRoom; Common::SharedPtr _optionsHandler; bool _isInOptions; uint32 _optionsEnterTime; uint32 _sceneStartTime; int32 _currentTime; Common::Array _cursors; Common::List _sceneTimers; Common::SharedPtr _wdPodFile; Common::SharedPtr _heroBelt; Common::String _cheat; Common::SharedPtr _gfxContext; bool _cheatsEnabled; Common::Point _mousePos; Persistent _persistent; Common::Array _nextRoom; bool _isRestoring; bool _isQuitting; int _subtitleID; int _subtitleDelayPerChar; #ifdef USE_TRANSLATION Common::TranslationManager *_transMan; #endif // For freeing purposes Common::Array _macCursors; Common::Array _winCursors; }; extern HadeschEngine *g_vm; } // End of namespace Hadesch #endif