aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/cursors.cpp64
-rw-r--r--engines/mohawk/cursors.h37
2 files changed, 41 insertions, 60 deletions
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index be1f8204a6..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,13 +211,31 @@ void LivingBooksCursorManager_v2::setCursor(const Common::String &name) {
setCursor(id);
}
+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;
+}
+
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;
+ if (exe->loadFromEXE(appName)) {
+ // Not all have cursors anyway, so it's not a problem if this fails
+ loadCursors(exe);
+ }
+ delete exe;
+}
+
+WinCursorManager::~WinCursorManager() {
+ for (uint i = 0; i < _cursors.size(); i++) {
+ delete _cursors[i].cursorGroup;
}
+}
+void WinCursorManager::loadCursors(Common::WinResources *exe) {
const Common::Array<Common::WinResourceID> cursorGroups = exe->getIDList(Common::kWinGroupCursor);
_cursors.resize(cursorGroups.size());
@@ -255,17 +243,9 @@ PECursorManager::PECursorManager(const Common::String &appName) {
_cursors[i].id = cursorGroups[i].getID();
_cursors[i].cursorGroup = Graphics::WinCursorGroup::createCursorGroup(exe, cursorGroups[i]);
}
-
- delete exe;
-}
-
-PECursorManager::~PECursorManager() {
- for (uint i = 0; i < _cursors.size(); i++) {
- delete _cursors[i].cursorGroup;
- }
}
-void PECursorManager::setCursor(uint16 id) {
+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