[Scummvm-git-logs] scummvm master -> e77c0317c5bfd307d19514c56fd96af9ff28c7dd
fracturehill
noreply at scummvm.org
Sat Apr 15 12:11:17 UTC 2023
This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
92e96f2791 NANCY: Do not adjust total playtime when calling GMM
f1a26334a0 NANCY: ConversationCel fixes
b612dbe0b0 NANCY: Fix crash when loading game
c578321578 NANCY: Play correct "can't" sounds in nancy2
2150c7c525 NANCY: Fix crash when loading Overlay
82b6138258 NANCY: Fix crash in TVD
642656c895 NANCY: Don't hide textbox after returning from GMM
46f6632af1 NANCY: Allow OrderingPuzzle to reset
fbb2a55da1 NANCY: Implement nancy2 clock
e77c0317c5 NANCY: Implement button hovering
Commit: 92e96f27915bd87ea164497f38f406e586522759
https://github.com/scummvm/scummvm/commit/92e96f27915bd87ea164497f38f406e586522759
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:21+03:00
Commit Message:
NANCY: Do not adjust total playtime when calling GMM
Changed paths:
engines/nancy/state/scene.cpp
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 614c427e3d0..b9076a5de41 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -156,6 +156,11 @@ void Scene::process() {
void Scene::onStateEnter(const NancyState::NancyState prevState) {
if (_state != kInit) {
registerGraphics();
+
+ if (prevState != NancyState::kPause) {
+ g_nancy->setTotalPlayTime((uint32)_timers.pushedPlayTime);
+ }
+
_actionManager.onPause(false);
g_nancy->_graphicsManager->redrawAll();
@@ -164,18 +169,16 @@ void Scene::onStateEnter(const NancyState::NancyState prevState) {
g_nancy->_cursorManager->setCursorItemID(getHeldItem());
}
- // Run once to clear out the previous scene when coming from Map
- process();
-
- g_nancy->setTotalPlayTime((uint32)_timers.pushedPlayTime);
-
unpauseSceneSpecificSounds();
g_nancy->_sound->stopSound("MSND");
}
}
bool Scene::onStateExit(const NancyState::NancyState nextState) {
- _timers.pushedPlayTime = g_nancy->getTotalPlayTime();
+ if (nextState != NancyState::kPause) {
+ _timers.pushedPlayTime = g_nancy->getTotalPlayTime();
+ }
+
_actionManager.onPause(true);
pauseSceneSpecificSounds();
_gameStateRequested = NancyState::kNone;
Commit: f1a26334a09bd26f841a352edb04a98595c3c484
https://github.com/scummvm/scummvm/commit/f1a26334a09bd26f841a352edb04a98595c3c484
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:21+03:00
Commit Message:
NANCY: ConversationCel fixes
Fixed an integer overflow causing sped-up video. Changed
the update code so the last frame is shown. Fixed incorrect
data reading of scene branch structs.
Changed paths:
engines/nancy/action/conversation.cpp
engines/nancy/action/conversation.h
diff --git a/engines/nancy/action/conversation.cpp b/engines/nancy/action/conversation.cpp
index 0b7e0ee998e..836179bea62 100644
--- a/engines/nancy/action/conversation.cpp
+++ b/engines/nancy/action/conversation.cpp
@@ -106,7 +106,8 @@ void ConversationSound::readData(Common::SeekableReadStream &stream) {
for (uint i = 0; i < numSceneBranchStructs; ++i) {
_sceneBranchStructs[i].conditions.read(stream);
_sceneBranchStructs[i].sceneChange.readData(stream, g_nancy->getGameType() == kGameTypeVampire);
- stream.skip(0x32);
+ ser.skip(0x32, kGameTypeVampire, kGameTypeNancy1);
+ ser.skip(2, kGameTypeNancy2);
}
uint16 numFlagsStructs = stream.readUint16LE();
@@ -510,6 +511,8 @@ Common::String ConversationVideo::getRecordTypeName() const {
void ConversationCel::init() {
registerGraphics();
+ _curFrame = _firstFrame;
+ _nextFrameTime = g_nancy->getTotalPlayTime();
ConversationSound::init();
}
@@ -521,7 +524,7 @@ void ConversationCel::registerGraphics() {
void ConversationCel::updateGraphics() {
uint32 currentTime = g_nancy->getTotalPlayTime();
- if (currentTime > _nextFrameTime && _curFrame < _cels.size()) {
+ if (_state == kRun && currentTime > _nextFrameTime && _curFrame <= _lastFrame) {
Cel &curCel = _cels[_curFrame];
_drawSurface.create(curCel.bodySurf, curCel.bodySrc);
@@ -530,10 +533,6 @@ void ConversationCel::updateGraphics() {
_headRObj._drawSurface.create(curCel.headSurf, curCel.headSrc);
_headRObj.moveTo(curCel.headDest);
- if (_nextFrameTime == 0) {
- _nextFrameTime = currentTime;
- }
-
_nextFrameTime += _frameTime;
++_curFrame;
}
diff --git a/engines/nancy/action/conversation.h b/engines/nancy/action/conversation.h
index cdcb57f506a..cb4588dab4a 100644
--- a/engines/nancy/action/conversation.h
+++ b/engines/nancy/action/conversation.h
@@ -169,7 +169,7 @@ public:
uint16 _lastFrame = 0;
uint _curFrame = 0;
- uint16 _nextFrameTime = 0;
+ uint32 _nextFrameTime = 0;
// We use the built-in RenderObject for the body
HeadCel _headRObj;
Commit: b612dbe0b044efd2546fae0f394d57aeea59fbea
https://github.com/scummvm/scummvm/commit/b612dbe0b044efd2546fae0f394d57aeea59fbea
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:21+03:00
Commit Message:
NANCY: Fix crash when loading game
Fixed a crash when loading a game directly from the launcher.
Changed paths:
engines/nancy/ui/textbox.cpp
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index a481f26680c..478462df023 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -83,6 +83,7 @@ void Textbox::registerGraphics() {
RenderObject::registerGraphics();
_scrollbar->registerGraphics();
_highlightRObj.registerGraphics();
+ _highlightRObj.setVisible(false);
}
void Textbox::updateGraphics() {
Commit: c578321578378bf69a11ccacd69d0f6463f429d7
https://github.com/scummvm/scummvm/commit/c578321578378bf69a11ccacd69d0f6463f429d7
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:22+03:00
Commit Message:
NANCY: Play correct "can't" sounds in nancy2
Added code to play the correct sound when an action
record requires a held item.
Changed paths:
engines/nancy/action/actionmanager.cpp
diff --git a/engines/nancy/action/actionmanager.cpp b/engines/nancy/action/actionmanager.cpp
index a2346cfd270..2551cc13484 100644
--- a/engines/nancy/action/actionmanager.cpp
+++ b/engines/nancy/action/actionmanager.cpp
@@ -63,7 +63,13 @@ void ActionManager::handleInput(NancyInput &input) {
}
if (!shouldTrigger) {
- g_nancy->_sound->playSound("CANT");
+ if (g_nancy->getGameType() >= kGameTypeNancy2) {
+ SoundDescription &sound = g_nancy->_inventoryData->itemDescriptions[rec->_itemRequired].specificCantSound;
+ g_nancy->_sound->loadSound(sound);
+ g_nancy->_sound->playSound(sound);
+ } else {
+ g_nancy->_sound->playSound("CANT");
+ }
}
} else {
shouldTrigger = true;
Commit: 2150c7c525fdccefca01a1c5633f7f214e732512
https://github.com/scummvm/scummvm/commit/2150c7c525fdccefca01a1c5633f7f214e732512
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:22+03:00
Commit Message:
NANCY: Fix crash when loading Overlay
Changed paths:
engines/nancy/action/overlay.cpp
diff --git a/engines/nancy/action/overlay.cpp b/engines/nancy/action/overlay.cpp
index 5ff6dfad94b..bdbb238e018 100644
--- a/engines/nancy/action/overlay.cpp
+++ b/engines/nancy/action/overlay.cpp
@@ -62,7 +62,13 @@ void Overlay::readData(Common::SeekableReadStream &stream) {
ser.syncAsUint16LE(_firstFrame);
ser.syncAsUint16LE(_loopFirstFrame);
ser.syncAsUint16LE(_loopLastFrame);
- _frameTime = Common::Rational(1000, stream.readUint16LE()).toInt();
+ uint16 frameTime = stream.readUint16LE();
+
+ // Avoid divide by 0
+ if (frameTime) {
+ _frameTime = Common::Rational(1000, frameTime).toInt();
+ }
+
ser.syncAsUint16LE(_z, kGameTypeNancy1, kGameTypeNancy1);
if (ser.getVersion() > kGameTypeNancy1) {
Commit: 82b613825881ef71e8069322e32fd16962c4157c
https://github.com/scummvm/scummvm/commit/82b613825881ef71e8069322e32fd16962c4157c
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:22+03:00
Commit Message:
NANCY: Fix crash in TVD
Fixed a file loading error that would result in no images
being opened in The Vampire Diaries.
Changed paths:
engines/nancy/resource.cpp
diff --git a/engines/nancy/resource.cpp b/engines/nancy/resource.cpp
index b8af481f200..0fad3e15210 100644
--- a/engines/nancy/resource.cpp
+++ b/engines/nancy/resource.cpp
@@ -807,7 +807,6 @@ bool ResourceManager::loadImage(const Common::String &name, Graphics::Surface &s
bool ResourceManager::loadImage(const Common::String &name, Graphics::ManagedSurface &surf, const Common::String treeName, Common::Rect *outSrc, Common::Rect *outDest) {
CifInfo info;
- bool loadedFromBitmapFile = false;
surf.free();
byte *buf = nullptr;
@@ -818,12 +817,11 @@ bool ResourceManager::loadImage(const Common::String &name, Graphics::ManagedSur
buf = getCifData(name, info);
}
- if (!buf && treeName.size() > 0) {
+ if (!buf) {
// Couldn't find image in a cif tree, try to open a .bmp file
// This is used by The Vampire Diaries
Common::File f;
- loadedFromBitmapFile = f.open(name + ".bmp");
- if (loadedFromBitmapFile) {
+ if (treeName.size() == 0 && f.open(name + ".bmp")) {
Image::BitmapDecoder dec;
if (dec.loadStream(f)) {
GraphicsManager::copyToManaged(*dec.getSurface(), surf);
Commit: 642656c895ca1cd5cb56fbc92dfefef989979643
https://github.com/scummvm/scummvm/commit/642656c895ca1cd5cb56fbc92dfefef989979643
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:22+03:00
Commit Message:
NANCY: Don't hide textbox after returning from GMM
Fixed an issue where the textbox would get hidden in
TVD and nancy1 when returning from the GMM.
Changed paths:
engines/nancy/action/conversation.cpp
diff --git a/engines/nancy/action/conversation.cpp b/engines/nancy/action/conversation.cpp
index 836179bea62..5f6fbc5ab69 100644
--- a/engines/nancy/action/conversation.cpp
+++ b/engines/nancy/action/conversation.cpp
@@ -446,6 +446,7 @@ void ConversationVideo::init() {
setTransparent(true);
}
+ ConversationSound::init();
registerGraphics();
}
Commit: 46f6632af156b345954c2d189f0d051bfb8725bb
https://github.com/scummvm/scummvm/commit/46f6632af156b345954c2d189f0d051bfb8725bb
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:23+03:00
Commit Message:
NANCY: Allow OrderingPuzzle to reset
Fixed a bug where an ordering puzzle would never reset,
regardless of how many buttons have been pressed.
Changed paths:
engines/nancy/action/orderingpuzzle.cpp
diff --git a/engines/nancy/action/orderingpuzzle.cpp b/engines/nancy/action/orderingpuzzle.cpp
index 3f61025185a..f5f561c24e1 100644
--- a/engines/nancy/action/orderingpuzzle.cpp
+++ b/engines/nancy/action/orderingpuzzle.cpp
@@ -131,13 +131,14 @@ void OrderingPuzzle::execute() {
case kRun:
switch (_solveState) {
case kNotSolved:
- if (_clickedSequence.size() != _sequenceLength) {
+ if (_clickedSequence.size() < _sequenceLength) {
return;
}
for (uint i = 0; i < _sequenceLength; ++i) {
+
if (_clickedSequence[i] != (int16)_correctSequence[i]) {
- if (_clickedSequence.size() > (uint)_sequenceLength + ((g_nancy->getGameType() == kGameTypeVampire) ? -1 : 1)) {
+ if (_clickedSequence.size() > (g_nancy->getGameType() == kGameTypeVampire ? 4 : (uint)_sequenceLength + 1)) {
clearAllElements();
}
Commit: fbb2a55da111ce1c68a6d8bf20996d1f7536f444
https://github.com/scummvm/scummvm/commit/fbb2a55da111ce1c68a6d8bf20996d1f7536f444
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T14:46:23+03:00
Commit Message:
NANCY: Implement nancy2 clock
Changed paths:
engines/nancy/enginedata.cpp
engines/nancy/enginedata.h
engines/nancy/state/scene.cpp
engines/nancy/ui/animatedbutton.cpp
engines/nancy/ui/animatedbutton.h
engines/nancy/ui/clock.cpp
engines/nancy/ui/clock.h
diff --git a/engines/nancy/enginedata.cpp b/engines/nancy/enginedata.cpp
index 7e7b7af600a..72696bcdd90 100644
--- a/engines/nancy/enginedata.cpp
+++ b/engines/nancy/enginedata.cpp
@@ -51,22 +51,21 @@ BSUM::BSUM(Common::SeekableReadStream *chunkStream) {
s.skip(4, kGameTypeNancy3);
s.skip(8, kGameTypeVampire, kGameTypeVampire);
- if (s.getVersion() == kGameTypeVampire) {
- readRect(*chunkStream, mapButtonHotspot);
- }
-
- s.skip(0x10, kGameTypeVampire, kGameTypeNancy1);
- s.skip(0x20, kGameTypeNancy2, kGameTypeNancy3);
- readRect(*chunkStream, textboxScreenPosition);
- readRect(*chunkStream, inventoryBoxScreenPosition);
- readRect(*chunkStream, menuButtonSrc);
- readRect(*chunkStream, helpButtonSrc);
- readRect(*chunkStream, menuButtonDest);
- readRect(*chunkStream, helpButtonDest);
+ readRect(s, mapButtonHotspot, kGameTypeVampire, kGameTypeVampire);
+ readRect(s, clockHotspot, kGameTypeNancy2);
+ s.skip(0x10);
+ readRect(s, textboxScreenPosition);
+ readRect(s, inventoryBoxScreenPosition);
+ readRect(s, menuButtonSrc);
+ readRect(s, helpButtonSrc);
+ readRect(s, menuButtonDest);
+ readRect(s, helpButtonDest);
+ readRect(s, menuButtonHighlightSrc, kGameTypeNancy2);
+ readRect(s, helpButtonHighlightSrc, kGameTypeNancy2);
+ readRect(s, clockHighlightSrc, kGameTypeNancy2);
s.skip(0xE, kGameTypeVampire, kGameTypeVampire);
- s.skip(9, kGameTypeNancy1, kGameTypeNancy1);
- s.skip(0x39, kGameTypeNancy2, kGameTypeNancy3);
+ s.skip(9, kGameTypeNancy1);
s.syncAsUint16LE(horizontalEdgesSize);
s.syncAsUint16LE(verticalEdgesSize);
@@ -379,18 +378,27 @@ CLOK::CLOK(Common::SeekableReadStream *chunkStream) {
Common::Serializer s(chunkStream, nullptr);
s.setVersion(g_nancy->getGameType());
- readRectArray(s, animSrcs, 8);
+ uint numFrames = s.getVersion() == kGameTypeVampire? 8 : 7;
+
+ readRectArray(s, animSrcs, numFrames);
+ readRectArray(s, animDests, numFrames, kGameTypeNancy2);
+
+ readRect(s, staticImageSrc, kGameTypeNancy2);
+ readRect(s, staticImageDest, kGameTypeNancy2);
readRectArray(s, hoursHandSrcs, 12);
+ readRectArray(s, hoursHandDests, 12, kGameTypeNancy2);
+
readRectArray(s, minutesHandSrcs, 4);
+ readRectArray(s, minutesHandDests, 4, kGameTypeNancy2);
- readRect(s, screenPosition);
+ readRect(s, screenPosition, kGameTypeVampire, kGameTypeVampire);
- readRectArray(s, hoursHandDests, 12);
- readRectArray(s, minutesHandDests, 4);
+ readRectArray(s, hoursHandDests, 12, kGameTypeVampire, kGameTypeVampire);
+ readRectArray(s, minutesHandDests, 4, kGameTypeVampire, kGameTypeVampire);
- readRect(*chunkStream, gargoyleEyesSrc);
- readRect(*chunkStream, gargoyleEyesDest);
+ readRect(s, staticImageSrc, kGameTypeVampire, kGameTypeVampire);
+ readRect(s, staticImageDest, kGameTypeVampire, kGameTypeVampire);
s.syncAsUint32LE(timeToKeepOpen);
s.syncAsUint16LE(frameTime);
diff --git a/engines/nancy/enginedata.h b/engines/nancy/enginedata.h
index fb4106f634e..2c0e812f6c4 100644
--- a/engines/nancy/enginedata.h
+++ b/engines/nancy/enginedata.h
@@ -40,12 +40,16 @@ struct BSUM {
// UI
Common::Rect mapButtonHotspot;
+ Common::Rect clockHotspot;
Common::Rect textboxScreenPosition;
Common::Rect inventoryBoxScreenPosition;
Common::Rect menuButtonSrc;
Common::Rect helpButtonSrc;
Common::Rect menuButtonDest;
Common::Rect helpButtonDest;
+ Common::Rect menuButtonHighlightSrc;
+ Common::Rect helpButtonHighlightSrc;
+ Common::Rect clockHighlightSrc;
uint16 horizontalEdgesSize;
uint16 verticalEdgesSize;
@@ -188,6 +192,7 @@ struct CLOK {
CLOK(Common::SeekableReadStream *chunkStream);
Common::Array<Common::Rect> animSrcs;
+ Common::Array<Common::Rect> animDests;
Common::Array<Common::Rect> hoursHandSrcs;
Common::Array<Common::Rect> minutesHandSrcs;
@@ -195,8 +200,8 @@ struct CLOK {
Common::Array<Common::Rect> hoursHandDests;
Common::Array<Common::Rect> minutesHandDests;
- Common::Rect gargoyleEyesSrc;
- Common::Rect gargoyleEyesDest;
+ Common::Rect staticImageSrc;
+ Common::Rect staticImageDest;
uint32 timeToKeepOpen;
uint16 frameTime;
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index b9076a5de41..ae998f14c08 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -782,6 +782,11 @@ void Scene::initStaticData() {
_clock->init();
}
+ if (g_nancy->getGameType() >= kGameTypeNancy2) {
+ _clock = new UI::Clock();
+ _clock->init();
+ }
+
_state = kLoad;
}
diff --git a/engines/nancy/ui/animatedbutton.cpp b/engines/nancy/ui/animatedbutton.cpp
index 115432daeaa..b8f1453012e 100644
--- a/engines/nancy/ui/animatedbutton.cpp
+++ b/engines/nancy/ui/animatedbutton.cpp
@@ -69,7 +69,12 @@ void AnimatedButton::updateGraphics() {
void AnimatedButton::handleInput(NancyInput &input) {
if (_hotspot.contains(input.mousePos)) {
if (_alwaysHighlightCursor || _currentFrame == -1 || _currentFrame == (int)_srcRects.size()) {
- g_nancy->_cursorManager->setCursorType(CursorManager::kHotspot);
+ g_nancy->_cursorManager->setCursorType(g_nancy->getGameType() == kGameTypeVampire ? CursorManager::kHotspot : CursorManager::kHotspotArrow);
+ }
+
+ if (!_highlightSrcRect.isEmpty() && !isVisible()) {
+ _drawSurface.create(g_nancy->_graphicsManager->_object0, _highlightSrcRect);
+ moveTo(_hotspot);
}
if (input.input & NancyInput::kLeftMouseButtonUp) {
@@ -90,6 +95,11 @@ void AnimatedButton::setFrame(int frame) {
if (frame > -1 && frame < (int)_srcRects.size()) {
_drawSurface.create(g_nancy->_graphicsManager->_object0, _srcRects[frame]);
setTransparent(true);
+
+ if (_destRects.size()) {
+ moveTo(_destRects[frame]);
+ }
+
_needsRedraw = true;
}
}
diff --git a/engines/nancy/ui/animatedbutton.h b/engines/nancy/ui/animatedbutton.h
index ff84c9c19ff..b5c7f7eb8a4 100644
--- a/engines/nancy/ui/animatedbutton.h
+++ b/engines/nancy/ui/animatedbutton.h
@@ -48,6 +48,9 @@ public:
protected:
Common::Array<Common::Rect> _srcRects;
+ Common::Array<Common::Rect> _destRects;
+ Common::Rect _highlightSrcRect;
+
uint32 _frameTime;
bool _alwaysHighlightCursor;
diff --git a/engines/nancy/ui/clock.cpp b/engines/nancy/ui/clock.cpp
index 83ca8cf518b..c44c8aee51d 100644
--- a/engines/nancy/ui/clock.cpp
+++ b/engines/nancy/ui/clock.cpp
@@ -34,9 +34,9 @@
namespace Nancy {
namespace UI {
-Clock::Clock() : RenderObject(11),
- _globe(10, this),
- _gargoyleEyes(9),
+Clock::Clock() : RenderObject(g_nancy->getGameType() == kGameTypeVampire ? 11 : 10),
+ _animation(g_nancy->getGameType() == kGameTypeVampire ? 10 : 11, this),
+ _staticImage(9),
_clockData(nullptr) {}
void Clock::init() {
@@ -45,29 +45,44 @@ void Clock::init() {
_clockData = g_nancy->_clockData;
assert(_clockData);
- _drawSurface.create(_clockData->screenPosition.width(), _clockData->screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
- moveTo(_clockData->screenPosition);
+ // Calculate the size and location of the surface we'll need to draw the clock hands,
+ // since their dest rects are in absolute screen space
+ Common::Rect clockSurfaceScreenBounds;
- _gargoyleEyes._drawSurface.create(object0, _clockData->gargoyleEyesSrc);
- _gargoyleEyes.moveTo(_clockData->gargoyleEyesDest);
- _gargoyleEyes.setVisible(false);
+ for (Common::Rect &r : _clockData->hoursHandDests) {
+ clockSurfaceScreenBounds.extend(r);
+ }
+
+ for (Common::Rect &r : _clockData->minutesHandDests) {
+ clockSurfaceScreenBounds.extend(r);
+ }
- _gargoyleEyes.setTransparent(true);
- _globe.setTransparent(true);
- GraphicsManager::loadSurfacePalette(_drawSurface, "OBJECT0");
+ _drawSurface.create(clockSurfaceScreenBounds.width(), clockSurfaceScreenBounds.height(), g_nancy->_graphicsManager->getInputPixelFormat());
+ moveTo(clockSurfaceScreenBounds);
+
+ _staticImage._drawSurface.create(object0, _clockData->staticImageSrc);
+ _staticImage.moveTo(_clockData->staticImageDest);
+ _staticImage.setVisible(false);
+ _staticImage.setTransparent(g_nancy->getGameType() == kGameTypeVampire);
+
+ _animation.setTransparent(true);
+ if (g_nancy->getGameType() == kGameTypeVampire) {
+ GraphicsManager::loadSurfacePalette(_drawSurface, "OBJECT0");
+ }
+
setTransparent(true);
- _globe.init();
+ _animation.init();
}
void Clock::registerGraphics() {
- _gargoyleEyes.registerGraphics();
- _globe.registerGraphics();
+ _staticImage.registerGraphics();
+ _animation.registerGraphics();
RenderObject::registerGraphics();
}
void Clock::updateGraphics() {
- setVisible(_globe.getCurrentFrame() >= 5);
+ setVisible(_animation.getCurrentFrame() >= (g_nancy->getGameType() == kGameTypeVampire ? 5 : 1));
if (_isVisible) {
Time newPlayerTime = NancySceneState.getPlayerTime();
@@ -83,8 +98,8 @@ void Clock::updateGraphics() {
}
void Clock::handleInput(NancyInput &input) {
- if (!_globe.isPlaying()) {
- _globe.handleInput(input);
+ if (!_animation.isPlaying()) {
+ _animation.handleInput(input);
}
}
@@ -107,9 +122,15 @@ void Clock::drawClockHands() {
_drawSurface.blitFrom(object0, _clockData->minutesHandSrcs[minutesHand], minutesDest);
}
-void Clock::ClockGlobe::init() {
+void Clock::ClockAnim::init() {
_srcRects = _owner->_clockData->animSrcs;
- moveTo(_owner->_clockData->screenPosition);
+ _destRects = _owner->_clockData->animDests;
+
+ if (_destRects.size()) {
+ moveTo(g_nancy->_bootSummary->clockHotspot);
+ } else {
+ moveTo(_owner->_clockData->screenPosition);
+ }
_timeToKeepOpen = _owner->_clockData->timeToKeepOpen;
_frameTime = _owner->_clockData->frameTime;
@@ -118,32 +139,43 @@ void Clock::ClockGlobe::init() {
_hotspot = _screenPosition;
}
-void Clock::ClockGlobe::updateGraphics() {
+void Clock::ClockAnim::updateGraphics() {
AnimatedButton::updateGraphics();
if (_isOpen && !isPlaying() && g_nancy->getTotalPlayTime() > _closeTime && _isVisible) {
setOpen(false);
- _owner->_gargoyleEyes.setVisible(false);
+ if (g_nancy->getGameType() == kGameTypeVampire) {
+ _owner->_staticImage.setVisible(false);
+ }
g_nancy->_sound->playSound("GLOB");
}
}
-void Clock::ClockGlobe::onClick() {
+void Clock::ClockAnim::onClick() {
if (!isPlaying()) {
setOpen(!_isOpen);
+
if (!_isOpen) {
- _owner->_gargoyleEyes.setVisible(false);
+ if (g_nancy->getGameType() == kGameTypeVampire) {
+ _owner->_staticImage.setVisible(false);
+ }
+ } else if (g_nancy->getGameType() != kGameTypeVampire) {
+ _owner->_staticImage.setVisible(true);
}
+
_owner->_playerTime = NancySceneState.getPlayerTime();
g_nancy->_sound->playSound("GLOB");
}
}
-void Clock::ClockGlobe::onTrigger() {
+void Clock::ClockAnim::onTrigger() {
if (_isOpen) {
_closeTime = g_nancy->getTotalPlayTime() + _timeToKeepOpen;
- _owner->_gargoyleEyes.setVisible(true);
+ if (g_nancy->getGameType() == kGameTypeVampire) {
+ _owner->_staticImage.setVisible(true);
+ }
} else {
_owner->setVisible(false);
+ _owner->_staticImage.setVisible(false);
}
}
diff --git a/engines/nancy/ui/clock.h b/engines/nancy/ui/clock.h
index b788fd5a76b..9a41bd80ec2 100644
--- a/engines/nancy/ui/clock.h
+++ b/engines/nancy/ui/clock.h
@@ -35,7 +35,7 @@ struct NancyInput;
namespace UI {
class Clock : public RenderObject {
- friend class ClockGlobe;
+ friend class ClockAnim;
public:
Clock();
virtual ~Clock() = default;
@@ -48,10 +48,10 @@ public:
void drawClockHands();
protected:
- class ClockGlobe : public AnimatedButton {
+ class ClockAnim : public AnimatedButton {
public:
- ClockGlobe(uint zOrder, Clock *owner) : AnimatedButton(zOrder), _owner(owner), _closeTime(0), _timeToKeepOpen(0) {}
- virtual ~ClockGlobe() = default;
+ ClockAnim(uint zOrder, Clock *owner) : AnimatedButton(zOrder), _owner(owner), _closeTime(0), _timeToKeepOpen(0) {}
+ virtual ~ClockAnim() = default;
void init() override;
void updateGraphics() override;
@@ -66,8 +66,10 @@ protected:
};
CLOK *_clockData;
- RenderObject _gargoyleEyes;
- ClockGlobe _globe;
+ ClockAnim _animation;
+
+ // Used for gargoyle eyes in TVD, inside of watch in nancy2 and up
+ RenderObject _staticImage;
Time _playerTime;
};
Commit: e77c0317c5bfd307d19514c56fd96af9ff28c7dd
https://github.com/scummvm/scummvm/commit/e77c0317c5bfd307d19514c56fd96af9ff28c7dd
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-04-15T15:08:54+03:00
Commit Message:
NANCY: Implement button hovering
Added code to display a different image when hovering over
a button, as introduced in nancy2. Also fixed loading of
HELP data.
Changed paths:
engines/nancy/enginedata.cpp
engines/nancy/enginedata.h
engines/nancy/state/help.cpp
engines/nancy/state/help.h
engines/nancy/state/scene.cpp
engines/nancy/ui/button.cpp
engines/nancy/ui/button.h
diff --git a/engines/nancy/enginedata.cpp b/engines/nancy/enginedata.cpp
index 72696bcdd90..70000e708e6 100644
--- a/engines/nancy/enginedata.cpp
+++ b/engines/nancy/enginedata.cpp
@@ -305,16 +305,22 @@ HELP::HELP(Common::SeekableReadStream *chunkStream) {
chunkStream->seek(0);
readFilename(*chunkStream, imageName);
-
chunkStream->skip(20);
- buttonDest.left = chunkStream->readUint16LE();
- buttonDest.top = chunkStream->readUint16LE();
- buttonDest.right = chunkStream->readUint16LE();
- buttonDest.bottom = chunkStream->readUint16LE();
- buttonSrc.left = chunkStream->readUint16LE();
- buttonSrc.top = chunkStream->readUint16LE();
- buttonSrc.right = chunkStream->readUint16LE();
- buttonSrc.bottom = chunkStream->readUint16LE();
+
+ if (g_nancy->getGameType() <= kGameTypeNancy1) {
+ buttonDest.left = chunkStream->readUint16LE();
+ buttonDest.top = chunkStream->readUint16LE();
+ buttonDest.right = chunkStream->readUint16LE();
+ buttonDest.bottom = chunkStream->readUint16LE();
+ buttonSrc.left = chunkStream->readUint16LE();
+ buttonSrc.top = chunkStream->readUint16LE();
+ buttonSrc.right = chunkStream->readUint16LE();
+ buttonSrc.bottom = chunkStream->readUint16LE();
+ } else {
+ readRect(*chunkStream, buttonDest);
+ readRect(*chunkStream, buttonSrc);
+ readRect(*chunkStream, buttonHoverSrc);
+ }
delete chunkStream;
}
diff --git a/engines/nancy/enginedata.h b/engines/nancy/enginedata.h
index 2c0e812f6c4..c1bfb1c4fbc 100644
--- a/engines/nancy/enginedata.h
+++ b/engines/nancy/enginedata.h
@@ -161,8 +161,9 @@ struct HELP {
HELP(Common::SeekableReadStream *chunkStream);
Common::String imageName;
- Common::Rect buttonSrc;
Common::Rect buttonDest;
+ Common::Rect buttonSrc;
+ Common::Rect buttonHoverSrc;
};
struct CRED {
diff --git a/engines/nancy/state/help.cpp b/engines/nancy/state/help.cpp
index 1a4204877d5..63815fc33d4 100644
--- a/engines/nancy/state/help.cpp
+++ b/engines/nancy/state/help.cpp
@@ -84,7 +84,7 @@ void Help::init() {
assert(helpData);
_image.init(helpData->imageName);
- _button = new UI::Button(5, _image._drawSurface, helpData->buttonSrc, helpData->buttonDest);
+ _button = new UI::Button(5, _image._drawSurface, helpData->buttonSrc, helpData->buttonDest, helpData->buttonHoverSrc);
_button->init();
_state = kBegin;
diff --git a/engines/nancy/state/help.h b/engines/nancy/state/help.h
index bd4e3aa4fd0..b0ad4480c52 100644
--- a/engines/nancy/state/help.h
+++ b/engines/nancy/state/help.h
@@ -25,9 +25,8 @@
#include "common/singleton.h"
#include "engines/nancy/commontypes.h"
-
+#include "engines/nancy/time.h"
#include "engines/nancy/state/state.h"
-
#include "engines/nancy/ui/fullscreenimage.h"
namespace Nancy {
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index ae998f14c08..b2c4c430fcd 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -763,8 +763,8 @@ void Scene::initStaticData() {
_mapHotspot = g_nancy->_mapData->buttonDest;
}
- _menuButton = new UI::Button(5, g_nancy->_graphicsManager->_object0, bsum->menuButtonSrc, bsum->menuButtonDest);
- _helpButton = new UI::Button(5, g_nancy->_graphicsManager->_object0, bsum->helpButtonSrc, bsum->helpButtonDest);
+ _menuButton = new UI::Button(5, g_nancy->_graphicsManager->_object0, bsum->menuButtonSrc, bsum->menuButtonDest, bsum->menuButtonHighlightSrc);
+ _helpButton = new UI::Button(5, g_nancy->_graphicsManager->_object0, bsum->helpButtonSrc, bsum->helpButtonDest, bsum->helpButtonHighlightSrc);
g_nancy->setMouseEnabled(true);
// Init ornaments and clock (TVD only)
diff --git a/engines/nancy/ui/button.cpp b/engines/nancy/ui/button.cpp
index c83d613a8e8..67fa6cd97fa 100644
--- a/engines/nancy/ui/button.cpp
+++ b/engines/nancy/ui/button.cpp
@@ -33,8 +33,11 @@
namespace Nancy {
namespace UI {
-Button::Button(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
- RenderObject(zOrder, surface, srcBounds, destBounds),
+Button::Button(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &clickSrcBounds, const Common::Rect &destBounds, const Common::Rect &hoverSrcBounds) :
+ RenderObject(zOrder, surface, clickSrcBounds, destBounds),
+ surf(surface),
+ _clickSrc(clickSrcBounds),
+ _hoverSrc(hoverSrcBounds),
_isClicked(false) {
setVisible(false);
setTransparent(true);
@@ -44,10 +47,21 @@ void Button::handleInput(NancyInput &input) {
if (_screenPosition.contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
+ if (!_hoverSrc.isEmpty() && !_isClicked) {
+ _drawSurface.create(surf, _hoverSrc);
+ setVisible(true);
+ }
+
if (input.input & NancyInput::kLeftMouseButtonUp) {
_isClicked = true;
- setVisible(true);
+ if (_hoverSrc.isEmpty()) {
+ setVisible(true);
+ } else {
+ _drawSurface.create(surf, _clickSrc);
+ }
}
+ } else if (!_isClicked && _isVisible) {
+ setVisible(false);
}
}
diff --git a/engines/nancy/ui/button.h b/engines/nancy/ui/button.h
index aca785f3e7e..f193bf521d6 100644
--- a/engines/nancy/ui/button.h
+++ b/engines/nancy/ui/button.h
@@ -32,11 +32,17 @@ namespace UI {
class Button : public RenderObject {
public:
- Button(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
+ Button(uint16 zOrder, Graphics::ManagedSurface &surface,
+ const Common::Rect &clickSrcBounds,
+ const Common::Rect &destBounds,
+ const Common::Rect &hoverSrcBounds = Common::Rect());
virtual ~Button() = default;
void handleInput(NancyInput &input);
+ Graphics::ManagedSurface &surf;
+ Common::Rect _clickSrc;
+ Common::Rect _hoverSrc;
bool _isClicked;
};
More information about the Scummvm-git-logs
mailing list