From 93dc7c8e63f138a3d3bac4474cd3065b053ed22a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Feb 2013 08:33:42 +0100 Subject: HOPKINS: Move mouse data initialization to EventsManager, set mouse variable as private --- engines/hopkins/dialogs.cpp | 4 ++-- engines/hopkins/events.cpp | 33 +++++++++++++++++++++++++++++++++ engines/hopkins/events.h | 6 ++++-- engines/hopkins/hopkins.cpp | 31 +------------------------------ 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index e13e820bb8..fe5f8cc2a5 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -43,12 +43,12 @@ DialogsManager::DialogsManager() { _inventWidth = _inventHeight = 0; _inventWin1 = g_PTRNUL; _inventBuf2 = g_PTRNUL; - _inventoryIcons = NULL; + _inventoryIcons = g_PTRNUL; } DialogsManager::~DialogsManager() { _vm->_globals.freeMemory(_inventWin1); - free(_inventoryIcons); + _vm->_globals.freeMemory(_inventoryIcons); } void DialogsManager::setParent(HopkinsEngine *vm) { diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index c55d0c5395..769696e2a0 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -64,6 +64,39 @@ void EventsManager::setParent(HopkinsEngine *vm) { _vm = vm; } +void EventsManager::initMouseData() { + if (_vm->getPlatform() == Common::kPlatformLinux) + _mouseLinuxFl = true; + else + _mouseLinuxFl = false; + + if (_mouseLinuxFl) { + _mouseSizeX = 52; + _mouseSizeY = 32; + } else { + _mouseSizeX = 34; + _mouseSizeY = 20; + } + + switch (_vm->_globals._language) { + case LANG_EN: + if (!_mouseLinuxFl) + _mouseCursor = _vm->_fileManager.loadFile("SOUAN.SPR"); + else + _mouseCursor = _vm->_fileManager.loadFile("LSOUAN.SPR"); + break; + case LANG_FR: + if (!_mouseLinuxFl) + _mouseCursor = _vm->_fileManager.loadFile("SOUFR.SPR"); + else + _mouseCursor = _vm->_fileManager.loadFile("LSOUFR.SPR"); + break; + case LANG_SP: + _mouseCursor = _vm->_fileManager.loadFile("SOUES.SPR"); + break; + } +} + // Mouse On void EventsManager::setMouseOn() { _mouseFl = true; diff --git a/engines/hopkins/events.h b/engines/hopkins/events.h index 03f8593091..d4759dfe1b 100644 --- a/engines/hopkins/events.h +++ b/engines/hopkins/events.h @@ -42,6 +42,8 @@ private: uint32 _priorCounterTime; uint32 _priorFrameTime; bool _keyState[256]; + bool _mouseLinuxFl; + int _mouseSizeX, _mouseSizeY; HopkinsEngine *_vm; @@ -56,7 +58,6 @@ public: uint32 _gameCounter; bool _escKeyFl; bool _mouseFl; - bool _mouseLinuxFl; bool _breakoutFl; Common::Point _startPos; Common::Point _mousePos; @@ -65,13 +66,14 @@ public: int _curMouseButton; int _mouseButton; int _mouseCursorId; - int _mouseSizeX, _mouseSizeY; byte *_objectBuf; byte *_mouseCursor; EventsManager(); ~EventsManager(); void setParent(HopkinsEngine *vm); + void initMouseData(); + void delay(int totalMilli); void changeMouseCursor(int id); void refreshEvents(); diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 2b7c026111..a8695dbe70 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -1557,36 +1557,7 @@ void HopkinsEngine::initializeSystem() { SearchMan.addSubDirectoryMatching(gameDataDir, "VOICE"); SearchMan.addSubDirectoryMatching(gameDataDir, "TSVGA"); - if (getPlatform() == Common::kPlatformLinux) - _eventsManager._mouseLinuxFl = true; - else - _eventsManager._mouseLinuxFl = false; - - if (_eventsManager._mouseLinuxFl) { - _eventsManager._mouseSizeX = 52; - _eventsManager._mouseSizeY = 32; - } else { - _eventsManager._mouseSizeX = 34; - _eventsManager._mouseSizeY = 20; - } - - switch (_globals._language) { - case LANG_EN: - if (!_eventsManager._mouseLinuxFl) - _eventsManager._mouseCursor = _fileManager.loadFile("SOUAN.SPR"); - else - _eventsManager._mouseCursor = _fileManager.loadFile("LSOUAN.SPR"); - break; - case LANG_FR: - if (!_eventsManager._mouseLinuxFl) - _eventsManager._mouseCursor = _fileManager.loadFile("SOUFR.SPR"); - else - _eventsManager._mouseCursor = _fileManager.loadFile("LSOUFR.SPR"); - break; - case LANG_SP: - _eventsManager._mouseCursor = _fileManager.loadFile("SOUES.SPR"); - break; - } + _eventsManager.initMouseData(); _globals.clearAll(); -- cgit v1.2.3