aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2016-02-06 12:57:03 +0100
committerBastien Bouclet2016-02-07 15:27:03 +0100
commit085f3700f7cd6ddb23abe3719ca21b7025695da4 (patch)
treeaaee4b1035a9add41cb9f88bf3aa6cd705b46aec /engines
parent0c8d8bbd40e4806e1b63196e283bcbff21431080 (diff)
downloadscummvm-rg350-085f3700f7cd6ddb23abe3719ca21b7025695da4.tar.gz
scummvm-rg350-085f3700f7cd6ddb23abe3719ca21b7025695da4.tar.bz2
scummvm-rg350-085f3700f7cd6ddb23abe3719ca21b7025695da4.zip
MOHAWK: Make MystResourceType8::_subImages private
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/myst_areas.cpp44
-rw-r--r--engines/mohawk/myst_areas.h14
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp40
-rw-r--r--engines/mohawk/myst_stacks/selenitic.cpp7
4 files changed, 58 insertions, 47 deletions
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 2221ef1165..45840bc4ed 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -369,37 +369,37 @@ MystResourceType8::MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableRead
debugC(kDebugResource, "\tvar8: %d", _var8);
debugC(kDebugResource, "\tnumSubImages: %d", _numSubImages);
- _subImages = new MystResourceType8::SubImage[_numSubImages];
-
for (uint16 i = 0; i < _numSubImages; i++) {
debugC(kDebugResource, "\tSubimage %d:", i);
- _subImages[i].wdib = rlstStream->readUint16LE();
- _subImages[i].rect.left = rlstStream->readSint16LE();
+ SubImage subImage;
+ subImage.wdib = rlstStream->readUint16LE();
+ subImage.rect.left = rlstStream->readSint16LE();
- if (_subImages[i].rect.left != -1) {
- _subImages[i].rect.top = rlstStream->readSint16LE();
- _subImages[i].rect.right = rlstStream->readSint16LE();
- _subImages[i].rect.bottom = rlstStream->readSint16LE();
+ if (subImage.rect.left != -1) {
+ subImage.rect.top = rlstStream->readSint16LE();
+ subImage.rect.right = rlstStream->readSint16LE();
+ subImage.rect.bottom = rlstStream->readSint16LE();
} else {
// Use the hotspot rect as the source rect since the subimage is fullscreen
// Convert to bitmap coordinates (upside down)
- _subImages[i].rect.left = _rect.left;
- _subImages[i].rect.top = 333 - _rect.bottom;
- _subImages[i].rect.right = _rect.right;
- _subImages[i].rect.bottom = 333 - _rect.top;
+ subImage.rect.left = _rect.left;
+ subImage.rect.top = 333 - _rect.bottom;
+ subImage.rect.right = _rect.right;
+ subImage.rect.bottom = 333 - _rect.top;
}
- debugC(kDebugResource, "\twdib: %d", _subImages[i].wdib);
- debugC(kDebugResource, "\tleft: %d", _subImages[i].rect.left);
- debugC(kDebugResource, "\ttop: %d", _subImages[i].rect.top);
- debugC(kDebugResource, "\tright: %d", _subImages[i].rect.right);
- debugC(kDebugResource, "\tbottom: %d", _subImages[i].rect.bottom);
+ debugC(kDebugResource, "\twdib: %d", subImage.wdib);
+ debugC(kDebugResource, "\tleft: %d", subImage.rect.left);
+ debugC(kDebugResource, "\ttop: %d", subImage.rect.top);
+ debugC(kDebugResource, "\tright: %d", subImage.rect.right);
+ debugC(kDebugResource, "\tbottom: %d", subImage.rect.bottom);
+
+ _subImages.push_back(subImage);
}
}
MystResourceType8::~MystResourceType8() {
- delete[] _subImages;
}
void MystResourceType8::drawDataToScreen() {
@@ -480,6 +480,14 @@ uint16 MystResourceType8::getType8Var() {
return _var8;
}
+MystResourceType8::SubImage MystResourceType8::getSubImage(uint index) const {
+ return _subImages[index];
+}
+
+void MystResourceType8::setSubImageRect(uint index, const Common::Rect &rect) {
+ _subImages[index].rect = rect;
+}
+
const Common::String MystResourceType8::describe() {
Common::String desc = Common::String::format("%s var: %2d",
MystResourceType7::describe().c_str(), _var8);
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 46abc9abcd..881edf28d4 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -146,20 +146,24 @@ class MystResourceType8 : public MystResourceType7 {
public:
MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType8();
- virtual const Common::String describe() override;
+ struct SubImage {
+ uint16 wdib;
+ Common::Rect rect;
+ };
+
+ virtual const Common::String describe() override;
virtual void drawDataToScreen() override;
void drawConditionalDataToScreen(uint16 state, bool update = true);
uint16 getType8Var() override;
- struct SubImage {
- uint16 wdib;
- Common::Rect rect;
- } *_subImages;
+ SubImage getSubImage(uint index) const;
+ void setSubImageRect(uint index, const Common::Rect &rect);
protected:
uint16 _var8;
uint16 _numSubImages;
+ Common::Array<SubImage> _subImages;
};
// No MystResourceType9!
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index c449cccbf9..c5f76fe54d 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -2302,14 +2302,14 @@ void Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv)
MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
// What the hell??
- Common::Rect src = key->_subImages[1].rect;
- Common::Rect rect = key->_subImages[0].rect;
+ Common::Rect src = key->getSubImage(1).rect;
+ Common::Rect rect = key->getSubImage(0).rect;
Common::Rect dest = rect;
dest.top = 332 - rect.bottom;
dest.bottom = 332 - rect.top;
// Draw pressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
_vm->_system->updateScreen();
// Play note
@@ -2328,27 +2328,27 @@ void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Unpress previous key
MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
- Common::Rect src = key->_subImages[0].rect;
+ Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
dest.top = 332 - src.bottom;
dest.bottom = 332 - src.top;
// Draw unpressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[0].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
if (piano.contains(mouse)) {
MystResource *resource = _vm->updateCurrentResource();
if (resource && resource->type == kMystDragArea) {
// Press new key
key = static_cast<MystResourceType11 *>(resource);
- src = key->_subImages[1].rect;
- Common::Rect rect = key->_subImages[0].rect;
+ src = key->getSubImage(1).rect;
+ Common::Rect rect = key->getSubImage(0).rect;
dest = rect;
dest.top = 332 - rect.bottom;
dest.bottom = 332 - rect.top;
// Draw pressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(1).wdib, src, dest);
// Play note
if (_state.generatorVoltage == 59 && !_state.generatorBreakers) {
@@ -2370,13 +2370,13 @@ void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
MystResourceType8 *key = static_cast<MystResourceType8 *>(_invokingResource);
- Common::Rect &src = key->_subImages[0].rect;
+ Common::Rect src = key->getSubImage(0).rect;
Common::Rect dest = src;
dest.top = 332 - src.bottom;
dest.bottom = 332 - src.top;
// Draw unpressed piano key
- _vm->_gfx->copyImageSectionToScreen(key->_subImages[0].wdib, src, dest);
+ _vm->_gfx->copyImageSectionToScreen(key->getSubImage(0).wdib, src, dest);
_vm->_system->updateScreen();
_vm->_sound->stopSound();
@@ -3503,18 +3503,14 @@ bool Myst::observatoryIsDDMMYYYY2400() {
}
void Myst::observatoryUpdateVisualizer(uint16 x, uint16 y) {
- Common::Rect &visu0 = _observatoryVisualizer->_subImages[0].rect;
- Common::Rect &visu1 = _observatoryVisualizer->_subImages[1].rect;
-
- visu0.left = x;
- visu0.right = visu0.left + 105;
- visu0.bottom = 512 - y;
- visu0.top = visu0.bottom - 106;
-
- visu1.left = visu0.left;
- visu1.top = visu0.top;
- visu1.right = visu0.right;
- visu1.bottom = visu0.bottom;
+ Common::Rect visu;
+ visu.left = x;
+ visu.right = visu.left + 105;
+ visu.bottom = 512 - y;
+ visu.top = visu.bottom - 106;
+
+ _observatoryVisualizer->setSubImageRect(0, visu);
+ _observatoryVisualizer->setSubImageRect(1, visu);
}
void Myst::observatorySetTargetToSetting() {
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 0cf89eb0a1..7d1e1b9dff 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -671,9 +671,12 @@ void Selenitic::soundReceiverUpdate() {
void Selenitic::soundReceiverDrawView() {
uint32 left = ((*_soundReceiverPosition) * 1800) / 3600;
- _soundReceiverViewer->_subImages->rect.left = left;
- _soundReceiverViewer->_subImages->rect.right = left + 136;
+ Common::Rect rect = _soundReceiverViewer->getSubImage(0).rect;
+ rect.left = left;
+ rect.right = left + 136;
+
+ _soundReceiverViewer->setSubImageRect(0, rect);
_soundReceiverViewer->drawConditionalDataToScreen(0);
soundReceiverDrawAngle();