From 63589812018eafc0c7ed4b7a8b77b7e048db10ad Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 17 May 2016 07:09:42 +0200 Subject: GNAP: USe Common::Point for mouse position, initialize some more variables --- engines/gnap/gnap.cpp | 17 ++++++++++------- engines/gnap/gnap.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp index 2a143ad141..21f44c3e59 100644 --- a/engines/gnap/gnap.cpp +++ b/engines/gnap/gnap.cpp @@ -103,6 +103,10 @@ GnapEngine::GnapEngine(OSystem *syst, const ADGameDescription *gd) : _savedTimers[i] = _timers[i] = 0; _isWaiting = false; + _sceneWaiting = false; + + _mousePos = Common::Point(0, 0); + _currGrabCursorX = _currGrabCursorY = 0; } GnapEngine::~GnapEngine() { @@ -205,8 +209,7 @@ void GnapEngine::updateEvents() { _keyDownState[event.kbd.keycode] = 0; break; case Common::EVENT_MOUSEMOVE: - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; + _mousePos = event.mouse; break; case Common::EVENT_LBUTTONUP: _mouseButtonState._left = false; @@ -352,7 +355,7 @@ int GnapEngine::getHotspotIndexAtPos(Common::Point pos) { void GnapEngine::updateCursorByHotspot() { if (!_isWaiting) { - int hotspotIndex = getHotspotIndexAtPos(Common::Point(_mouseX, _mouseY)); + int hotspotIndex = getHotspotIndexAtPos(_mousePos); if (_debugger->_showHotspotNumber) { // NOTE This causes some display glitches @@ -474,8 +477,8 @@ void GnapEngine::setGrabCursorSprite(int index) { void GnapEngine::createGrabCursorSprite(int spriteId) { _grabCursorSprite = _gameSys->createSurface(spriteId); _gameSys->insertSpriteDrawItem(_grabCursorSprite, - _mouseX - (_grabCursorSprite->w / 2), - _mouseY - (_grabCursorSprite->h / 2), + _mousePos.x - (_grabCursorSprite->w / 2), + _mousePos.y - (_grabCursorSprite->h / 2), 300); delayTicks(5); } @@ -491,8 +494,8 @@ void GnapEngine::freeGrabCursorSprite() { void GnapEngine::updateGrabCursorSprite(int x, int y) { if (_grabCursorSprite) { - int newGrabCursorX = _mouseX - (_grabCursorSprite->w / 2) - x; - int newGrabCursorY = _mouseY - (_grabCursorSprite->h / 2) - y; + int newGrabCursorX = _mousePos.x - (_grabCursorSprite->w / 2) - x; + int newGrabCursorY = _mousePos.y - (_grabCursorSprite->h / 2) - y; if (_currGrabCursorX != newGrabCursorX || _currGrabCursorY != newGrabCursorY) { _currGrabCursorX = newGrabCursorX; _currGrabCursorY = newGrabCursorY; diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index 45f675c848..3cedf1b9fe 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -286,7 +286,7 @@ public: int _newCursorValue, _cursorValue; int _verbCursor, _cursorIndex; - int _mouseX, _mouseY; + Common::Point _mousePos; int _leftClickMouseX, _leftClickMouseY; Graphics::Surface *_grabCursorSprite; -- cgit v1.2.3