diff options
author | Bastien Bouclet | 2017-07-01 14:56:03 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | b9a72ff7a6dc7033beae4a75dc5f596264c39419 (patch) | |
tree | b2956cb326808f0254df92ec9cc49d126db2fe78 /engines | |
parent | 672cfbd518626fffc3476c2f6d0cdd391ab12e17 (diff) | |
download | scummvm-rg350-b9a72ff7a6dc7033beae4a75dc5f596264c39419.tar.gz scummvm-rg350-b9a72ff7a6dc7033beae4a75dc5f596264c39419.tar.bz2 scummvm-rg350-b9a72ff7a6dc7033beae4a75dc5f596264c39419.zip |
MOHAWK: Preload all the PE cursors on startup
We were previously reloading the current cursor from raw data on each
frame.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/cursors.cpp | 29 | ||||
-rw-r--r-- | engines/mohawk/cursors.h | 14 | ||||
-rw-r--r-- | engines/mohawk/riven_stacks/jspit.cpp | 2 |
3 files changed, 29 insertions, 16 deletions
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index b78f71a71d..ebc556137a 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -251,28 +251,33 @@ void LivingBooksCursorManager_v2::setCursor(const Common::String &name) { } PECursorManager::PECursorManager(const Common::String &appName) { - _exe = new Common::PEResources(); - - if (!_exe->loadFromEXE(appName)) { + Common::PEResources exe; + if (!exe.loadFromEXE(appName)) { // Not all have cursors anyway, so this is not a problem - delete _exe; - _exe = 0; + return; + } + + const Common::Array<Common::WinResourceID> cursorGroups = exe.getNameList(Common::kPEGroupCursor); + + _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() { - delete _exe; + for (uint i = 0; i < _cursors.size(); i++) { + delete _cursors[i].cursorGroup; + } } void PECursorManager::setCursor(uint16 id) { - if (_exe) { - Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, id); - - if (cursorGroup) { - Graphics::Cursor *cursor = cursorGroup->cursors[0].cursor; + for (uint i = 0; i < _cursors.size(); i++) { + if (_cursors[i].id == id) { + Graphics::Cursor *cursor = _cursors[i].cursorGroup->cursors[0].cursor; CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor()); CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256); - delete cursorGroup; return; } } diff --git a/engines/mohawk/cursors.h b/engines/mohawk/cursors.h index 742ae30107..d0d38c9b46 100644 --- a/engines/mohawk/cursors.h +++ b/engines/mohawk/cursors.h @@ -28,11 +28,14 @@ namespace Common { class MacResManager; class NEResources; -class PEResources; class SeekableReadStream; class String; } +namespace Graphics { +struct WinCursorGroup; +} + #include "mohawk/resource.h" namespace Mohawk { @@ -170,10 +173,15 @@ public: ~PECursorManager(); void setCursor(uint16 id); - bool hasSource() const { return _exe != 0; } + bool hasSource() const { return !_cursors.empty(); } private: - Common::PEResources *_exe; + struct CursorItem { + uint16 id; + Graphics::WinCursorGroup *cursorGroup; + }; + + Common::Array<CursorItem> _cursors; }; } // End of namespace Mohawk diff --git a/engines/mohawk/riven_stacks/jspit.cpp b/engines/mohawk/riven_stacks/jspit.cpp index 216fdd5745..cd3b4baf51 100644 --- a/engines/mohawk/riven_stacks/jspit.cpp +++ b/engines/mohawk/riven_stacks/jspit.cpp @@ -258,7 +258,7 @@ void JSpit::xvga1300_carriage(uint16 argc, uint16 *argv) { _vm->getCard()->drawPicture(1); _vm->_gfx->applyScreenUpdate(); - _vm->_cursor->setCursor(3000); + _vm->_cursor->setCursor(kRivenMainCursor); mouseForceUp(); if (_vm->_vars["jgallows"] == 1) { |