[Scummvm-git-logs] scummvm master -> cebaa64088858e1cd3f94bda875a38b1fceb6779
fracturehill
noreply at scummvm.org
Sat Feb 25 17:46:55 UTC 2023
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0a856b9b43 NANCY: Implement The Vampire Diaries UI ornaments
78df65e416 NANCY: Simplify and improve graphics code
8e69d52ce3 NANCY: The Vampire Diaries scrollbar visual fixes
e7f6852f1c NANCY: Remove leftover friend class declarations
cebaa64088 NANCY: Fix buttons in The Vampire Diaries
Commit: 0a856b9b43b0cfc94f003166bcb1a331597c5c76
https://github.com/scummvm/scummvm/commit/0a856b9b43b0cfc94f003166bcb1a331597c5c76
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-02-25T19:37:23+02:00
Commit Message:
NANCY: Implement The Vampire Diaries UI ornaments
Added the UI ornaments that appear over the viewport and textbox
in The Vampire Diaries.
Changed paths:
A engines/nancy/ui/ornaments.cpp
A engines/nancy/ui/ornaments.h
engines/nancy/module.mk
engines/nancy/state/scene.cpp
engines/nancy/state/scene.h
diff --git a/engines/nancy/module.mk b/engines/nancy/module.mk
index 21d49ca320e..128025c9e2f 100644
--- a/engines/nancy/module.mk
+++ b/engines/nancy/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS = \
ui/fullscreenimage.o \
ui/button.o \
ui/inventorybox.o \
+ ui/ornaments.o \
ui/scrollbar.o \
ui/textbox.o \
ui/viewport.o \
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 471107984ab..84d216c0319 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -34,6 +34,7 @@
#include "engines/nancy/state/scene.h"
#include "engines/nancy/ui/button.h"
+#include "engines/nancy/ui/ornaments.h"
namespace Common {
DECLARE_SINGLETON(Nancy::State::Scene);
@@ -101,6 +102,8 @@ Scene::Scene() :
_inventoryBox(_frame),
_menuButton(nullptr),
_helpButton(nullptr),
+ _viewportOrnaments(nullptr),
+ _textboxOrnaments(nullptr),
_actionManager(),
_difficulty(0),
_activePrimaryVideo(nullptr) {}
@@ -108,6 +111,8 @@ Scene::Scene() :
Scene::~Scene() {
delete _helpButton;
delete _menuButton;
+ delete _viewportOrnaments;
+ delete _textboxOrnaments;
}
void Scene::process() {
@@ -285,12 +290,28 @@ void Scene::registerGraphics() {
_viewport.registerGraphics();
_textbox.registerGraphics();
_inventoryBox.registerGraphics();
- _menuButton->registerGraphics();
- _helpButton->registerGraphics();
+
+ if (_menuButton) {
+ _menuButton->registerGraphics();
+ _menuButton->setVisible(false);
+ }
+
+ if (_helpButton) {
+ _helpButton->registerGraphics();
+ _helpButton->setVisible(false);
+ }
+
+ if (_viewportOrnaments) {
+ _viewportOrnaments->registerGraphics();
+ _viewportOrnaments->setVisible(true);
+ }
+
+ if (_textboxOrnaments) {
+ _textboxOrnaments->registerGraphics();
+ _textboxOrnaments->setVisible(true);
+ }
_textbox.setVisible(!_shouldClearTextbox);
- _menuButton->setVisible(false);
- _helpButton->setVisible(false);
}
void Scene::synchronize(Common::Serializer &ser) {
@@ -644,6 +665,15 @@ void Scene::initStaticData() {
_helpButton->init();
g_nancy->_cursorManager->showCursor(true);
+ // Init ornaments (TVD only)
+ if (g_nancy->getGameType() == Nancy::GameType::kGameTypeVampire) {
+ _viewportOrnaments = new UI::ViewportOrnaments(_viewport, 9);
+ _viewportOrnaments->init();
+
+ _textboxOrnaments = new UI::TextboxOrnaments(_textbox, 9);
+ _textboxOrnaments->init();
+ }
+
_state = kLoad;
}
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index 41c40387c51..76a07d96884 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -54,6 +54,8 @@ class PlayPrimaryVideoChan0;
namespace UI {
class Button;
+class ViewportOrnaments;
+class TextboxOrnaments;
}
namespace State {
@@ -240,6 +242,9 @@ private:
UI::Button *_menuButton;
UI::Button *_helpButton;
+ UI::ViewportOrnaments *_viewportOrnaments;
+ UI::TextboxOrnaments *_textboxOrnaments;
+
// Data
SceneState _sceneState;
PlayFlags _flags;
diff --git a/engines/nancy/ui/ornaments.cpp b/engines/nancy/ui/ornaments.cpp
new file mode 100644
index 00000000000..dc2738c5f66
--- /dev/null
+++ b/engines/nancy/ui/ornaments.cpp
@@ -0,0 +1,115 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "engines/nancy/ui/ornaments.h"
+
+#include "engines/nancy/nancy.h"
+#include "engines/nancy/graphics.h"
+#include "engines/nancy/util.h"
+
+namespace Nancy {
+namespace UI {
+
+void ViewportOrnaments::init() {
+ Common::Rect viewportBounds;
+ Common::SeekableReadStream *viewChunk = g_nancy->getBootChunkStream("VIEW");
+ viewChunk->seek(0);
+ readRect(*viewChunk, _screenPosition);
+ readRect(*viewChunk, viewportBounds);
+
+ Graphics::ManagedSurface &object0 = g_nancy->_graphicsManager->_object0;
+
+ _drawSurface.create(viewportBounds.width(), viewportBounds.height(), g_nancy->_graphicsManager->getInputPixelFormat());
+
+ uint8 palette[256 * 3];
+ object0.grabPalette(palette, 0, 256);
+ _drawSurface.setPalette(palette, 0, 256);
+
+ // All values for the viewport ornaments are hardcoded and not stored in a chunk
+ Common::Rect src[6] = {
+ { 0, 0, 31, 110 },
+ { 49, 0, 81, 110 },
+ { 33, 24, 45, 37 },
+ { 33, 69, 46, 82 },
+ { 33, 0, 43, 22 },
+ { 33, 39, 40, 59 }
+ };
+
+ _drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
+ setTransparent(true);
+
+ // Top left
+ _drawSurface.blitFrom(object0, src[0], Common::Point(0, 0));
+ // Top right
+ _drawSurface.blitFrom(object0, src[1], Common::Point(viewportBounds.right - src[1].width(), 0));
+ // Bottom left
+ _drawSurface.blitFrom(object0, src[2], Common::Point(0, viewportBounds.bottom - src[2].height()));
+ // Bottom right
+ _drawSurface.blitFrom(object0, src[3], Common::Point(viewportBounds.right - src[3].width(), viewportBounds.bottom - src[3].height()));
+ // Middle left
+ _drawSurface.blitFrom(object0, src[4], Common::Point(0, 204));
+ // Middle right
+ _drawSurface.blitFrom(object0, src[5], Common::Point(viewportBounds.right - src[5].width(), 205));
+
+
+ RenderObject::init();
+}
+
+void TextboxOrnaments::init() {
+ _screenPosition = g_nancy->_textboxScreenPosition;
+ Common::Rect textboxBounds = _screenPosition;
+ textboxBounds.moveTo(0, 0);
+
+ Graphics::ManagedSurface &object0 = g_nancy->_graphicsManager->_object0;
+
+ _drawSurface.create(textboxBounds.width(), textboxBounds.height(), g_nancy->_graphicsManager->getInputPixelFormat());
+
+ uint8 palette[256 * 3];
+ object0.grabPalette(palette, 0, 256);
+ _drawSurface.setPalette(palette, 0, 256);
+
+ _drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
+ setTransparent(true);
+
+ // Values for textbox ornaments are stored in the TBOX chunk
+ Common::Rect src[14];
+ Common::Rect dest[14];
+
+ Common::SeekableReadStream *tboxChunk = g_nancy->getBootChunkStream("TBOX");
+ tboxChunk->seek(0x3E);
+
+ for (uint i = 0; i < 14; ++i) {
+ readRect(*tboxChunk, src[i]);
+ }
+
+ for (uint i = 0; i < 14; ++i) {
+ readRect(*tboxChunk, dest[i]);
+ }
+
+ for (uint i = 0; i < 14; ++i) {
+ _drawSurface.blitFrom(object0, src[i], Common::Point(dest[i].left - _screenPosition.left, dest[i].top - _screenPosition.top));
+ }
+
+ RenderObject::init();
+}
+
+} // End of namespace UI
+} // End of namespace Nancy
diff --git a/engines/nancy/ui/ornaments.h b/engines/nancy/ui/ornaments.h
new file mode 100644
index 00000000000..119950ee857
--- /dev/null
+++ b/engines/nancy/ui/ornaments.h
@@ -0,0 +1,50 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NANCY_UI_ORNAMENTS_H
+#define NANCY_UI_ORNAMENTS_H
+
+#include "engines/nancy/renderobject.h"
+
+namespace Nancy {
+namespace UI {
+
+class ViewportOrnaments : public Nancy::RenderObject {
+public:
+ ViewportOrnaments(Nancy::RenderObject &redrawFrom, uint16 zOrder) : RenderObject(redrawFrom, zOrder) {}
+ virtual ~ViewportOrnaments() {}
+
+ void init() override;
+};
+
+class TextboxOrnaments : public Nancy::RenderObject {
+public:
+ TextboxOrnaments(Nancy::RenderObject &redrawFrom, uint16 zOrder) : RenderObject(redrawFrom, zOrder) {}
+ virtual ~TextboxOrnaments() {}
+
+ void init() override;
+};
+
+} // End of namespace Nancy
+} // End of namespace Nancy
+
+
+#endif // NANCY_UI_ORNAMENTS_H
Commit: 78df65e4160e097e0c0b0d9d1f4295eaae6ef2dc
https://github.com/scummvm/scummvm/commit/78df65e4160e097e0c0b0d9d1f4295eaae6ef2dc
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-02-25T19:37:23+02:00
Commit Message:
NANCY: Simplify and improve graphics code
Rewrote GraphicsManager::draw() to be simpler and more correct,
eliminating the need for RenderObjects to know what they're
overlapping at creation. This comes at the cost of slightly increased
redraw, but that can be reduced fairly easily if needed.
Changed paths:
engines/nancy/action/arfactory.cpp
engines/nancy/action/leverpuzzle.h
engines/nancy/action/orderingpuzzle.h
engines/nancy/action/passwordpuzzle.h
engines/nancy/action/primaryvideo.h
engines/nancy/action/recordtypes.h
engines/nancy/action/rotatinglockpuzzle.h
engines/nancy/action/secondarymovie.h
engines/nancy/action/secondaryvideo.h
engines/nancy/action/sliderpuzzle.h
engines/nancy/action/staticbitmapanim.h
engines/nancy/action/telephone.h
engines/nancy/graphics.cpp
engines/nancy/renderobject.cpp
engines/nancy/renderobject.h
engines/nancy/state/credits.h
engines/nancy/state/help.cpp
engines/nancy/state/mainmenu.h
engines/nancy/state/map.cpp
engines/nancy/state/scene.cpp
engines/nancy/ui/button.cpp
engines/nancy/ui/button.h
engines/nancy/ui/inventorybox.cpp
engines/nancy/ui/inventorybox.h
engines/nancy/ui/ornaments.h
engines/nancy/ui/scrollbar.cpp
engines/nancy/ui/scrollbar.h
engines/nancy/ui/textbox.cpp
engines/nancy/ui/textbox.h
diff --git a/engines/nancy/action/arfactory.cpp b/engines/nancy/action/arfactory.cpp
index 155a074656d..87eee81d67a 100644
--- a/engines/nancy/action/arfactory.cpp
+++ b/engines/nancy/action/arfactory.cpp
@@ -77,17 +77,17 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
case 0x25:
return new FlickerOff();
case 0x28:
- return new PlayPrimaryVideoChan0(NancySceneState.getViewport());
+ return new PlayPrimaryVideoChan0();
case 0x29:
- return new PlaySecondaryVideo(0, NancySceneState.getViewport());
+ return new PlaySecondaryVideo(0);
case 0x2A:
- return new PlaySecondaryVideo(1, NancySceneState.getViewport());
+ return new PlaySecondaryVideo(1);
case 0x2B:
- return new PlaySecondaryMovie(NancySceneState.getViewport());
+ return new PlaySecondaryMovie();
case 0x2C:
- return new PlayStaticBitmapAnimation(false, NancySceneState.getViewport()); // PlayStaticBitmapAnimation
+ return new PlayStaticBitmapAnimation(false); // PlayStaticBitmapAnimation
case 0x2D:
- return new PlayStaticBitmapAnimation(true, NancySceneState.getViewport()); // PlayIntStaticBitmapAnimation
+ return new PlayStaticBitmapAnimation(true); // PlayIntStaticBitmapAnimation
case 0x32:
return new MapCall();
case 0x33:
@@ -127,7 +127,7 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
case 0x61:
return new EventFlags();
case 0x62:
- return new OrderingPuzzle(NancySceneState.getViewport());
+ return new OrderingPuzzle();
case 0x63:
return new LoseGame();
case 0x64:
@@ -139,21 +139,21 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
case 0x67:
return new DifficultyLevel();
case 0x68:
- return new RotatingLockPuzzle(NancySceneState.getViewport());
+ return new RotatingLockPuzzle();
case 0x69:
- return new LeverPuzzle(NancySceneState.getViewport());
+ return new LeverPuzzle();
case 0x6A:
- return new Telephone(NancySceneState.getViewport());
+ return new Telephone();
case 0x6B:
- return new SliderPuzzle(NancySceneState.getViewport());
+ return new SliderPuzzle();
case 0x6C:
- return new PasswordPuzzle(NancySceneState.getViewport());
+ return new PasswordPuzzle();
case 0x6E:
return new AddInventoryNoHS();
case 0x6F:
return new RemoveInventoryNoHS();
case 0x70:
- return new ShowInventoryItem(NancySceneState.getViewport());
+ return new ShowInventoryItem();
case 0x8C:
return new PlayDigiSoundAndDie(); // TODO
case 0x8D:
diff --git a/engines/nancy/action/leverpuzzle.h b/engines/nancy/action/leverpuzzle.h
index 24e4fc1cd76..666c80a8868 100644
--- a/engines/nancy/action/leverpuzzle.h
+++ b/engines/nancy/action/leverpuzzle.h
@@ -32,7 +32,7 @@ namespace Action {
class LeverPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
- LeverPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
+ LeverPuzzle() : RenderObject(7) {}
virtual ~LeverPuzzle() {}
void init() override;
diff --git a/engines/nancy/action/orderingpuzzle.h b/engines/nancy/action/orderingpuzzle.h
index 9ebab25493c..43213ff28ed 100644
--- a/engines/nancy/action/orderingpuzzle.h
+++ b/engines/nancy/action/orderingpuzzle.h
@@ -32,7 +32,7 @@ namespace Action {
class OrderingPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
- OrderingPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
+ OrderingPuzzle() : RenderObject(7) {}
virtual ~OrderingPuzzle() {}
void init() override;
diff --git a/engines/nancy/action/passwordpuzzle.h b/engines/nancy/action/passwordpuzzle.h
index c164d75ecbe..5296b0aaaeb 100644
--- a/engines/nancy/action/passwordpuzzle.h
+++ b/engines/nancy/action/passwordpuzzle.h
@@ -32,7 +32,7 @@ namespace Action {
class PasswordPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kFailed, kSolved };
- PasswordPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
+ PasswordPuzzle() : RenderObject(7) {}
virtual ~PasswordPuzzle() {}
void init() override;
diff --git a/engines/nancy/action/primaryvideo.h b/engines/nancy/action/primaryvideo.h
index c20a2cc640a..c8c0e65b495 100644
--- a/engines/nancy/action/primaryvideo.h
+++ b/engines/nancy/action/primaryvideo.h
@@ -69,7 +69,7 @@ struct FlagsStruct {
};
public:
- PlayPrimaryVideoChan0(RenderObject &redrawFrom) : RenderObject(redrawFrom, 8) {}
+ PlayPrimaryVideoChan0() : RenderObject(8) {}
virtual ~PlayPrimaryVideoChan0();
void init() override;
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index 980208dbe03..ee99e028ca0 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -433,7 +433,7 @@ public:
void readData(Common::SeekableReadStream &stream) override;
void execute() override;
- ShowInventoryItem(RenderObject &redrawFrom) : RenderObject(redrawFrom, 9) {}
+ ShowInventoryItem() : RenderObject(9) {}
virtual ~ShowInventoryItem() { _fullSurface.free(); }
void init() override;
diff --git a/engines/nancy/action/rotatinglockpuzzle.h b/engines/nancy/action/rotatinglockpuzzle.h
index 3b981c37fdd..252c3fecf40 100644
--- a/engines/nancy/action/rotatinglockpuzzle.h
+++ b/engines/nancy/action/rotatinglockpuzzle.h
@@ -32,7 +32,7 @@ namespace Action {
class RotatingLockPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
- RotatingLockPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
+ RotatingLockPuzzle() : RenderObject(7) {}
virtual ~RotatingLockPuzzle() {}
void init() override;
diff --git a/engines/nancy/action/secondarymovie.h b/engines/nancy/action/secondarymovie.h
index 9795aabb0ca..eaefb2d0888 100644
--- a/engines/nancy/action/secondarymovie.h
+++ b/engines/nancy/action/secondarymovie.h
@@ -38,7 +38,7 @@ public:
EventFlagDescription flagDesc;
};
- PlaySecondaryMovie(RenderObject &redrawFrom) : RenderObject(redrawFrom, 8) {}
+ PlaySecondaryMovie() : RenderObject(8) {}
virtual ~PlaySecondaryMovie();
void init() override;
diff --git a/engines/nancy/action/secondaryvideo.h b/engines/nancy/action/secondaryvideo.h
index 46ec631059a..8cc50d491b5 100644
--- a/engines/nancy/action/secondaryvideo.h
+++ b/engines/nancy/action/secondaryvideo.h
@@ -37,7 +37,7 @@ class PlaySecondaryVideo : public ActionRecord, public RenderObject {
public:
enum HoverState { kNoHover, kHover, kEndHover };
- PlaySecondaryVideo(uint chan, RenderObject &redrawFrom) : RenderObject(redrawFrom, 8), channel(chan) {}
+ PlaySecondaryVideo(uint chan) : RenderObject(8), channel(chan) {}
virtual ~PlaySecondaryVideo() { _decoder.close(); }
void init() override;
diff --git a/engines/nancy/action/sliderpuzzle.h b/engines/nancy/action/sliderpuzzle.h
index 457bb1d466f..4add2baa4e2 100644
--- a/engines/nancy/action/sliderpuzzle.h
+++ b/engines/nancy/action/sliderpuzzle.h
@@ -37,7 +37,7 @@ namespace Action {
class SliderPuzzle: public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kWaitForSound };
- SliderPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
+ SliderPuzzle() : RenderObject(7) {}
virtual ~SliderPuzzle() {}
void init() override;
diff --git a/engines/nancy/action/staticbitmapanim.h b/engines/nancy/action/staticbitmapanim.h
index f0f21d0f0dc..b83973ec768 100644
--- a/engines/nancy/action/staticbitmapanim.h
+++ b/engines/nancy/action/staticbitmapanim.h
@@ -36,7 +36,7 @@ namespace Action {
// action record types, whose functionality is nearly identical
class PlayStaticBitmapAnimation : public ActionRecord, public RenderObject {
public:
- PlayStaticBitmapAnimation(bool interruptible, RenderObject &redrawFrom) : RenderObject(redrawFrom, 7), _isInterruptible(interruptible) {}
+ PlayStaticBitmapAnimation(bool interruptible) : RenderObject(7), _isInterruptible(interruptible) {}
virtual ~PlayStaticBitmapAnimation() { _fullSurface.free(); }
void init() override;
diff --git a/engines/nancy/action/telephone.h b/engines/nancy/action/telephone.h
index 22b2860de56..593f91f6846 100644
--- a/engines/nancy/action/telephone.h
+++ b/engines/nancy/action/telephone.h
@@ -43,8 +43,8 @@ public:
enum CallState { kWaiting, kButtonPress, kRinging, kBadNumber, kCall, kHangUp };
- Telephone(RenderObject &redrawFrom) :
- RenderObject(redrawFrom, 7),
+ Telephone() :
+ RenderObject(7),
_callState(kWaiting),
_selected(0) {}
virtual ~Telephone() {}
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 56c908b7f0f..c2ed5892aa8 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -51,37 +51,58 @@ void GraphicsManager::init() {
}
void GraphicsManager::draw() {
+ Common::List<Common::Rect> dirtyRects;
+
+ // Update graphics for all RenderObjects and determine
+ // the areas of the screen that need to be redrawn
for (auto it : _objects) {
RenderObject ¤t = *it;
current.updateGraphics();
- if (current._isVisible && current._needsRedraw) {
- // object is visible and updated
-
- if (current._redrawFrom) {
+ if (current._needsRedraw) {
+ if (current._isVisible) {
if (current.hasMoved() && !current.getPreviousScreenPosition().isEmpty()) {
- // Redraw previous location if moved
- blitToScreen(*current._redrawFrom, current.getPreviousScreenPosition());
+ // Object moved to a new location on screen, update the previous one
+ dirtyRects.push_back(current.getPreviousScreenPosition());
}
- if (current._drawSurface.hasTransparentColor()) {
- // Redraw below if transparent
- blitToScreen(*current._redrawFrom, current.getScreenPosition());
- }
+ // Redraw the current location
+ dirtyRects.push_back(current.getScreenPosition());
+ } else if (!current.getPreviousScreenPosition().isEmpty()) {
+ // Object just turned invisible, redraw the last location
+ dirtyRects.push_back(current.getPreviousScreenPosition());
}
-
- // Draw the object itself
- blitToScreen(current, current.getScreenPosition());
- } else if (!current._isVisible && current._needsRedraw && current._redrawFrom && !current.getPreviousScreenPosition().isEmpty()) {
- // Object just turned invisible, redraw below
- blitToScreen(*current._redrawFrom, current.getPreviousScreenPosition());
}
-
+
current._needsRedraw = false;
current._previousScreenPosition = current._screenPosition;
}
+ // Filter out dirty rects that are completely inside others to reduce overdraw
+ for (Common::Rect &outer : dirtyRects) {
+ for (Common::Rect &inner : dirtyRects) {
+ if (inner != outer && outer.contains(inner)) {
+ dirtyRects.remove(inner);
+ }
+ }
+ }
+
+ // Redraw all dirty rects
+ for (auto it : _objects) {
+ RenderObject ¤t = *it;
+
+ if (!current._isVisible || current.getScreenPosition().isEmpty()) {
+ continue;
+ }
+
+ for (Common::Rect rect : dirtyRects) {
+ if (rect.intersects(current.getScreenPosition())) {
+ blitToScreen(current, rect.findIntersectingRect(current.getScreenPosition()));
+ }
+ }
+ }
+
// Draw the screen
_screen.update();
}
diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index 4f289f5ae03..9b5829eb29a 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -30,17 +30,10 @@ namespace Nancy {
RenderObject::RenderObject(uint16 zOrder) :
_needsRedraw(true),
_isVisible(true),
- _redrawFrom(nullptr),
_z(zOrder) {}
-RenderObject::RenderObject(RenderObject &redrawFrom, uint16 zOrder) :
- _needsRedraw(true),
- _isVisible(true),
- _redrawFrom(&redrawFrom),
- _z(zOrder) {}
-
-RenderObject::RenderObject(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
- RenderObject(redrawFrom, zOrder) {
+RenderObject::RenderObject(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
+ RenderObject(zOrder) {
_drawSurface.create(surface, srcBounds);
_screenPosition = destBounds;
}
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index 3e12fefa11d..a15eeab50dc 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -31,14 +31,12 @@ class GraphicsManager;
// Loosely equivalent to the original engine's ZRenderStructs.
// A subclass of this will be automatically updated and drawn from the graphics manager,
-// but initialization needs to be done manually. Objects are expected to know which
-// object is below them at creation.
+// but initialization needs to be done manually.
class RenderObject {
friend class GraphicsManager;
public:
RenderObject(uint16 zOrder);
- RenderObject(RenderObject &redrawFrom, uint16 zOrder);
- RenderObject(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
+ RenderObject(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
virtual ~RenderObject();
@@ -71,9 +69,7 @@ protected:
// Needed for proper handling of objects inside the viewport
virtual bool isViewportRelative() const { return false; }
-
- RenderObject *_redrawFrom;
-
+
bool _needsRedraw;
bool _isVisible;
uint16 _z;
diff --git a/engines/nancy/state/credits.h b/engines/nancy/state/credits.h
index 105182f0fc3..2e982003ed6 100644
--- a/engines/nancy/state/credits.h
+++ b/engines/nancy/state/credits.h
@@ -38,7 +38,7 @@ namespace State {
class Credits : public State, public Common::Singleton<Credits> {
public:
enum State { kInit, kRun };
- Credits() : _state(kInit), _background(), _text(_background), _pixelsToScroll(0) {}
+ Credits() : _state(kInit), _background(), _text(), _pixelsToScroll(0) {}
// State API
void process() override;
@@ -51,7 +51,7 @@ protected:
class CreditsText : public RenderObject {
friend class Credits;
public:
- CreditsText(RenderObject &redrawFrom) : RenderObject(redrawFrom, 1) {}
+ CreditsText() : RenderObject(1) {}
virtual ~CreditsText() = default;
};
diff --git a/engines/nancy/state/help.cpp b/engines/nancy/state/help.cpp
index 2f8cf36af69..1e1a15e844e 100644
--- a/engines/nancy/state/help.cpp
+++ b/engines/nancy/state/help.cpp
@@ -81,7 +81,7 @@ void Help::init() {
buttonSrc.right = chunk->readUint16LE();
buttonSrc.bottom = chunk->readUint16LE();
- _button = new UI::Button(_image, 5, _image._drawSurface, buttonSrc, buttonDest);
+ _button = new UI::Button(5, _image._drawSurface, buttonSrc, buttonDest);
_button->init();
_state = kBegin;
diff --git a/engines/nancy/state/mainmenu.h b/engines/nancy/state/mainmenu.h
index e6ddfabec1b..384785bdf41 100644
--- a/engines/nancy/state/mainmenu.h
+++ b/engines/nancy/state/mainmenu.h
@@ -34,7 +34,7 @@ namespace State {
class MainMenu : public State, public Common::Singleton<MainMenu> {
friend class MainMenuButton;
public:
- MainMenu() : _state(kInit), _selected(-1), _playedOKSound(false), _buttonDown(_background, 5) {}
+ MainMenu() : _state(kInit), _selected(-1), _playedOKSound(false), _buttonDown(5) {}
// State API
void process() override;
diff --git a/engines/nancy/state/map.cpp b/engines/nancy/state/map.cpp
index dbf56576e32..b4501deb4cf 100644
--- a/engines/nancy/state/map.cpp
+++ b/engines/nancy/state/map.cpp
@@ -43,8 +43,8 @@ Map::Map() : _state(kInit),
_mapButtonClicked(false),
_pickedLocationID(-1),
_viewport(),
- _label(NancySceneState.getFrame(), 7),
- _closedLabel(NancySceneState.getFrame(), 7),
+ _label(7),
+ _closedLabel(7),
_button(nullptr) {}
Map::~Map() {
@@ -87,7 +87,7 @@ void Map::init() {
setLabel(-1);
- _button = new UI::Button(NancySceneState.getFrame(), 9, g_nancy->_graphicsManager->_object0, buttonSrc, buttonDest);
+ _button = new UI::Button(9, g_nancy->_graphicsManager->_object0, buttonSrc, buttonDest);
_button->init();
_button->setVisible(true);
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 84d216c0319..3ba24cc8a88 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -98,8 +98,8 @@ Scene::Scene() :
_gameStateRequested(NancyState::kNone),
_frame(),
_viewport(),
- _textbox(_frame),
- _inventoryBox(_frame),
+ _textbox(),
+ _inventoryBox(),
_menuButton(nullptr),
_helpButton(nullptr),
_viewportOrnaments(nullptr),
@@ -659,18 +659,18 @@ void Scene::initStaticData() {
readRect(*chunk, helpSrc);
readRect(*chunk, menuDest);
readRect(*chunk, helpDest);
- _menuButton = new UI::Button(_frame, 5, g_nancy->_graphicsManager->_object0, menuSrc, menuDest);
- _helpButton = new UI::Button(_frame, 5, g_nancy->_graphicsManager->_object0, helpSrc, helpDest);
+ _menuButton = new UI::Button(5, g_nancy->_graphicsManager->_object0, menuSrc, menuDest);
+ _helpButton = new UI::Button(5, g_nancy->_graphicsManager->_object0, helpSrc, helpDest);
_menuButton->init();
_helpButton->init();
g_nancy->_cursorManager->showCursor(true);
// Init ornaments (TVD only)
if (g_nancy->getGameType() == Nancy::GameType::kGameTypeVampire) {
- _viewportOrnaments = new UI::ViewportOrnaments(_viewport, 9);
+ _viewportOrnaments = new UI::ViewportOrnaments(9);
_viewportOrnaments->init();
- _textboxOrnaments = new UI::TextboxOrnaments(_textbox, 9);
+ _textboxOrnaments = new UI::TextboxOrnaments(9);
_textboxOrnaments->init();
}
diff --git a/engines/nancy/ui/button.cpp b/engines/nancy/ui/button.cpp
index decb3bb75af..06d7903d849 100644
--- a/engines/nancy/ui/button.cpp
+++ b/engines/nancy/ui/button.cpp
@@ -33,8 +33,8 @@
namespace Nancy {
namespace UI {
-Button::Button(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
- RenderObject(redrawFrom, zOrder, surface, srcBounds, destBounds),
+Button::Button(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
+ RenderObject(zOrder, surface, srcBounds, destBounds),
_isClicked(false) {
setVisible(false);
setTransparent(true);
diff --git a/engines/nancy/ui/button.h b/engines/nancy/ui/button.h
index 811513b409f..aca785f3e7e 100644
--- a/engines/nancy/ui/button.h
+++ b/engines/nancy/ui/button.h
@@ -32,7 +32,7 @@ namespace UI {
class Button : public RenderObject {
public:
- Button(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
+ Button(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
virtual ~Button() = default;
void handleInput(NancyInput &input);
diff --git a/engines/nancy/ui/inventorybox.cpp b/engines/nancy/ui/inventorybox.cpp
index 20e52eaae40..f88ac99730d 100644
--- a/engines/nancy/ui/inventorybox.cpp
+++ b/engines/nancy/ui/inventorybox.cpp
@@ -37,10 +37,10 @@
namespace Nancy {
namespace UI {
-InventoryBox::InventoryBox(RenderObject &redrawFrom) :
- RenderObject(redrawFrom, 6),
+InventoryBox::InventoryBox() :
+ RenderObject(6),
_scrollbar(nullptr),
- _curtains(*this, this),
+ _curtains(this),
_scrollbarPos(0),
_curtainsFrameTime(0) {}
@@ -111,7 +111,7 @@ void InventoryBox::init() {
RenderObject::init();
- _scrollbar = new Scrollbar(NancySceneState.getFrame(), 9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ _scrollbar = new Scrollbar(9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
_scrollbar->init();
_curtains.init();
}
diff --git a/engines/nancy/ui/inventorybox.h b/engines/nancy/ui/inventorybox.h
index 85fbe535e52..78dc37381fa 100644
--- a/engines/nancy/ui/inventorybox.h
+++ b/engines/nancy/ui/inventorybox.h
@@ -51,7 +51,7 @@ public:
Common::Rect sourceRect; // 0x16
};
- InventoryBox(RenderObject &redrawFrom);
+ InventoryBox();
virtual ~InventoryBox();
void init() override;
@@ -73,8 +73,8 @@ private:
class Curtains : public RenderObject {
public:
- Curtains(RenderObject &redrawFrom, InventoryBox *parent) :
- RenderObject(redrawFrom, 9),
+ Curtains(InventoryBox *parent) :
+ RenderObject(9),
_parent(parent),
_soundTriggered(false),
_areOpen(false),
diff --git a/engines/nancy/ui/ornaments.h b/engines/nancy/ui/ornaments.h
index 119950ee857..97351070b35 100644
--- a/engines/nancy/ui/ornaments.h
+++ b/engines/nancy/ui/ornaments.h
@@ -29,7 +29,7 @@ namespace UI {
class ViewportOrnaments : public Nancy::RenderObject {
public:
- ViewportOrnaments(Nancy::RenderObject &redrawFrom, uint16 zOrder) : RenderObject(redrawFrom, zOrder) {}
+ ViewportOrnaments(uint16 zOrder) : RenderObject(zOrder) {}
virtual ~ViewportOrnaments() {}
void init() override;
@@ -37,7 +37,7 @@ public:
class TextboxOrnaments : public Nancy::RenderObject {
public:
- TextboxOrnaments(Nancy::RenderObject &redrawFrom, uint16 zOrder) : RenderObject(redrawFrom, zOrder) {}
+ TextboxOrnaments(uint16 zOrder) : RenderObject(zOrder) {}
virtual ~TextboxOrnaments() {}
void init() override;
diff --git a/engines/nancy/ui/scrollbar.cpp b/engines/nancy/ui/scrollbar.cpp
index d0e30942274..b12b6e3ceab 100644
--- a/engines/nancy/ui/scrollbar.cpp
+++ b/engines/nancy/ui/scrollbar.cpp
@@ -29,8 +29,8 @@
namespace Nancy {
namespace UI {
-Scrollbar::Scrollbar(RenderObject &redrawFrom, uint16 zOrder, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical) :
- RenderObject(redrawFrom, zOrder),
+Scrollbar::Scrollbar(uint16 zOrder, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical) :
+ RenderObject(zOrder),
_isVertical(isVertical),
_isClicked(false),
_currentPosition(0),
diff --git a/engines/nancy/ui/scrollbar.h b/engines/nancy/ui/scrollbar.h
index 4b18a90af12..9129c6d38f6 100644
--- a/engines/nancy/ui/scrollbar.h
+++ b/engines/nancy/ui/scrollbar.h
@@ -32,7 +32,7 @@ namespace UI {
class Scrollbar : public RenderObject {
public:
- Scrollbar(RenderObject &redrawFrom, uint16 zOrder, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical = true);
+ Scrollbar(uint16 zOrder, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical = true);
virtual ~Scrollbar() = default;
void init() override;
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index e925527ce45..f2f92907ef8 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -42,8 +42,8 @@ const char Textbox::_newLineToken[] = "<n>";
const char Textbox::_tabToken[] = "<t>";
const char Textbox::_telephoneEndToken[] = "<e>";
-Textbox::Textbox(RenderObject &redrawFrom) :
- RenderObject(redrawFrom, 6),
+Textbox::Textbox() :
+ RenderObject(6),
_firstLineOffset(0),
_lineHeight(0),
_borderWidth(0),
@@ -88,7 +88,7 @@ void Textbox::init() {
RenderObject::init();
- _scrollbar = new Scrollbar(NancySceneState.getFrame(), 9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ _scrollbar = new Scrollbar(9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
_scrollbar->init();
}
diff --git a/engines/nancy/ui/textbox.h b/engines/nancy/ui/textbox.h
index 90a4edc8236..690db4d5572 100644
--- a/engines/nancy/ui/textbox.h
+++ b/engines/nancy/ui/textbox.h
@@ -36,7 +36,7 @@ class Scrollbar;
class Textbox : public Nancy::RenderObject {
public:
- Textbox(RenderObject &redrawFrom);
+ Textbox();
virtual ~Textbox();
void init() override;
Commit: 8e69d52ce36cfad3d3f10007ee048f8d196e218a
https://github.com/scummvm/scummvm/commit/8e69d52ce36cfad3d3f10007ee048f8d196e218a
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-02-25T19:37:23+02:00
Commit Message:
NANCY: The Vampire Diaries scrollbar visual fixes
Scrollbars in The Vampire Diaries are now drawn one pixel to the left
so they are in the exact spot as the original engine. Also, the textbox
scrollbar now correctly overlaps the inventory box curtains.
Changed paths:
engines/nancy/ui/textbox.cpp
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index f2f92907ef8..74e1093d4ba 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -70,6 +70,12 @@ void Textbox::init() {
Common::Point scrollbarDefaultPos;
scrollbarDefaultPos.x = chunk->readUint16LE();
scrollbarDefaultPos.y = chunk->readUint16LE();
+
+ // TVD handles coordinates differently, so we need to nudge scrollbars one pixel to the left
+ if (g_nancy->getGameType() == Nancy::GameType::kGameTypeVampire) {
+ scrollbarDefaultPos.x -= 1;
+ }
+
uint16 scrollbarMaxScroll = chunk->readUint16LE();
_firstLineOffset = chunk->readUint16LE() + 1;
@@ -88,7 +94,8 @@ void Textbox::init() {
RenderObject::init();
- _scrollbar = new Scrollbar(9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ // zOrder bumped by 1 to avoid overlap with the inventory box curtains in The Vampire Diaries
+ _scrollbar = new Scrollbar(10, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
_scrollbar->init();
}
Commit: e7f6852f1cb93434c2b44b337e0683203d835849
https://github.com/scummvm/scummvm/commit/e7f6852f1cb93434c2b44b337e0683203d835849
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-02-25T19:37:24+02:00
Commit Message:
NANCY: Remove leftover friend class declarations
Changed paths:
engines/nancy/state/map.h
engines/nancy/ui/inventorybox.h
diff --git a/engines/nancy/state/map.h b/engines/nancy/state/map.h
index cc26aafc60d..0b6b06d2e4d 100644
--- a/engines/nancy/state/map.h
+++ b/engines/nancy/state/map.h
@@ -39,8 +39,6 @@ class Button;
namespace State {
class Map : public State, public Common::Singleton<Map> {
- friend class MapLabel;
- friend class MapButton;
public:
enum State { kInit, kRun };
Map();
diff --git a/engines/nancy/ui/inventorybox.h b/engines/nancy/ui/inventorybox.h
index 78dc37381fa..f4b9f0e4ac8 100644
--- a/engines/nancy/ui/inventorybox.h
+++ b/engines/nancy/ui/inventorybox.h
@@ -40,8 +40,6 @@ namespace UI {
class Scrollbar;
class InventoryBox : public RenderObject {
- friend class InventoryScrollbar;
- friend class Shades;
friend class Nancy::State::Scene;
public:
Commit: cebaa64088858e1cd3f94bda875a38b1fceb6779
https://github.com/scummvm/scummvm/commit/cebaa64088858e1cd3f94bda875a38b1fceb6779
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-02-25T19:37:24+02:00
Commit Message:
NANCY: Fix buttons in The Vampire Diaries
Made the menu and help buttons in The Vampire Diaries functional.
Changed paths:
engines/nancy/state/scene.cpp
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 3ba24cc8a88..d6d2910af8e 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -653,7 +653,11 @@ void Scene::initStaticData() {
// Init menu and help buttons
chunk = g_nancy->getBootChunkStream("BSUM");
- chunk->seek(0x184);
+ chunk->seek(0);
+ Common::Serializer ser(chunk, nullptr);
+ ser.setVersion(g_nancy->getGameType());
+ ser.skip(0x176, kGameTypeVampire, kGameTypeVampire);
+ ser.skip(0x184, kGameTypeNancy1);
Common::Rect menuSrc, helpSrc, menuDest, helpDest;
readRect(*chunk, menuSrc);
readRect(*chunk, helpSrc);
@@ -666,7 +670,7 @@ void Scene::initStaticData() {
g_nancy->_cursorManager->showCursor(true);
// Init ornaments (TVD only)
- if (g_nancy->getGameType() == Nancy::GameType::kGameTypeVampire) {
+ if (g_nancy->getGameType() == kGameTypeVampire) {
_viewportOrnaments = new UI::ViewportOrnaments(9);
_viewportOrnaments->init();
More information about the Scummvm-git-logs
mailing list