diff options
author | Paul Gilbert | 2016-04-17 21:08:42 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:21 -0400 |
commit | 46a30255b0e5a7f5dad4fd032388d31a69208b62 (patch) | |
tree | 1e668339aecb1246c9ec20515b81866d81ab75d2 /engines/titanic/pet_control | |
parent | a11e677494d7cb3c6b8ed2c56095873d46a00ab8 (diff) | |
download | scummvm-rg350-46a30255b0e5a7f5dad4fd032388d31a69208b62.tar.gz scummvm-rg350-46a30255b0e5a7f5dad4fd032388d31a69208b62.tar.bz2 scummvm-rg350-46a30255b0e5a7f5dad4fd032388d31a69208b62.zip |
TITANIC: Seperate PET classes setup and reset methods
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_control.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control.h | 10 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_element.h | 6 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_frame.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_frame.h | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_gfx_element.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_gfx_element.h | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 31 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.cpp | 24 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.h | 8 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory_glyphs.cpp | 31 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory_glyphs.h | 15 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_section.h | 4 |
14 files changed, 131 insertions, 50 deletions
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 |