aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-18 11:36:39 -0400
committerPaul Gilbert2016-07-10 16:11:29 -0400
commit47024115941c125452bb787758091686c91fc4fb (patch)
tree338d53d05c22902cdbf5ed9249e119e261f96d21 /engines
parent5316951ba6e4403a388e49a1e23fc7858d1c3980 (diff)
downloadscummvm-rg350-47024115941c125452bb787758091686c91fc4fb.tar.gz
scummvm-rg350-47024115941c125452bb787758091686c91fc4fb.tar.bz2
scummvm-rg350-47024115941c125452bb787758091686c91fc4fb.zip
TITANIC: Further cleanup of pet element setups
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/pet_control/pet_glyphs.cpp18
-rw-r--r--engines/titanic/pet_control/pet_glyphs.h19
-rw-r--r--engines/titanic/pet_control/pet_inventory.cpp37
-rw-r--r--engines/titanic/pet_control/pet_inventory.h6
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.cpp14
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.h10
-rw-r--r--engines/titanic/pet_control/pet_section.cpp4
-rw-r--r--engines/titanic/pet_control/pet_section.h6
8 files changed, 90 insertions, 24 deletions
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp
index e38efdddbe..2bf73d909c 100644
--- a/engines/titanic/pet_control/pet_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_glyphs.cpp
@@ -21,10 +21,11 @@
*/
#include "titanic/pet_control/pet_glyphs.h"
+#include "titanic/pet_control/pet_section.h"
namespace Titanic {
-void CPetGlyph::setOwner(CPetControl *petControl, CPetGlyphs *owner) {
+void CPetGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
_element.setBounds(Rect(0, 0, 52, 50));
_owner = owner;
}
@@ -47,6 +48,10 @@ bool CPetGlyph::translateContains(const Point &delta, const Point &pt) {
return result;
}
+CPetSection *CPetGlyph::getPetSection() const {
+ return _owner ? _owner->getOwner() : nullptr;
+}
+
/*------------------------------------------------------------------------*/
CPetGlyphs::CPetGlyphs() : _firstVisibleIndex(0), _numVisibleGlyphs(TOTAL_GLYPHS),
@@ -78,8 +83,17 @@ void CPetGlyphs::setup(int numVisible, CPetSection *owner) {
}
void CPetGlyphs::reset() {
+ if (_owner && _owner->_petControl) {
+ CPetControl *pet = _owner->_petControl;
+
+ _scrollLeft.reset("PetScrollLeft", pet, MODE_UNSELECTED);
+ _scrollRight.reset("PetScrollRight", pet, MODE_UNSELECTED);
+ _selection.reset("PetSelection", pet, MODE_UNSELECTED);
- warning("TODO: CPetGlyphs::reset");
+ for (iterator i = begin(); i != end(); ++i) {
+ (*i)->reset();
+ }
+ }
}
void CPetGlyphs::proc10() {
diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h
index 54abe9d72e..c9962bdb2a 100644
--- a/engines/titanic/pet_control/pet_glyphs.h
+++ b/engines/titanic/pet_control/pet_glyphs.h
@@ -47,6 +47,11 @@ public:
};
class CPetGlyph : public ListItem {
+protected:
+ /**
+ * Get the overall pet section owner
+ */
+ CPetSection *getPetSection() const;
public:
CPetGfxElement _element;
CPetGlyphs *_owner;
@@ -64,11 +69,14 @@ public:
void translateBack(const Point &pt) { _element.translate(-pt.x, -pt.y); }
/**
- * Set the glyph
+ * Setup the glyph
*/
- virtual void setOwner(CPetControl *petControl, CPetGlyphs *owner);
+ virtual void setup(CPetControl *petControl, CPetGlyphs *owner);
- virtual int proc9() { return 0; }
+ /**
+ * Reset the glyph
+ */
+ virtual bool reset() { return false; }
virtual void proc10() {}
virtual void proc11() {}
@@ -202,6 +210,11 @@ public:
* Highlight a specific glyph
*/
void highlight(int index);
+
+ /**
+ * Get the owning section for the glyphs
+ */
+ CPetSection *getOwner() const { return _owner; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp
index 5dd2078bd2..2d11bc11b3 100644
--- a/engines/titanic/pet_control/pet_inventory.cpp
+++ b/engines/titanic/pet_control/pet_inventory.cpp
@@ -123,7 +123,7 @@ void CPetInventory::itemsChanged() {
CGameObject *item = _petControl->getFirstObject();
while (item) {
CPetInventoryGlyph *glyph = new CPetInventoryGlyph();
- glyph->setOwner(_petControl, &_items);
+ glyph->setup(_petControl, &_items);
glyph->setItem(item, _field290);
_items.push_back(glyph);
@@ -145,5 +145,40 @@ int CPetInventory::getItemIndex(CGameObject *item) const {
return index;
}
+CGameObject *CPetInventory::getImage(int index) {
+ if (index >= 0 && index < 46) {
+ int offset = index - 20;
+ int bits;
+ switch (offset) {
+ case 0:
+ bits = 4;
+ break;
+ case 1:
+ bits = 8;
+ break;
+ case 2:
+ bits = 1;
+ break;
+ case 23:
+ bits = 2;
+ break;
+ case 36:
+ bits = 32;
+ break;
+ case 39:
+ bits = 16;
+ break;
+ default:
+ break;
+ }
+
+ if (!(bits & _field298)) {
+ _field298 = bits | _field298;
+ return _itemGlyphs[index];
+ }
+ }
+
+ return nullptr;
+}
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h
index e192bf8a92..fca9dede14 100644
--- a/engines/titanic/pet_control/pet_inventory.h
+++ b/engines/titanic/pet_control/pet_inventory.h
@@ -96,6 +96,10 @@ public:
*/
virtual bool isValid(CPetControl *petControl);
+ virtual CGameObject *getBackground(int index) const {
+ return (index >= 0 && index < 46) ? _itemBackgrounds[index] : nullptr;
+ }
+
/**
*
*/
@@ -115,6 +119,8 @@ public:
* Called when the inventory can't be shown after adding an item
*/
void highlightItem(CGameObject *item);
+
+ CGameObject *getImage(int index);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
index a26919965b..6ce130f22d 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
@@ -22,6 +22,7 @@
#include "common/textconsole.h"
#include "titanic/pet_control/pet_inventory_glyphs.h"
+#include "titanic/pet_control/pet_inventory.h"
#include "titanic/titanic.h"
namespace Titanic {
@@ -38,8 +39,8 @@ void CPetInventoryGlyph::setItem(CGameObject *item, int val) {
if (_owner && item) {
int v1 = populateItem(item, val);
- _field3C = static_cast<CPetInventoryGlyphs *>(_owner)->fn1(v1);
- warning("TODO: CPetInventoryGlyph::setItem");
+ _background = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(v1);
+ _image = static_cast<CPetInventory *>(getPetSection())->getImage(v1);
}
}
@@ -134,7 +135,7 @@ bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
case ACTION_REMOVED:
if (invAction->_item == _item) {
_item = nullptr;
- _field3C = 0;
+ _background = nullptr;
_field34 = 0;
}
break;
@@ -142,7 +143,7 @@ bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
case ACTION_REMOVE:
if (_item == invAction->_item && _owner) {
int v = populateItem(_item, 0);
- _field3C = owner->fn1(v);
+ _background = owner->getBackground(v);
}
}
@@ -159,9 +160,8 @@ bool CPetInventoryGlyphs::change(CInventoryGlyphAction *action) {
return true;
}
-int CPetInventoryGlyphs::fn1(int val) {
- warning("TODO: CPetInventoryGlyphs::fn1");
- return 0;
+CGameObject *CPetInventoryGlyphs::getBackground(int index) {
+ return _owner ? _owner->getBackground(index) : nullptr;
}
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h
index 633aee16ac..190bce77ac 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.h
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.h
@@ -40,13 +40,13 @@ private:
public:
CGameObject *_item;
int _field34;
- int _field3C;
- int _field40;
+ CGameObject *_background;
+ CGameObject *_image;
public:
CPetInventoryGlyph() : _item(nullptr), _field34(0),
- _field3C(0), _field40(0) {}
+ _background(nullptr), _image(nullptr) {}
CPetInventoryGlyph(CCarry *item, int val) : _item(item),
- _field34(val), _field3C(0), _field40(0) {}
+ _field34(val), _background(nullptr), _image(nullptr) {}
/**
* Set the inventory item
@@ -70,7 +70,7 @@ public:
class CPetInventoryGlyphs : public CPetGlyphs {
friend class CPetInventoryGlyph;
private:
- int fn1(int val);
+ CGameObject *getBackground(int index);
public:
/**
*
diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp
index 349fa40fcf..f913ac6b50 100644
--- a/engines/titanic/pet_control/pet_section.cpp
+++ b/engines/titanic/pet_control/pet_section.cpp
@@ -49,8 +49,4 @@ void CPetSection::proc30() {
error("TODO");
}
-void CPetSection::proc31() {
- error("TODO");
-}
-
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 606aac182d..07b935a318 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -48,7 +48,7 @@ struct CPetSectionSubData {
};
class CPetSection {
-protected:
+public:
CPetControl *_petControl;
public:
CPetSection() : _petControl(nullptr) {}
@@ -144,7 +144,9 @@ public:
virtual void proc28();
virtual void proc29();
virtual void proc30();
- virtual void proc31();
+
+ virtual CGameObject *getBackground(int index) const { return nullptr; }
+
virtual void proc32() {}
virtual void proc33() {}
virtual void proc34() {}