NEVERHOOD: More work on Scene1002
- Implement NavigationMouse and NavigationLists - Some renaming
This commit is contained in:
parent
78365121ea
commit
db9e45706c
8 changed files with 272 additions and 20 deletions
|
@ -790,17 +790,17 @@ uint32 AsScene1002Door::handleMessage(int messageNum, const MessageParam ¶m,
|
|||
switch (messageNum) {
|
||||
case 0x4808:
|
||||
setGlobalVar(0x8306F218, 1);
|
||||
SetSpriteCallback(&AsScene1002Door::spriteUpdate447D10);
|
||||
SetSpriteCallback(&AsScene1002Door::suOpenDoor);
|
||||
break;
|
||||
case 0x4809:
|
||||
setGlobalVar(0x8306F218, 0);
|
||||
SetSpriteCallback(&AsScene1002Door::spriteUpdate447D40);
|
||||
SetSpriteCallback(&AsScene1002Door::suCloseDoor);
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void AsScene1002Door::spriteUpdate447D10() {
|
||||
void AsScene1002Door::suOpenDoor() {
|
||||
if (_y > 49) {
|
||||
_y -= 8;
|
||||
if (_y < 49) {
|
||||
|
@ -811,7 +811,7 @@ void AsScene1002Door::spriteUpdate447D10() {
|
|||
}
|
||||
}
|
||||
|
||||
void AsScene1002Door::spriteUpdate447D40() {
|
||||
void AsScene1002Door::suCloseDoor() {
|
||||
if (_y < 239) {
|
||||
_y += 8;
|
||||
if (_y > 239) {
|
||||
|
@ -1332,6 +1332,36 @@ void Class506::sub4492C0() {
|
|||
setFileHash1();
|
||||
}
|
||||
|
||||
Class478::Class478(NeverhoodEngine *vm, Klayman *klayman)
|
||||
: AnimatedSprite(vm, 1200), _klayman(klayman) {
|
||||
|
||||
createSurface(1200, 40, 163);
|
||||
SetUpdateHandler(&Class478::update);
|
||||
SetMessageHandler(&Sprite::handleMessage);
|
||||
_surface->setVisible(false);
|
||||
}
|
||||
|
||||
void Class478::update() {
|
||||
if (_klayman->getCurrAnimFileHash() == 0x3A292504) {
|
||||
setFileHash(0xBA280522, _frameIndex, -1);
|
||||
_newHashListIndex = _klayman->getFrameIndex();
|
||||
_surface->setVisible(true);
|
||||
_x = _klayman->getX();
|
||||
_y = _klayman->getY();
|
||||
setDoDeltaX(_klayman->isDoDeltaX() ? 1 : 0);
|
||||
} else if (_klayman->getCurrAnimFileHash() == 0x122D1505) {
|
||||
setFileHash(0x1319150C, _frameIndex, -1);
|
||||
_newHashListIndex = _klayman->getFrameIndex();
|
||||
_surface->setVisible(true);
|
||||
_x = _klayman->getX();
|
||||
_y = _klayman->getY();
|
||||
setDoDeltaX(_klayman->isDoDeltaX() ? 1 : 0);
|
||||
} else {
|
||||
_surface->setVisible(false);
|
||||
}
|
||||
AnimatedSprite::update();
|
||||
}
|
||||
|
||||
Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which)
|
||||
: Scene(vm, parentModule, true), _soundResource1(vm), _soundResource2(vm), _soundResource3(vm),
|
||||
_flag1B4(false), _flag1BE(false) {
|
||||
|
@ -1373,36 +1403,39 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which)
|
|||
|
||||
_class599 = addSprite(new Class599(_vm, this));
|
||||
|
||||
// DEBUG/HACK!!!!
|
||||
which = 1; setGlobalVar(0x8306F218, 1);
|
||||
|
||||
if (which < 0) {
|
||||
if (_vm->_gameState.field2 == 0) {
|
||||
_klayman = new KmScene1002(_vm, this, _class599, _ssLadderArch, 90, 226);
|
||||
//_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
setMessageList(0x004B4270);
|
||||
// TODO
|
||||
_klayman->setRepl(64, 0);
|
||||
} else {
|
||||
_klayman = new KmScene1002(_vm, this, _class599, _ssLadderArch, 379, 435);
|
||||
//_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
setMessageList(0x004B4270);
|
||||
// TODO
|
||||
}
|
||||
} else {
|
||||
if (which == 1) {
|
||||
_klayman = new KmScene1002(_vm, this, _class599, _ssLadderArch, 650, 435);
|
||||
//_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
setMessageList(0x004B4478);
|
||||
// TODO
|
||||
_vm->_gameState.field2 = 1;
|
||||
} else if (which == 2) {
|
||||
_klayman = new KmScene1002(_vm, this, _class599, _ssLadderArch, 68, 645);
|
||||
//_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
setMessageList(0x004B4298);
|
||||
// TODO
|
||||
_vm->_gameState.field2 = 1;
|
||||
_klayman->sendMessage(0x4820, 0, this);
|
||||
} else {
|
||||
_klayman = new KmScene1002(_vm, this, _class599, _ssLadderArch, 90, 226);
|
||||
//_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
_class478 = addSprite(new Class478(_vm, _klayman));
|
||||
setMessageList(0x004B4470);
|
||||
// TODO
|
||||
//_class479 = addSprite(new Class479(_vm, this, _klayman));
|
||||
|
|
|
@ -172,8 +172,8 @@ public:
|
|||
protected:
|
||||
void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void spriteUpdate447D10();
|
||||
void spriteUpdate447D40();
|
||||
void suOpenDoor();
|
||||
void suCloseDoor();
|
||||
};
|
||||
|
||||
class Class505 : public AnimatedSprite {
|
||||
|
@ -254,6 +254,14 @@ protected:
|
|||
void sub4492C0();
|
||||
};
|
||||
|
||||
class Class478 : public AnimatedSprite {
|
||||
public:
|
||||
Class478(NeverhoodEngine *vm, Klayman *klayman);
|
||||
protected:
|
||||
Klayman *_klayman;
|
||||
void update();
|
||||
};
|
||||
|
||||
class Scene1002 : public Scene {
|
||||
public:
|
||||
Scene1002(NeverhoodEngine *vm, Module *parentModule, int which);
|
||||
|
|
|
@ -224,4 +224,159 @@ void Mouse435::updateCursor() {
|
|||
|
||||
}
|
||||
|
||||
// NavigationMouse
|
||||
|
||||
NavigationMouse::NavigationMouse(NeverhoodEngine *vm, uint32 fileHash, int type)
|
||||
: StaticSprite(vm, 2000), _mouseCursorResource(vm), _type(type), _frameNum(0) {
|
||||
|
||||
_mouseCursorResource.load(fileHash);
|
||||
_mouseCursorResource.setCursorNum(0);
|
||||
_x = _vm->getMouseX();
|
||||
_y = _vm->getMouseY();
|
||||
createSurface(2000, 32, 32);
|
||||
SetUpdateHandler(&NavigationMouse::update);
|
||||
SetMessageHandler(&NavigationMouse::handleMessage);
|
||||
_drawRect.x = 0;
|
||||
_drawRect.y = 0;
|
||||
_drawRect.width = 32;
|
||||
_drawRect.height = 32;
|
||||
_deltaRect.x = 0;
|
||||
_deltaRect.y = 0;
|
||||
_deltaRect.width = 32;
|
||||
_deltaRect.height = 32;
|
||||
processDelta();
|
||||
_needRefresh = true;
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
void NavigationMouse::update() {
|
||||
updateCursor();
|
||||
_frameNum++;
|
||||
if (_frameNum >= 6)
|
||||
_frameNum = 0;
|
||||
_needRefresh = _frameNum % 2 == 0;
|
||||
}
|
||||
|
||||
uint32 NavigationMouse::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = 0;
|
||||
switch (messageNum) {
|
||||
case 0x2064:
|
||||
_x = param.asPoint().x;
|
||||
_y = param.asPoint().y;
|
||||
switch (_type) {
|
||||
case 1:
|
||||
if (_x >= 320)
|
||||
messageResult = 1;
|
||||
else
|
||||
messageResult = 0;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
if (_x < 100)
|
||||
messageResult = 0;
|
||||
else if (_x > 540)
|
||||
messageResult = 1;
|
||||
else
|
||||
messageResult = 2;
|
||||
break;
|
||||
case 3:
|
||||
if (_x < 100)
|
||||
messageResult = 0;
|
||||
else if (_x > 540)
|
||||
messageResult = 1;
|
||||
else
|
||||
messageResult = 4;
|
||||
break;
|
||||
case 4:
|
||||
if (_x < 100)
|
||||
messageResult = 0;
|
||||
else if (_x > 540)
|
||||
messageResult = 1;
|
||||
else if (_y >= 150)
|
||||
messageResult = 2;
|
||||
else
|
||||
messageResult = 3;
|
||||
break;
|
||||
case 5:
|
||||
if (_y >= 240)
|
||||
messageResult = 4;
|
||||
else
|
||||
messageResult = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x4002:
|
||||
_x = param.asPoint().x;
|
||||
_y = param.asPoint().y;
|
||||
switch (_type) {
|
||||
case 1:
|
||||
if (_x >= 320)
|
||||
_mouseCursorResource.setCursorNum(6);
|
||||
else
|
||||
_mouseCursorResource.setCursorNum(5);
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
if (_x < 100)
|
||||
_mouseCursorResource.setCursorNum(6);
|
||||
else if (_x > 540)
|
||||
_mouseCursorResource.setCursorNum(5);
|
||||
else
|
||||
_mouseCursorResource.setCursorNum(0);
|
||||
break;
|
||||
case 3:
|
||||
if (_x < 100)
|
||||
_mouseCursorResource.setCursorNum(1);
|
||||
else if (_x > 540)
|
||||
_mouseCursorResource.setCursorNum(1);
|
||||
break;
|
||||
case 4:
|
||||
if (_x < 100)
|
||||
_mouseCursorResource.setCursorNum(6);
|
||||
else if (_x > 540)
|
||||
_mouseCursorResource.setCursorNum(5);
|
||||
else if (_y >= 150)
|
||||
_mouseCursorResource.setCursorNum(0);
|
||||
else
|
||||
_mouseCursorResource.setCursorNum(3);
|
||||
break;
|
||||
case 5:
|
||||
if (_y >= 240)
|
||||
_mouseCursorResource.setCursorNum(2);
|
||||
else
|
||||
_mouseCursorResource.setCursorNum(3);
|
||||
break;
|
||||
}
|
||||
_needRefresh = true;
|
||||
processDelta();
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void NavigationMouse::updateCursor() {
|
||||
|
||||
if (!_surface)
|
||||
return;
|
||||
|
||||
if (_doDeltaX) {
|
||||
_surface->getDrawRect().x = filterX(_x - _drawRect.width - _drawRect.x + 1);
|
||||
} else {
|
||||
_surface->getDrawRect().x = filterX(_x + _drawRect.x);
|
||||
}
|
||||
|
||||
if (_doDeltaY) {
|
||||
_surface->getDrawRect().y = filterY(_y - _drawRect.height - _drawRect.y + 1);
|
||||
} else {
|
||||
_surface->getDrawRect().y = filterY(_y + _drawRect.y);
|
||||
}
|
||||
|
||||
if (_needRefresh) {
|
||||
_needRefresh = false;
|
||||
_drawRect = _mouseCursorResource.getRect();
|
||||
_surface->drawMouseCursorResource(_mouseCursorResource, _frameNum / 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // End of namespace Neverhood
|
||||
|
|
|
@ -57,6 +57,19 @@ protected:
|
|||
void updateCursor();
|
||||
};
|
||||
|
||||
class NavigationMouse : public StaticSprite {
|
||||
public:
|
||||
NavigationMouse(NeverhoodEngine *vm, uint32 fileHash, int type);
|
||||
void load(uint32 fileHash);
|
||||
protected:
|
||||
MouseCursorResource _mouseCursorResource;
|
||||
int _frameNum;
|
||||
int _type;
|
||||
void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void updateCursor();
|
||||
};
|
||||
|
||||
} // End of namespace Neverhood
|
||||
|
||||
#endif /* NEVERHOOD_MOUSE_H */
|
||||
|
|
|
@ -286,11 +286,11 @@ void AnimatedSprite::updateAnim() {
|
|||
|
||||
if (_fileHash2 != 0) {
|
||||
if (_animResource.loadInternal(_fileHash2)) {
|
||||
_fileHash3 = _fileHash2;
|
||||
_currAnimFileHash = _fileHash2;
|
||||
} else {
|
||||
debug("TODO");
|
||||
// TODO _animResource.loadInternal(calcHash("sqDefault"));
|
||||
_fileHash3 = 0;
|
||||
_currAnimFileHash = 0;
|
||||
}
|
||||
if (_replOldColor != _replNewColor) {
|
||||
_animResource.setRepl(_replOldColor, _replNewColor);
|
||||
|
@ -318,11 +318,11 @@ void AnimatedSprite::updateAnim() {
|
|||
} else {
|
||||
if (_animStatus == 1) {
|
||||
if (_animResource.loadInternal(_fileHash1)) {
|
||||
_fileHash3 = _fileHash1;
|
||||
_currAnimFileHash = _fileHash1;
|
||||
} else {
|
||||
debug("TODO");
|
||||
// TODO _animResource.loadInternal(calcHash("sqDefault"));
|
||||
_fileHash3 = 0;
|
||||
_currAnimFileHash = 0;
|
||||
}
|
||||
if (_replOldColor != _replNewColor) {
|
||||
_animResource.setRepl(_replOldColor, _replNewColor);
|
||||
|
@ -332,11 +332,11 @@ void AnimatedSprite::updateAnim() {
|
|||
_frameIndex2 = _fileHash5 != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_fileHash5)) : _animResource.getFrameCount() - 1;
|
||||
} else {
|
||||
if (_animResource.loadInternal(_fileHash1)) {
|
||||
_fileHash3 = _fileHash1;
|
||||
_currAnimFileHash = _fileHash1;
|
||||
} else {
|
||||
debug("TODO");
|
||||
// TODO _animResource.loadInternal(calcHash("sqDefault"));
|
||||
_fileHash3 = 0;
|
||||
_currAnimFileHash = 0;
|
||||
}
|
||||
if (_replOldColor != _replNewColor) {
|
||||
_animResource.setRepl(_replOldColor, _replNewColor);
|
||||
|
@ -386,7 +386,7 @@ void AnimatedSprite::updatePosition() {
|
|||
|
||||
void AnimatedSprite::updateFrameIndex() {
|
||||
if (!_playBackwards) {
|
||||
//debug("%08X ### _frameIndex = %d; _frameIndex2 = %d", _fileHash3, _frameIndex, _frameIndex2);
|
||||
//debug("%08X ### _frameIndex = %d; _frameIndex2 = %d", _currAnimFileHash, _frameIndex, _frameIndex2);
|
||||
if (_frameIndex < _frameIndex2) {
|
||||
_frameIndex++;
|
||||
} else {
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
bool isDoDeltaX() const { return _doDeltaX; }
|
||||
bool isDoDeltaY() const { return _doDeltaY; }
|
||||
NRect& getRect() { return _rect; }
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
protected:
|
||||
void (Sprite::*_spriteUpdateCb)();
|
||||
Common::String _spriteUpdateCbName; // For debugging purposes
|
||||
|
@ -70,7 +71,6 @@ protected:
|
|||
//0000004A field4A dw ? // seems to be unused except in ctor
|
||||
//0000004C rectResource RectResource ?
|
||||
//void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void createSurface(int surfacePriority, int16 width, int16 height);
|
||||
void handleSpriteUpdate() {
|
||||
if (_spriteUpdateCb)
|
||||
|
@ -109,12 +109,14 @@ public:
|
|||
void updateDeltaXY();
|
||||
void setRepl(byte oldColor, byte newColor);
|
||||
void clearRepl();
|
||||
uint32 getCurrAnimFileHash() const { return _currAnimFileHash; }
|
||||
int16 getFrameIndex() const { return _frameIndex; }
|
||||
protected:
|
||||
typedef void (AnimatedSprite::*AnimationCb)();
|
||||
AnimResource _animResource;
|
||||
uint32 _currAnimFileHash;
|
||||
uint32 _fileHash1;
|
||||
uint32 _fileHash2;
|
||||
uint32 _fileHash3;
|
||||
int16 _frameIndex;
|
||||
int16 _frameIndex3;
|
||||
int16 _frameIndex2;
|
||||
|
|
|
@ -104,6 +104,27 @@ void StaticData::load(const char *filename) {
|
|||
_hitRectLists[id] = hitRectList;
|
||||
}
|
||||
|
||||
// Load navigation lists
|
||||
uint32 navigationListsCount = fd.readUint32LE();
|
||||
debug("navigationListsCount: %d", navigationListsCount);
|
||||
for (uint32 i = 0; i < navigationListsCount; i++) {
|
||||
NavigationList *navigationList = new NavigationList();
|
||||
uint32 id = fd.readUint32LE();
|
||||
uint32 itemCount = fd.readUint32LE();
|
||||
for (uint32 itemIndex = 0; itemIndex < itemCount; itemIndex++) {
|
||||
NavigationItem navigationItem;
|
||||
navigationItem.fileHash = fd.readUint32LE();
|
||||
navigationItem.leftSmackerFileHash = fd.readUint32LE();
|
||||
navigationItem.rightSmackerFileHash = fd.readUint32LE();
|
||||
navigationItem.middleSmackerFileHash = fd.readUint32LE();
|
||||
navigationItem.interactive = fd.readByte();
|
||||
navigationItem.middleFlag = fd.readByte();
|
||||
navigationItem.mouseCursorFileHash = fd.readUint32LE();
|
||||
navigationList->push_back(navigationItem);
|
||||
}
|
||||
_navigationLists[id] = navigationList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HitRectList *StaticData::getHitRectList(uint32 id) {
|
||||
|
@ -124,4 +145,10 @@ MessageList *StaticData::getMessageList(uint32 id) {
|
|||
return _messageLists[id];
|
||||
}
|
||||
|
||||
NavigationList *StaticData::getNavigationList(uint32 id) {
|
||||
if (!_navigationLists[id])
|
||||
error("StaticData::getNavigationList() NavigationList with id %08X not found", id);
|
||||
return _navigationLists[id];
|
||||
}
|
||||
|
||||
} // End of namespace Neverhood
|
||||
|
|
|
@ -56,6 +56,18 @@ struct MessageItem {
|
|||
|
||||
typedef Common::Array<MessageItem> MessageList;
|
||||
|
||||
struct NavigationItem {
|
||||
uint32 fileHash;
|
||||
uint32 leftSmackerFileHash;
|
||||
uint32 rightSmackerFileHash;
|
||||
uint32 middleSmackerFileHash;
|
||||
byte interactive;
|
||||
byte middleFlag;
|
||||
uint32 mouseCursorFileHash;
|
||||
};
|
||||
|
||||
typedef Common::Array<NavigationItem> NavigationList;
|
||||
|
||||
class StaticData {
|
||||
public:
|
||||
StaticData();
|
||||
|
@ -64,10 +76,12 @@ public:
|
|||
HitRectList *getHitRectList(uint32 id);
|
||||
RectList *getRectList(uint32 id);
|
||||
MessageList *getMessageList(uint32 id);
|
||||
NavigationList *getNavigationList(uint32 id);
|
||||
protected:
|
||||
Common::HashMap<uint32, HitRectList*> _hitRectLists;
|
||||
Common::HashMap<uint32, RectList*> _rectLists;
|
||||
Common::HashMap<uint32, MessageList*> _messageLists;
|
||||
Common::HashMap<uint32, NavigationList*> _navigationLists;
|
||||
};
|
||||
|
||||
} // End of namespace Neverhood
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue