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; _firstTimeStruct = 0;
_pendingDeleteTimeEvent = 0; _pendingDeleteTimeEvent = 0;
_mouseX = 0;
_mouseY = 0;
_mouseXOld = 0;
_mouseYOld = 0;
_leftButtonDown = 0; _leftButtonDown = 0;
_rightButtonDown = 0; _rightButtonDown = 0;
_noRightClick = false; _noRightClick = false;
@ -446,9 +441,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_oracleMaxScrollY = 0; _oracleMaxScrollY = 0;
_noOracleScroll = 0; _noOracleScroll = 0;
_sdlMouseX = 0;
_sdlMouseY = 0;
_backGroundBuf = 0; _backGroundBuf = 0;
_frontBuf = 0; _frontBuf = 0;
_backBuf = 0; _backBuf = 0;

View file

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

View file

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

View file

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

View file

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

View file

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