aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/carry/arm.cpp2
-rw-r--r--engines/titanic/carry/carry.cpp8
-rw-r--r--engines/titanic/carry/carry.h2
-rw-r--r--engines/titanic/carry/chicken.cpp2
-rw-r--r--engines/titanic/core/tree_item.cpp2
-rw-r--r--engines/titanic/debugger.cpp2
-rw-r--r--engines/titanic/pet_control/pet_control.cpp16
-rw-r--r--engines/titanic/pet_control/pet_control.h10
-rw-r--r--engines/titanic/pet_control/pet_element.h6
-rw-r--r--engines/titanic/pet_control/pet_frame.cpp16
-rw-r--r--engines/titanic/pet_control/pet_frame.h2
-rw-r--r--engines/titanic/pet_control/pet_gfx_element.cpp2
-rw-r--r--engines/titanic/pet_control/pet_gfx_element.h4
-rw-r--r--engines/titanic/pet_control/pet_glyphs.cpp12
-rw-r--r--engines/titanic/pet_control/pet_glyphs.h31
-rw-r--r--engines/titanic/pet_control/pet_inventory.cpp24
-rw-r--r--engines/titanic/pet_control/pet_inventory.h8
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.cpp31
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.h15
-rw-r--r--engines/titanic/pet_control/pet_section.h4
20 files changed, 142 insertions, 57 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp
index c39812fd26..d662b43f76 100644
--- a/engines/titanic/carry/arm.cpp
+++ b/engines/titanic/carry/arm.cpp
@@ -172,7 +172,7 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) {
_visibleFrame = _field170;
loadFrame(_visibleFrame);
_string6 = "None";
- invFn3();
+ invChange();
}
}
diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp
index 31d0ff02d2..cb87b94c90 100644
--- a/engines/titanic/carry/carry.cpp
+++ b/engines/titanic/carry/carry.cpp
@@ -240,14 +240,16 @@ bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
void CCarry::addToInventory() {
CPetControl *pet = getPetControl();
- if (pet)
+ if (pet) {
+ makeDirty();
pet->addToInventory(this);
+ }
}
-void CCarry::invFn3() {
+void CCarry::invChange() {
CPetControl *pet = getPetControl();
if (pet)
- pet->invFn3(this);
+ pet->invChange(this);
}
} // End of namespace Titanic
diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h
index 2370556607..ba782fda7e 100644
--- a/engines/titanic/carry/carry.h
+++ b/engines/titanic/carry/carry.h
@@ -65,7 +65,7 @@ protected:
/**
*
*/
- void invFn3();
+ void invChange();
public:
CLASSDEF
CCarry();
diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp
index 74b42aafcd..8483a3fb29 100644
--- a/engines/titanic/carry/chicken.cpp
+++ b/engines/titanic/carry/chicken.cpp
@@ -171,7 +171,7 @@ bool CChicken::TimerMsg(CTimerMsg *msg) {
}
if (flag) {
- invFn3();
+ invChange();
stopTimer(_timerId);
}
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index abd6f6c51b..039d597ece 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -280,7 +280,7 @@ void CTreeItem::clearPet() const {
}
CPetControl *CTreeItem::getPetControl() const {
- return dynamic_cast<CPetControl *>(getDontSaveChild(CPetControl::_type));
+ return static_cast<CPetControl *>(getDontSaveChild(CPetControl::_type));
}
CMailMan *CTreeItem::getMailMan() const {
diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp
index f525f4f3b9..d643a87a4b 100644
--- a/engines/titanic/debugger.cpp
+++ b/engines/titanic/debugger.cpp
@@ -244,6 +244,8 @@ bool Debugger::cmdItem(int argc, const char **argv) {
debugPrintf("Current location: %s\n", fullName.c_str());
} else if (CString(argv[2]) == "add") {
CPetControl *pet = item->getPetControl();
+ assert(pet);
+
pet->_visible = true;
item->addToInventory();
return false;
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 25ab972df9..31f95d1a88 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -45,6 +45,7 @@ CPetControl::CPetControl() : CGameObject(),
_currentArea(PET_CONVERSATION), _fieldC0(0), _locked(0), _fieldC8(0),
_treeItem1(nullptr), _treeItem2(nullptr), _hiddenRoom(nullptr),
_drawBounds(20, 350, 620, 480) {
+ setup();
_timers[0] = _timers[1] = nullptr;
_sections[PET_INVENTORY] = &_inventory;
_sections[PET_CONVERSATION] = &_conversations;
@@ -80,6 +81,17 @@ void CPetControl::load(SimpleFile *file) {
CGameObject::load(file);
}
+void CPetControl::setup() {
+ warning("TODO: CPetControl::setup");
+ _rooms.setup(this);
+ _remote.setup(this);
+ _inventory.setup(this);
+ _sub5.setup(this);
+ _saves.setup(this);
+ _sub7.setup(this);
+ _frame.setup(this);
+}
+
bool CPetControl::isValid() {
return _conversations.isValid(this) &&
_rooms.isValid(this) &&
@@ -399,8 +411,8 @@ void CPetControl::removeFromInventory(CCarry *item, bool refreshUI, bool sendMsg
removeFromInventory(item, view, refreshUI, sendMsg);
}
-void CPetControl::invFn3(CCarry *item) {
- _inventory.fn3(item);
+void CPetControl::invChange(CCarry *item) {
+ _inventory.change(item);
}
void CPetControl::moveToHiddenRoom(CTreeItem *item) {
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 4192d9ebf4..1e98e3f5d8 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -125,6 +125,11 @@ public:
virtual Rect getBounds();
/**
+ * Setups the sections within the PET
+ */
+ void setup();
+
+ /**
* Called after loading a game has finished
*/
void postLoad();
@@ -224,7 +229,10 @@ public:
*/
void removeFromInventory(CCarry *item, bool refreshUI = true, bool sendMsg = true);
- void invFn3(CCarry *item);
+ /**
+ * Called when the status of an item in the inventory has changed
+ */
+ void invChange(CCarry *item);
/**
* Moves a tree item from it's original position to be under the hidden room
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h
index d4ca580349..a8f5000155 100644
--- a/engines/titanic/pet_control/pet_element.h
+++ b/engines/titanic/pet_control/pet_element.h
@@ -50,10 +50,10 @@ public:
CPetControl *petControl) {}
/**
- * Sets up the element
+ * Reset the element
*/
- virtual void setup(int val, const CString &name, CPetControl *petControl) {}
-
+ virtual void reset(const CString &name, CPetControl *petControl, PetElementMode mode) {}
+
/**
* Draw the item
*/
diff --git a/engines/titanic/pet_control/pet_frame.cpp b/engines/titanic/pet_control/pet_frame.cpp
index 1859b0d39f..25d67fb661 100644
--- a/engines/titanic/pet_control/pet_frame.cpp
+++ b/engines/titanic/pet_control/pet_frame.cpp
@@ -35,28 +35,28 @@ CPetFrame::CPetFrame() : CPetSection() {
bool CPetFrame::setup(CPetControl *petControl) {
if (setPetControl(petControl))
- return setup();
+ return reset();
return false;
}
-bool CPetFrame::setup() {
+bool CPetFrame::reset() {
if (_petControl) {
- _background.setup("PetBackground", _petControl, MODE_UNSELECTED);
- _modeBackground.setup("PetModeBackground", _petControl, MODE_UNSELECTED);
+ _background.reset("PetBackground", _petControl, MODE_UNSELECTED);
+ _modeBackground.reset("PetModeBackground", _petControl, MODE_UNSELECTED);
for (int idx = 0; idx < 5; ++idx) {
CString resName = Common::String::format("PetMode%d", idx);
- _modeButtons[idx].setup(resName, _petControl, MODE_UNSELECTED);
+ _modeButtons[idx].reset(resName, _petControl, MODE_UNSELECTED);
}
for (int idx = 0; idx < 6; ++idx) {
CString resName = Common::String::format("3Pettitle%d", idx);
- _titles[idx].setup(resName, _petControl, MODE_UNSELECTED);
+ _titles[idx].reset(resName, _petControl, MODE_UNSELECTED);
}
for (int idx = 0; idx < 7; ++idx) {
CString resName = Common::String::format("PetIndent%d", idx);
- _indent[idx].setup(resName, _petControl, MODE_UNSELECTED);
+ _indent[idx].reset(resName, _petControl, MODE_UNSELECTED);
}
}
@@ -87,7 +87,7 @@ bool CPetFrame::isValid(CPetControl *petControl) {
}
void CPetFrame::postLoad() {
- setup();
+ reset();
}
bool CPetFrame::setPetControl(CPetControl *petControl) {
diff --git a/engines/titanic/pet_control/pet_frame.h b/engines/titanic/pet_control/pet_frame.h
index ec8bd1e1d8..0bc872a33d 100644
--- a/engines/titanic/pet_control/pet_frame.h
+++ b/engines/titanic/pet_control/pet_frame.h
@@ -57,7 +57,7 @@ public:
/**
* Sets up the section
*/
- virtual bool setup();
+ virtual bool reset();
/**
* Handles mouse down messages
diff --git a/engines/titanic/pet_control/pet_gfx_element.cpp b/engines/titanic/pet_control/pet_gfx_element.cpp
index 7f249f0c2d..fbe9e6db53 100644
--- a/engines/titanic/pet_control/pet_gfx_element.cpp
+++ b/engines/titanic/pet_control/pet_gfx_element.cpp
@@ -44,7 +44,7 @@ void CPetGfxElement::setup(PetElementMode mode, const CString &name,
}
}
-void CPetGfxElement::setup(const CString &name, CPetControl *petControl, PetElementMode mode) {
+void CPetGfxElement::reset(const CString &name, CPetControl *petControl, PetElementMode mode) {
if (!petControl)
return;
diff --git a/engines/titanic/pet_control/pet_gfx_element.h b/engines/titanic/pet_control/pet_gfx_element.h
index a4c39c6d24..bc9150e04c 100644
--- a/engines/titanic/pet_control/pet_gfx_element.h
+++ b/engines/titanic/pet_control/pet_gfx_element.h
@@ -43,9 +43,9 @@ public:
CPetControl *petControl);
/**
- * Setup the element
+ * Reset the element
*/
- virtual void setup(const CString &name, CPetControl *petControl, PetElementMode mode);
+ virtual void reset(const CString &name, CPetControl *petControl, PetElementMode mode);
/**
* Draw the item
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp
index fc3fcc593a..a9a15c5ac2 100644
--- a/engines/titanic/pet_control/pet_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_glyphs.cpp
@@ -53,18 +53,24 @@ CPetGlyphs::CPetGlyphs() : _firstVisibleIndex(0), _numVisibleGlyphs(7),
_highlightIndex(-1), _field1C(-1), _field20(0), _field24(0) {
}
+void CPetGlyphs::setNumVisible(int total) {
+ if (total > 0)
+ _numVisibleGlyphs = total;
+}
+
void CPetGlyphs::clear() {
changeHighlight(-1);
destroyContents();
_firstVisibleIndex = 0;
}
-void CPetGlyphs::proc8() {
+void CPetGlyphs::setup(int numVisible, CPetSection *owner) {
error("TODO");
}
-void CPetGlyphs::setup() {
- warning("TODO: CPetGlyphs::setup");
+void CPetGlyphs::reset() {
+
+ warning("TODO: CPetGlyphs::reset");
}
void CPetGlyphs::proc10() {
diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h
index 6160c454a1..fceca4d27e 100644
--- a/engines/titanic/pet_control/pet_glyphs.h
+++ b/engines/titanic/pet_control/pet_glyphs.h
@@ -30,6 +30,19 @@
namespace Titanic {
class CPetGlyphs;
+class CPetSection;
+
+enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 };
+
+class CGlyphAction {
+protected:
+ GlyphActionMode _mode;
+public:
+ CGlyphAction() : _mode(ACTION_REMOVED) {}
+ CGlyphAction(GlyphActionMode mode) : _mode(mode) {}
+
+ GlyphActionMode getMode() const { return _mode; }
+};
class CPetGlyph : public ListItem {
public:
@@ -105,7 +118,11 @@ public:
virtual int proc35() { return 0; }
virtual void proc36() {}
virtual int proc37() { return 0; }
- virtual int proc38() { return 1; }
+
+ /**
+ * Does a processing action on the glyph
+ */
+ virtual bool doAction(CGlyphAction *action) { return true; }
};
class CPetGlyphs : public List<CPetGlyph> {
@@ -149,17 +166,25 @@ public:
CPetGlyphs();
/**
+ * Set the number of visible glyphs
+ */
+ void setNumVisible(int total);
+
+ /**
* Clears the glyph list
*/
void clear();
- virtual void proc8();
+ /**
+ * The visual dimensions for the control and it's components
+ */
+ virtual void setup(int numVisible, CPetSection *owner);
/**
* Set up the control
*/
- virtual void setup();
+ virtual void reset();
virtual void proc10();
virtual void proc11();
diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp
index e765db60ea..ff333ed79c 100644
--- a/engines/titanic/pet_control/pet_inventory.cpp
+++ b/engines/titanic/pet_control/pet_inventory.cpp
@@ -35,11 +35,11 @@ CPetInventory::CPetInventory() : CPetSection(),
}
bool CPetInventory::setup(CPetControl *petControl) {
- return setPetControl(petControl) && setup();
+ return setPetControl(petControl) && reset();
}
-bool CPetInventory::setup() {
- _items.setup();
+bool CPetInventory::reset() {
+ _items.reset();
_sub12.setup();
// TODO
@@ -80,7 +80,7 @@ bool CPetInventory::setPetControl(CPetControl *petControl) {
return false;
_petControl = petControl;
- _items.proc8();
+ _items.setup(7, this);
_items.set20(28);
Rect tempRect(0, 0, 52, 52);
@@ -103,20 +103,18 @@ bool CPetInventory::setPetControl(CPetControl *petControl) {
return true;
}
-void CPetInventory::addItem(CCarry *item) {
+void CPetInventory::change(CCarry *item) {
if (item) {
- CPetCarry glyphItem(item, 2);
-
+ CInventoryGlyphAction action(item, ACTION_CHANGE);
+ _items.change(&action);
}
- warning("TODO: CPetInventory::addItem");
}
void CPetInventory::itemRemoved(CCarry *item) {
- warning("TODO: CPetInventory::itemRemoved");
-}
-
-void CPetInventory::fn3(CCarry *item) {
- warning("TODO: CPetInventory::fn3");
+ if (item) {
+ CInventoryGlyphAction action(item, ACTION_REMOVED);
+ _items.change(&action);
+ }
}
void CPetInventory::itemsChanged() {
diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h
index f228840857..e192bf8a92 100644
--- a/engines/titanic/pet_control/pet_inventory.h
+++ b/engines/titanic/pet_control/pet_inventory.h
@@ -64,7 +64,7 @@ public:
/**
* Sets up the section
*/
- virtual bool setup();
+ virtual bool reset();
/**
* Draw the section
@@ -97,17 +97,15 @@ public:
virtual bool isValid(CPetControl *petControl);
/**
- * Add an item to the inventory
+ *
*/
- void addItem(CCarry *item);
+ void change(CCarry *item);
/**
* Called when an item has been removed from the PET
*/
void itemRemoved(CCarry *item);
- void fn3(CCarry *item);
-
/**
* Called when the items under the PET have changed
*/
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
index 2614306891..a26919965b 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
@@ -124,10 +124,39 @@ int CPetInventoryGlyph::subMode(CGameObject *item, int val) {
return frameNum;
}
+bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
+ CInventoryGlyphAction *invAction = static_cast<CInventoryGlyphAction *>(action);
+ CPetInventoryGlyphs *owner = static_cast<CPetInventoryGlyphs *>(_owner);
+ if (!invAction)
+ return false;
+
+ switch (invAction->getMode()) {
+ case ACTION_REMOVED:
+ if (invAction->_item == _item) {
+ _item = nullptr;
+ _field3C = 0;
+ _field34 = 0;
+ }
+ break;
+
+ case ACTION_REMOVE:
+ if (_item == invAction->_item && _owner) {
+ int v = populateItem(_item, 0);
+ _field3C = owner->fn1(v);
+ }
+ }
+
+ return true;
+}
+
/*------------------------------------------------------------------------*/
-void CPetInventoryGlyphs::addItem(CPetCarry *item) {
+bool CPetInventoryGlyphs::change(CInventoryGlyphAction *action) {
+ for (iterator i = begin(); i != end(); ++i) {
+ (*i)->doAction(action);
+ }
+ return true;
}
int CPetInventoryGlyphs::fn1(int val) {
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h
index 8c483ea60c..633aee16ac 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.h
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.h
@@ -52,14 +52,19 @@ public:
* Set the inventory item
*/
void setItem(CGameObject *item, int val);
+
+ /**
+ * Does a processing action on the glyph
+ */
+ virtual bool doAction(CGlyphAction *action);
};
-class CPetCarry {
+class CInventoryGlyphAction : public CGlyphAction {
public:
- int _val;
CCarry *_item;
public:
- CPetCarry(CCarry *item, int val) : _item(item), _val(val) {}
+ CInventoryGlyphAction(CCarry *item, GlyphActionMode mode) :
+ CGlyphAction(mode), _item(item) {}
};
class CPetInventoryGlyphs : public CPetGlyphs {
@@ -68,9 +73,9 @@ private:
int fn1(int val);
public:
/**
- * Add a new item to the list
+ *
*/
- void addItem(CPetCarry *item);
+ bool change(CInventoryGlyphAction *item);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 43ae623b37..606aac182d 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -60,9 +60,9 @@ public:
virtual bool setup(CPetControl *petControl) { return false; }
/**
- * Sets up the section
+ * Reset the section
*/
- virtual bool setup() { return false; }
+ virtual bool reset() { return false; }
/**
* Draw the section