Moving the "Collision" stuff to Hotspots in hotspots.cpp/.h
svn-id: r42123
This commit is contained in:
parent
835dea71ce
commit
18550c1314
15 changed files with 1957 additions and 4111 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "gob/util.h"
|
||||
#include "gob/game.h"
|
||||
#include "gob/resources.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/scenery.h"
|
||||
#include "gob/inter.h"
|
||||
#include "gob/sound/sound.h"
|
||||
|
@ -58,7 +59,6 @@ void Draw_v1::blitCursor() {
|
|||
}
|
||||
|
||||
void Draw_v1::animateCursor(int16 cursor) {
|
||||
Game::Collision *ptr;
|
||||
int16 cursorIndex = cursor;
|
||||
int16 newX = 0, newY = 0;
|
||||
uint16 hotspotX = 0, hotspotY = 0;
|
||||
|
@ -66,29 +66,10 @@ void Draw_v1::animateCursor(int16 cursor) {
|
|||
_showCursor = 2;
|
||||
|
||||
if (cursorIndex == -1) {
|
||||
cursorIndex = 0;
|
||||
for (ptr = _vm->_game->_collisionAreas; ptr->left != 0xFFFF; ptr++) {
|
||||
if (ptr->flags & 0xFFF0)
|
||||
continue;
|
||||
cursorIndex =
|
||||
_vm->_game->_hotspots->findCursor(_vm->_global->_inter_mouseX,
|
||||
_vm->_global->_inter_mouseY);
|
||||
|
||||
if (ptr->left > _vm->_global->_inter_mouseX)
|
||||
continue;
|
||||
|
||||
if (ptr->right < _vm->_global->_inter_mouseX)
|
||||
continue;
|
||||
|
||||
if (ptr->top > _vm->_global->_inter_mouseY)
|
||||
continue;
|
||||
|
||||
if (ptr->bottom < _vm->_global->_inter_mouseY)
|
||||
continue;
|
||||
|
||||
if ((ptr->flags & 0xF) < 3)
|
||||
cursorIndex = 1;
|
||||
else
|
||||
cursorIndex = 3;
|
||||
break;
|
||||
}
|
||||
if (_cursorAnimLow[cursorIndex] == -1)
|
||||
cursorIndex = 1;
|
||||
}
|
||||
|
@ -317,7 +298,7 @@ void Draw_v1::printTotText(int16 id) {
|
|||
_renderFlags = savedFlags;
|
||||
|
||||
if (_renderFlags & RENDERFLAG_COLLISIONS)
|
||||
_vm->_game->checkCollisions(0, 0, 0, 0);
|
||||
_vm->_game->_hotspots->check(0, 0);
|
||||
|
||||
if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->_pCaptureCounter != 0) {
|
||||
(*_vm->_scenery->_pCaptureCounter)--;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "gob/game.h"
|
||||
#include "gob/script.h"
|
||||
#include "gob/resources.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/scenery.h"
|
||||
#include "gob/inter.h"
|
||||
#include "gob/video.h"
|
||||
|
@ -82,7 +83,6 @@ void Draw_v2::blitCursor() {
|
|||
}
|
||||
|
||||
void Draw_v2::animateCursor(int16 cursor) {
|
||||
Game::Collision *ptr;
|
||||
int16 cursorIndex = cursor;
|
||||
int16 newX = 0, newY = 0;
|
||||
uint16 hotspotX = 0, hotspotY = 0;
|
||||
|
@ -91,32 +91,10 @@ void Draw_v2::animateCursor(int16 cursor) {
|
|||
|
||||
// .-- _draw_animateCursorSUB1 ---
|
||||
if (cursorIndex == -1) {
|
||||
cursorIndex = 0;
|
||||
for (ptr = _vm->_game->_collisionAreas; ptr->left != 0xFFFF; ptr++) {
|
||||
if ((ptr->flags & 0xF00) || (ptr->id & 0x4000))
|
||||
continue;
|
||||
cursorIndex =
|
||||
_vm->_game->_hotspots->findCursor(_vm->_global->_inter_mouseX,
|
||||
_vm->_global->_inter_mouseY);
|
||||
|
||||
if (ptr->left > _vm->_global->_inter_mouseX)
|
||||
continue;
|
||||
|
||||
if (ptr->right < _vm->_global->_inter_mouseX)
|
||||
continue;
|
||||
|
||||
if (ptr->top > _vm->_global->_inter_mouseY)
|
||||
continue;
|
||||
|
||||
if (ptr->bottom < _vm->_global->_inter_mouseY)
|
||||
continue;
|
||||
|
||||
if ((ptr->flags & 0xF000) == 0) {
|
||||
if ((ptr->flags & 0xF) >= 3) {
|
||||
cursorIndex = 3;
|
||||
break;
|
||||
} else if (((ptr->flags & 0xF0) != 0x10) && (cursorIndex == 0))
|
||||
cursorIndex = 1;
|
||||
} else if (cursorIndex == 0)
|
||||
cursorIndex = (ptr->flags >> 12) & 0xF;
|
||||
}
|
||||
if (_cursorAnimLow[cursorIndex] == -1)
|
||||
cursorIndex = 1;
|
||||
}
|
||||
|
@ -407,8 +385,8 @@ void Draw_v2::printTotText(int16 id) {
|
|||
adjustCoords(2, &rectRight, &rectBottom);
|
||||
|
||||
if (colId != -1)
|
||||
_vm->_game->addNewCollision(colId + 0xD000, rectLeft, rectTop,
|
||||
rectRight, rectBottom, 2, 0, 0, 0);
|
||||
_vm->_game->_hotspots->add(colId + 0xD000, rectLeft, rectTop,
|
||||
rectRight, rectBottom, (uint16) Hotspots::kTypeClick, 0, 0, 0, 0);
|
||||
|
||||
if (_needAdjust != 2)
|
||||
printTextCentered(colCmd & 0x0F, rectLeft + 4, rectTop + 4,
|
||||
|
@ -501,8 +479,8 @@ void Draw_v2::printTotText(int16 id) {
|
|||
rectBottom = destY + (int16)READ_LE_UINT16(ptr + 6);
|
||||
adjustCoords(2, &rectLeft, &rectTop);
|
||||
adjustCoords(2, &rectRight, &rectBottom);
|
||||
_vm->_game->addNewCollision(colId + 0x0D000, rectLeft, rectTop,
|
||||
rectRight, rectBottom, 2, 0, 0, 0);
|
||||
_vm->_game->_hotspots->add(colId + 0x0D000, rectLeft, rectTop,
|
||||
rectRight, rectBottom, (uint16) Hotspots::kTypeClick, 0, 0, 0, 0);
|
||||
ptr += 8;
|
||||
}
|
||||
break;
|
||||
|
@ -604,7 +582,7 @@ void Draw_v2::printTotText(int16 id) {
|
|||
if (!(_renderFlags & RENDERFLAG_COLLISIONS))
|
||||
return;
|
||||
|
||||
_vm->_game->checkCollisions(0, 0, 0, 0);
|
||||
_vm->_game->_hotspots->check(0, 0);
|
||||
|
||||
if (*_vm->_scenery->_pCaptureCounter != 0) {
|
||||
(*_vm->_scenery->_pCaptureCounter)--;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "gob/variables.h"
|
||||
#include "gob/script.h"
|
||||
#include "gob/resources.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/inter.h"
|
||||
#include "gob/draw.h"
|
||||
#include "gob/mult.h"
|
||||
|
@ -169,30 +170,14 @@ bool Environments::has(Resources *resources, uint8 startEnv, int16 except) const
|
|||
|
||||
|
||||
Game::Game(GobEngine *vm) : _vm(vm) {
|
||||
_collisionAreas = 0;
|
||||
_shouldPushColls = 0;
|
||||
|
||||
_captureCount = 0;
|
||||
|
||||
_collStackSize = 0;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
_collStack[i] = 0;
|
||||
_collStackElemSizes[i] = 0;
|
||||
}
|
||||
|
||||
_curTotFile[0] = 0;
|
||||
_totToLoad[0] = 0;
|
||||
|
||||
_startTimeKey = 0;
|
||||
_mouseButtons = kMouseButtonsNone;
|
||||
|
||||
_lastCollKey = 0;
|
||||
_lastCollAreaIndex = 0;
|
||||
_lastCollId = 0;
|
||||
|
||||
_activeCollResId = 0;
|
||||
_activeCollIndex = 0;
|
||||
_handleMouse = 0;
|
||||
_forceHandleMouse = 0;
|
||||
_menuLevel = 0;
|
||||
|
@ -203,7 +188,6 @@ Game::Game(GobEngine *vm) : _vm(vm) {
|
|||
_noCd = false;
|
||||
|
||||
_tempStr[0] = 0;
|
||||
_collStr[0] = 0;
|
||||
|
||||
_numEnvironments = 0;
|
||||
_curEnvironment = 0;
|
||||
|
@ -211,19 +195,14 @@ Game::Game(GobEngine *vm) : _vm(vm) {
|
|||
_environments = new Environments(_vm);
|
||||
_script = new Script(_vm);
|
||||
_resources = new Resources(_vm);
|
||||
_hotspots = new Hotspots(_vm);
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
delete _environments;
|
||||
delete _script;
|
||||
delete _resources;
|
||||
}
|
||||
|
||||
void Game::freeCollision(int16 id) {
|
||||
for (int i = 0; i < 250; i++) {
|
||||
if (_collisionAreas[i].id == id)
|
||||
_collisionAreas[i].left = 0xFFFF;
|
||||
}
|
||||
delete _hotspots;
|
||||
}
|
||||
|
||||
void Game::capturePush(int16 left, int16 top, int16 width, int16 height) {
|
||||
|
@ -379,21 +358,10 @@ int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY,
|
|||
return _vm->_util->checkKey();
|
||||
}
|
||||
|
||||
int16 Game::adjustKey(int16 key) {
|
||||
if (key <= 0x60 || key >= 0x7B)
|
||||
return key;
|
||||
|
||||
return key - 0x20;
|
||||
}
|
||||
|
||||
void Game::start(void) {
|
||||
_collisionAreas = new Collision[250];
|
||||
memset(_collisionAreas, 0, 250 * sizeof(Collision));
|
||||
|
||||
prepareStart();
|
||||
playTot(-2);
|
||||
|
||||
delete[] _collisionAreas;
|
||||
_vm->_draw->closeScreen();
|
||||
|
||||
for (int i = 0; i < SPRITES_COUNT; i++)
|
||||
|
@ -430,7 +398,7 @@ void Game::totSub(int8 flags, const char *newTotFile) {
|
|||
return;
|
||||
}
|
||||
|
||||
pushCollisions(0);
|
||||
_hotspots->push(0, true);
|
||||
|
||||
if (flags & 2)
|
||||
playTot(-1);
|
||||
|
@ -440,7 +408,7 @@ void Game::totSub(int8 flags, const char *newTotFile) {
|
|||
if (_vm->_inter->_terminate != 2)
|
||||
_vm->_inter->_terminate = 0;
|
||||
|
||||
popCollisions();
|
||||
_hotspots->pop();
|
||||
|
||||
if ((flags & 1) && _vm->_inter->_variables) {
|
||||
_vm->_inter->delocateVars();
|
||||
|
@ -488,13 +456,13 @@ void Game::switchTotSub(int16 index, int16 skipPlay) {
|
|||
return;
|
||||
}
|
||||
|
||||
pushCollisions(0);
|
||||
_hotspots->push(0, true);
|
||||
playTot(skipPlay);
|
||||
|
||||
if (_vm->_inter->_terminate != 2)
|
||||
_vm->_inter->_terminate = 0;
|
||||
|
||||
popCollisions();
|
||||
_hotspots->pop();
|
||||
|
||||
clearUnusedEnvironment();
|
||||
|
||||
|
@ -503,87 +471,6 @@ void Game::switchTotSub(int16 index, int16 skipPlay) {
|
|||
_environments->get(_curEnvironment);
|
||||
}
|
||||
|
||||
void Game::setCollisions(byte arg_0) {
|
||||
uint16 left;
|
||||
uint16 top;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
Collision *collArea;
|
||||
|
||||
for (collArea = _collisionAreas; collArea->left != 0xFFFF; collArea++) {
|
||||
if (((collArea->id & 0xC000) != 0x8000) || (collArea->funcSub == 0))
|
||||
continue;
|
||||
|
||||
_script->call(collArea->funcSub);
|
||||
|
||||
left = _script->readValExpr();
|
||||
top = _script->readValExpr();
|
||||
width = _script->readValExpr();
|
||||
height = _script->readValExpr();
|
||||
if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) &&
|
||||
(left != 0xFFFF)) {
|
||||
left += _vm->_draw->_backDeltaX;
|
||||
top += _vm->_draw->_backDeltaY;
|
||||
}
|
||||
if (_vm->_draw->_needAdjust != 2) {
|
||||
_vm->_draw->adjustCoords(0, &left, &top);
|
||||
if ((collArea->flags & 0x0F) < 3)
|
||||
_vm->_draw->adjustCoords(2, &width, &height);
|
||||
else {
|
||||
height &= 0xFFFE;
|
||||
_vm->_draw->adjustCoords(2, 0, &height);
|
||||
}
|
||||
}
|
||||
collArea->left = left;
|
||||
collArea->top = top;
|
||||
collArea->right = left + width - 1;
|
||||
collArea->bottom = top + height - 1;
|
||||
|
||||
_script->pop();
|
||||
}
|
||||
}
|
||||
|
||||
void Game::collSub(uint16 offset) {
|
||||
int16 collStackSize;
|
||||
|
||||
_script->call(offset);
|
||||
|
||||
_shouldPushColls = 1;
|
||||
collStackSize = _collStackSize;
|
||||
|
||||
_vm->_inter->funcBlock(0);
|
||||
|
||||
if (collStackSize != _collStackSize)
|
||||
popCollisions();
|
||||
|
||||
_shouldPushColls = 0;
|
||||
|
||||
_script->pop();
|
||||
|
||||
setCollisions();
|
||||
}
|
||||
|
||||
void Game::collAreaSub(int16 index, int8 enter) {
|
||||
uint16 collId;
|
||||
|
||||
collId = _collisionAreas[index].id & 0xF000;
|
||||
|
||||
if ((collId == 0xA000) || (collId == 0x9000)) {
|
||||
if (enter == 0)
|
||||
WRITE_VAR(17, _collisionAreas[index].id & 0x0FFF);
|
||||
else
|
||||
WRITE_VAR(17, -(_collisionAreas[index].id & 0x0FFF));
|
||||
}
|
||||
|
||||
if (enter != 0) {
|
||||
if (_collisionAreas[index].funcEnter != 0)
|
||||
collSub(_collisionAreas[index].funcEnter);
|
||||
} else {
|
||||
if (_collisionAreas[index].funcLeave != 0)
|
||||
collSub(_collisionAreas[index].funcLeave);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::clearUnusedEnvironment() {
|
||||
if (!_environments->has(_script)) {
|
||||
delete _script;
|
||||
|
@ -593,7 +480,6 @@ void Game::clearUnusedEnvironment() {
|
|||
delete _resources;
|
||||
_resources = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // End of namespace Gob
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace Gob {
|
|||
class Script;
|
||||
class Resources;
|
||||
class Variables;
|
||||
class Hotspots;
|
||||
|
||||
class Environments {
|
||||
public:
|
||||
|
@ -69,37 +70,9 @@ private:
|
|||
|
||||
class Game {
|
||||
public:
|
||||
|
||||
#include "common/pack-start.h" // START STRUCT PACKING
|
||||
|
||||
struct Collision {
|
||||
int16 id;
|
||||
uint16 left;
|
||||
uint16 top;
|
||||
uint16 right;
|
||||
uint16 bottom;
|
||||
int16 flags;
|
||||
int16 key;
|
||||
uint16 funcEnter;
|
||||
uint16 funcLeave;
|
||||
uint16 funcSub;
|
||||
Script *script;
|
||||
} PACKED_STRUCT;
|
||||
|
||||
struct InputDesc {
|
||||
int16 fontIndex;
|
||||
int16 backColor;
|
||||
int16 frontColor;
|
||||
byte *ptr;
|
||||
} PACKED_STRUCT;
|
||||
|
||||
#include "common/pack-end.h" // END STRUCT PACKING
|
||||
|
||||
Collision *_collisionAreas;
|
||||
Collision *_collStack[5];
|
||||
|
||||
Script *_script;
|
||||
Resources *_resources;
|
||||
Hotspots *_hotspots;
|
||||
|
||||
char _curTotFile[14];
|
||||
char _totToLoad[20];
|
||||
|
@ -113,6 +86,9 @@ public:
|
|||
|
||||
bool _noCd;
|
||||
|
||||
byte _handleMouse;
|
||||
char _forceHandleMouse;
|
||||
|
||||
Game(GobEngine *vm);
|
||||
virtual ~Game();
|
||||
|
||||
|
@ -130,54 +106,19 @@ public:
|
|||
virtual void totSub(int8 flags, const char *newTotFile);
|
||||
virtual void switchTotSub(int16 index, int16 skipPlay);
|
||||
|
||||
void freeCollision(int16 id);
|
||||
|
||||
virtual void playTot(int16 skipPlay) = 0;
|
||||
|
||||
virtual void clearCollisions(void) = 0;
|
||||
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
|
||||
uint16 right, uint16 bottom, int16 flags, int16 key,
|
||||
uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0) = 0;
|
||||
virtual void collisionsBlock(void) = 0;
|
||||
virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
|
||||
InputDesc *inpDesc, int16 *collResId,
|
||||
int16 *collIndex, bool mono = true) = 0;
|
||||
virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
|
||||
int16 backColor, int16 frontColor, char *str, int16 fontIndex,
|
||||
char inpType, int16 *pTotTime, int16 *collResId,
|
||||
int16 *collIndex, bool mono = true) = 0;
|
||||
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
|
||||
int16 *pResId, int16 *pResIndex) = 0;
|
||||
|
||||
virtual void prepareStart(void) = 0;
|
||||
|
||||
virtual void pushCollisions(char all) = 0;
|
||||
virtual void popCollisions(void) = 0;
|
||||
|
||||
protected:
|
||||
int16 _lastCollKey;
|
||||
int16 _lastCollAreaIndex;
|
||||
int16 _lastCollId;
|
||||
|
||||
int16 _activeCollResId;
|
||||
int16 _activeCollIndex;
|
||||
byte _handleMouse;
|
||||
char _forceHandleMouse;
|
||||
uint32 _menuLevel;
|
||||
|
||||
char _tempStr[256];
|
||||
|
||||
int16 _collStackSize;
|
||||
int16 _collStackElemSizes[5];
|
||||
|
||||
char _shouldPushColls;
|
||||
|
||||
// Capture
|
||||
Common::Rect _captureStack[20];
|
||||
int16 _captureCount;
|
||||
|
||||
char _collStr[256];
|
||||
|
||||
// For totSub()
|
||||
int8 _curEnvironment;
|
||||
int8 _numEnvironments;
|
||||
|
@ -185,125 +126,41 @@ protected:
|
|||
|
||||
GobEngine *_vm;
|
||||
|
||||
virtual int16 adjustKey(int16 key);
|
||||
|
||||
void collAreaSub(int16 index, int8 enter);
|
||||
|
||||
virtual void setCollisions(byte arg_0 = 1);
|
||||
virtual void collSub(uint16 offset);
|
||||
|
||||
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex) = 0;
|
||||
|
||||
void clearUnusedEnvironment();
|
||||
};
|
||||
|
||||
class Game_v1 : public Game {
|
||||
public:
|
||||
virtual void playTot(int16 skipPlay);
|
||||
|
||||
virtual void clearCollisions(void);
|
||||
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
|
||||
uint16 right, uint16 bottom, int16 flags, int16 key,
|
||||
uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0);
|
||||
virtual void collisionsBlock(void);
|
||||
virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
|
||||
InputDesc *inpDesc, int16 *collResId,
|
||||
int16 *collIndex, bool mono = true);
|
||||
virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
|
||||
int16 backColor, int16 frontColor, char *str, int16 fontIndex,
|
||||
char inpType, int16 *pTotTime, int16 *collResId,
|
||||
int16 *collIndex, bool mono = true);
|
||||
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
|
||||
int16 *pResId, int16 *pResIndex);
|
||||
|
||||
virtual void prepareStart(void);
|
||||
|
||||
virtual void pushCollisions(char all);
|
||||
virtual void popCollisions(void);
|
||||
|
||||
Game_v1(GobEngine *vm);
|
||||
virtual ~Game_v1() {}
|
||||
|
||||
protected:
|
||||
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
|
||||
virtual void playTot(int16 skipPlay);
|
||||
|
||||
virtual void prepareStart(void);
|
||||
};
|
||||
|
||||
class Game_v2 : public Game_v1 {
|
||||
public:
|
||||
virtual void playTot(int16 skipPlay);
|
||||
|
||||
virtual void clearCollisions(void);
|
||||
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
|
||||
uint16 right, uint16 bottom, int16 flags, int16 key,
|
||||
uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0);
|
||||
virtual void collisionsBlock(void);
|
||||
virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
|
||||
InputDesc *inpDesc, int16 *collResId,
|
||||
int16 *collIndex, bool mono = true);
|
||||
virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
|
||||
int16 backColor, int16 frontColor, char *str, int16 fontIndex,
|
||||
char inpType, int16 *pTotTime, int16 *collResId,
|
||||
int16 *collIndex, bool mono = true);
|
||||
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
|
||||
int16 *pResId, int16 *pResIndex);
|
||||
|
||||
virtual void prepareStart(void);
|
||||
|
||||
virtual void pushCollisions(char all);
|
||||
virtual void popCollisions(void);
|
||||
|
||||
Game_v2(GobEngine *vm);
|
||||
virtual ~Game_v2() {}
|
||||
|
||||
protected:
|
||||
struct CollLast {
|
||||
int16 key;
|
||||
int16 id;
|
||||
int16 areaIndex;
|
||||
};
|
||||
virtual void playTot(int16 skipPlay);
|
||||
|
||||
CollLast _collLasts[5];
|
||||
|
||||
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
|
||||
virtual void prepareStart(void);
|
||||
};
|
||||
|
||||
class Game_v6 : public Game_v2 {
|
||||
public:
|
||||
virtual void totSub(int8 flags, const char *newTotFile);
|
||||
|
||||
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
|
||||
uint16 right, uint16 bottom, int16 flags, int16 key,
|
||||
uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0);
|
||||
|
||||
virtual void prepareStart(void);
|
||||
|
||||
virtual void pushCollisions(char all);
|
||||
|
||||
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
|
||||
int16 *pResId, int16 *pResIndex);
|
||||
virtual void collisionsBlock(void);
|
||||
|
||||
Game_v6(GobEngine *vm);
|
||||
virtual ~Game_v6() {}
|
||||
|
||||
protected:
|
||||
uint32 _someTimeDly;
|
||||
virtual void totSub(int8 flags, const char *newTotFile);
|
||||
|
||||
virtual void setCollisions(byte arg_0 = 1);
|
||||
virtual void collSub(uint16 offset);
|
||||
|
||||
virtual int16 adjustKey(int16 key);
|
||||
|
||||
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
|
||||
|
||||
void collSubReenter();
|
||||
virtual void prepareStart(void);
|
||||
};
|
||||
|
||||
class Game_Fascination : public Game_v2 {
|
||||
public:
|
||||
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
|
||||
int16 *pResId, int16 *pResIndex);
|
||||
|
||||
Game_Fascination(GobEngine *vm);
|
||||
virtual ~Game_Fascination() {}
|
||||
};
|
||||
|
|
|
@ -45,159 +45,4 @@ namespace Gob {
|
|||
Game_Fascination::Game_Fascination(GobEngine *vm) : Game_v2(vm) {
|
||||
}
|
||||
|
||||
int16 Game_Fascination::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
|
||||
int16 *pResIndex) {
|
||||
int16 resIndex;
|
||||
int16 key;
|
||||
int16 oldIndex;
|
||||
int16 oldId;
|
||||
int16 newkey;
|
||||
uint32 timeKey;
|
||||
|
||||
_scrollHandleMouse = handleMouse != 0;
|
||||
|
||||
if (deltaTime >= -1) {
|
||||
_lastCollKey = 0;
|
||||
_lastCollAreaIndex = 0;
|
||||
_lastCollId = 0;
|
||||
}
|
||||
|
||||
if (pResId != 0)
|
||||
*pResId = 0;
|
||||
|
||||
resIndex = 0;
|
||||
|
||||
if ((_vm->_draw->_cursorIndex == -1) &&
|
||||
(handleMouse != 0) && (_lastCollKey == 0)) {
|
||||
_lastCollKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
|
||||
|
||||
if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
|
||||
collAreaSub(_lastCollAreaIndex, 1);
|
||||
}
|
||||
|
||||
if (handleMouse != 0) {
|
||||
if ((handleMouse==1) && (_vm->_draw->_renderFlags & RENDERFLAG_UNKNOWN))
|
||||
warning("checkCollisions : RENDERFLAG_UNKNOWN - Unknown behavior");
|
||||
_vm->_draw->animateCursor(-1);
|
||||
}
|
||||
|
||||
timeKey = _vm->_util->getTimeKey();
|
||||
while (1) {
|
||||
if (_vm->_inter->_terminate || _vm->shouldQuit()) {
|
||||
if (handleMouse)
|
||||
_vm->_draw->blitCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_vm->_draw->_noInvalidated) {
|
||||
if (handleMouse != 0)
|
||||
_vm->_draw->animateCursor(-1);
|
||||
else
|
||||
_vm->_draw->blitInvalidated();
|
||||
_vm->_video->waitRetrace();
|
||||
}
|
||||
|
||||
key = checkKeys(&_vm->_global->_inter_mouseX,
|
||||
&_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
|
||||
|
||||
if ((handleMouse == 0) && (_mouseButtons != kMouseButtonsNone)) {
|
||||
_vm->_util->waitMouseRelease(0);
|
||||
key = 3;
|
||||
}
|
||||
|
||||
if (key != 0) {
|
||||
|
||||
if (handleMouse & 1)
|
||||
_vm->_draw->blitCursor();
|
||||
|
||||
if (pResId != 0)
|
||||
*pResId = 0;
|
||||
|
||||
if (pResIndex != 0)
|
||||
*pResIndex = 0;
|
||||
|
||||
if (_lastCollKey != 0)
|
||||
collAreaSub(_lastCollAreaIndex, 0);
|
||||
|
||||
_lastCollKey = 0;
|
||||
if (key != 0)
|
||||
return key;
|
||||
}
|
||||
|
||||
if (handleMouse != 0) {
|
||||
if (_mouseButtons != kMouseButtonsNone) {
|
||||
if (deltaTime > 0) {
|
||||
_vm->_draw->animateCursor(2);
|
||||
_vm->_util->delay(deltaTime);
|
||||
} else if (handleMouse & 1)
|
||||
_vm->_util->waitMouseRelease(1);
|
||||
_vm->_draw->animateCursor(-1);
|
||||
|
||||
if (pResId != 0)
|
||||
*pResId = 0;
|
||||
|
||||
key = checkMousePoint(0, pResId, &resIndex);
|
||||
if (pResIndex != 0)
|
||||
*pResIndex = resIndex;
|
||||
|
||||
if ((key != 0) || ((pResId != 0) && (*pResId != 0))) {
|
||||
if ((handleMouse & 1) &&
|
||||
((deltaTime <= 0) || (_mouseButtons == kMouseButtonsNone)))
|
||||
_vm->_draw->blitCursor();
|
||||
|
||||
if ((_lastCollKey != 0) && (key != _lastCollKey))
|
||||
collAreaSub(_lastCollAreaIndex, 0);
|
||||
|
||||
_lastCollKey = 0;
|
||||
return key;
|
||||
}
|
||||
|
||||
if (handleMouse & 4)
|
||||
return 0;
|
||||
|
||||
if (_lastCollKey != 0)
|
||||
collAreaSub(_lastCollAreaIndex, 0);
|
||||
|
||||
_lastCollKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
|
||||
if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
|
||||
collAreaSub(_lastCollAreaIndex, 1);
|
||||
} else if ((_vm->_global->_inter_mouseX != _vm->_draw->_cursorX) ||
|
||||
(_vm->_global->_inter_mouseY != _vm->_draw->_cursorY)) {
|
||||
|
||||
oldIndex = _lastCollAreaIndex;
|
||||
oldId = _lastCollId;
|
||||
newkey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
|
||||
|
||||
if (newkey != _lastCollKey) {
|
||||
if ((_lastCollKey != 0) && (oldId & 0x8000))
|
||||
collAreaSub(oldIndex, 0);
|
||||
|
||||
_lastCollKey = newkey;
|
||||
|
||||
if ((newkey != 0) && (_lastCollId & 0x8000))
|
||||
collAreaSub(_lastCollAreaIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((deltaTime < 0) && (key == 0) && (_mouseButtons == kMouseButtonsNone)) {
|
||||
uint32 curtime = _vm->_util->getTimeKey();
|
||||
if ((curtime + deltaTime) > timeKey) {
|
||||
if (pResId != 0)
|
||||
*pResId = 0;
|
||||
|
||||
if (pResIndex != 0)
|
||||
*pResIndex = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (handleMouse != 0)
|
||||
_vm->_draw->animateCursor(-1);
|
||||
|
||||
_vm->_util->delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Gob
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1706
engines/gob/hotspots.cpp
Normal file
1706
engines/gob/hotspots.cpp
Normal file
File diff suppressed because it is too large
Load diff
177
engines/gob/hotspots.h
Normal file
177
engines/gob/hotspots.h
Normal file
|
@ -0,0 +1,177 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOB_HOTSPOTS_H
|
||||
#define GOB_HOTSPOTS_H
|
||||
|
||||
#include "common/stack.h"
|
||||
|
||||
#include "gob/util.h"
|
||||
|
||||
namespace Gob {
|
||||
|
||||
class Script;
|
||||
|
||||
class Hotspots {
|
||||
public:
|
||||
static const int kHotspotCount = 250;
|
||||
|
||||
enum Type {
|
||||
kTypeNone = 0,
|
||||
kTypeMove = 1,
|
||||
kTypeClick = 2,
|
||||
kTypeInput1NoLeave = 3,
|
||||
kTypeInput1Leave = 4,
|
||||
kTypeInput2NoLeave = 5,
|
||||
kTypeInput2Leave = 6,
|
||||
kTypeInput3NoLeave = 7,
|
||||
kTypeInput3Leave = 8,
|
||||
kTypeInputFloatNoLeave = 9,
|
||||
kTypeInputFloatLeave = 10
|
||||
};
|
||||
|
||||
Hotspots(GobEngine *vm);
|
||||
~Hotspots();
|
||||
|
||||
void clear();
|
||||
|
||||
/** Add a hotspot, returning the new index. */
|
||||
uint16 add(uint16 id,
|
||||
uint16 left, uint16 top, uint16 right, uint16 bottom,
|
||||
uint16 flags, uint16 key,
|
||||
uint16 funcEnter, uint16 funcLeave, uint16 funcPos);
|
||||
|
||||
void remove(uint16 id);
|
||||
void removeState(uint16 state);
|
||||
|
||||
/** Push the current hotspots onto the stack.
|
||||
*
|
||||
* @param all 0: Don't push global ones; 1: Push all; 2: Push only the ones with the correct state
|
||||
* @param force Force a push although _shouldPush is false
|
||||
*/
|
||||
void push(uint8 all, bool force = false);
|
||||
/** Pop hotspots from the stack. */
|
||||
void pop();
|
||||
|
||||
uint16 check(uint8 handleMouse, int16 delay, uint16 &id, uint16 &index);
|
||||
uint16 check(uint8 handleMouse, int16 delay);
|
||||
|
||||
void evaluate();
|
||||
|
||||
int16 findCursor(uint16 x, uint16 y) const;
|
||||
|
||||
private:
|
||||
struct Hotspot {
|
||||
uint16 id;
|
||||
uint16 left;
|
||||
uint16 top;
|
||||
uint16 right;
|
||||
uint16 bottom;
|
||||
uint16 flags;
|
||||
uint16 key;
|
||||
uint16 funcEnter;
|
||||
uint16 funcLeave;
|
||||
uint16 funcPos;
|
||||
Script *script;
|
||||
|
||||
Hotspot();
|
||||
Hotspot(uint16 i,
|
||||
uint16 l, uint16 t, uint16 r, uint16 b, uint16 f, uint16 k,
|
||||
uint16 enter, uint16 leave, uint16 pos);
|
||||
|
||||
void clear();
|
||||
|
||||
Type getType() const;
|
||||
MouseButtons getButton() const;
|
||||
uint8 getWindow() const;
|
||||
uint8 getCursor() const;
|
||||
|
||||
/** Are the specified coordinates in the hotspot? */
|
||||
bool isIn(uint16 x, uint16 y) const;
|
||||
/** Does the specified button trigger the hotspot? */
|
||||
bool buttonMatch(MouseButtons button) const;
|
||||
};
|
||||
|
||||
struct StackEntry {
|
||||
bool shouldPush;
|
||||
Hotspot *hotspots;
|
||||
uint32 size;
|
||||
uint32 key;
|
||||
uint32 id;
|
||||
uint32 index;
|
||||
};
|
||||
|
||||
struct InputDesc {
|
||||
uint16 fontIndex;
|
||||
uint16 backColor;
|
||||
uint16 frontColor;
|
||||
byte *ptr;
|
||||
};
|
||||
|
||||
GobEngine *_vm;
|
||||
|
||||
Hotspot *_hotspots;
|
||||
Common::Stack<StackEntry> _stack;
|
||||
|
||||
bool _shouldPush;
|
||||
|
||||
uint16 _currentKey;
|
||||
uint16 _currentIndex;
|
||||
uint16 _currentId;
|
||||
|
||||
/** Add a hotspot, returning the new index. */
|
||||
uint16 add(const Hotspot &hotspot);
|
||||
|
||||
/** Recalculate all hotspot parameters
|
||||
*
|
||||
* @param force Force recalculation of all hotspots, including global ones.
|
||||
*/
|
||||
void recalculate(bool force);
|
||||
|
||||
bool isValid(uint16 key, uint16 id, uint16 index) const;
|
||||
|
||||
/** Call a hotspot subroutine. */
|
||||
void call(uint16 offset);
|
||||
/** Handling hotspot enter events. */
|
||||
void enter(uint16 index);
|
||||
/** Handling hotspot leave events. */
|
||||
void leave(uint16 index);
|
||||
|
||||
/** Which hotspot is the mouse cursor currently at? */
|
||||
uint16 checkMouse(Type type, uint16 &id, uint16 &index) const;
|
||||
|
||||
void checkHotspotChanged();
|
||||
|
||||
uint16 readString(uint16 xPos, uint16 yPos, uint16 width, uint16 height,
|
||||
uint16 backColor, uint16 frontColor, char *str, uint16 fontIndex,
|
||||
Type type, int16 &duration, uint16 &id, uint16 index);
|
||||
|
||||
uint16 handleInput(int16 time, uint16 hotspotIndex, uint16 &curPos,
|
||||
InputDesc *inpDesc, uint16 &id, uint16 &index);
|
||||
};
|
||||
|
||||
} // End of namespace Gob
|
||||
|
||||
#endif // GOB_HOTSPOTS_H
|
|
@ -35,6 +35,7 @@
|
|||
#include "gob/game.h"
|
||||
#include "gob/expression.h"
|
||||
#include "gob/script.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/scenery.h"
|
||||
#include "gob/sound/sound.h"
|
||||
|
||||
|
@ -334,7 +335,7 @@ void Inter::callSub(int16 retFlag) {
|
|||
if (block == 1)
|
||||
funcBlock(retFlag);
|
||||
else if (block == 2)
|
||||
_vm->_game->collisionsBlock();
|
||||
_vm->_game->_hotspots->evaluate();
|
||||
else
|
||||
error("Unknown block type %d in Inter::callSub()", block);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "gob/expression.h"
|
||||
#include "gob/script.h"
|
||||
#include "gob/resources.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/goblin.h"
|
||||
#include "gob/inter.h"
|
||||
#include "gob/map.h"
|
||||
|
@ -1173,7 +1174,7 @@ bool Inter_v1::o1_keyFunc(OpFuncParams ¶ms) {
|
|||
case 0:
|
||||
_vm->_draw->_showCursor &= ~2;
|
||||
_vm->_util->longDelay(1);
|
||||
key = _vm->_game->checkCollisions(0, 0, 0, 0);
|
||||
key = _vm->_game->_hotspots->check(0, 0);
|
||||
storeKey(key);
|
||||
|
||||
_vm->_util->clearKeyBuf();
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "gob/expression.h"
|
||||
#include "gob/script.h"
|
||||
#include "gob/resources.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/goblin.h"
|
||||
#include "gob/map.h"
|
||||
#include "gob/mult.h"
|
||||
|
@ -1177,27 +1178,18 @@ bool Inter_v2::o2_animPalInit(OpFuncParams ¶ms) {
|
|||
}
|
||||
|
||||
bool Inter_v2::o2_addCollision(OpFuncParams ¶ms) {
|
||||
int16 id;
|
||||
int16 left, top, width, height;
|
||||
int16 flags;
|
||||
int16 key;
|
||||
int16 funcSub;
|
||||
|
||||
id = _vm->_game->_script->readValExpr();
|
||||
funcSub = _vm->_game->_script->pos();
|
||||
left = _vm->_game->_script->readValExpr();
|
||||
top = _vm->_game->_script->readValExpr();
|
||||
width = _vm->_game->_script->readValExpr();
|
||||
height = _vm->_game->_script->readValExpr();
|
||||
flags = _vm->_game->_script->readValExpr();
|
||||
key = _vm->_game->_script->readInt16();
|
||||
int16 id = _vm->_game->_script->readValExpr();
|
||||
uint16 funcPos = _vm->_game->_script->pos();
|
||||
int16 left = _vm->_game->_script->readValExpr();
|
||||
int16 top = _vm->_game->_script->readValExpr();
|
||||
uint16 width = _vm->_game->_script->readValExpr();
|
||||
uint16 height = _vm->_game->_script->readValExpr();
|
||||
uint16 flags = _vm->_game->_script->readValExpr();
|
||||
uint16 key = _vm->_game->_script->readInt16();
|
||||
|
||||
if (key == 0)
|
||||
key = ABS(id) + 41960;
|
||||
|
||||
_vm->_draw->adjustCoords(0, &left, &top);
|
||||
_vm->_draw->adjustCoords(2, &width, &height);
|
||||
|
||||
if (left < 0) {
|
||||
width += left;
|
||||
left = 0;
|
||||
|
@ -1210,33 +1202,24 @@ bool Inter_v2::o2_addCollision(OpFuncParams ¶ms) {
|
|||
|
||||
int16 index;
|
||||
if (id < 0)
|
||||
index = _vm->_game->addNewCollision(0xD000 - id, left & 0xFFFC, top & 0xFFFC,
|
||||
left + width + 3, top + height + 3, flags, key, 0, 0);
|
||||
index = _vm->_game->_hotspots->add(0xD000 - id, left & 0xFFFC, top & 0xFFFC,
|
||||
left + width + 3, top + height + 3, flags, key, 0, 0, funcPos);
|
||||
else
|
||||
index = _vm->_game->addNewCollision(0xE000 + id, left, top,
|
||||
left + width - 1, top + height - 1, flags, key, 0, 0);
|
||||
|
||||
_vm->_game->_collisionAreas[index].funcSub = funcSub;
|
||||
index = _vm->_game->_hotspots->add(0xE000 + id, left, top,
|
||||
left + width - 1, top + height - 1, flags, key, 0, 0, funcPos);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Inter_v2::o2_freeCollision(OpFuncParams ¶ms) {
|
||||
int16 id;
|
||||
int16 id = _vm->_game->_script->readValExpr();
|
||||
|
||||
id = _vm->_game->_script->readValExpr();
|
||||
if (id == -2) {
|
||||
for (int i = 0; i < 150; i++) {
|
||||
if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xD000)
|
||||
_vm->_game->_collisionAreas[i].left = 0xFFFF;
|
||||
}
|
||||
} else if (id == -1) {
|
||||
for (int i = 0; i < 150; i++) {
|
||||
if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xE000)
|
||||
_vm->_game->_collisionAreas[i].left = 0xFFFF;
|
||||
}
|
||||
} else
|
||||
_vm->_game->freeCollision(0xE000 + id);
|
||||
if (id == -2)
|
||||
_vm->_game->_hotspots->removeState(0xD000);
|
||||
else if (id == -1)
|
||||
_vm->_game->_hotspots->removeState(0xE000);
|
||||
else
|
||||
_vm->_game->_hotspots->remove(0xE000 + id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gob/expression.h"
|
||||
#include "gob/script.h"
|
||||
#include "gob/resources.h"
|
||||
#include "gob/hotspots.h"
|
||||
#include "gob/draw.h"
|
||||
#include "gob/sound/sound.h"
|
||||
#include "gob/videoplayer.h"
|
||||
|
@ -359,29 +360,23 @@ bool Inter_v6::o6_freeCollision(OpFuncParams ¶ms) {
|
|||
|
||||
switch (id + 5) {
|
||||
case 0:
|
||||
_vm->_game->pushCollisions(1);
|
||||
_vm->_game->_hotspots->push(1);
|
||||
break;
|
||||
case 1:
|
||||
_vm->_game->popCollisions();
|
||||
_vm->_game->_hotspots->pop();
|
||||
break;
|
||||
case 2:
|
||||
_vm->_game->pushCollisions(2);
|
||||
_vm->_game->_hotspots->push(2);
|
||||
break;
|
||||
case 3:
|
||||
for (int i = 0; i < 150; i++) {
|
||||
if (((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xD000) ||
|
||||
((_vm->_game->_collisionAreas[i].id & 0xF000) == 0x4000))
|
||||
_vm->_game->_collisionAreas[i].left = 0xFFFF;
|
||||
}
|
||||
_vm->_game->_hotspots->removeState(0xD000);
|
||||
_vm->_game->_hotspots->removeState(0x4000);
|
||||
break;
|
||||
case 4:
|
||||
for (int i = 0; i < 150; i++) {
|
||||
if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xE000)
|
||||
_vm->_game->_collisionAreas[i].left = 0xFFFF;
|
||||
}
|
||||
_vm->_game->_hotspots->removeState(0xE000);
|
||||
break;
|
||||
default:
|
||||
_vm->_game->freeCollision(0xE000 + id);
|
||||
_vm->_game->_hotspots->remove(0xE000 + id);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ MODULE_OBJS := \
|
|||
goblin_v2.o \
|
||||
goblin_v3.o \
|
||||
goblin_v4.o \
|
||||
videoplayer.o \
|
||||
hotspots.o \
|
||||
init.o \
|
||||
init_v1.o \
|
||||
init_v2.o \
|
||||
|
@ -56,6 +56,7 @@ MODULE_OBJS := \
|
|||
video_v1.o \
|
||||
video_v2.o \
|
||||
video_v6.o \
|
||||
videoplayer.o \
|
||||
demos/demoplayer.o \
|
||||
demos/scnplayer.o \
|
||||
demos/batplayer.o \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue