[Scummvm-git-logs] scummvm master -> 503d1d8c1dea24125efe1af18c9484bdf3373f92
fracturehill
76959842+fracturehill at users.noreply.github.com
Thu Apr 15 12:13:14 UTC 2021
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7e50ecd0ac NANCY: Add stubs for The Vampire Diaries action record types
f255542672 NANCY: Scrollbar fixes
c9b2e4473d NANCY: Button fixes
a29cdd43c0 NANCY: Make RenderObject non-abstract
533f8aebf2 NANCY: Correctly implement map labels
503d1d8c1d NANCY: Update The Vampire Diaries detection entry
Commit: 7e50ecd0aca41966257846d68159575ab03a8aec
https://github.com/scummvm/scummvm/commit/7e50ecd0aca41966257846d68159575ab03a8aec
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-15T15:11:58+03:00
Commit Message:
NANCY: Add stubs for The Vampire Diaries action record types
Added declarations for all action record types unique to The Vampire Diaries. Made all unimplemented action record types output a debug message when encountered.
Changed paths:
engines/nancy/action/arfactory.cpp
engines/nancy/action/recordtypes.cpp
engines/nancy/action/recordtypes.h
diff --git a/engines/nancy/action/arfactory.cpp b/engines/nancy/action/arfactory.cpp
index 52cfc84b28..a62a03f46c 100644
--- a/engines/nancy/action/arfactory.cpp
+++ b/engines/nancy/action/arfactory.cpp
@@ -51,12 +51,32 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
return new HotMultiframeMultisceneChange();
case 0x04:
return new Hot1FrExitSceneChange();
+ case 0x0A:
+ return new PaletteThisScene();
+ case 0x0B:
+ return new PaletteNextScene();
case 0x0C:
return new StartFrameNextScene();
case 0x14:
return new StartStopPlayerScrolling(); // TODO
case 0x15:
return new StartStopPlayerScrolling(); // TODO
+ case 0x1E:
+ return new LightningOn();
+ case 0x1F:
+ return new LightningOff();
+ case 0x20:
+ return new AmbientLightUp();
+ case 0x21:
+ return new AmbientLightDown();
+ case 0x22:
+ return new AmbientLightToTod();
+ case 0x23:
+ return new AmbientLightToTodOff();
+ case 0x24:
+ return new FlickerOn();
+ case 0x25:
+ return new FlickerOff();
case 0x28:
return new PlayPrimaryVideoChan0(NancySceneState.getViewport());
case 0x29:
@@ -77,6 +97,10 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
return new MapCallHotMultiframe();
case 0x35:
return new MapLocationAccess();
+ case 0x36:
+ return new MapLightning();
+ case 0x37:
+ return new MapLightningOff();
case 0x38:
return new MapSound();
case 0x39:
diff --git a/engines/nancy/action/recordtypes.cpp b/engines/nancy/action/recordtypes.cpp
index 4186e503db..f2ffa22417 100644
--- a/engines/nancy/action/recordtypes.cpp
+++ b/engines/nancy/action/recordtypes.cpp
@@ -35,6 +35,11 @@
namespace Nancy {
namespace Action {
+void Unimplemented::execute() {
+ debugC(Nancy::kDebugActionRecord, "Unimplemented Action Record type %s", getRecordTypeName().c_str());
+ _isDone = true;
+}
+
void SceneChange::readData(Common::SeekableReadStream &stream) {
_sceneChange.readData(stream);
}
@@ -107,6 +112,14 @@ void HotMultiframeMultisceneChange::readData(Common::SeekableReadStream &stream)
stream.skip(size);
}
+void PaletteThisScene::readData(Common::SeekableReadStream &stream) {
+ stream.skip(6);
+}
+
+void PaletteNextScene::readData(Common::SeekableReadStream &stream) {
+ stream.skip(6);
+}
+
void StartFrameNextScene::readData(Common::SeekableReadStream &stream) {
stream.skip(4);
}
@@ -115,6 +128,38 @@ void StartStopPlayerScrolling::readData(Common::SeekableReadStream &stream) {
stream.skip(1);
}
+void LightningOn::readData(Common::SeekableReadStream &stream) {
+ stream.skip(0xA);
+}
+
+void LightningOff::readData(Common::SeekableReadStream &stream) {
+ stream.skip(1);
+}
+
+void AmbientLightUp::readData(Common::SeekableReadStream &stream) {
+ stream.skip(0x12);
+}
+
+void AmbientLightDown::readData(Common::SeekableReadStream &stream) {
+ stream.skip(0x12);
+}
+
+void AmbientLightToTod::readData(Common::SeekableReadStream &stream) {
+ stream.skip(0x1C);
+}
+
+void AmbientLightToTodOff::readData(Common::SeekableReadStream &stream) {
+ stream.skip(1);
+}
+
+void FlickerOn::readData(Common::SeekableReadStream &stream) {
+ stream.skip(0xA);
+}
+
+void FlickerOff::readData(Common::SeekableReadStream &stream) {
+ stream.skip(1);
+}
+
void MapCall::readData(Common::SeekableReadStream &stream) {
stream.skip(1);
}
@@ -179,6 +224,14 @@ void MapLocationAccess::readData(Common::SeekableReadStream &stream) {
stream.skip(4);
}
+void MapLightning::readData(Common::SeekableReadStream &stream) {
+ stream.skip(0xA);
+}
+
+void MapLightningOff::readData(Common::SeekableReadStream &stream) {
+ stream.skip(1);
+}
+
void MapSound::readData(Common::SeekableReadStream &stream) {
stream.skip(0x10);
}
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index bbbc722f2f..dadc6b597a 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -34,6 +34,10 @@ class NancyEngine;
namespace Action {
+class Unimplemented : public ActionRecord {
+ virtual void execute() override;
+};
+
class SceneChange : public ActionRecord {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -74,7 +78,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "Hot1FrExitSceneChange"; }
};
-class HotMultiframeMultisceneChange : public ActionRecord {
+class HotMultiframeMultisceneChange : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -82,7 +86,23 @@ protected:
virtual Common::String getRecordTypeName() const override { return "HotMultiframeMultisceneChange"; }
};
-class StartFrameNextScene : public ActionRecord {
+class PaletteThisScene : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "PaletteThisScene"; }
+};
+
+class PaletteNextScene : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "PaletteNextScene"; }
+};
+
+class StartFrameNextScene : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -90,7 +110,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "StartFrameNextScene"; }
};
-class StartStopPlayerScrolling : public ActionRecord {
+class StartStopPlayerScrolling : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
// TODO add a Start and Stop subclass
@@ -101,6 +121,70 @@ protected:
virtual Common::String getRecordTypeName() const override { return "StartStopPlayerScrolling"; }
};
+class LightningOn : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "LightningOn"; }
+};
+
+class LightningOff : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "LightningOff"; }
+};
+
+class AmbientLightUp : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "AmbientLightUp"; }
+};
+
+class AmbientLightDown : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "AmbientLightDown"; }
+};
+
+class AmbientLightToTod : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "AmbientLightToTod"; }
+};
+
+class AmbientLightToTodOff : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "AmbientLightToTodOff"; }
+};
+
+class FlickerOn : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "FlickerOn"; }
+};
+
+class FlickerOff : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "FlickerOff"; }
+};
+
class MapCall : public ActionRecord {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -134,7 +218,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "MapCallHotMultiframe"; }
};
-class MapLocationAccess : public ActionRecord {
+class MapLocationAccess : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -142,7 +226,23 @@ protected:
virtual Common::String getRecordTypeName() const override { return "MapLocationAccess"; }
};
-class MapSound : public ActionRecord {
+class MapLightning : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "MapLightning"; }
+};
+
+class MapLightningOff : public Unimplemented {
+public:
+ virtual void readData(Common::SeekableReadStream &stream) override;
+
+protected:
+ virtual Common::String getRecordTypeName() const override { return "MapLightningOff"; }
+};
+
+class MapSound : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -150,7 +250,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "MapSound"; }
};
-class MapAviOverride : public ActionRecord {
+class MapAviOverride : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -158,7 +258,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "MapAviOverride"; }
};
-class MapAviOverrideOff : public ActionRecord {
+class MapAviOverrideOff : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -166,7 +266,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "MapAviOverrideOff"; }
};
-class TextBoxWrite : public ActionRecord {
+class TextBoxWrite : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -174,7 +274,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "TextBoxWrite"; }
};
-class TextBoxClear : public ActionRecord {
+class TextBoxClear : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -182,7 +282,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "TextBoxClear"; }
};
-class BumpPlayerClock : public ActionRecord {
+class BumpPlayerClock : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -199,7 +299,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "SaveContinueGame"; }
};
-class TurnOffMainRendering : public ActionRecord {
+class TurnOffMainRendering : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -207,7 +307,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "TurnOffMainRendering"; }
};
-class TurnOnMainRendering : public ActionRecord {
+class TurnOnMainRendering : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -264,7 +364,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "LoseGame"; }
};
-class PushScene : public ActionRecord {
+class PushScene : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -272,7 +372,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "PushScene"; }
};
-class PopScene : public ActionRecord {
+class PopScene : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -300,7 +400,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "AddInventoryNoHS"; }
};
-class RemoveInventoryNoHS : public ActionRecord {
+class RemoveInventoryNoHS : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
@@ -359,7 +459,7 @@ protected:
virtual Common::String getRecordTypeName() const override { return "PlayDigiSoundAndDie"; }
};
-class PlaySoundPanFrameAnchorAndDie : public ActionRecord {
+class PlaySoundPanFrameAnchorAndDie : public Unimplemented {
public:
virtual void readData(Common::SeekableReadStream &stream) override;
Commit: f2555426720d8c51c223d8cd7cc4b8b32dd7b747
https://github.com/scummvm/scummvm/commit/f2555426720d8c51c223d8cd7cc4b8b32dd7b747
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-15T15:11:59+03:00
Commit Message:
NANCY: Scrollbar fixes
Changed the UI::Scrollbar class so it doesn't require subclassing and added functionality for horizontal scrollbars. Fixed the textbox and inventory box scrollbars so their lowest point is consistent with the original engine's.
Changed paths:
engines/nancy/ui/inventorybox.cpp
engines/nancy/ui/inventorybox.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/ui/inventorybox.cpp b/engines/nancy/ui/inventorybox.cpp
index d158fee72a..e2af69ed07 100644
--- a/engines/nancy/ui/inventorybox.cpp
+++ b/engines/nancy/ui/inventorybox.cpp
@@ -32,18 +32,35 @@
#include "engines/nancy/state/scene.h"
+#include "engines/nancy/ui/scrollbar.h"
+
namespace Nancy {
namespace UI {
+InventoryBox::InventoryBox(RenderObject &redrawFrom) :
+ RenderObject(redrawFrom),
+ _scrollbar(nullptr),
+ _shades(*this, this),
+ _scrollbarPos(0),
+ _shadesFrameTime(0) {}
+
+InventoryBox::~InventoryBox() {
+ _fullInventorySurface.free();
+ _iconsSurface.free(); delete _scrollbar;
+}
+
void InventoryBox::init() {
Common::SeekableReadStream &stream = *g_nancy->getBootChunkStream("INV");
stream.seek(0, SEEK_SET);
_order.clear();
- readRect(stream, _sliderSource);
- _sliderDefaultDest.x = stream.readUint16LE();
- _sliderDefaultDest.y = stream.readUint16LE();
+ Common::Rect scrollbarSrcBounds;
+ readRect(stream, scrollbarSrcBounds);
+ Common::Point scrollbarDefaultPos;
+ scrollbarDefaultPos.x = stream.readUint16LE();
+ scrollbarDefaultPos.y = stream.readUint16LE();
+ uint16 scrollbarMaxScroll = stream.readUint16LE();
stream.seek(0xD6, SEEK_SET);
@@ -89,13 +106,14 @@ void InventoryBox::init() {
RenderObject::init();
- _scrollbar.init();
+ _scrollbar = new Scrollbar(NancySceneState.getFrame(), scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ _scrollbar->init();
_shades.init();
}
void InventoryBox::updateGraphics() {
- if (_scrollbarPos != _scrollbar.getPos()) {
- _scrollbarPos = _scrollbar.getPos();
+ if (_scrollbarPos != _scrollbar->getPos()) {
+ _scrollbarPos = _scrollbar->getPos();
onScrollbarMove();
}
@@ -103,13 +121,13 @@ void InventoryBox::updateGraphics() {
void InventoryBox::registerGraphics() {
RenderObject::registerGraphics();
- _scrollbar.registerGraphics();
+ _scrollbar->registerGraphics();
_shades.registerGraphics();
}
void InventoryBox::handleInput(NancyInput &input) {
if (_order.size()) {
- _scrollbar.handleInput(input);
+ _scrollbar->handleInput(input);
}
for (uint i = 0; i < 4; ++i) {
@@ -189,7 +207,7 @@ void InventoryBox::setHotspots(uint pageNr) {
}
void InventoryBox::onScrollbarMove() {
- float scrollPos = _scrollbar.getPos();
+ float scrollPos = _scrollbar->getPos();
float numPages = (_order.size() - 1) / 4 + 1;
float pageFrac = 1 / numPages;
@@ -204,23 +222,6 @@ void InventoryBox::onScrollbarMove() {
_needsRedraw = true;
}
-void InventoryBox::InventoryScrollbar::init() {
- Common::Rect &srcBounds = _parent->_sliderSource;
- Common::Point &topPosition = _parent->_sliderDefaultDest;
-
- _drawSurface.create(g_nancy->_graphicsManager->_object0, srcBounds);
-
- _startPosition = topPosition;
- _startPosition.x -= srcBounds.width() / 2;
-
- _screenPosition = srcBounds;
- _screenPosition.moveTo(_startPosition);
-
- _maxDist = _parent->getBounds().height() - _drawSurface.h;
-
- Scrollbar::init();
-}
-
void InventoryBox::Shades::init() {
Common::Rect bounds = _parent->getBounds();
_drawSurface.create(bounds.width(), bounds.height(), g_nancy->_graphicsManager->getScreenPixelFormat());
diff --git a/engines/nancy/ui/inventorybox.h b/engines/nancy/ui/inventorybox.h
index bb1de0f0a5..b63f50be45 100644
--- a/engines/nancy/ui/inventorybox.h
+++ b/engines/nancy/ui/inventorybox.h
@@ -25,7 +25,7 @@
#include "engines/nancy/time.h"
-#include "engines/nancy/ui/scrollbar.h"
+#include "engines/nancy/renderobject.h"
namespace Nancy {
@@ -38,6 +38,8 @@ class Scene;
namespace UI {
+class Scrollbar;
+
class InventoryBox : public RenderObject {
friend class InventoryScrollbar;
friend class Shades;
@@ -50,14 +52,8 @@ public:
Common::Rect sourceRect; // 0x16
};
- InventoryBox(RenderObject &redrawFrom) :
- RenderObject(redrawFrom),
- _scrollbar(redrawFrom, this),
- _shades(*this, this),
- _scrollbarPos(0),
- _shadesFrameTime(0) {}
-
- virtual ~InventoryBox() { _fullInventorySurface.free(); _iconsSurface.free(); }
+ InventoryBox(RenderObject &redrawFrom);
+ virtual ~InventoryBox();
virtual void init() override;
virtual void updateGraphics() override;
@@ -79,19 +75,6 @@ private:
void onReorder();
void setHotspots(uint pageNr);
- class InventoryScrollbar : public Scrollbar {
- public:
- InventoryScrollbar(RenderObject &redrawFrom, InventoryBox *parent) :
- Scrollbar(redrawFrom),
- _parent(parent) {}
- virtual ~InventoryScrollbar() = default;
-
- virtual void init() override;
-
- protected:
- InventoryBox *_parent;
- };
-
class Shades : public RenderObject {
public:
Shades(RenderObject &redrawFrom, InventoryBox *parent) :
@@ -128,7 +111,7 @@ private:
Graphics::Surface _iconsSurface;
Graphics::ManagedSurface _fullInventorySurface;
- InventoryScrollbar _scrollbar;
+ Scrollbar *_scrollbar;
Shades _shades;
float _scrollbarPos;
@@ -137,8 +120,6 @@ private:
ItemHotspot _itemHotspots[4];
// INV contents
- Common::Rect _sliderSource; // 0x00
- Common::Point _sliderDefaultDest; // 0x10
//...
Common::Rect _shadesSrc[14]; // 0xD6
// _screenPosition 0x1B6
diff --git a/engines/nancy/ui/scrollbar.cpp b/engines/nancy/ui/scrollbar.cpp
index d5f625ec20..f987c5d1fd 100644
--- a/engines/nancy/ui/scrollbar.cpp
+++ b/engines/nancy/ui/scrollbar.cpp
@@ -21,6 +21,7 @@
*/
#include "engines/nancy/nancy.h"
+#include "engines/nancy/graphics.h"
#include "engines/nancy/input.h"
#include "engines/nancy/cursor.h"
@@ -29,6 +30,21 @@
namespace Nancy {
namespace UI {
+Scrollbar::Scrollbar(RenderObject &redrawFrom, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical) :
+ RenderObject(redrawFrom),
+ _isVertical(isVertical),
+ _isClicked(false),
+ _currentPosition(0),
+ _maxDist(scrollDistance) {
+ _drawSurface.create(g_nancy->_graphicsManager->_object0, srcBounds);
+
+ _startPosition = topPosition;
+ _startPosition.x -= srcBounds.width() / 2;
+
+ _screenPosition = srcBounds;
+ _screenPosition.moveTo(_startPosition);
+}
+
void Scrollbar::init() {
setTransparent(true);
RenderObject::init();
@@ -54,10 +70,18 @@ void Scrollbar::handleInput(NancyInput &input) {
Common::Point newMousePos = input.mousePos - Common::Point(_screenPosition.left, _screenPosition.top);
if (newMousePos != _mousePosOnClick) {
- uint16 minY = _startPosition.y;
- uint16 maxY = minY + _maxDist;
- uint16 newTop = CLIP<uint16>((_screenPosition.top + newMousePos.y - _mousePosOnClick.y), minY, maxY);
- moveTo(Common::Point(_screenPosition.left, newTop));
+
+ if (_isVertical) {
+ uint16 minY = _startPosition.y;
+ uint16 maxY = minY + _maxDist;
+ uint16 newTop = CLIP<uint16>((_screenPosition.top + newMousePos.y - _mousePosOnClick.y), minY, maxY);
+ moveTo(Common::Point(_screenPosition.left, newTop));
+ } else {
+ uint16 minX = _startPosition.x;
+ uint16 maxX = minX + _maxDist;
+ uint16 newLeft = CLIP<uint16>((_screenPosition.left + newMousePos.x - _mousePosOnClick.x), minX, maxX);
+ moveTo(Common::Point(newLeft, _screenPosition.top));
+ }
calculatePosition();
}
@@ -70,9 +94,9 @@ void Scrollbar::handleInput(NancyInput &input) {
}
void Scrollbar::calculatePosition() {
- uint16 scrollY = _screenPosition.top - _startPosition.y;
+ uint16 scroll = _isVertical ? _screenPosition.top - _startPosition.y : _screenPosition.left - _startPosition.x;
- _currentPosition = scrollY != 0 ? (float)scrollY / (float)_maxDist : 0;
+ _currentPosition = scroll != 0 ? (float)scroll / (float)_maxDist : 0;
}
void Scrollbar::resetPosition() {
diff --git a/engines/nancy/ui/scrollbar.h b/engines/nancy/ui/scrollbar.h
index 7919aec04c..f8a8d1fa83 100644
--- a/engines/nancy/ui/scrollbar.h
+++ b/engines/nancy/ui/scrollbar.h
@@ -33,11 +33,7 @@ namespace UI {
class Scrollbar : public RenderObject {
public:
- Scrollbar(RenderObject &redrawFrom) :
- RenderObject(redrawFrom),
- _isClicked(false),
- _currentPosition(0),
- _maxDist(0) {}
+ Scrollbar(RenderObject &redrawFrom, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical = true);
virtual ~Scrollbar() = default;
virtual void init() override;
@@ -54,9 +50,9 @@ protected:
Common::Point _startPosition;
uint _maxDist;
+ bool _isVertical;
float _currentPosition;
-
bool _isClicked;
Common::Point _mousePosOnClick;
};
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index 5df39cd527..27bc1db682 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -29,6 +29,7 @@
#include "engines/nancy/state/scene.h"
#include "engines/nancy/ui/textbox.h"
+#include "engines/nancy/ui/scrollbar.h"
namespace Nancy {
namespace UI {
@@ -42,20 +43,36 @@ const char Textbox::_newLineToken[] = "<n>";
const char Textbox::_tabToken[] = "<t>";
const char Textbox::_telephoneEndToken[] = "<e>";
+Textbox::Textbox(RenderObject &redrawFrom) :
+ RenderObject(redrawFrom),
+ _firstLineOffset(0),
+ _lineHeight(0),
+ _borderWidth(0),
+ _needsTextRedraw(false),
+ _scrollbar(nullptr),
+ _scrollbarPos(0),
+ _numLines(0) {}
+
+Textbox::~Textbox() {
+ delete _scrollbar;
+}
+
void Textbox::init() {
Common::SeekableReadStream *chunk = g_nancy->getBootChunkStream("TBOX");
chunk->seek(0);
- readRect(*chunk, _scrollbarSourceBounds);
+ Common::Rect scrollbarSrcBounds;
+ readRect(*chunk, scrollbarSrcBounds);
chunk->seek(0x20);
Common::Rect innerBoundingBox;
readRect(*chunk, innerBoundingBox);
_fullSurface.create(innerBoundingBox.width(), innerBoundingBox.height(), g_nancy->_graphicsManager->getScreenPixelFormat());
- _scrollbarDefaultDest.x = chunk->readUint16LE();
- _scrollbarDefaultDest.y = chunk->readUint16LE();
+ Common::Point scrollbarDefaultPos;
+ scrollbarDefaultPos.x = chunk->readUint16LE();
+ scrollbarDefaultPos.y = chunk->readUint16LE();
+ uint16 scrollbarMaxScroll = chunk->readUint16LE();
- chunk->seek(0x36);
_firstLineOffset = chunk->readUint16LE();
_lineHeight = chunk->readUint16LE();
// Not sure why but to get exact results we subtract 1
@@ -74,12 +91,13 @@ void Textbox::init() {
RenderObject::init();
- _scrollbar.init();
+ _scrollbar = new Scrollbar(NancySceneState.getFrame(), scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ _scrollbar->init();
}
void Textbox::registerGraphics() {
RenderObject::registerGraphics();
- _scrollbar.registerGraphics();
+ _scrollbar->registerGraphics();
}
void Textbox::updateGraphics() {
@@ -87,8 +105,8 @@ void Textbox::updateGraphics() {
drawTextbox();
}
- if (_scrollbarPos != _scrollbar.getPos()) {
- _scrollbarPos = _scrollbar.getPos();
+ if (_scrollbarPos != _scrollbar->getPos()) {
+ _scrollbarPos = _scrollbar->getPos();
onScrollbarMove();
}
@@ -97,7 +115,7 @@ void Textbox::updateGraphics() {
}
void Textbox::handleInput(NancyInput &input) {
- _scrollbar.handleInput(input);
+ _scrollbar->handleInput(input);
for (uint i = 0; i < _hotspots.size(); ++i) {
Common::Rect hotspot = _hotspots[i];
@@ -231,7 +249,7 @@ void Textbox::clear() {
_fullSurface.clear();
_textLines.clear();
_hotspots.clear();
- _scrollbar.resetPosition();
+ _scrollbar->resetPosition();
_numLines = 0;
onScrollbarMove();
_needsRedraw = true;
@@ -280,22 +298,5 @@ uint16 Textbox::getInnerHeight() const {
return _numLines * lineDist + _firstLineOffset + lineDist / 2;
}
-void Textbox::TextboxScrollbar::init() {
- Common::Rect &srcBounds = _parent->_scrollbarSourceBounds;
- Common::Point &topPosition = _parent->_scrollbarDefaultDest;
-
- _drawSurface.create(g_nancy->_graphicsManager->_object0, srcBounds);
-
- _startPosition = topPosition;
- _startPosition.x -= srcBounds.width() / 2;
-
- _screenPosition = srcBounds;
- _screenPosition.moveTo(_startPosition);
-
- _maxDist = _parent->getBounds().height() - _drawSurface.h;
-
- Scrollbar::init();
-}
-
} // End of namespace UI
} // End of namespace Nancy
diff --git a/engines/nancy/ui/textbox.h b/engines/nancy/ui/textbox.h
index 012866f012..2d15b60d54 100644
--- a/engines/nancy/ui/textbox.h
+++ b/engines/nancy/ui/textbox.h
@@ -23,7 +23,7 @@
#ifndef NANCY_UI_TEXTBOX_H
#define NANCY_UI_TEXTBOX_H
-#include "engines/nancy/ui/scrollbar.h"
+#include "engines/nancy/renderobject.h"
namespace Nancy {
@@ -33,19 +33,12 @@ struct NancyInput;
namespace UI {
+class Scrollbar;
+
class Textbox : public Nancy::RenderObject {
public:
- Textbox(RenderObject &redrawFrom) :
- RenderObject(redrawFrom),
- _firstLineOffset(0),
- _lineHeight(0),
- _borderWidth(0),
- _needsTextRedraw(false),
- _scrollbar(redrawFrom, this),
- _scrollbarPos(0),
- _numLines(0) {}
-
- virtual ~Textbox() { _fullSurface.free(); }
+ Textbox(RenderObject &redrawFrom);
+ virtual ~Textbox();
virtual void init() override;
virtual void registerGraphics() override;
@@ -72,26 +65,13 @@ private:
Common::Rect hotspot;
};
- class TextboxScrollbar : public Scrollbar {
- public:
- TextboxScrollbar(RenderObject &redrawFrom, Textbox *parent) :
- Scrollbar(redrawFrom),
- _parent(parent) {}
- ~TextboxScrollbar() = default;
-
- virtual void init() override;
- Textbox *_parent;
- };
-
Graphics::ManagedSurface _fullSurface;
- TextboxScrollbar _scrollbar;
+ Scrollbar *_scrollbar;
Common::Array<Common::String> _textLines;
Common::Array<Common::Rect> _hotspots;
- Common::Rect _scrollbarSourceBounds;
- Common::Point _scrollbarDefaultDest;
uint16 _firstLineOffset;
uint16 _lineHeight;
uint16 _borderWidth;
Commit: c9b2e4473d5403de396d642d23403fd4165ccdf5
https://github.com/scummvm/scummvm/commit/c9b2e4473d5403de396d642d23403fd4165ccdf5
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-15T15:11:59+03:00
Commit Message:
NANCY: Button fixes
Changed the Button class so it doesn't require subclassing. Added a visible button to the Help screen. Also moved several classes' constructors to fix compilation errors.
Changed paths:
engines/nancy/state/help.cpp
engines/nancy/state/help.h
engines/nancy/state/map.cpp
engines/nancy/state/map.h
engines/nancy/state/scene.cpp
engines/nancy/state/scene.h
engines/nancy/ui/button.cpp
engines/nancy/ui/button.h
diff --git a/engines/nancy/state/help.cpp b/engines/nancy/state/help.cpp
index c96fa79af3..9894893bdc 100644
--- a/engines/nancy/state/help.cpp
+++ b/engines/nancy/state/help.cpp
@@ -28,6 +28,8 @@
#include "engines/nancy/state/help.h"
+#include "engines/nancy/ui/button.h"
+
namespace Common {
DECLARE_SINGLETON(Nancy::State::Help);
}
@@ -35,6 +37,15 @@ DECLARE_SINGLETON(Nancy::State::Help);
namespace Nancy {
namespace State {
+Help::Help() :
+ _state(kInit),
+ _image(),
+ _button(nullptr) {}
+
+Help::~Help() {
+ delete _button;
+}
+
void Help::process() {
switch (_state) {
case kInit:
@@ -61,10 +72,18 @@ void Help::init() {
_image.init(imageName);
chunk->skip(20);
- _hotspot.left = chunk->readUint16LE();
- _hotspot.top = chunk->readUint16LE();
- _hotspot.right = chunk->readUint16LE();
- _hotspot.bottom = chunk->readUint16LE();
+ Common::Rect buttonSrc, buttonDest;
+ buttonDest.left = chunk->readUint16LE();
+ buttonDest.top = chunk->readUint16LE();
+ buttonDest.right = chunk->readUint16LE();
+ buttonDest.bottom = chunk->readUint16LE();
+ buttonSrc.left = chunk->readUint16LE();
+ buttonSrc.top = chunk->readUint16LE();
+ buttonSrc.right = chunk->readUint16LE();
+ buttonSrc.bottom = chunk->readUint16LE();
+
+ _button = new UI::Button(_image, _image.getDrawSurface(), buttonSrc, buttonDest);
+ _button->init();
_state = kBegin;
}
@@ -75,6 +94,7 @@ void Help::begin() {
}
_image.registerGraphics();
+ _button->registerGraphics();
_image.setVisible(true);
g_nancy->_cursorManager->setCursorType(CursorManager::kNormalArrow);
@@ -84,8 +104,10 @@ void Help::begin() {
void Help::run() {
NancyInput input = g_nancy->_input->getInput();
+ _button->handleInput(input);
- if (_hotspot.contains(input.mousePos) && input.input & NancyInput::kLeftMouseButtonUp) {
+ if (_button->_isClicked) {
+ _button->_isClicked = false;
g_nancy->_sound->playSound("BUOK");
_state = kWaitForSound;
}
diff --git a/engines/nancy/state/help.h b/engines/nancy/state/help.h
index 0b798fffd7..cf07a5d4cc 100644
--- a/engines/nancy/state/help.h
+++ b/engines/nancy/state/help.h
@@ -33,12 +33,17 @@
namespace Nancy {
+namespace UI {
+class Button;
+}
+
namespace State {
class Help : public State, public Common::Singleton<Help> {
public:
enum State { kInit, kBegin, kRun, kWaitForSound };
- Help() : _state(kInit), _image() {}
+ Help();
+ virtual ~Help();
// State API
virtual void process() override;
@@ -52,7 +57,7 @@ private:
State _state;
UI::FullScreenImage _image;
- Common::Rect _hotspot; // Can be an array, but isn't in nancy1
+ UI::Button *_button;
};
#define NancyHelpState Nancy::State::Help::instance()
diff --git a/engines/nancy/state/map.cpp b/engines/nancy/state/map.cpp
index e1b3271711..497af841b6 100644
--- a/engines/nancy/state/map.cpp
+++ b/engines/nancy/state/map.cpp
@@ -30,6 +30,8 @@
#include "engines/nancy/state/map.h"
#include "engines/nancy/state/scene.h"
+#include "engines/nancy/ui/button.h"
+
namespace Common {
DECLARE_SINGLETON(Nancy::State::Map);
}
@@ -43,7 +45,11 @@ Map::Map() : _state(kInit),
_pickedLocationID(-1),
_viewport(),
_label(NancySceneState.getFrame(), this),
- _button(NancySceneState.getFrame(), this) {}
+ _button(nullptr) {}
+
+Map::~Map() {
+ delete _button;
+}
void Map::process() {
switch (_state) {
@@ -61,7 +67,15 @@ void Map::init() {
_viewport.init();
_label.init();
- _button.init();
+
+ Common::Rect buttonSrc, buttonDest;
+ chunk->seek(0x7A, SEEK_SET);
+ readRect(*chunk, buttonSrc);
+ readRect(*chunk, buttonDest);
+
+ _button = new UI::Button(NancySceneState.getFrame(), g_nancy->_graphicsManager->_object0, buttonSrc, buttonDest);
+ _button->init();
+ _button->setVisible(true);
if (NancySceneState.getEventFlag(40, kTrue) && // Has set up sting
NancySceneState.getEventFlag(95, kTrue)) { // Connie chickens
@@ -133,9 +147,10 @@ void Map::run() {
_label.setLabel(-1);
- _button.handleInput(input);
+ _button->handleInput(input);
- if (_mapButtonClicked) {
+ if (_button->_isClicked) {
+ _button->_isClicked = false;
g_nancy->setState(NancyState::kScene);
return;
}
@@ -179,7 +194,7 @@ void Map::onStateExit() {
void Map::registerGraphics() {
_viewport.registerGraphics();
_label.registerGraphics();
- _button.registerGraphics();
+ _button->registerGraphics();
}
void Map::MapLabel::init() {
@@ -198,22 +213,5 @@ void Map::MapLabel::setLabel(int labelID) {
}
}
-void Map::MapButton::init() {
- Common::SeekableReadStream *map = g_nancy->getBootChunkStream("MAP");
-
- map->seek(0x7A, SEEK_SET);
- Common::Rect src;
- readRect(*map, src);
- _drawSurface.create(g_nancy->_graphicsManager->_object0, src);
- readRect(*map, _screenPosition);
- setVisible(true);
-
- RenderObject::init();
-}
-
-void Map::MapButton::onClick() {
- _parent->_mapButtonClicked = true;
-}
-
} // End of namespace State
} // End of namespace Nancy
diff --git a/engines/nancy/state/map.h b/engines/nancy/state/map.h
index 147712b816..85d595265d 100644
--- a/engines/nancy/state/map.h
+++ b/engines/nancy/state/map.h
@@ -28,12 +28,15 @@
#include "engines/nancy/state/state.h"
#include "engines/nancy/ui/viewport.h"
-#include "engines/nancy/ui/button.h"
namespace Nancy {
class NancyEngine;
+namespace UI {
+class Button;
+}
+
namespace State {
class Map : public State, public Common::Singleton<Map> {
@@ -42,6 +45,7 @@ class Map : public State, public Common::Singleton<Map> {
public:
enum State { kInit, kRun };
Map();
+ virtual ~Map();
// State API
virtual void process() override;
@@ -78,20 +82,6 @@ private:
Map *_parent;
};
- class MapButton : public UI::Button {
- public:
- MapButton(RenderObject &redrawFrom, Map *parent) : Button(redrawFrom), _parent(parent) {}
- virtual ~MapButton() = default;
-
- virtual void init() override;
- virtual void onClick() override;
-
- protected:
- virtual uint16 getZOrder() const override { return 9; }
-
- Map *_parent;
- };
-
void init();
void run();
@@ -99,7 +89,7 @@ private:
Nancy::UI::Viewport _viewport;
MapLabel _label;
- MapButton _button;
+ UI::Button *_button;
SoundDescription _sound;
State _state;
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 67e5464f89..4e4d91cd24 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -33,6 +33,8 @@
#include "engines/nancy/state/scene.h"
+#include "engines/nancy/ui/button.h"
+
namespace Common {
DECLARE_SINGLETON(Nancy::State::Scene);
}
@@ -81,6 +83,24 @@ void Scene::SceneSummary::read(Common::SeekableReadStream &stream) {
delete[] buf;
}
+Scene::Scene() :
+ _state (kInit),
+ _lastHint(-1),
+ _gameStateRequested(NancyState::kNone),
+ _frame(),
+ _viewport(),
+ _textbox(_frame),
+ _inventoryBox(_frame),
+ _menuButton(nullptr),
+ _helpButton(nullptr),
+ _actionManager(),
+ _difficulty(0) {}
+
+Scene::~Scene() {
+ delete _helpButton;
+ delete _menuButton;
+}
+
void Scene::process() {
switch (_state) {
case kInit:
@@ -251,12 +271,12 @@ void Scene::registerGraphics() {
_viewport.registerGraphics();
_textbox.registerGraphics();
_inventoryBox.registerGraphics();
- _menuButton.registerGraphics();
- _helpButton.registerGraphics();
+ _menuButton->registerGraphics();
+ _helpButton->registerGraphics();
_textbox.setVisible(!_shouldClearTextbox);
- _menuButton.setVisible(false);
- _helpButton.setVisible(false);
+ _menuButton->setVisible(false);
+ _helpButton->setVisible(false);
}
void Scene::synchronize(Common::Serializer &ser) {
@@ -537,12 +557,24 @@ void Scene::run() {
// Update the UI elements and handle input
NancyInput input = g_nancy->_input->getInput();
_viewport.handleInput(input);
- _menuButton.handleInput(input);
- _helpButton.handleInput(input);
+ _menuButton->handleInput(input);
+ _helpButton->handleInput(input);
_textbox.handleInput(input);
_inventoryBox.handleInput(input);
_actionManager.handleInput(input);
+ if (_menuButton->_isClicked) {
+ _menuButton->_isClicked = false;
+ g_nancy->_sound->playSound("GLOB");
+ requestStateChange(NancyState::kMainMenu);
+ }
+
+ if (_helpButton->_isClicked) {
+ _helpButton->_isClicked = false;
+ g_nancy->_sound->playSound("GLOB");
+ requestStateChange(NancyState::kHelp);
+ }
+
_sceneState.currentScene.frameID = _viewport.getCurFrame();
_sceneState.currentScene.verticalOffset = _viewport.getCurVerticalScroll();
@@ -579,15 +611,26 @@ void Scene::initStaticData() {
_mapAccessSceneIDs.push_back(0x4E2);
_mapAccessSceneIDs.push_back(0x682);
- Common::SeekableReadStream *fr = g_nancy->getBootChunkStream("FR0");
- fr->seek(0);
+ chunk = g_nancy->getBootChunkStream("FR0");
+ chunk->seek(0);
- _frame.init(fr->readString());
+ _frame.init(chunk->readString());
_viewport.init();
_textbox.init();
_inventoryBox.init();
- _menuButton.init();
- _helpButton.init();
+
+ // Init menu and help buttons
+ chunk = g_nancy->getBootChunkStream("BSUM");
+ chunk->seek(0x184);
+ Common::Rect menuSrc, helpSrc, menuDest, helpDest;
+ readRect(*chunk, menuSrc);
+ readRect(*chunk, helpSrc);
+ readRect(*chunk, menuDest);
+ readRect(*chunk, helpDest);
+ _menuButton = new UI::Button(_frame, g_nancy->_graphicsManager->_object0, menuSrc, menuDest);
+ _helpButton = new UI::Button(_frame, g_nancy->_graphicsManager->_object0, helpSrc, helpDest);
+ _menuButton->init();
+ _helpButton->init();
g_nancy->_cursorManager->showCursor(true);
_state = kLoad;
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index dfd8d36068..7e33c96a12 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -35,7 +35,6 @@
#include "engines/nancy/ui/viewport.h"
#include "engines/nancy/ui/textbox.h"
#include "engines/nancy/ui/inventorybox.h"
-#include "engines/nancy/ui/button.h"
namespace Common {
class SeekableReadStream;
@@ -53,6 +52,10 @@ namespace Action {
class SliderPuzzle;
}
+namespace UI {
+class Button;
+}
+
namespace State {
struct SceneInfo {
@@ -100,18 +103,8 @@ public:
void read(Common::SeekableReadStream &stream);
};
- Scene() :
- _state (kInit),
- _lastHint(-1),
- _gameStateRequested(NancyState::kNone),
- _frame(),
- _viewport(),
- _textbox(_frame),
- _inventoryBox(_frame),
- _menuButton(_frame),
- _helpButton(_frame),
- _actionManager(),
- _difficulty(0) {}
+ Scene();
+ virtual ~Scene();
// State API
virtual void process() override;
@@ -233,8 +226,9 @@ private:
UI::Viewport _viewport;
UI::Textbox _textbox;
UI::InventoryBox _inventoryBox;
- UI::MenuButton _menuButton;
- UI::HelpButton _helpButton;
+
+ UI::Button *_menuButton;
+ UI::Button *_helpButton;
// Data
SceneState _sceneState;
diff --git a/engines/nancy/ui/button.cpp b/engines/nancy/ui/button.cpp
index fcf51e438b..8fb56f5ca2 100644
--- a/engines/nancy/ui/button.cpp
+++ b/engines/nancy/ui/button.cpp
@@ -34,57 +34,25 @@
namespace Nancy {
namespace UI {
+Button::Button(RenderObject &redrawFrom, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
+ RenderObject(redrawFrom),
+ _isClicked(false) {
+ _drawSurface.create(surface, srcBounds);
+ _screenPosition = destBounds;
+ setVisible(false);
+ setTransparent(true);
+}
+
void Button::handleInput(NancyInput &input) {
- if (_screenPosition.contains(input.mousePos)) {
+ if (!_isClicked && _screenPosition.contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
if (input.input & NancyInput::kLeftMouseButtonUp) {
- onClick();
+ _isClicked = true;
+ setVisible(true);
}
}
}
-void MenuButton::init() {
- Common::SeekableReadStream *bsum = g_nancy->getBootChunkStream("BSUM");
-
- bsum->seek(0x184, SEEK_SET);
- Common::Rect src;
- readRect(*bsum, src);
- _drawSurface.create(g_nancy->_graphicsManager->_object0, src);
- bsum->skip(16);
- readRect(*bsum, _screenPosition);
- setVisible(false);
- setTransparent(true);
-
- RenderObject::init();
-}
-
-void MenuButton::onClick() {
- NancySceneState.requestStateChange(NancyState::kMainMenu);
- g_nancy->_sound->playSound("GLOB");
- setVisible(true);
-}
-
-void HelpButton::init() {
- Common::SeekableReadStream *bsum = g_nancy->getBootChunkStream("BSUM");
-
- bsum->seek(0x194, SEEK_SET);
- Common::Rect src;
- readRect(*bsum, src);
- _drawSurface.create(g_nancy->_graphicsManager->_object0, src);
- bsum->skip(16);
- readRect(*bsum, _screenPosition);
- setVisible(false);
- setTransparent(true);
-
- RenderObject::init();
-}
-
-void HelpButton::onClick() {
- NancySceneState.requestStateChange(NancyState::kHelp);
- g_nancy->_sound->playSound("GLOB");
- setVisible(true);
-}
-
} // End of namespace UI
} // End of namespace Nancy
diff --git a/engines/nancy/ui/button.h b/engines/nancy/ui/button.h
index e73994290f..4070b063b5 100644
--- a/engines/nancy/ui/button.h
+++ b/engines/nancy/ui/button.h
@@ -33,35 +33,17 @@ namespace UI {
class Button : public RenderObject {
public:
- Button(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ Button(RenderObject &redrawFrom, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
virtual ~Button() = default;
- virtual void onClick() = 0;
-
void handleInput(NancyInput &input);
+ bool _isClicked;
+
protected:
virtual uint16 getZOrder() const override { return 5; }
};
-class MenuButton : public Button {
-public:
- MenuButton(RenderObject &redrawFrom) : Button(redrawFrom) {}
- virtual ~MenuButton() = default;
-
- virtual void init() override;
- virtual void onClick() override;
-};
-
-class HelpButton : public Button {
-public:
- HelpButton(RenderObject &redrawFrom) : Button(redrawFrom) {}
- virtual ~HelpButton() = default;
-
- virtual void init() override;
- virtual void onClick() override;
-};
-
} // End of namespace UI
} // End of namespace Nancy
Commit: a29cdd43c04ba1f62a0088d23ea4d2131e8df833
https://github.com/scummvm/scummvm/commit/a29cdd43c04ba1f62a0088d23ea4d2131e8df833
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-15T15:12:00+03:00
Commit Message:
NANCY: Make RenderObject non-abstract
Made RenderObject non-abstract so it can be used in some simple cases without the need for subclassing.
Changed paths:
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.cpp
engines/nancy/action/staticbitmapanim.h
engines/nancy/action/telephone.h
engines/nancy/renderobject.cpp
engines/nancy/renderobject.h
engines/nancy/state/credits.h
engines/nancy/state/help.cpp
engines/nancy/state/mainmenu.cpp
engines/nancy/state/mainmenu.h
engines/nancy/state/map.cpp
engines/nancy/state/map.h
engines/nancy/state/scene.cpp
engines/nancy/ui/button.cpp
engines/nancy/ui/button.h
engines/nancy/ui/fullscreenimage.h
engines/nancy/ui/inventorybox.cpp
engines/nancy/ui/inventorybox.h
engines/nancy/ui/scrollbar.cpp
engines/nancy/ui/scrollbar.h
engines/nancy/ui/textbox.cpp
engines/nancy/ui/textbox.h
engines/nancy/ui/viewport.h
diff --git a/engines/nancy/action/leverpuzzle.h b/engines/nancy/action/leverpuzzle.h
index 0bc5b6e677..188d22200b 100644
--- a/engines/nancy/action/leverpuzzle.h
+++ b/engines/nancy/action/leverpuzzle.h
@@ -33,7 +33,7 @@ namespace Action {
class LeverPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
- LeverPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ LeverPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
virtual ~LeverPuzzle() {}
virtual void init() override;
@@ -65,8 +65,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "LeverPuzzle"; }
-
- virtual uint16 getZOrder() const override { return 7; }
virtual bool isViewportRelative() const override { return true; }
void drawLever(uint id);
diff --git a/engines/nancy/action/orderingpuzzle.h b/engines/nancy/action/orderingpuzzle.h
index 3624c63dfe..29e059752d 100644
--- a/engines/nancy/action/orderingpuzzle.h
+++ b/engines/nancy/action/orderingpuzzle.h
@@ -33,7 +33,7 @@ namespace Action {
class OrderingPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
- OrderingPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ OrderingPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
virtual ~OrderingPuzzle() {}
virtual void init() override;
@@ -65,8 +65,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "OrderingPuzzle"; }
-
- virtual uint16 getZOrder() const override { return 7; }
virtual bool isViewportRelative() const override { return true; }
void drawElement(uint id);
diff --git a/engines/nancy/action/passwordpuzzle.h b/engines/nancy/action/passwordpuzzle.h
index 8732455ee0..4c612c6aa2 100644
--- a/engines/nancy/action/passwordpuzzle.h
+++ b/engines/nancy/action/passwordpuzzle.h
@@ -33,7 +33,7 @@ namespace Action {
class PasswordPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kFailed, kSolved };
- PasswordPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ PasswordPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
virtual ~PasswordPuzzle() {}
virtual void init() override;
@@ -69,8 +69,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "PasswordPuzzle"; }
-
- virtual uint16 getZOrder() const override { return 7; }
virtual bool isViewportRelative() const override { return true; }
void drawText();
diff --git a/engines/nancy/action/primaryvideo.h b/engines/nancy/action/primaryvideo.h
index 966d3c2798..7398715615 100644
--- a/engines/nancy/action/primaryvideo.h
+++ b/engines/nancy/action/primaryvideo.h
@@ -70,7 +70,7 @@ struct FlagsStruct {
};
public:
- PlayPrimaryVideoChan0(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ PlayPrimaryVideoChan0(RenderObject &redrawFrom) : RenderObject(redrawFrom, 8) {}
virtual ~PlayPrimaryVideoChan0();
virtual void init() override;
@@ -111,8 +111,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "PlayPrimaryVideoChan0"; }
-
- virtual uint16 getZOrder() const override { return 8; }
virtual bool isViewportRelative() const override { return true; }
};
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index dadc6b597a..62a6a174b8 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -425,7 +425,7 @@ public:
virtual void readData(Common::SeekableReadStream &stream) override;
virtual void execute() override;
- ShowInventoryItem(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ ShowInventoryItem(RenderObject &redrawFrom) : RenderObject(redrawFrom, 9) {}
virtual ~ShowInventoryItem() { _fullSurface.free(); }
virtual void init() override;
@@ -440,8 +440,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "ShowInventoryItem"; }
-
- virtual uint16 getZOrder() const override { return 9; }
virtual bool isViewportRelative() const override { return true; }
};
diff --git a/engines/nancy/action/rotatinglockpuzzle.h b/engines/nancy/action/rotatinglockpuzzle.h
index a578f51c22..5c79b5b7bf 100644
--- a/engines/nancy/action/rotatinglockpuzzle.h
+++ b/engines/nancy/action/rotatinglockpuzzle.h
@@ -33,7 +33,7 @@ namespace Action {
class RotatingLockPuzzle : public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
- RotatingLockPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ RotatingLockPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
virtual ~RotatingLockPuzzle() {}
virtual void init() override;
@@ -67,8 +67,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "RotatingLockPuzzle"; }
-
- virtual uint16 getZOrder() const override { return 7; }
virtual bool isViewportRelative() const override { return true; }
void drawDial(uint id);
diff --git a/engines/nancy/action/secondarymovie.h b/engines/nancy/action/secondarymovie.h
index dd58122ae8..6676e58a1b 100644
--- a/engines/nancy/action/secondarymovie.h
+++ b/engines/nancy/action/secondarymovie.h
@@ -39,7 +39,7 @@ public:
EventFlagDescription flagDesc;
};
- PlaySecondaryMovie(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ PlaySecondaryMovie(RenderObject &redrawFrom) : RenderObject(redrawFrom, 8) {}
virtual ~PlaySecondaryMovie();
virtual void init() override;
@@ -66,8 +66,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "PlaySecondaryMovie"; }
-
- virtual uint16 getZOrder() const override { return 8; }
virtual bool isViewportRelative() const override { return true; }
AVFDecoder _decoder;
diff --git a/engines/nancy/action/secondaryvideo.h b/engines/nancy/action/secondaryvideo.h
index 475ca21cb7..e752894e8d 100644
--- a/engines/nancy/action/secondaryvideo.h
+++ b/engines/nancy/action/secondaryvideo.h
@@ -38,7 +38,7 @@ class PlaySecondaryVideo : public ActionRecord, public RenderObject {
public:
enum HoverState { kNoHover, kHover, kEndHover };
- PlaySecondaryVideo(uint chan, RenderObject &redrawFrom) : RenderObject(redrawFrom), channel(chan) {}
+ PlaySecondaryVideo(uint chan, RenderObject &redrawFrom) : RenderObject(redrawFrom, 8), channel(chan) {}
virtual ~PlaySecondaryVideo() { _decoder.close(); }
virtual void init() override;
@@ -63,8 +63,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return Common::String::format("PlaySecondaryVideoChan%i", channel); }
-
- virtual uint16 getZOrder() const override { return 8; }
virtual bool isViewportRelative() const override { return true; }
HoverState _hoverState = kNoHover;
diff --git a/engines/nancy/action/sliderpuzzle.h b/engines/nancy/action/sliderpuzzle.h
index 2d8d311de8..6d73432283 100644
--- a/engines/nancy/action/sliderpuzzle.h
+++ b/engines/nancy/action/sliderpuzzle.h
@@ -38,7 +38,7 @@ namespace Action {
class SliderPuzzle: public ActionRecord, public RenderObject {
public:
enum SolveState { kNotSolved, kWaitForSound };
- SliderPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ SliderPuzzle(RenderObject &redrawFrom) : RenderObject(redrawFrom, 7) {}
virtual ~SliderPuzzle() {}
virtual void init() override;
@@ -67,8 +67,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "SliderPuzzle"; }
-
- virtual uint16 getZOrder() const override { return 7; }
virtual bool isViewportRelative() const override { return true; }
void drawTile(int tileID, uint posX, uint posY);
diff --git a/engines/nancy/action/staticbitmapanim.cpp b/engines/nancy/action/staticbitmapanim.cpp
index 95aceee3e3..fc86a1d737 100644
--- a/engines/nancy/action/staticbitmapanim.cpp
+++ b/engines/nancy/action/staticbitmapanim.cpp
@@ -52,7 +52,7 @@ void PlayStaticBitmapAnimation::readData(Common::SeekableReadStream &stream) {
_loopFirstFrame = stream.readUint16LE();
_loopLastFrame = stream.readUint16LE();
_frameTime = Common::Rational(1000, stream.readUint16LE()).toInt();
- _zOrder = stream.readUint16LE();
+ _z = stream.readUint16LE();
if (_isInterruptible) {
_interruptCondition.label = stream.readSint16LE();
diff --git a/engines/nancy/action/staticbitmapanim.h b/engines/nancy/action/staticbitmapanim.h
index ad878c96d5..e54158708e 100644
--- a/engines/nancy/action/staticbitmapanim.h
+++ b/engines/nancy/action/staticbitmapanim.h
@@ -37,7 +37,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), _isInterruptible(interruptible) {}
+ PlayStaticBitmapAnimation(bool interruptible, RenderObject &redrawFrom) : RenderObject(redrawFrom, 7), _isInterruptible(interruptible) {}
virtual ~PlayStaticBitmapAnimation() { _fullSurface.free(); }
virtual void init() override;
@@ -56,7 +56,6 @@ public:
uint16 _loopFirstFrame = 0; // 0x16
uint16 _loopLastFrame = 0; // 0x18
Time _frameTime;
- uint16 _zOrder = 0; // 0x1C
EventFlagDescription _interruptCondition; // 0x1E
SceneChangeDescription _sceneChange;
MultiEventFlagDescription _triggerFlags; // 0x2A
@@ -76,8 +75,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return _isInterruptible ? "PlayIntStaticBitmapAnimation" : "PlayStaticBitmapAnimation"; }
-
- virtual uint16 getZOrder() const override { return _zOrder; }
virtual bool isViewportRelative() const override { return true; }
void setFrame(uint frame);
diff --git a/engines/nancy/action/telephone.h b/engines/nancy/action/telephone.h
index bed411d303..5f19fa941d 100644
--- a/engines/nancy/action/telephone.h
+++ b/engines/nancy/action/telephone.h
@@ -45,7 +45,7 @@ public:
enum CallState { kWaiting, kButtonPress, kRinging, kBadNumber, kCall, kHangUp };
Telephone(RenderObject &redrawFrom) :
- RenderObject(redrawFrom),
+ RenderObject(redrawFrom, 7),
_callState(kWaiting),
_selected(0) {}
virtual ~Telephone() {}
@@ -83,8 +83,6 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "Telephone"; }
-
- virtual uint16 getZOrder() const override { return 7; }
virtual bool isViewportRelative() const override { return true; }
void drawButton(uint id);
diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index e29ea01db4..91937a8755 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -28,6 +28,24 @@
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) {
+ _drawSurface.create(surface, srcBounds);
+ _screenPosition = destBounds;
+}
+
void RenderObject::init() {
_previousScreenPosition = _screenPosition;
}
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index d22a9a4101..d26c9f3f04 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -37,15 +37,9 @@ class GraphicsManager;
class RenderObject {
friend class GraphicsManager;
public:
- RenderObject() :
- _needsRedraw(true),
- _isVisible(true),
- _redrawFrom(nullptr) {}
-
- RenderObject(RenderObject &redrawFrom) :
- _needsRedraw(true),
- _isVisible(true),
- _redrawFrom(&redrawFrom) {}
+ RenderObject(uint16 zOrder);
+ RenderObject(RenderObject &redrawFrom, uint16 zOrder);
+ RenderObject(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
virtual ~RenderObject();
@@ -67,22 +61,23 @@ public:
Common::Rect convertToScreen(const Common::Rect &rect) const;
Common::Rect getBounds() const { return Common::Rect(_drawSurface.w, _drawSurface.h); }
- Graphics::ManagedSurface &getDrawSurface() { return _drawSurface; }
+
+ Graphics::ManagedSurface _drawSurface;
+ Common::Rect _screenPosition;
protected:
// Z order and blit type are extracted directly from the corresponding
// ZRenderStruct from the original engine
- virtual uint16 getZOrder() const = 0;
+ uint16 getZOrder() const { return _z; }
// Needed for proper handling of objects inside the viewport
virtual bool isViewportRelative() const { return false; }
RenderObject *_redrawFrom;
- Graphics::ManagedSurface _drawSurface;
- Common::Rect _screenPosition;
bool _needsRedraw;
bool _isVisible;
+ uint16 _z;
Common::Rect _previousScreenPosition;
};
diff --git a/engines/nancy/state/credits.h b/engines/nancy/state/credits.h
index e1bb065e2a..395dfde89f 100644
--- a/engines/nancy/state/credits.h
+++ b/engines/nancy/state/credits.h
@@ -52,11 +52,8 @@ protected:
class CreditsText : public RenderObject {
friend class Credits;
public:
- CreditsText(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
+ CreditsText(RenderObject &redrawFrom) : RenderObject(redrawFrom, 1) {}
virtual ~CreditsText() = default;
-
- protected:
- virtual uint16 getZOrder() const override { return 1; }
};
State _state;
diff --git a/engines/nancy/state/help.cpp b/engines/nancy/state/help.cpp
index 9894893bdc..0c2f2b9f68 100644
--- a/engines/nancy/state/help.cpp
+++ b/engines/nancy/state/help.cpp
@@ -82,7 +82,7 @@ void Help::init() {
buttonSrc.right = chunk->readUint16LE();
buttonSrc.bottom = chunk->readUint16LE();
- _button = new UI::Button(_image, _image.getDrawSurface(), buttonSrc, buttonDest);
+ _button = new UI::Button(_image, 5, _image._drawSurface, buttonSrc, buttonDest);
_button->init();
_state = kBegin;
diff --git a/engines/nancy/state/mainmenu.cpp b/engines/nancy/state/mainmenu.cpp
index 52d1373d5d..25a015d6cd 100644
--- a/engines/nancy/state/mainmenu.cpp
+++ b/engines/nancy/state/mainmenu.cpp
@@ -93,7 +93,6 @@ void MainMenu::init() {
}
_buttonDown.registerGraphics();
- _buttonDown._redrawFrom = &_background;
_state = kRun;
}
@@ -117,7 +116,7 @@ void MainMenu::run() {
_selected = i;
_state = kStop;
- _buttonDown._drawSurface.create(_background.getDrawSurface(), _srcRects[i]);
+ _buttonDown._drawSurface.create(_background._drawSurface, _srcRects[i]);
_buttonDown._screenPosition = _destRects[i];
_buttonDown.setVisible(true);
diff --git a/engines/nancy/state/mainmenu.h b/engines/nancy/state/mainmenu.h
index eef90e7e46..b1b4547611 100644
--- a/engines/nancy/state/mainmenu.h
+++ b/engines/nancy/state/mainmenu.h
@@ -35,24 +35,13 @@ namespace State {
class MainMenu : public State, public Common::Singleton<MainMenu> {
friend class MainMenuButton;
public:
- MainMenu() : _state(kInit), _selected(-1), _playedOKSound(false) {}
+ MainMenu() : _state(kInit), _selected(-1), _playedOKSound(false), _buttonDown(_background, 5) {}
// State API
virtual void process() override;
virtual void onStateExit() override;
private:
- // This is not a UI::Button subclass since the cursor doesn't change on hover
- class ButtonDownLabel : public RenderObject {
- friend class MainMenu;
- public:
- ButtonDownLabel() {}
- virtual ~ButtonDownLabel() override {}
-
- protected:
- virtual uint16 getZOrder() const override { return 5; }
- };
-
void init();
void run();
void stop();
@@ -60,7 +49,7 @@ private:
enum State { kInit, kRun, kStop };
UI::FullScreenImage _background;
- ButtonDownLabel _buttonDown;
+ RenderObject _buttonDown;
State _state;
int16 _selected;
bool _playedOKSound;
diff --git a/engines/nancy/state/map.cpp b/engines/nancy/state/map.cpp
index 497af841b6..d3ece84eb1 100644
--- a/engines/nancy/state/map.cpp
+++ b/engines/nancy/state/map.cpp
@@ -44,7 +44,7 @@ Map::Map() : _state(kInit),
_mapButtonClicked(false),
_pickedLocationID(-1),
_viewport(),
- _label(NancySceneState.getFrame(), this),
+ _label(NancySceneState.getFrame(), 7),
_button(nullptr) {}
Map::~Map() {
@@ -68,12 +68,14 @@ void Map::init() {
_viewport.init();
_label.init();
+ setLabel(-1);
+
Common::Rect buttonSrc, buttonDest;
chunk->seek(0x7A, SEEK_SET);
readRect(*chunk, buttonSrc);
readRect(*chunk, buttonDest);
- _button = new UI::Button(NancySceneState.getFrame(), g_nancy->_graphicsManager->_object0, buttonSrc, buttonDest);
+ _button = new UI::Button(NancySceneState.getFrame(), 9, g_nancy->_graphicsManager->_object0, buttonSrc, buttonDest);
_button->init();
_button->setVisible(true);
@@ -145,7 +147,7 @@ void Map::run() {
NancyInput input = g_nancy->_input->getInput();
- _label.setLabel(-1);
+ setLabel(-1);
_button->handleInput(input);
@@ -160,7 +162,7 @@ void Map::run() {
if (loc.isActive && _viewport.convertToScreen(loc.hotspot).contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
- _label.setLabel(i);
+ setLabel(i);
if (input.input & NancyInput::kLeftMouseButtonUp) {
_pickedLocationID = i;
@@ -197,19 +199,13 @@ void Map::registerGraphics() {
_button->registerGraphics();
}
-void Map::MapLabel::init() {
- setLabel(-1);
-
- RenderObject::init();
-}
-
-void Map::MapLabel::setLabel(int labelID) {
+void Map::setLabel(int labelID) {
if (labelID == -1) {
- setVisible(false);
+ _label.setVisible(false);
} else {
- _screenPosition = _parent->_locations[labelID].labelDest;
- _drawSurface.create(g_nancy->_graphicsManager->_object0, _parent->_locations[labelID].labelSrc);
- setVisible(true);
+ _label._screenPosition = _locations[labelID].labelDest;
+ _label._drawSurface.create(g_nancy->_graphicsManager->_object0, _locations[labelID].labelSrc);
+ _label.setVisible(true);
}
}
diff --git a/engines/nancy/state/map.h b/engines/nancy/state/map.h
index 85d595265d..44dfea6750 100644
--- a/engines/nancy/state/map.h
+++ b/engines/nancy/state/map.h
@@ -67,28 +67,15 @@ private:
Common::Rect labelDest;
};
- class MapLabel : public Nancy::RenderObject {
- public:
- MapLabel(RenderObject &redrawFrom, Map *parent) : Nancy::RenderObject(redrawFrom), _parent(parent) {}
- virtual ~MapLabel() = default;
-
- virtual void init() override;
-
- void setLabel(int labelID);
-
- protected:
- virtual uint16 getZOrder() const override { return 7; }
-
- Map *_parent;
- };
-
void init();
void run();
void registerGraphics();
+ void setLabel(int labelID);
+
Nancy::UI::Viewport _viewport;
- MapLabel _label;
+ RenderObject _label;
UI::Button *_button;
SoundDescription _sound;
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 4e4d91cd24..bbabdd1f76 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -627,8 +627,8 @@ void Scene::initStaticData() {
readRect(*chunk, helpSrc);
readRect(*chunk, menuDest);
readRect(*chunk, helpDest);
- _menuButton = new UI::Button(_frame, g_nancy->_graphicsManager->_object0, menuSrc, menuDest);
- _helpButton = new UI::Button(_frame, g_nancy->_graphicsManager->_object0, helpSrc, 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->init();
_helpButton->init();
g_nancy->_cursorManager->showCursor(true);
diff --git a/engines/nancy/ui/button.cpp b/engines/nancy/ui/button.cpp
index 8fb56f5ca2..29b208a11e 100644
--- a/engines/nancy/ui/button.cpp
+++ b/engines/nancy/ui/button.cpp
@@ -34,11 +34,9 @@
namespace Nancy {
namespace UI {
-Button::Button(RenderObject &redrawFrom, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
- RenderObject(redrawFrom),
+Button::Button(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds) :
+ RenderObject(redrawFrom, zOrder, surface, srcBounds, destBounds),
_isClicked(false) {
- _drawSurface.create(surface, srcBounds);
- _screenPosition = destBounds;
setVisible(false);
setTransparent(true);
}
diff --git a/engines/nancy/ui/button.h b/engines/nancy/ui/button.h
index 4070b063b5..cc0f0cc4c5 100644
--- a/engines/nancy/ui/button.h
+++ b/engines/nancy/ui/button.h
@@ -33,15 +33,12 @@ namespace UI {
class Button : public RenderObject {
public:
- Button(RenderObject &redrawFrom, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
+ Button(RenderObject &redrawFrom, uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
virtual ~Button() = default;
void handleInput(NancyInput &input);
bool _isClicked;
-
-protected:
- virtual uint16 getZOrder() const override { return 5; }
};
} // End of namespace UI
diff --git a/engines/nancy/ui/fullscreenimage.h b/engines/nancy/ui/fullscreenimage.h
index 0de317f051..7d7355b1dd 100644
--- a/engines/nancy/ui/fullscreenimage.h
+++ b/engines/nancy/ui/fullscreenimage.h
@@ -30,14 +30,13 @@ namespace UI {
class FullScreenImage : public RenderObject {
public:
- FullScreenImage() : RenderObject() {}
+ FullScreenImage() : RenderObject(0) {}
virtual ~FullScreenImage() = default;
void init(const Common::String &imageName);
protected:
virtual void init() override {}
- virtual uint16 getZOrder() const override { return 0; }
};
} // End of namespace UI
diff --git a/engines/nancy/ui/inventorybox.cpp b/engines/nancy/ui/inventorybox.cpp
index e2af69ed07..1cf5928541 100644
--- a/engines/nancy/ui/inventorybox.cpp
+++ b/engines/nancy/ui/inventorybox.cpp
@@ -38,7 +38,7 @@ namespace Nancy {
namespace UI {
InventoryBox::InventoryBox(RenderObject &redrawFrom) :
- RenderObject(redrawFrom),
+ RenderObject(redrawFrom, 6),
_scrollbar(nullptr),
_shades(*this, this),
_scrollbarPos(0),
@@ -106,7 +106,7 @@ void InventoryBox::init() {
RenderObject::init();
- _scrollbar = new Scrollbar(NancySceneState.getFrame(), scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ _scrollbar = new Scrollbar(NancySceneState.getFrame(), 9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
_scrollbar->init();
_shades.init();
}
diff --git a/engines/nancy/ui/inventorybox.h b/engines/nancy/ui/inventorybox.h
index b63f50be45..9188316454 100644
--- a/engines/nancy/ui/inventorybox.h
+++ b/engines/nancy/ui/inventorybox.h
@@ -66,9 +66,6 @@ public:
ItemDescription getItemDescription(uint id) const { return _itemDescriptions[id]; }
-protected:
- virtual uint16 getZOrder() const override { return 6; }
-
void onScrollbarMove();
private:
@@ -78,7 +75,7 @@ private:
class Shades : public RenderObject {
public:
Shades(RenderObject &redrawFrom, InventoryBox *parent) :
- RenderObject(redrawFrom),
+ RenderObject(redrawFrom, 9),
_parent(parent),
_soundTriggered(false),
_areOpen(false),
@@ -90,9 +87,6 @@ private:
void setOpen(bool open) { _areOpen = open; }
- protected:
- virtual uint16 getZOrder() const override { return 9; }
-
void setAnimationFrame(uint frame);
InventoryBox *_parent;
diff --git a/engines/nancy/ui/scrollbar.cpp b/engines/nancy/ui/scrollbar.cpp
index f987c5d1fd..c7fa3345a8 100644
--- a/engines/nancy/ui/scrollbar.cpp
+++ b/engines/nancy/ui/scrollbar.cpp
@@ -30,8 +30,8 @@
namespace Nancy {
namespace UI {
-Scrollbar::Scrollbar(RenderObject &redrawFrom, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical) :
- RenderObject(redrawFrom),
+Scrollbar::Scrollbar(RenderObject &redrawFrom, uint16 zOrder, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical) :
+ RenderObject(redrawFrom, zOrder),
_isVertical(isVertical),
_isClicked(false),
_currentPosition(0),
diff --git a/engines/nancy/ui/scrollbar.h b/engines/nancy/ui/scrollbar.h
index f8a8d1fa83..55357f48e1 100644
--- a/engines/nancy/ui/scrollbar.h
+++ b/engines/nancy/ui/scrollbar.h
@@ -33,7 +33,7 @@ namespace UI {
class Scrollbar : public RenderObject {
public:
- Scrollbar(RenderObject &redrawFrom, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical = true);
+ Scrollbar(RenderObject &redrawFrom, uint16 zOrder, const Common::Rect &srcBounds, const Common::Point &topPosition, uint16 scrollDistance, bool isVertical = true);
virtual ~Scrollbar() = default;
virtual void init() override;
@@ -43,9 +43,6 @@ public:
void resetPosition();
float getPos() const { return _currentPosition; }
-protected:
- virtual uint16 getZOrder() const override { return 9; }
-
void calculatePosition();
Common::Point _startPosition;
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index 27bc1db682..c0f43e57b7 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -44,7 +44,7 @@ const char Textbox::_tabToken[] = "<t>";
const char Textbox::_telephoneEndToken[] = "<e>";
Textbox::Textbox(RenderObject &redrawFrom) :
- RenderObject(redrawFrom),
+ RenderObject(redrawFrom, 6),
_firstLineOffset(0),
_lineHeight(0),
_borderWidth(0),
@@ -91,7 +91,7 @@ void Textbox::init() {
RenderObject::init();
- _scrollbar = new Scrollbar(NancySceneState.getFrame(), scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
+ _scrollbar = new Scrollbar(NancySceneState.getFrame(), 9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
_scrollbar->init();
}
diff --git a/engines/nancy/ui/textbox.h b/engines/nancy/ui/textbox.h
index 2d15b60d54..4487fa3e25 100644
--- a/engines/nancy/ui/textbox.h
+++ b/engines/nancy/ui/textbox.h
@@ -53,9 +53,6 @@ public:
static void assembleTextLine(char *rawCaption, Common::String &output, uint size);
-protected:
- virtual uint16 getZOrder() const override { return 6; }
-
private:
uint16 getInnerHeight() const;
void onScrollbarMove();
diff --git a/engines/nancy/ui/viewport.h b/engines/nancy/ui/viewport.h
index c68c36a949..20bf6722e2 100644
--- a/engines/nancy/ui/viewport.h
+++ b/engines/nancy/ui/viewport.h
@@ -42,7 +42,7 @@ namespace UI {
class Viewport : public Nancy::RenderObject {
public:
Viewport() :
- RenderObject(),
+ RenderObject(6),
_movementLastFrame(0),
_edgesMask(0),
_currentFrame(0),
@@ -78,9 +78,6 @@ public:
void disableEdges(byte edges);
void enableEdges(byte edges);
-protected:
- virtual uint16 getZOrder() const override { return 6; }
-
Common::Rect _upHotspot;
Common::Rect _downHotspot;
Common::Rect _leftHotspot;
Commit: 533f8aebf26986fcdf8200f4d6fdb3847419e301
https://github.com/scummvm/scummvm/commit/533f8aebf26986fcdf8200f4d6fdb3847419e301
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-15T15:12:00+03:00
Commit Message:
NANCY: Correctly implement map labels
The map label's position is now properly calculated instead of being hardcoded. Added the (closed) label that shows up when hovering a disabled location on the map.
Changed paths:
engines/nancy/state/map.cpp
engines/nancy/state/map.h
diff --git a/engines/nancy/state/map.cpp b/engines/nancy/state/map.cpp
index d3ece84eb1..9cfcd125a0 100644
--- a/engines/nancy/state/map.cpp
+++ b/engines/nancy/state/map.cpp
@@ -45,6 +45,7 @@ Map::Map() : _state(kInit),
_pickedLocationID(-1),
_viewport(),
_label(NancySceneState.getFrame(), 7),
+ _closedLabel(NancySceneState.getFrame(), 7),
_button(nullptr) {}
Map::~Map() {
@@ -64,17 +65,29 @@ void Map::process() {
void Map::init() {
Common::SeekableReadStream *chunk = g_nancy->getBootChunkStream("MAP");
+ Common::Rect textboxScreenPosition = NancySceneState.getTextbox().getScreenPosition();
_viewport.init();
_label.init();
- setLabel(-1);
-
Common::Rect buttonSrc, buttonDest;
chunk->seek(0x7A, SEEK_SET);
readRect(*chunk, buttonSrc);
readRect(*chunk, buttonDest);
+ chunk->seek(0xDA, SEEK_SET);
+ Common::Rect closedLabelSrc;
+ readRect(*chunk, closedLabelSrc);
+
+ _closedLabel._drawSurface.create(g_nancy->_graphicsManager->_object0, closedLabelSrc);
+
+ _closedLabel._screenPosition.left = textboxScreenPosition.left + ((textboxScreenPosition.width() - closedLabelSrc.width()) / 2);
+ _closedLabel._screenPosition.right = _closedLabel._screenPosition.left + closedLabelSrc.width() - 1;
+ _closedLabel._screenPosition.bottom = textboxScreenPosition.bottom - 11;
+ _closedLabel._screenPosition.top = _closedLabel._screenPosition.bottom - closedLabelSrc.height() + 1;
+
+ setLabel(-1);
+
_button = new UI::Button(NancySceneState.getFrame(), 9, g_nancy->_graphicsManager->_object0, buttonSrc, buttonDest);
_button->init();
_button->setVisible(true);
@@ -103,10 +116,17 @@ void Map::init() {
_locations.clear();
_locations.reserve(4);
+ char buf[30];
for (uint i = 0; i < 4; ++i) {
- chunk->seek(0x162 + i * 16, SEEK_SET);
_locations.push_back(Location());
Location &loc = _locations.back();
+
+ chunk->seek(0xEA + i * 16, SEEK_SET);
+ chunk->read(buf, 30);
+ buf[29] = '\0';
+ loc.description = buf;
+
+ chunk->seek(0x162 + i * 16, SEEK_SET);
readRect(*chunk, loc.hotspot);
if (_mapID == 1 && (i % 2) != 0) {
@@ -128,10 +148,10 @@ void Map::init() {
chunk->seek(0x9A + i * 16, SEEK_SET);
readRect(*chunk, loc.labelSrc);
- // TODO this gets initialized using MAP and the textbox's on-screen location
- // but the code is annoyingly long so fpr now i just directly write the result
- loc.labelDest = Common::Rect(0x56, 0x166, 0x15E, 0x19B);
-
+ loc.labelDest.left = textboxScreenPosition.left + ((textboxScreenPosition.width() - loc.labelSrc.width()) / 2);
+ loc.labelDest.right = loc.labelDest.left + loc.labelSrc.width() - 1;
+ loc.labelDest.bottom = _closedLabel._screenPosition.bottom - ((_closedLabel._screenPosition.bottom - loc.labelSrc.height() - textboxScreenPosition.top) / 2) - 11;
+ loc.labelDest.top = loc.labelDest.bottom - loc.labelSrc.height() + 1;
}
registerGraphics();
@@ -159,14 +179,16 @@ void Map::run() {
for (uint i = 0; i < 4; ++i) {
auto &loc = _locations[i];
- if (loc.isActive && _viewport.convertToScreen(loc.hotspot).contains(input.mousePos)) {
- g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
-
+ if (_viewport.convertToScreen(loc.hotspot).contains(input.mousePos)) {
setLabel(i);
- if (input.input & NancyInput::kLeftMouseButtonUp) {
- _pickedLocationID = i;
- g_nancy->setState(NancyState::kScene);
+ if (loc.isActive){
+ g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
+
+ if (input.input & NancyInput::kLeftMouseButtonUp) {
+ _pickedLocationID = i;
+ g_nancy->setState(NancyState::kScene);
+ }
}
return;
@@ -196,16 +218,22 @@ void Map::onStateExit() {
void Map::registerGraphics() {
_viewport.registerGraphics();
_label.registerGraphics();
+ _closedLabel.registerGraphics();
_button->registerGraphics();
}
void Map::setLabel(int labelID) {
if (labelID == -1) {
_label.setVisible(false);
+ _closedLabel.setVisible(false);
} else {
_label._screenPosition = _locations[labelID].labelDest;
_label._drawSurface.create(g_nancy->_graphicsManager->_object0, _locations[labelID].labelSrc);
_label.setVisible(true);
+
+ if (!_locations[labelID].isActive) {
+ _closedLabel.setVisible(true);
+ }
}
}
diff --git a/engines/nancy/state/map.h b/engines/nancy/state/map.h
index 44dfea6750..2f7f65ac94 100644
--- a/engines/nancy/state/map.h
+++ b/engines/nancy/state/map.h
@@ -59,6 +59,8 @@ private:
uint16 verticalOffset = 0;
};
+ Common::String description;
+
bool isActive = false;
Common::Rect hotspot;
Common::Array<SceneChange> scenes;
@@ -76,6 +78,7 @@ private:
Nancy::UI::Viewport _viewport;
RenderObject _label;
+ RenderObject _closedLabel;
UI::Button *_button;
SoundDescription _sound;
Commit: 503d1d8c1dea24125efe1af18c9484bdf3373f92
https://github.com/scummvm/scummvm/commit/503d1d8c1dea24125efe1af18c9484bdf3373f92
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-15T15:12:00+03:00
Commit Message:
NANCY: Update The Vampire Diaries detection entry
Updated the detection entry for The Vampire Diaries so it doesn't depend on a non-essential file.
Changed paths:
engines/nancy/detection.cpp
diff --git a/engines/nancy/detection.cpp b/engines/nancy/detection.cpp
index f2572f2ad1..6024ba3dcb 100644
--- a/engines/nancy/detection.cpp
+++ b/engines/nancy/detection.cpp
@@ -27,7 +27,7 @@
const char *const directoryGlobs[] = {
"game",
- "datafiles",
+ "iff",
0
};
@@ -48,7 +48,7 @@ static const Nancy::NancyGameDescription gameDescriptions[] = {
{ // MD5 by fracturehill
{
"vampirediaries", 0,
- AD_ENTRY1s("vampire.exe", "c6207f4bb7418b8a067ad75ed9f57bdf", 114688),
+ AD_ENTRY1s("boot.iff", "66d3b6fe9a90d35de7a28950870719ec", 20340),
Common::EN_ANY,
Common::kPlatformWindows,
Nancy::NGF_8BITCOLOR,
More information about the Scummvm-git-logs
mailing list