diff options
author | craigsc | 2020-01-11 12:08:21 -0800 |
---|---|---|
committer | craigsc | 2020-01-11 12:08:21 -0800 |
commit | 3dd4fb16f017a8eab5c6c11fd119a397b457866e (patch) | |
tree | 5b80b5c5038d8577c2d674a5a4742b335deca515 /engines/mohawk | |
parent | f9f81ea9baecb714f26cf1c17a1b0ae58431467b (diff) | |
parent | 5893672b80f00fced33c42e63471d68ba47d7dd4 (diff) | |
download | scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.tar.gz scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.tar.bz2 scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/cursors.cpp | 68 | ||||
-rw-r--r-- | engines/mohawk/cursors.h | 37 |
2 files changed, 43 insertions, 62 deletions
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index 12c3ebfffe..152861b806 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -141,36 +141,6 @@ void MystCursorManager::setDefaultCursor() { #endif -NECursorManager::NECursorManager(const Common::String &appName) { - _exe = new Common::NEResources(); - - if (!_exe->loadFromEXE(appName)) { - // Not all have cursors anyway, so this is not a problem - delete _exe; - _exe = nullptr; - } -} - -NECursorManager::~NECursorManager() { - delete _exe; -} - -void NECursorManager::setCursor(uint16 id) { - if (_exe) { - Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, id); - - if (cursorGroup) { - Graphics::Cursor *cursor = cursorGroup->cursors[0].cursor; - CursorMan.replaceCursor(cursor); - delete cursorGroup; - return; - } - } - - // Last resort (not all have cursors) - setDefaultCursor(); -} - MacCursorManager::MacCursorManager(const Common::String &appName) { if (!appName.empty()) { _resFork = new Common::MacResManager(); @@ -241,31 +211,41 @@ void LivingBooksCursorManager_v2::setCursor(const Common::String &name) { setCursor(id); } -PECursorManager::PECursorManager(const Common::String &appName) { - Common::PEResources *exe = new Common::PEResources(); - if (!exe->loadFromEXE(appName)) { - // Not all have cursors anyway, so this is not a problem - return; +NECursorManager::NECursorManager(const Common::String &appName) { + Common::NEResources *exe = new Common::NEResources(); + if (exe->loadFromEXE(appName)) { + // Not all have cursors anyway, so it's not a problem if this fails + loadCursors(exe); } + delete exe; +} - const Common::Array<Common::WinResourceID> cursorGroups = exe->getNameList(Common::kWinGroupCursor); - - _cursors.resize(cursorGroups.size()); - for (uint i = 0; i < cursorGroups.size(); i++) { - _cursors[i].id = cursorGroups[i].getID(); - _cursors[i].cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*exe, cursorGroups[i]); +PECursorManager::PECursorManager(const Common::String &appName) { + Common::PEResources *exe = new Common::PEResources(); + if (exe->loadFromEXE(appName)) { + // Not all have cursors anyway, so it's not a problem if this fails + loadCursors(exe); } - delete exe; } -PECursorManager::~PECursorManager() { +WinCursorManager::~WinCursorManager() { for (uint i = 0; i < _cursors.size(); i++) { delete _cursors[i].cursorGroup; } } -void PECursorManager::setCursor(uint16 id) { +void WinCursorManager::loadCursors(Common::WinResources *exe) { + const Common::Array<Common::WinResourceID> cursorGroups = exe->getIDList(Common::kWinGroupCursor); + + _cursors.resize(cursorGroups.size()); + for (uint i = 0; i < cursorGroups.size(); i++) { + _cursors[i].id = cursorGroups[i].getID(); + _cursors[i].cursorGroup = Graphics::WinCursorGroup::createCursorGroup(exe, cursorGroups[i]); + } +} + +void WinCursorManager::setCursor(uint16 id) { for (uint i = 0; i < _cursors.size(); i++) { if (_cursors[i].id == id) { Graphics::Cursor *cursor = _cursors[i].cursorGroup->cursors[0].cursor; diff --git a/engines/mohawk/cursors.h b/engines/mohawk/cursors.h index ff5db5b59c..eaee34b4e1 100644 --- a/engines/mohawk/cursors.h +++ b/engines/mohawk/cursors.h @@ -27,7 +27,7 @@ namespace Common { class MacResManager; -class NEResources; +class WinResources; class SeekableReadStream; class String; } @@ -125,19 +125,6 @@ private: #endif // ENABLE_MYST -// The cursor manager for NE EXE's -class NECursorManager : public CursorManager { -public: - explicit NECursorManager(const Common::String &appName); - ~NECursorManager() override; - - void setCursor(uint16 id) override; - bool hasSource() const override { return _exe != nullptr; } - -private: - Common::NEResources *_exe; -}; - // The cursor manager for Mac applications class MacCursorManager : public CursorManager { public: @@ -166,15 +153,17 @@ private: MohawkArchive *_sysArchive; }; -// The cursor manager for PE EXE's -class PECursorManager : public CursorManager { +// The cursor manager for Windows EXE's +class WinCursorManager : public CursorManager { public: - explicit PECursorManager(const Common::String &appName); - ~PECursorManager() override; + ~WinCursorManager() override; void setCursor(uint16 id) override; bool hasSource() const override { return !_cursors.empty(); } +protected: + void loadCursors(Common::WinResources *exe); + private: struct CursorItem { uint16 id; @@ -184,6 +173,18 @@ private: Common::Array<CursorItem> _cursors; }; +// The cursor manager for NE EXE's +class NECursorManager : public WinCursorManager { +public: + explicit NECursorManager(const Common::String &appName); +}; + +// The cursor manager for PE EXE's +class PECursorManager : public WinCursorManager { +public: + explicit PECursorManager(const Common::String &appName); +}; + } // End of namespace Mohawk #endif |