diff options
author | johndoe123 | 2011-07-11 12:53:28 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:38:47 +0200 |
commit | 626cea6d1c516d4da1f8c6aad1bdb0552e54bf91 (patch) | |
tree | b473c933a016611dc3da5fde09b9ddfa6381106e /engines | |
parent | 9f6e6c6f7fde2e1c927deee732cb03cf34d18455 (diff) | |
download | scummvm-rg350-626cea6d1c516d4da1f8c6aad1bdb0552e54bf91.tar.gz scummvm-rg350-626cea6d1c516d4da1f8c6aad1bdb0552e54bf91.tar.bz2 scummvm-rg350-626cea6d1c516d4da1f8c6aad1bdb0552e54bf91.zip |
NEVERHOOD: Implement Mouse435
Diffstat (limited to 'engines')
-rw-r--r-- | engines/neverhood/module1000.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/mouse.cpp | 98 | ||||
-rw-r--r-- | engines/neverhood/mouse.h | 14 |
3 files changed, 112 insertions, 2 deletions
diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp index 547f8c1ee0..bc52cfd573 100644 --- a/engines/neverhood/module1000.cpp +++ b/engines/neverhood/module1000.cpp @@ -629,7 +629,7 @@ Class152::Class152(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundF _background = addBackground(new DirtyBackground(_vm, backgroundFileHash, 0, 0)); _palette = new Palette(_vm, backgroundFileHash); _palette->usePalette(); - // TODO _mouseCursor = addSprite(new Class435(_vm, cursorFileHash, 20, 620)); + _mouseCursor = addSprite(new Mouse435(_vm, cursorFileHash, 20, 620)); } diff --git a/engines/neverhood/mouse.cpp b/engines/neverhood/mouse.cpp index 5693048ed5..c753183269 100644 --- a/engines/neverhood/mouse.cpp +++ b/engines/neverhood/mouse.cpp @@ -112,7 +112,103 @@ void Mouse433::updateCursor() { _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); + } + +} + +Mouse435::Mouse435(NeverhoodEngine *vm, uint32 fileHash, int16 x1, int16 x2) + : StaticSprite(vm, 2000), _mouseCursorResource(vm), _frameNum(0), _x1(x1), _x2(x2) { + + debug("Mouse435::Mouse435(%08X)", fileHash); + + _mouseCursorResource.load(fileHash); + _x = _vm->getMouseX(); + _y = _vm->getMouseY(); + if (_x <= _x1) { + _mouseCursorResource.setCursorNum(6); + } else if (_x >= _x2) { + _mouseCursorResource.setCursorNum(5); + } else { + _mouseCursorResource.setCursorNum(4); + } + createSurface(2000, 32, 32); + SetUpdateHandler(&Mouse435::update); + SetMessageHandler(&Mouse435::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 Mouse435::load(uint32 fileHash) { + _mouseCursorResource.load(fileHash); + _needRefresh = true; +} + +void Mouse435::update() { + debug("Mouse435::update()"); + updateCursor(); + _frameNum++; + if (_frameNum >= 6) + _frameNum = 0; + _needRefresh = _frameNum % 2 == 0; +} + +uint32 Mouse435::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + debug("Mouse435::handleMessage(%04X)", messageNum); + uint32 messageResult = 0; + if (messageNum != 5) { + messageResult = Sprite::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x4002: + _x = param.asPoint().x; + _y = param.asPoint().y; + if (_x <= _x1) { + _mouseCursorResource.setCursorNum(6); + } else if (_x >= _x2) { + _mouseCursorResource.setCursorNum(5); + } else { + _mouseCursorResource.setCursorNum(4); + } + processDelta(); + break; + } + } else { + // TODO: Debug stuff + } + return messageResult; +} + +void Mouse435::updateCursor() { + debug("Mouse435::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); diff --git a/engines/neverhood/mouse.h b/engines/neverhood/mouse.h index d03588f4e0..4bda936a91 100644 --- a/engines/neverhood/mouse.h +++ b/engines/neverhood/mouse.h @@ -43,6 +43,20 @@ protected: void updateCursor(); }; +class Mouse435 : public StaticSprite { +public: + Mouse435(NeverhoodEngine *vm, uint32 fileHash, int16 x1, int16 x2); + void load(uint32 fileHash); +protected: + MouseCursorResource _mouseCursorResource; + int _frameNum; + int16 _x1; + int16 _x2; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + void updateCursor(); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_MOUSE_H */ |