diff options
author | Max Horn | 2007-11-28 15:00:41 +0000 |
---|---|---|
committer | Max Horn | 2007-11-28 15:00:41 +0000 |
commit | a556368c9942cfb8e43727ac06d73afefad6ccdc (patch) | |
tree | 3eee96d0e07d0376d2f032072a9f0f6bc68edad8 /engines | |
parent | 81c7b9a78689d5e22fdaf7760b5b9d3ee20b014a (diff) | |
download | scummvm-rg350-a556368c9942cfb8e43727ac06d73afefad6ccdc.tar.gz scummvm-rg350-a556368c9942cfb8e43727ac06d73afefad6ccdc.tar.bz2 scummvm-rg350-a556368c9942cfb8e43727ac06d73afefad6ccdc.zip |
Update mouse coordinates onn *all* mouse events, i.e. also after click events
svn-id: r29657
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/agi.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 4 | ||||
-rw-r--r-- | engines/sword1/control.cpp | 26 | ||||
-rw-r--r-- | engines/sword1/control.h | 3 | ||||
-rw-r--r-- | engines/sword1/mouse.cpp | 8 | ||||
-rw-r--r-- | engines/sword1/mouse.h | 2 | ||||
-rw-r--r-- | engines/sword1/sword1.cpp | 17 | ||||
-rw-r--r-- | engines/sword1/sword1.h | 3 |
8 files changed, 33 insertions, 32 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index b5b396f0e9..412b19fb17 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -110,6 +110,8 @@ void AgiEngine::processEvents() { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONUP: g_mouse.button = 0; + g_mouse.x = event.mouse.x; + g_mouse.y = event.mouse.y; break; case Common::EVENT_KEYDOWN: _keyControl = 0; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 1bbe06984b..e4f936cda8 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -216,18 +216,22 @@ uint16 Parallaction::readInput() { case Common::EVENT_LBUTTONDOWN: _mouseButtons = kMouseLeftDown; + _mousePos = e.mouse; break; case Common::EVENT_LBUTTONUP: _mouseButtons = kMouseLeftUp; + _mousePos = e.mouse; break; case Common::EVENT_RBUTTONDOWN: _mouseButtons = kMouseRightDown; + _mousePos = e.mouse; break; case Common::EVENT_RBUTTONUP: _mouseButtons = kMouseRightUp; + _mousePos = e.mouse; break; case Common::EVENT_MOUSEMOVE: diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 388cb132da..10097c0a1f 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -344,7 +344,7 @@ uint8 Control::getClicks(uint8 mode, uint8 *retVal) { return 0; if (_mouseState & BS1L_BUTTON_DOWN) for (uint8 cnt = 0; cnt < checkButtons; cnt++) - if (_buttons[cnt]->wasClicked(_mouseX, _mouseY)) { + if (_buttons[cnt]->wasClicked(_mouseCoord.x, _mouseCoord.y)) { _selectedButton = cnt; _buttons[cnt]->setSelected(1); if (_buttons[cnt]->isSaveslot()) @@ -352,7 +352,7 @@ uint8 Control::getClicks(uint8 mode, uint8 *retVal) { } if (_mouseState & BS1L_BUTTON_UP) { for (uint8 cnt = 0; cnt < checkButtons; cnt++) - if (_buttons[cnt]->wasClicked(_mouseX, _mouseY)) + if (_buttons[cnt]->wasClicked(_mouseCoord.x, _mouseCoord.y)) if (_selectedButton == cnt) { // saveslots stay selected after clicking if (!_buttons[cnt]->isSaveslot()) @@ -525,12 +525,12 @@ void Control::handleVolumeClicks(void) { if (_mouseDown) { uint8 clickedId = 0; for (uint8 cnt = 1; cnt < 4; cnt++) - if (_buttons[cnt]->wasClicked(_mouseX, _mouseY)) + if (_buttons[cnt]->wasClicked(_mouseCoord.x, _mouseCoord.y)) clickedId = cnt; if (clickedId) { // these are circle shaped, so check again if it was clicked. uint8 clickDest = 0; - int16 mouseDiffX = _mouseX - (_volumeButtons[clickedId].x + 48); - int16 mouseDiffY = _mouseY - (_volumeButtons[clickedId].y + 48); + int16 mouseDiffX = _mouseCoord.x - (_volumeButtons[clickedId].x + 48); + int16 mouseDiffY = _mouseCoord.y - (_volumeButtons[clickedId].y + 48); int16 mouseOffs = (int16)sqrt((double)(mouseDiffX * mouseDiffX + mouseDiffY * mouseDiffY)); // check if the player really hit the button (but not the center). if ((mouseOffs <= 42) && (mouseOffs >= 8)) { @@ -627,9 +627,9 @@ bool Control::getConfirm(const uint8 *title) { else if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER) retVal = 1; if (_mouseState & BS1L_BUTTON_DOWN) { - if (buttons[0]->wasClicked(_mouseX, _mouseY)) + if (buttons[0]->wasClicked(_mouseCoord.x, _mouseCoord.y)) clickVal = 1; - else if (buttons[1]->wasClicked(_mouseX, _mouseY)) + else if (buttons[1]->wasClicked(_mouseCoord.x, _mouseCoord.y)) clickVal = 2; else clickVal = 0; @@ -637,7 +637,7 @@ bool Control::getConfirm(const uint8 *title) { buttons[clickVal - 1]->setSelected(1); } if ((_mouseState & BS1L_BUTTON_UP) && (clickVal)) { - if (buttons[clickVal - 1]->wasClicked(_mouseX, _mouseY)) + if (buttons[clickVal - 1]->wasClicked(_mouseCoord.x, _mouseCoord.y)) retVal = clickVal; else buttons[clickVal - 1]->setSelected(0); @@ -1043,24 +1043,22 @@ void Control::delay(uint32 msecs) { // to handle keyboard input return; case Common::EVENT_MOUSEMOVE: - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; + _mouseCoord = event.mouse; break; case Common::EVENT_LBUTTONDOWN: _mouseDown = true; _mouseState |= BS1L_BUTTON_DOWN; -#if defined(_WIN32_WCE) || defined(PALMOS_MODE) - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; -#endif + _mouseCoord = event.mouse; break; case Common::EVENT_LBUTTONUP: _mouseDown = false; _mouseState |= BS1L_BUTTON_UP; + _mouseCoord = event.mouse; break; case Common::EVENT_WHEELUP: _mouseDown = false; _mouseState |= BS1_WHEEL_UP; + _mouseCoord = event.mouse; break; case Common::EVENT_WHEELDOWN: _mouseDown = false; diff --git a/engines/sword1/control.h b/engines/sword1/control.h index 1825350170..21181dd0bc 100644 --- a/engines/sword1/control.h +++ b/engines/sword1/control.h @@ -144,7 +144,8 @@ private: uint8 *_screenBuf; Common::KeyState _keyPressed; void delay(uint32 msecs); - uint16 _mouseX, _mouseY, _mouseState; + Common::Point _mouseCoord; + uint16 _mouseState; bool _mouseDown; }; diff --git a/engines/sword1/mouse.cpp b/engines/sword1/mouse.cpp index 6e9888a5bb..b21d7b063a 100644 --- a/engines/sword1/mouse.cpp +++ b/engines/sword1/mouse.cpp @@ -112,8 +112,8 @@ void Mouse::engine(uint16 x, uint16 y, uint16 eventFlags) { _state &= MOUSE_DOWN_MASK; } - _mouseX = x; - _mouseY = y; + _mouse.x = x; + _mouse.y = y; if (!(Logic::_scriptVars[MOUSE_STATUS] & 1)) { // no human? _numObjs = 0; return; // no human, so we don't want the mouse engine @@ -311,8 +311,8 @@ void Mouse::fnUnlockMouse(void) { } void Mouse::giveCoords(uint16 *x, uint16 *y) { - *x = _mouseX; - *y = _mouseY; + *x = _mouse.x; + *y = _mouse.y; } } // End of namespace Sword1 diff --git a/engines/sword1/mouse.h b/engines/sword1/mouse.h index f2c800d63b..b1774c3999 100644 --- a/engines/sword1/mouse.h +++ b/engines/sword1/mouse.h @@ -97,7 +97,7 @@ private: MouseObj _objList[MAX_MOUSE]; ResMan *_resMan; ObjectMan *_objMan; - uint16 _mouseX, _mouseY; + Common::Point _mouse; uint32 _currentPtrId, _currentLuggageId, _frame; MousePtr *_currentPtr; diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 625f484ed5..04328c0571 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -679,7 +679,7 @@ uint8 SwordEngine::mainLoop(void) { _screen->updateScreen(); delay((1000 / FRAME_RATE) - (_system->getMillis() - frameTime)); - _mouse->engine( _mouseX, _mouseY, _mouseState); + _mouse->engine(_mouseCoord.x, _mouseCoord.y, _mouseState); if (_systemVars.forceRestart) retCode = CONTROL_RESTART_GAME; @@ -725,28 +725,23 @@ void SwordEngine::delay(int32 amount) { //copied and mutilated from sky.cpp _keyPressed = event.kbd; break; case Common::EVENT_MOUSEMOVE: - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; + _mouseCoord = event.mouse; break; case Common::EVENT_LBUTTONDOWN: _mouseState |= BS1L_BUTTON_DOWN; -#if defined(_WIN32_WCE) || defined(PALMOS_MODE) - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; -#endif + _mouseCoord = event.mouse; break; case Common::EVENT_RBUTTONDOWN: _mouseState |= BS1R_BUTTON_DOWN; -#if defined(_WIN32_WCE) || defined(PALMOS_MODE) - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; -#endif + _mouseCoord = event.mouse; break; case Common::EVENT_LBUTTONUP: _mouseState |= BS1L_BUTTON_UP; + _mouseCoord = event.mouse; break; case Common::EVENT_RBUTTONUP: _mouseState |= BS1R_BUTTON_UP; + _mouseCoord = event.mouse; break; case Common::EVENT_QUIT: _systemVars.engineQuit = true; diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h index 7065b5498a..cfb6750a47 100644 --- a/engines/sword1/sword1.h +++ b/engines/sword1/sword1.h @@ -92,7 +92,8 @@ private: void flagsToBool(bool *dest, uint8 flags); uint8 mainLoop(void); - uint16 _mouseX, _mouseY, _mouseState; + Common::Point _mouseCoord; + uint16 _mouseState; Common::KeyState _keyPressed; ResMan *_resMan; |