aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2009-07-05 11:26:23 +0000
committerSven Hesse2009-07-05 11:26:23 +0000
commitd2c2386c6ad70cb1e7edd40b1c007c5f863be99c (patch)
treedc462c9040986a3ebf21e490e095d709bdd17835 /engines
parent5c60d94725764c278aa463b8c206abb796406da9 (diff)
downloadscummvm-rg350-d2c2386c6ad70cb1e7edd40b1c007c5f863be99c.tar.gz
scummvm-rg350-d2c2386c6ad70cb1e7edd40b1c007c5f863be99c.tar.bz2
scummvm-rg350-d2c2386c6ad70cb1e7edd40b1c007c5f863be99c.zip
Adding an enum MouseButtons
svn-id: r42119
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/game.cpp9
-rw-r--r--engines/gob/game.h6
-rw-r--r--engines/gob/game_fascin.cpp8
-rw-r--r--engines/gob/game_v1.cpp16
-rw-r--r--engines/gob/game_v2.cpp14
-rw-r--r--engines/gob/game_v6.cpp14
-rw-r--r--engines/gob/inter.cpp2
-rw-r--r--engines/gob/inter_bargon.cpp4
-rw-r--r--engines/gob/util.cpp38
-rw-r--r--engines/gob/util.h13
10 files changed, 67 insertions, 57 deletions
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index 5771ee9f76..f69b899ce1 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -29,7 +29,6 @@
#include "gob/game.h"
#include "gob/helper.h"
#include "gob/global.h"
-#include "gob/util.h"
#include "gob/dataio.h"
#include "gob/variables.h"
#include "gob/script.h"
@@ -186,7 +185,7 @@ Game::Game(GobEngine *vm) : _vm(vm) {
_totToLoad[0] = 0;
_startTimeKey = 0;
- _mouseButtons = 0;
+ _mouseButtons = kMouseButtonsNone;
_lastCollKey = 0;
_lastCollAreaIndex = 0;
@@ -349,7 +348,7 @@ void Game::evaluateScroll(int16 x, int16 y) {
}
int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY,
- int16 *pButtons, char handleMouse) {
+ MouseButtons *pButtons, char handleMouse) {
_vm->_util->processInput(true);
@@ -373,8 +372,8 @@ int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY,
if (pMouseX && pMouseY && pButtons) {
_vm->_util->getMouseState(pMouseX, pMouseY, pButtons);
- if (*pButtons == 3)
- *pButtons = 0;
+ if (*pButtons == kMouseButtonsBoth)
+ *pButtons = kMouseButtonsNone;
}
return _vm->_util->checkKey();
diff --git a/engines/gob/game.h b/engines/gob/game.h
index ead4a56492..eb579d44a4 100644
--- a/engines/gob/game.h
+++ b/engines/gob/game.h
@@ -26,6 +26,8 @@
#ifndef GOB_GAME_H
#define GOB_GAME_H
+#include "gob/util.h"
+
namespace Gob {
class Script;
@@ -103,7 +105,7 @@ public:
char _totToLoad[20];
int32 _startTimeKey;
- int16 _mouseButtons;
+ MouseButtons _mouseButtons;
bool _noScroll;
bool _preventScroll;
@@ -122,7 +124,7 @@ public:
void evaluateScroll(int16 x, int16 y);
int16 checkKeys(int16 *pMousex = 0, int16 *pMouseY = 0,
- int16 *pButtons = 0, char handleMouse = 0);
+ MouseButtons *pButtons = 0, char handleMouse = 0);
void start(void);
virtual void totSub(int8 flags, const char *newTotFile);
diff --git a/engines/gob/game_fascin.cpp b/engines/gob/game_fascin.cpp
index 38ad03f0f8..1387bf1de1 100644
--- a/engines/gob/game_fascin.cpp
+++ b/engines/gob/game_fascin.cpp
@@ -100,7 +100,7 @@ int16 Game_Fascination::checkCollisions(byte handleMouse, int16 deltaTime, int16
key = checkKeys(&_vm->_global->_inter_mouseX,
&_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
- if ((handleMouse == 0) && (_mouseButtons != 0)) {
+ if ((handleMouse == 0) && (_mouseButtons != kMouseButtonsNone)) {
_vm->_util->waitMouseRelease(0);
key = 3;
}
@@ -125,7 +125,7 @@ int16 Game_Fascination::checkCollisions(byte handleMouse, int16 deltaTime, int16
}
if (handleMouse != 0) {
- if (_mouseButtons != 0) {
+ if (_mouseButtons != kMouseButtonsNone) {
if (deltaTime > 0) {
_vm->_draw->animateCursor(2);
_vm->_util->delay(deltaTime);
@@ -142,7 +142,7 @@ int16 Game_Fascination::checkCollisions(byte handleMouse, int16 deltaTime, int16
if ((key != 0) || ((pResId != 0) && (*pResId != 0))) {
if ((handleMouse & 1) &&
- ((deltaTime <= 0) || (_mouseButtons == 0)))
+ ((deltaTime <= 0) || (_mouseButtons == kMouseButtonsNone)))
_vm->_draw->blitCursor();
if ((_lastCollKey != 0) && (key != _lastCollKey))
@@ -180,7 +180,7 @@ int16 Game_Fascination::checkCollisions(byte handleMouse, int16 deltaTime, int16
}
}
- if ((deltaTime < 0) && (key == 0) && (_mouseButtons == 0)) {
+ if ((deltaTime < 0) && (key == 0) && (_mouseButtons == kMouseButtonsNone)) {
uint32 curtime = _vm->_util->getTimeKey();
if ((curtime + deltaTime) > timeKey) {
if (pResId != 0)
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index 87dc78e3b1..cf1641928c 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -317,7 +317,7 @@ int16 Game_v1::checkCollisions(byte handleMouse, int16 deltaTime,
key = checkKeys(&_vm->_global->_inter_mouseX,
&_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
- if ((handleMouse == 0) && (_mouseButtons != 0)) {
+ if ((handleMouse == 0) && (_mouseButtons != kMouseButtonsNone)) {
_vm->_util->waitMouseRelease(0);
key = 3;
}
@@ -347,7 +347,7 @@ int16 Game_v1::checkCollisions(byte handleMouse, int16 deltaTime,
}
if (handleMouse != 0) {
- if (_mouseButtons != 0) {
+ if (_mouseButtons != kMouseButtonsNone) {
oldIndex = 0;
_vm->_draw->animateCursor(2);
@@ -368,7 +368,7 @@ int16 Game_v1::checkCollisions(byte handleMouse, int16 deltaTime,
if ((key != 0) || ((pResId != 0) && (*pResId != 0))) {
if ((handleMouse == 1) &&
- ((deltaTime <= 0) || (_mouseButtons == 0)))
+ ((deltaTime <= 0) || (_mouseButtons == kMouseButtonsNone)))
_vm->_draw->blitCursor();
if ((_lastCollKey != 0) &&
@@ -775,7 +775,7 @@ void Game_v1::collisionsBlock(void) {
_activeCollIndex = i;
WRITE_VAR(2, _vm->_global->_inter_mouseX);
WRITE_VAR(3, _vm->_global->_inter_mouseY);
- WRITE_VAR(4, _mouseButtons);
+ WRITE_VAR(4, (uint32) _mouseButtons);
WRITE_VAR(16, array[(uint16) _activeCollResId & ~0x8000]);
if (collPtr->funcLeave != 0) {
@@ -870,7 +870,7 @@ void Game_v1::collisionsBlock(void) {
WRITE_VAR(2, _vm->_global->_inter_mouseX);
WRITE_VAR(3, _vm->_global->_inter_mouseY);
- WRITE_VAR(4, _mouseButtons);
+ WRITE_VAR(4, (uint32) _mouseButtons);
WRITE_VAR(16, array[(uint16) _activeCollResId & ~0x8000]);
if (_collisionAreas[_activeCollIndex].funcEnter != 0) {
@@ -965,7 +965,7 @@ void Game_v1::collisionsBlock(void) {
WRITE_VAR(2, _vm->_global->_inter_mouseX);
WRITE_VAR(3, _vm->_global->_inter_mouseY);
- WRITE_VAR(4, _mouseButtons);
+ WRITE_VAR(4, (uint32) _mouseButtons);
if (VAR(16) == 0)
WRITE_VAR(16, array[(uint16) _activeCollResId & ~0x8000]);
@@ -1400,7 +1400,7 @@ int16 Game_v1::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
if (((ptr->flags & 0xF) != 1) && ((ptr->flags & 0xF) != 2))
continue;
- if ((((ptr->flags & 0xF0) >> 4) != (_mouseButtons - 1))
+ if ((((ptr->flags & 0xF0) >> 4) != (((int32) _mouseButtons) - 1))
&& (((ptr->flags & 0xF0) >> 4) != 2))
continue;
@@ -1417,7 +1417,7 @@ int16 Game_v1::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
}
}
- if ((_mouseButtons != 1) && (all == 0))
+ if ((_mouseButtons != kMouseButtonsLeft) && (all == 0))
return 0x11B;
return 0;
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index 08184e73d0..e910b5278e 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -338,7 +338,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
key = checkKeys(&_vm->_global->_inter_mouseX,
&_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
- if ((handleMouse == 0) && (_mouseButtons != 0)) {
+ if ((handleMouse == 0) && (_mouseButtons != kMouseButtonsNone)) {
_vm->_util->waitMouseRelease(0);
key = 3;
}
@@ -363,7 +363,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
}
if (handleMouse != 0) {
- if (_mouseButtons != 0) {
+ if (_mouseButtons != kMouseButtonsNone) {
if (deltaTime > 0) {
_vm->_draw->animateCursor(2);
_vm->_util->delay(deltaTime);
@@ -380,7 +380,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
if ((key != 0) || ((pResId != 0) && (*pResId != 0))) {
if ((handleMouse & 1) &&
- ((deltaTime <= 0) || (_mouseButtons == 0)))
+ ((deltaTime <= 0) || (_mouseButtons == kMouseButtonsNone)))
_vm->_draw->blitCursor();
if ((_lastCollKey != 0) && (key != _lastCollKey))
@@ -418,7 +418,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
}
}
- if ((deltaTime < 0) && (key == 0) && (_mouseButtons == 0)) {
+ if ((deltaTime < 0) && (key == 0) && (_mouseButtons == kMouseButtonsNone)) {
uint32 curtime = _vm->_util->getTimeKey();
if ((curtime + deltaTime) > timeKey) {
if (pResId != 0)
@@ -1103,7 +1103,7 @@ int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos,
if (*collResId == 0)
return 0;
- if (_mouseButtons != 0) {
+ if (_mouseButtons != kMouseButtonsNone) {
for (collArea = _collisionAreas, i = 0;
collArea->left != 0xFFFF; collArea++, i++) {
if ((collArea->flags & 0xF00))
@@ -1535,7 +1535,7 @@ int16 Game_v2::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
if ((ptr->flags & 0xF) < 1)
continue;
- if ((((ptr->flags & 0xF0) >> 4) != (_mouseButtons - 1)) &&
+ if ((((ptr->flags & 0xF0) >> 4) != (((int32) _mouseButtons) - 1)) &&
(((ptr->flags & 0xF0) >> 4) != 2))
continue;
@@ -1554,7 +1554,7 @@ int16 Game_v2::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
}
}
- if ((_mouseButtons != 1) && (all == 0))
+ if ((_mouseButtons != kMouseButtonsLeft) && (all == 0))
return 0x11B;
return 0;
diff --git a/engines/gob/game_v6.cpp b/engines/gob/game_v6.cpp
index 8d40d41acc..dade2adddf 100644
--- a/engines/gob/game_v6.cpp
+++ b/engines/gob/game_v6.cpp
@@ -261,7 +261,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
key = checkKeys(&_vm->_global->_inter_mouseX,
&_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
- if ((handleMouse == 0) && (_mouseButtons != 0)) {
+ if ((handleMouse == 0) && (_mouseButtons != kMouseButtonsNone)) {
_vm->_util->waitMouseRelease(0);
key = 3;
}
@@ -289,7 +289,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
}
if (handleMouse != 0) {
- if (_mouseButtons != 0) {
+ if (_mouseButtons != kMouseButtonsNone) {
if (deltaTime > 0) {
_vm->_draw->animateCursor(2);
@@ -308,7 +308,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
if ((key != 0) || ((pResId != 0) && (*pResId != 0))) {
if ((handleMouse & 1) &&
- ((deltaTime <= 0) || (_mouseButtons == 0)))
+ ((deltaTime <= 0) || (_mouseButtons == kMouseButtonsNone)))
_vm->_draw->blitCursor();
if (key != _lastCollKey)
@@ -331,7 +331,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
collSubReenter();
}
- if ((deltaTime == -2) && (key == 0) && (_mouseButtons == 0)) {
+ if ((deltaTime == -2) && (key == 0) && (_mouseButtons == kMouseButtonsNone)) {
if (pResId != 0)
*pResId = 0;
@@ -343,7 +343,7 @@ int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
} else if (handleMouse != 0)
_vm->_draw->animateCursor(-1);
- if ((deltaTime < 0) && (key == 0) && (_mouseButtons == 0)) {
+ if ((deltaTime < 0) && (key == 0) && (_mouseButtons == kMouseButtonsNone)) {
uint32 curtime = _vm->_util->getTimeKey();
if ((curtime + deltaTime) > timeKey) {
if (pResId != 0)
@@ -1069,7 +1069,7 @@ int16 Game_v6::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
if ((ptr->flags & 0xF) < 1)
continue;
- if ((((ptr->flags & 0x70) >> 4) != (_mouseButtons - 1)) &&
+ if ((((ptr->flags & 0x70) >> 4) != (((int32) _mouseButtons) - 1)) &&
(((ptr->flags & 0x70) >> 4) != 2))
continue;
@@ -1088,7 +1088,7 @@ int16 Game_v6::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) {
}
}
- if ((_mouseButtons != 1) && (all == 0))
+ if ((_mouseButtons != kMouseButtonsLeft) && (all == 0))
return 0x11B;
return 0;
diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp
index 8be07034c6..3cbdaa3584 100644
--- a/engines/gob/inter.cpp
+++ b/engines/gob/inter.cpp
@@ -180,7 +180,7 @@ void Inter::storeMouse() {
WRITE_VAR(2, x);
WRITE_VAR(3, y);
- WRITE_VAR(4, _vm->_game->_mouseButtons);
+ WRITE_VAR(4, (uint32) _vm->_game->_mouseButtons);
}
void Inter::storeKey(int16 key) {
diff --git a/engines/gob/inter_bargon.cpp b/engines/gob/inter_bargon.cpp
index 12079600c0..1cffe4ca2d 100644
--- a/engines/gob/inter_bargon.cpp
+++ b/engines/gob/inter_bargon.cpp
@@ -89,7 +89,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams &params) {
int i;
int16 mouseX;
int16 mouseY;
- int16 buttons;
+ MouseButtons buttons;
SurfaceDescPtr surface;
SoundDesc samples[4];
int16 comp[5] = { 0, 1, 2, 3, -1 };
@@ -137,7 +137,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams &params) {
void Inter_Bargon::oBargon_intro3(OpGobParams &params) {
int16 mouseX;
int16 mouseY;
- int16 buttons;
+ MouseButtons buttons;
Video::Color *palBak;
SoundDesc samples[2];
int16 comp[3] = { 0, 1, -1 };
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index b0e7691c07..6c38dcb5a9 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -38,14 +38,14 @@
namespace Gob {
Util::Util(GobEngine *vm) : _vm(vm) {
- _mouseButtons = 0;
- _keyBufferHead = 0;
- _keyBufferTail = 0;
- _fastMode = 0;
- _frameRate = 12;
- _frameWaitTime = 0;
+ _mouseButtons = kMouseButtonsNone,
+ _keyBufferHead = 0;
+ _keyBufferTail = 0;
+ _fastMode = 0;
+ _frameRate = 12;
+ _frameWaitTime = 0;
_startFrameTime = 0;
- _frameWaitLag = 0;
+ _frameWaitLag = 0;
}
uint32 Util::getTimeKey(void) {
@@ -85,7 +85,7 @@ void Util::longDelay(uint16 msecs) {
}
void Util::initInput(void) {
- _mouseButtons = 0;
+ _mouseButtons = kMouseButtonsNone;
_keyBufferHead = _keyBufferTail = 0;
}
@@ -103,16 +103,16 @@ void Util::processInput(bool scroll) {
y = event.mouse.y;
break;
case Common::EVENT_LBUTTONDOWN:
- _mouseButtons |= 1;
+ _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) | ((uint32) kMouseButtonsLeft));
break;
case Common::EVENT_RBUTTONDOWN:
- _mouseButtons |= 2;
+ _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) | ((uint32) kMouseButtonsRight));
break;
case Common::EVENT_LBUTTONUP:
- _mouseButtons &= ~1;
+ _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) & ~((uint32) kMouseButtonsLeft));
break;
case Common::EVENT_RBUTTONUP:
- _mouseButtons &= ~2;
+ _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) & ~((uint32) kMouseButtonsRight));
break;
case Common::EVENT_KEYDOWN:
if (event.kbd.flags == Common::KBD_CTRL) {
@@ -246,7 +246,7 @@ bool Util::checkKey(int16 &key) {
return true;
}
-void Util::getMouseState(int16 *pX, int16 *pY, int16 *pButtons) {
+void Util::getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons) {
Common::Point mouse = g_system->getEventManager()->getMousePos();
*pX = mouse.x + _vm->_video->_scrollOffsetX - _vm->_video->_screenDeltaX;
*pY = mouse.y + _vm->_video->_scrollOffsetY - _vm->_video->_screenDeltaY;
@@ -264,15 +264,15 @@ void Util::setMousePos(int16 x, int16 y) {
void Util::waitMouseUp(void) {
do {
processInput();
- if (_mouseButtons != 0)
+ if (_mouseButtons != kMouseButtonsNone)
delay(10);
- } while (_mouseButtons != 0);
+ } while (_mouseButtons != kMouseButtonsNone);
}
void Util::waitMouseDown(void) {
int16 x;
int16 y;
- int16 buttons;
+ MouseButtons buttons;
do {
processInput();
@@ -283,7 +283,7 @@ void Util::waitMouseDown(void) {
}
void Util::waitMouseRelease(char drawMouse) {
- int16 buttons;
+ MouseButtons buttons;
int16 mouseX;
int16 mouseY;
@@ -300,8 +300,8 @@ void Util::forceMouseUp(bool onlyWhenSynced) {
if (onlyWhenSynced && (_vm->_game->_mouseButtons != _mouseButtons))
return;
- _vm->_game->_mouseButtons = 0;
- _mouseButtons = 0;
+ _vm->_game->_mouseButtons = kMouseButtonsNone;
+ _mouseButtons = kMouseButtonsNone;
}
void Util::clearPalette(void) {
diff --git a/engines/gob/util.h b/engines/gob/util.h
index 0a76ee40ab..2b6ea7fdc3 100644
--- a/engines/gob/util.h
+++ b/engines/gob/util.h
@@ -34,6 +34,14 @@ namespace Gob {
#define KEYBUFSIZE 16
+enum MouseButtons {
+ kMouseButtonsNone = 0,
+ kMouseButtonsLeft = 1,
+ kMouseButtonsRight = 2,
+ kMouseButtonsBoth = 3,
+ kMouseButtonsAny = 4
+};
+
class Util {
public:
struct ListNode;
@@ -66,7 +74,7 @@ public:
int16 checkKey(void);
bool checkKey(int16 &key);
- void getMouseState(int16 *pX, int16 *pY, int16 *pButtons);
+ void getMouseState(int16 *pX, int16 *pY, MouseButtons *pButtons);
void setMousePos(int16 x, int16 y);
void waitMouseUp(void);
void waitMouseDown(void);
@@ -95,7 +103,8 @@ public:
Util(GobEngine *vm);
protected:
- int16 _mouseButtons;
+ MouseButtons _mouseButtons;
+
Common::KeyState _keyBuffer[KEYBUFSIZE];
int16 _keyBufferHead;
int16 _keyBufferTail;