Update mouse coordinates onn *all* mouse events, i.e. also after click events

svn-id: r29657
This commit is contained in:
Max Horn 2007-11-28 15:00:41 +00:00
parent 81c7b9a786
commit a556368c99
8 changed files with 33 additions and 32 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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;

View File

@ -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;
};

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;