aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-07-28 20:00:10 -0400
committerPaul Gilbert2017-07-28 20:00:10 -0400
commit83b46ee3ccc28f602049ed62ce89d119af1d17df (patch)
tree1eb4adeaa34aad83ff2dd29a05106e2575da5a11 /engines
parentc1ed17ce861d7434f5b1aabb70a54cef250b6378 (diff)
downloadscummvm-rg350-83b46ee3ccc28f602049ed62ce89d119af1d17df.tar.gz
scummvm-rg350-83b46ee3ccc28f602049ed62ce89d119af1d17df.tar.bz2
scummvm-rg350-83b46ee3ccc28f602049ed62ce89d119af1d17df.zip
TITANIC: Further cleanup of inventory glyphs
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/pet_control/pet_inventory.cpp14
-rw-r--r--engines/titanic/pet_control/pet_inventory.h9
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.cpp74
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.h16
4 files changed, 60 insertions, 53 deletions
diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp
index e7e8e1f02b..57a4e5eb1a 100644
--- a/engines/titanic/pet_control/pet_inventory.cpp
+++ b/engines/titanic/pet_control/pet_inventory.cpp
@@ -28,7 +28,7 @@
namespace Titanic {
CPetInventory::CPetInventory() : CPetSection(),
- _movie(nullptr), _isLoading(false), _field298(0) {
+ _movie(nullptr), _isLoading(false), _titaniaBitFlags(0) {
for (int idx = 0; idx < TOTAL_ITEMS; ++idx) {
_itemBackgrounds[idx] = _itemGlyphs[idx] = nullptr;
}
@@ -113,7 +113,7 @@ bool CPetInventory::isValid(CPetControl *petControl) {
}
void CPetInventory::load(SimpleFile *file, int param) {
- _field298 = file->readNumber();
+ _titaniaBitFlags = file->readNumber();
}
void CPetInventory::postLoad() {
@@ -124,7 +124,7 @@ void CPetInventory::postLoad() {
}
void CPetInventory::save(SimpleFile *file, int indent) {
- file->writeNumberLine(_field298, indent);
+ file->writeNumberLine(_titaniaBitFlags, indent);
}
void CPetInventory::enter(PetArea oldArea) {
@@ -209,7 +209,7 @@ int CPetInventory::getItemIndex(CGameObject *item) const {
return index;
}
-CGameObject *CPetInventory::getImage(int index) {
+CGameObject *CPetInventory::getFirstAnimation(int index) {
if (index >= 0 && index < 46) {
int bits = 0;
switch (index) {
@@ -235,8 +235,10 @@ CGameObject *CPetInventory::getImage(int index) {
break;
}
- if (!(bits & _field298)) {
- _field298 = bits | _field298;
+ // Only return/show the transformation for Titania's parts the
+ // first time they're added to the inventory
+ if (!(bits & _titaniaBitFlags)) {
+ _titaniaBitFlags = bits | _titaniaBitFlags;
return _itemGlyphs[index];
}
}
diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h
index 8a95efbc24..96fa51c532 100644
--- a/engines/titanic/pet_control/pet_inventory.h
+++ b/engines/titanic/pet_control/pet_inventory.h
@@ -41,7 +41,7 @@ private:
CGameObject *_itemGlyphs[46];
CGameObject *_movie;
bool _isLoading;
- int _field298;
+ int _titaniaBitFlags;
private:
/**
* Handles initial setup
@@ -161,7 +161,12 @@ public:
*/
void highlightItem(CGameObject *item);
- CGameObject *getImage(int index);
+ /**
+ * Gets the object, if any, containing the initial animation played for
+ * an inventory item. For example, the animation when items transform
+ * into pieces of Titania
+ */
+ CGameObject *getFirstAnimation(int index);
/**
* Play the animated movie for an object
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
index 9422eb6f3b..8d6528f347 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
@@ -44,43 +44,43 @@ void CPetInventoryGlyph::leave() {
}
void CPetInventoryGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) {
- if (!_field34)
+ if (!_active)
return;
- if (_image) {
- if (_image->hasActiveMovie()) {
+ if (_singular) {
+ if (_singular->hasActiveMovie()) {
if (isHighlighted_)
- _image->draw(screenManager);
+ _singular->draw(screenManager);
else
- _image->draw(screenManager, pt);
+ _singular->draw(screenManager, pt);
return;
}
- _image = nullptr;
- if (_background && isHighlighted_) {
- _background->setPosition(pt);
+ _singular = nullptr;
+ if (_repeated && isHighlighted_) {
+ _repeated->setPosition(pt);
startRepeatedMovie();
}
}
- if (_background) {
+ if (_repeated) {
if (isHighlighted_)
- _background->draw(screenManager);
+ _repeated->draw(screenManager);
else
- _background->draw(screenManager, pt);
- } else if (_image) {
- _image->draw(screenManager, pt, Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
+ _repeated->draw(screenManager, pt);
+ } else if (_singular) {
+ _singular->draw(screenManager, pt, Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
}
}
void CPetInventoryGlyph::unhighlightCurrent() {
- if (_image) {
- _image->setPosition(Point(0, 0));
+ if (_singular) {
+ _singular->setPosition(Point(0, 0));
stopMovie();
- } else if (_background) {
- _background->setPosition(Point(0, 0));
- _background->loadFrame(0);
+ } else if (_repeated) {
+ _repeated->setPosition(Point(0, 0));
+ _repeated->loadFrame(0);
stopMovie();
}
}
@@ -94,16 +94,16 @@ void CPetInventoryGlyph::highlightCurrent(const Point &pt) {
}
void CPetInventoryGlyph::glyphFocused(const Point &topLeft, bool flag) {
- if (_background && flag)
- _background->setPosition(topLeft);
+ if (_repeated && flag)
+ _repeated->setPosition(topLeft);
}
bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) {
if (!_item)
return false;
- if (_background) {
- _field34 = 0;
+ if (_repeated) {
+ _active = false;
stopMovie();
}
@@ -133,8 +133,8 @@ bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg
msg->_handled = true;
if (msg->execute(item)) {
_item = nullptr;
- _background = nullptr;
- _field34 = 0;
+ _repeated = nullptr;
+ _active = false;
petControl->setAreaChangeType(1);
return true;
} else {
@@ -147,7 +147,7 @@ void CPetInventoryGlyph::getTooltip(CTextControl *text) {
if (text) {
text->setText("");
- if (_field34 && _item) {
+ if (_active && _item) {
int itemIndex = populateItem(_item, 0);
if (itemIndex >= 14 && itemIndex <= 18) {
// Variations of the chicken
@@ -176,15 +176,15 @@ bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
case ACTION_REMOVED:
if (invAction->_item == _item) {
_item = nullptr;
- _background = nullptr;
- _field34 = 0;
+ _repeated = nullptr;
+ _active = false;
}
break;
case ACTION_CHANGE:
if (_item == invAction->_item && _owner) {
int v = populateItem(_item, 0);
- _background = owner->getBackground(v);
+ _repeated = owner->getBackground(v);
if (isHighlighted()) {
Point glyphPos = _owner->getHighlightedGlyphPos();
@@ -205,9 +205,9 @@ void CPetInventoryGlyph::setItem(CGameObject *item, bool isLoading) {
_item = item;
if (_owner && item) {
- int v1 = populateItem(item, isLoading);
- _background = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(v1);
- _image = static_cast<CPetInventory *>(getPetSection())->getImage(v1);
+ int idx = populateItem(item, isLoading);
+ _repeated = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(idx);
+ _singular = static_cast<CPetInventory *>(getPetSection())->getFirstAnimation(idx);
}
}
@@ -306,7 +306,7 @@ void CPetInventoryGlyph::startRepeatedMovie() {
if (_owner) {
CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner());
if (section)
- section->playMovie(_background, true);
+ section->playMovie(_repeated, true);
}
}
@@ -314,7 +314,7 @@ void CPetInventoryGlyph::startSingularMovie() {
if (_owner) {
CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner());
if (section)
- section->playMovie(_image, false);
+ section->playMovie(_singular, false);
}
}
@@ -327,13 +327,13 @@ void CPetInventoryGlyph::stopMovie() {
}
void CPetInventoryGlyph::reposition(const Point &pt) {
- if (_image) {
+ if (_singular) {
// Special transformation of item to piece of Titania
- _image->setPosition(pt);
+ _singular->setPosition(pt);
startSingularMovie();
- } else if (_background) {
+ } else if (_repeated) {
// Standard repeating animation
- _background->setPosition(pt);
+ _repeated->setPosition(pt);
startRepeatedMovie();
}
}
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h
index e35ecc00f7..906bf18888 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.h
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.h
@@ -65,14 +65,14 @@ private:
void reposition(const Point &pt);
public:
CGameObject *_item;
- int _field34;
- CGameObject *_background;
- CGameObject *_image;
+ bool _active;
+ CGameObject *_repeated;
+ CGameObject *_singular;
public:
- CPetInventoryGlyph() : _item(nullptr), _field34(1),
- _background(nullptr), _image(nullptr) {}
- CPetInventoryGlyph(CCarry *item, int val) : _item(item),
- _field34(val), _background(nullptr), _image(nullptr) {}
+ CPetInventoryGlyph() : _item(nullptr), _active(true),
+ _repeated(nullptr), _singular(nullptr) {}
+ CPetInventoryGlyph(CCarry *item, bool active) : _item(item),
+ _active(active), _repeated(nullptr), _singular(nullptr) {}
/**
* Called when the PET area is entered
@@ -117,7 +117,7 @@ public:
/**
* Return whether the glyph is currently valid
*/
- virtual bool isValid() const { return _item && _background; }
+ virtual bool isValid() const { return _item && _repeated; }
/**
* Returns the object associated with the glyph