Changed AGOS to use the EventManager to track the mouse position; added a FIXME comment about _mouseOld never being set

svn-id: r26206
This commit is contained in:
Max Horn 2007-03-18 13:29:12 +00:00
parent 48cb57ec89
commit 72ee9ee86a
6 changed files with 29 additions and 46 deletions

View file

@ -259,11 +259,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_firstTimeStruct = 0;
_pendingDeleteTimeEvent = 0;
_mouseX = 0;
_mouseY = 0;
_mouseXOld = 0;
_mouseYOld = 0;
_leftButtonDown = 0;
_rightButtonDown = 0;
_noRightClick = false;
@ -446,9 +441,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_oracleMaxScrollY = 0;
_noOracleScroll = 0;
_sdlMouseX = 0;
_sdlMouseY = 0;
_backGroundBuf = 0;
_frontBuf = 0;
_backBuf = 0;

View file

@ -356,8 +356,8 @@ protected:
TimeEvent *_firstTimeStruct, *_pendingDeleteTimeEvent;
int _mouseX, _mouseY;
int _mouseXOld, _mouseYOld;
Common::Point _mouse;
Common::Point _mouseOld;
byte *_mouseData;
byte _animatePointer;
@ -515,8 +515,6 @@ protected:
bool _oopsValid;
int _sdlMouseX, _sdlMouseY;
byte *_backGroundBuf;
byte *_frontBuf;
byte *_backBuf;
@ -777,7 +775,6 @@ protected:
void invertBox(HitArea * ha, byte a, byte b, byte c, byte d);
void handleMouseMoved();
void pollMouseXY();
void initMouse();
void loadMouseImage();
void drawMousePointer();

View file

@ -23,6 +23,7 @@
#include "common/stdafx.h"
#include "common/events.h"
#include "common/system.h"
#include "graphics/cursorman.h"
@ -308,21 +309,24 @@ void AGOSEngine::handleMouseMoved() {
}
CursorMan.showMouse(true);
pollMouseXY();
if (_mouseX <= 0)
_mouseX = 0;
if (_mouseX >= _screenWidth - 1)
_mouseX = _screenWidth - 1;
_mouse = _system->getEventManager()->getMousePos();
if (_mouseY <= 0)
_mouseY = 0;
if (_mouseY >= _screenHeight - 1)
_mouseY = _screenHeight - 1;
// Clip the mouse to the screen
// TODO this should not be necessary
if (_mouse.x <= 0)
_mouse.x = 0;
if (_mouse.x >= _screenWidth - 1)
_mouse.x = _screenWidth - 1;
if (_mouse.y <= 0)
_mouse.y = 0;
if (_mouse.y >= _screenHeight - 1)
_mouse.y = _screenHeight - 1;
if (_defaultVerb) {
uint id = 101;
if (_mouseY >= 136)
if (_mouse.y >= 136)
id = 102;
if (_defaultVerb != id)
resetVerbs();
@ -337,7 +341,7 @@ void AGOSEngine::handleMouseMoved() {
if (getGameType() == GType_FF) {
if (getBitFlag(99)) { // Oracle
if (_mouseX >= 10 && _mouseX <= 635 && _mouseY >= 5 && _mouseY <= 475) {
if (_mouse.x >= 10 && _mouse.x <= 635 && _mouse.y >= 5 && _mouse.y <= 475) {
setBitFlag(98, true);
} else {
if (getBitFlag(98)) {
@ -345,7 +349,7 @@ void AGOSEngine::handleMouseMoved() {
}
}
} else if (getBitFlag(88)) { // Close Up
if (_mouseX >= 10 && _mouseX <= 635 && _mouseY >= 5 && _mouseY <= 475) {
if (_mouse.x >= 10 && _mouse.x <= 635 && _mouse.y >= 5 && _mouse.y <= 475) {
setBitFlag(87, true);
} else {
if (getBitFlag(87)) {
@ -361,15 +365,15 @@ void AGOSEngine::handleMouseMoved() {
} else if (getGameType() == GType_SIMON2) {
if (getBitFlag(79)) {
if (!_vgaVar9) {
if (_mouseX >= 315 || _mouseX < 9)
if (_mouse.x >= 315 || _mouse.x < 9)
goto get_out2;
_vgaVar9 = 1;
}
if (_scrollCount == 0) {
if (_mouseX >= 315) {
if (_mouse.x >= 315) {
if (_scrollX != _scrollXMax)
_scrollFlag = 1;
} else if (_mouseX < 8) {
} else if (_mouse.x < 8) {
if (_scrollX != 0)
_scrollFlag = -1;
}
@ -395,12 +399,14 @@ void AGOSEngine::handleMouseMoved() {
}
}
if (_mouseX != _mouseXOld || _mouseY != _mouseYOld)
// FIXME: The value of _mouseOld is *never* changed and hence
// always equal to (0,0). This seems like a bug.
if (_mouse != _mouseOld)
_needHitAreaRecalc++;
if (_leftButtonOld == 0 && _leftButtonCount != 0) {
_lastClickRem = 0;
boxController(_mouseX, _mouseY, 3);
boxController(_mouse.x, _mouse.y, 3);
}
_leftButtonOld = _leftButton;
@ -437,7 +443,7 @@ void AGOSEngine::handleMouseMoved() {
}
boxstuff:
boxController(_mouseX, _mouseY, x);
boxController(_mouse.x, _mouse.y, x);
_lastHitArea3 = _lastHitArea;
if (x == 1 && _lastHitArea == NULL)
_lastHitArea3 = (HitArea *) -1;
@ -465,11 +471,6 @@ void AGOSEngine::mouseOn() {
_lockWord &= ~1;
}
void AGOSEngine::pollMouseXY() {
_mouseX = _sdlMouseX;
_mouseY = _sdlMouseY;
}
void AGOSEngine::initMouse() {
if (getGameType() == GType_PP) {
_maxCursorWidth = 75;

View file

@ -377,19 +377,12 @@ void AGOSEngine::delay(uint amount) {
_keyPressed = (byte)event.kbd.ascii;
break;
case Common::EVENT_MOUSEMOVE:
_sdlMouseX = event.mouse.x;
_sdlMouseY = event.mouse.y;
break;
case Common::EVENT_LBUTTONDOWN:
if (getGameType() == GType_FF)
setBitFlag(89, true);
_leftButtonDown++;
_leftButton = 1;
#if defined (_WIN32_WCE) || defined(PALMOS_MODE)
_sdlMouseX = event.mouse.x;
_sdlMouseY = event.mouse.y;
#endif
break;
case Common::EVENT_LBUTTONUP:
if (getGameType() == GType_FF)

View file

@ -357,7 +357,7 @@ dragMode:
_dragCount = 0;
_dragEnd = 0;
boxController(_mouseX, _mouseY, 1);
boxController(_mouse.x, _mouse.y, 1);
if (_currentBox != NULL) {
_hitAreaObjectItem = _currentBox->item_ptr;

View file

@ -511,9 +511,9 @@ void AGOSEngine::resetVerbs() {
if (getGameType() == GType_SIMON2) {
id = 2;
if (!getBitFlag(79))
id = (_mouseY >= 136) ? 102 : 101;
id = (_mouse.y >= 136) ? 102 : 101;
} else {
id = (_mouseY >= 136) ? 102 : 101;
id = (_mouse.y >= 136) ? 102 : 101;
}
_defaultVerb = id;