diff options
author | Bastien Bouclet | 2018-05-27 20:39:26 +0200 |
---|---|---|
committer | Bastien Bouclet | 2018-06-13 07:55:55 +0200 |
commit | 13b3371f1af143a319656bf476712abf41ee613b (patch) | |
tree | ae4c51e877e2627358c12a6431931c56bd905d1c /engines/mohawk/myst.h | |
parent | e3972150482531fdeea16609680fa6db1209c6ac (diff) | |
download | scummvm-rg350-13b3371f1af143a319656bf476712abf41ee613b.tar.gz scummvm-rg350-13b3371f1af143a319656bf476712abf41ee613b.tar.bz2 scummvm-rg350-13b3371f1af143a319656bf476712abf41ee613b.zip |
MOHAWK: MYST: Extract a Card class out of the main engine class
This is to allow having multiple cards loaded at the same time in the
future.
Diffstat (limited to 'engines/mohawk/myst.h')
-rw-r--r-- | engines/mohawk/myst.h | 104 |
1 files changed, 8 insertions, 96 deletions
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 64fee10fde..867131a712 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -47,6 +47,7 @@ class MystSound; class MystArea; class MystAreaImageSwitch; class MystAreaHover; +class MystCard; // Engine Debug Flags enum { @@ -121,52 +122,7 @@ enum { // Other positive values are PlayNewSound of that id }; -// View flags -enum { - kMystZipDestination = (1 << 0) -}; - -struct MystView { - uint16 flags; - - // Image Data - Common::Array<MystCondition> conditionalImages; - uint16 mainImage; - - // Sound Data - MystSoundBlock soundBlock; - - // Script Resources - enum ScriptResourceType { - kResourceImage = 1, - kResourceSound = 2, - kResourceSwitch = 3, - kResourceImageNoCache = 4, - kResourceSoundNoCache = 5 - }; - - struct ScriptResource { - ScriptResourceType type; - uint16 id; - uint16 switchVar; - ScriptResourceType switchResourceType; - Common::Array<int16> switchResourceIds; - }; - Common::Array<ScriptResource> scriptResources; - - // Resource ID's - uint16 rlst; - uint16 hint; - uint16 init; - uint16 exit; -}; - -struct MystCursorHint { - uint16 id; - int16 cursor; - - MystCondition variableHint; -}; +typedef Common::SharedPtr<MystCard> MystCardPtr; class MohawkEngine_Myst : public MohawkEngine { protected: @@ -178,15 +134,16 @@ public: Common::SeekableReadStream *getResource(uint32 tag, uint16 id) override; Common::Array<uint16> getResourceIDList(uint32 type) const; + void cachePreload(uint32 tag, uint16 id); void changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound); void changeToCard(uint16 card, TransitionType transition); - uint16 getCurCard() { return _curCard; } + MystCard *getCard() { return _card.get(); }; + MystCardPtr getCardPtr() { return _card; }; uint16 getCurStack() { return _curStack; } void setMainCursor(uint16 cursor); uint16 getMainCursor() { return _mainCursor; } - void checkCursorHints(); - MystArea *forceUpdateClickedResource(); + void refreshCursor(); bool wait(uint32 duration, bool skippable = false); /** Update the game state according to events and update the screen */ @@ -207,19 +164,10 @@ public: MystGraphics *_gfx; MystGameState *_gameState; MystScriptParser *_scriptParser; - Common::Array<MystArea *> _resources; Common::RandomSource *_rnd; MystArea *loadResource(Common::SeekableReadStream *rlstStream, MystArea *parent); - void setResourceEnabled(uint16 resourceId, bool enable); - void redrawArea(uint16 var, bool update = true); void redrawResource(MystAreaImageSwitch *resource, bool update = true); - void drawResourceImages(); - void drawCardBackground(); - uint16 getCardBackgroundId(); - - template<class T> - T *getViewResource(uint index); void setCacheState(bool state) { _cache.enabled = state; } bool getCacheState() { return _cache.enabled; } @@ -253,65 +201,29 @@ private: MystOptionsDialog *_optionsDialog; MystScriptParser *_prevStack; ResourceCache _cache; - void cachePreload(uint32 tag, uint16 id); uint16 _curStack; - uint16 _curCard; + MystCardPtr _card; uint32 _lastSaveTime; - MystView _view; - - bool _runExitScript; bool hasGameSaveSupport() const; void dropPage(); - void loadCard(); - void unloadCard(); - void runInitScript(); - void runExitScript(); - - void loadResources(); - void drawResourceRects(); - void checkCurrentResource(); - void updateActiveResource(); - Common::String wrapMovieFilename(const Common::String &movieName, uint16 stack); - /** Area of type kMystAreaHover being hovered by the mouse, if any */ - MystAreaHover *_hoverResource; - - /** Active area being hovered by the mouse, if any */ - MystArea *_activeResource; - - /** Active area being clicked on / dragged, if any */ - MystArea *_clickedResource; - // Input bool _mouseClicked; bool _mouseMoved; bool _escapePressed; bool _waitingOnBlockingOperation; - Common::Array<MystCursorHint> _cursorHints; - void loadCursorHints(); uint16 _currentCursor; uint16 _mainCursor; // Also defines the current page being held (white, blue, red, or none) - void pauseEngineIntern(bool) override; + void pauseEngineIntern(bool pause) override; }; -template<class T> -T *MohawkEngine_Myst::getViewResource(uint index) { - T *resource = dynamic_cast<T *>(_resources[index]); - - if (!resource) { - error("View resource '%d' has unexpected type", index); - } - - return resource; -} - } // End of namespace Mohawk #endif |