From 7d819f71f7d9fdd794b12ac55bd2177f12069c1b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 31 Mar 2016 21:40:36 -0400 Subject: TITANIC: PET frame is now showing --- engines/titanic/pet_control/pet_control.cpp | 123 +++++++++++++-------- engines/titanic/pet_control/pet_control.h | 22 +++- engines/titanic/pet_control/pet_control_sub5.cpp | 5 + engines/titanic/pet_control/pet_control_sub5.h | 5 + engines/titanic/pet_control/pet_control_sub7.cpp | 5 + engines/titanic/pet_control/pet_control_sub7.h | 5 +- .../pet_control/pet_conversation_section.cpp | 5 + .../titanic/pet_control/pet_conversation_section.h | 5 + engines/titanic/pet_control/pet_frame.h | 4 + .../titanic/pet_control/pet_inventory_section.cpp | 5 + .../titanic/pet_control/pet_inventory_section.h | 5 + engines/titanic/pet_control/pet_remote_section.cpp | 5 + engines/titanic/pet_control/pet_remote_section.h | 6 +- engines/titanic/pet_control/pet_rooms_section.cpp | 6 + engines/titanic/pet_control/pet_rooms_section.h | 5 + engines/titanic/pet_control/pet_save_section.cpp | 5 + engines/titanic/pet_control/pet_save_section.h | 5 +- engines/titanic/pet_control/pet_section.cpp | 4 - engines/titanic/pet_control/pet_section.h | 11 +- 19 files changed, 172 insertions(+), 64 deletions(-) (limited to 'engines/titanic/pet_control') diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 8376f4ac2c..6df688ef75 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -29,7 +29,8 @@ namespace Titanic { CPetControl::CPetControl() : CGameObject(), _currentArea(PET_CONVERSATION), _fieldC0(0), _locked(0), _fieldC8(0), - _treeItem1(nullptr), _treeItem2(nullptr), _hiddenRoom(nullptr) { + _treeItem1(nullptr), _treeItem2(nullptr), _hiddenRoom(nullptr), + _drawBounds(20, 350, 620, 480) { } void CPetControl::save(SimpleFile *file, int indent) const { @@ -58,46 +59,46 @@ void CPetControl::load(SimpleFile *file) { } bool CPetControl::isValid() { - return _convSection.isValid(this) && - _roomsSection.isValid(this) && - _remoteSection.isValid(this) && - _invSection.isValid(this) && + return _conversations.isValid(this) && + _rooms.isValid(this) && + _remote.isValid(this) && + _inventory.isValid(this) && _sub5.isValid(this) && - _saveSection.isValid(this) && + _saves.isValid(this) && _sub7.isValid(this) && _frame.isValid(this); } void CPetControl::loadAreas(SimpleFile *file, int param) { - _convSection.load(file, param); - _roomsSection.load(file, param); - _remoteSection.load(file, param); - _invSection.load(file, param); + _conversations.load(file, param); + _rooms.load(file, param); + _remote.load(file, param); + _inventory.load(file, param); _sub5.load(file, param); - _saveSection.load(file, param); + _saves.load(file, param); _sub7.load(file, param); _frame.load(file, param); } void CPetControl::saveAreas(SimpleFile *file, int indent) const { - _convSection.save(file, indent); - _roomsSection.save(file, indent); - _remoteSection.save(file, indent); - _invSection.save(file, indent); + _conversations.save(file, indent); + _rooms.save(file, indent); + _remote.save(file, indent); + _inventory.save(file, indent); _sub5.save(file, indent); - _saveSection.save(file, indent); + _saves.save(file, indent); _sub7.save(file, indent); _frame.save(file, indent); } void CPetControl::draw(CScreenManager *screenManager) { CGameManager *gameManager = getGameManager(); - Rect bounds = _oldBounds; + Rect bounds = _drawBounds; bounds.constrain(gameManager->_bounds); if (!bounds.isEmpty()) { if (_fieldC8 >= 0) { - _invSection.proc5(_fieldC8); + _inventory.proc5(_fieldC8); _fieldC8 = -1; } @@ -106,19 +107,19 @@ void CPetControl::draw(CScreenManager *screenManager) { // Draw the specific area that's currently active switch (_currentArea) { case PET_INVENTORY: - _invSection.draw(screenManager); + _inventory.draw(screenManager); break; case PET_CONVERSATION: - _convSection.draw(screenManager); + _conversations.draw(screenManager); break; case PET_REMOTE: - _remoteSection.draw(screenManager); + _remote.draw(screenManager); break; case PET_ROOMS: - _roomsSection.draw(screenManager); + _rooms.draw(screenManager); break; case PET_SAVE: - _saveSection.draw(screenManager); + _saves.draw(screenManager); break; case PET_5: _sub5.draw(screenManager); @@ -132,6 +133,34 @@ void CPetControl::draw(CScreenManager *screenManager) { } } +Rect CPetControl::getBounds() { + switch (_currentArea) { + case PET_INVENTORY: + return _inventory.getBounds(); + break; + case PET_CONVERSATION: + return _conversations.getBounds(); + break; + case PET_REMOTE: + return _remote.getBounds(); + break; + case PET_ROOMS: + return _rooms.getBounds(); + break; + case PET_SAVE: + return _saves.getBounds(); + break; + case PET_5: + return _sub5.getBounds(); + break; + case PET_6: + return _sub7.getBounds(); + break; + default: + break; + } +} + void CPetControl::postLoad() { CProjectItem *root = getRoot(); @@ -145,12 +174,12 @@ void CPetControl::postLoad() { } void CPetControl::loaded() { - _convSection.postLoad(); - _roomsSection.postLoad(); - _remoteSection.postLoad(); - _invSection.postLoad(); + _conversations.postLoad(); + _rooms.postLoad(); + _remote.postLoad(); + _inventory.postLoad(); _sub5.postLoad(); - _saveSection.postLoad(); + _saves.postLoad(); _sub7.postLoad(); _frame.postLoad(); } @@ -160,8 +189,8 @@ void CPetControl::enterNode(CNodeItem *node) { } void CPetControl::enterRoom(CRoomItem *room) { - _roomsSection.enterRoom(room); - _remoteSection.enterRoom(room); + _rooms.enterRoom(room); + _remote.enterRoom(room); } void CPetControl::clear() { @@ -185,19 +214,19 @@ PetArea CPetControl::setArea(PetArea newArea) { // Signal the currently active area that it's being left switch (_currentArea) { case PET_INVENTORY: - _invSection.leave(); + _inventory.leave(); break; case PET_CONVERSATION: - _convSection.leave(); + _conversations.leave(); break; case PET_REMOTE: - _remoteSection.leave(); + _remote.leave(); break; case PET_ROOMS: - _roomsSection.leave(); + _rooms.leave(); break; case PET_SAVE: - _saveSection.leave(); + _saves.leave(); break; case PET_5: _sub5.leave(); @@ -217,20 +246,20 @@ PetArea CPetControl::setArea(PetArea newArea) { // Signal to the new view that it's been activated switch (newArea) { case PET_INVENTORY: - _invSection.enter(oldArea); + _inventory.enter(oldArea); break; case PET_CONVERSATION: - _convSection.enter(oldArea); + _conversations.enter(oldArea); break; case PET_REMOTE: - _remoteSection.enter(oldArea); + _remote.enter(oldArea); break; case PET_ROOMS: - _roomsSection.enter(oldArea); + _rooms.enter(oldArea); break; case PET_SAVE: - _saveSection.enter(oldArea); + _saves.enter(oldArea); break; case PET_5: _sub5.enter(oldArea); @@ -249,19 +278,19 @@ PetArea CPetControl::setArea(PetArea newArea) { void CPetControl::fn2(int val) { switch (_currentArea) { case PET_INVENTORY: - _invSection.proc38(val); + _inventory.proc38(val); break; case PET_CONVERSATION: - _convSection.proc38(val); + _conversations.proc38(val); break; case PET_REMOTE: - _remoteSection.proc38(val); + _remote.proc38(val); break; case PET_ROOMS: - _roomsSection.proc38(val); + _rooms.proc38(val); break; case PET_SAVE: - _saveSection.proc38(val); + _saves.proc38(val); break; case PET_5: _sub5.proc38(val); @@ -309,4 +338,8 @@ CGameObject *CPetControl::getHiddenObject(const CString &name) { return room ? findItemInRoom(room, name) : nullptr; } +bool CPetControl::containsPt(const Common::Point &pt) const { + return _drawBounds.contains(pt); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index ea7c6845f3..24ab78a963 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -42,11 +42,11 @@ private: int _fieldC0; int _locked; int _fieldC8; - CPetConversationSection _convSection; - CPetInventorySection _invSection; - CPetRemoteSection _remoteSection; - CPetRoomsSection _roomsSection; - CPetSaveSection _saveSection; + CPetConversationSection _conversations; + CPetInventorySection _inventory; + CPetRemoteSection _remote; + CPetRoomsSection _rooms; + CPetSaveSection _saves; CPetControlSub5 _sub5; CPetControlSub7 _sub7; CPetFrame _frame; @@ -55,7 +55,7 @@ private: CTreeItem *_treeItem2; CString _string2; CRoomItem *_hiddenRoom; - Rect _oldBounds; + Rect _drawBounds; private: /** * Returns true if the control is in a valid state @@ -81,6 +81,11 @@ private: * Scan the specified room for an item by name */ CGameObject *findItemInRoom(CRoomItem *room, const CString &name) const; + + /** + * Returns true if the draw bounds contains the specified point + */ + bool containsPt(const Common::Point &pt) const; public: PetArea _currentArea; public: @@ -102,6 +107,11 @@ public: */ virtual void draw(CScreenManager *screenManager); + /** + * Gets the bounds occupied by the item + */ + virtual Rect getBounds(); + /** * Called after loading a game has finished */ diff --git a/engines/titanic/pet_control/pet_control_sub5.cpp b/engines/titanic/pet_control/pet_control_sub5.cpp index 6a9b92e7b2..0b43853704 100644 --- a/engines/titanic/pet_control/pet_control_sub5.cpp +++ b/engines/titanic/pet_control/pet_control_sub5.cpp @@ -40,4 +40,9 @@ void CPetControlSub5::load(SimpleFile *file, int param) { } } +bool CPetControlSub5::isValid(CPetControl *petControl) { + // TODO + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub5.h b/engines/titanic/pet_control/pet_control_sub5.h index 088ba6fd27..4997bf195d 100644 --- a/engines/titanic/pet_control/pet_control_sub5.h +++ b/engines/titanic/pet_control/pet_control_sub5.h @@ -56,6 +56,11 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file, int param); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub7.cpp b/engines/titanic/pet_control/pet_control_sub7.cpp index f57454da67..5b033220c7 100644 --- a/engines/titanic/pet_control/pet_control_sub7.cpp +++ b/engines/titanic/pet_control/pet_control_sub7.cpp @@ -24,4 +24,9 @@ namespace Titanic { +bool CPetControlSub7::isValid(CPetControl *petControl) { + // TODO + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub7.h b/engines/titanic/pet_control/pet_control_sub7.h index fba7d2d6bf..5ad0ba793e 100644 --- a/engines/titanic/pet_control/pet_control_sub7.h +++ b/engines/titanic/pet_control/pet_control_sub7.h @@ -33,7 +33,10 @@ private: CPetControlSub12 _sub1; CPetControlSub12 _sub2; public: - + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_conversation_section.cpp b/engines/titanic/pet_control/pet_conversation_section.cpp index 890a03dac6..166c8ecc47 100644 --- a/engines/titanic/pet_control/pet_conversation_section.cpp +++ b/engines/titanic/pet_control/pet_conversation_section.cpp @@ -40,4 +40,9 @@ void CPetConversationSection::load(SimpleFile *file, int param) { _valArray3[idx] = file->readNumber(); } +bool CPetConversationSection::isValid(CPetControl *petControl) { + // TODO + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_conversation_section.h b/engines/titanic/pet_control/pet_conversation_section.h index 863a0d99e2..55492ceb1a 100644 --- a/engines/titanic/pet_control/pet_conversation_section.h +++ b/engines/titanic/pet_control/pet_conversation_section.h @@ -62,6 +62,11 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file, int param); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_frame.h b/engines/titanic/pet_control/pet_frame.h index 83543ef87c..2bf9f2ace4 100644 --- a/engines/titanic/pet_control/pet_frame.h +++ b/engines/titanic/pet_control/pet_frame.h @@ -28,6 +28,10 @@ namespace Titanic { +/** + * This implements the frame and background for the PET display. + * This includes the area buttons and title + */ class CPetFrame : public CPetSection { private: static int _indexes[6]; diff --git a/engines/titanic/pet_control/pet_inventory_section.cpp b/engines/titanic/pet_control/pet_inventory_section.cpp index d859576399..675d6033c9 100644 --- a/engines/titanic/pet_control/pet_inventory_section.cpp +++ b/engines/titanic/pet_control/pet_inventory_section.cpp @@ -39,4 +39,9 @@ void CPetInventorySection::load(SimpleFile *file, int param) { _field298 = file->readNumber(); } +bool CPetInventorySection::isValid(CPetControl *petControl) { + // TODO + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_inventory_section.h b/engines/titanic/pet_control/pet_inventory_section.h index 4adad469a7..4d36e2fba9 100644 --- a/engines/titanic/pet_control/pet_inventory_section.h +++ b/engines/titanic/pet_control/pet_inventory_section.h @@ -52,6 +52,11 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file, int param); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_remote_section.cpp b/engines/titanic/pet_control/pet_remote_section.cpp index 7cdde01252..37720848cc 100644 --- a/engines/titanic/pet_control/pet_remote_section.cpp +++ b/engines/titanic/pet_control/pet_remote_section.cpp @@ -24,4 +24,9 @@ namespace Titanic { +bool CPetRemoteSection::isValid(CPetControl *petControl) { + // TODO + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_remote_section.h b/engines/titanic/pet_control/pet_remote_section.h index 562579dc50..f3063bdd16 100644 --- a/engines/titanic/pet_control/pet_remote_section.h +++ b/engines/titanic/pet_control/pet_remote_section.h @@ -46,8 +46,10 @@ private: CPetGfxElement _val11; CPetControlSub12 _sub12; public: - - + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_rooms_section.cpp b/engines/titanic/pet_control/pet_rooms_section.cpp index b866fb349d..d0d098580a 100644 --- a/engines/titanic/pet_control/pet_rooms_section.cpp +++ b/engines/titanic/pet_control/pet_rooms_section.cpp @@ -56,4 +56,10 @@ void CPetRoomsSection::load(SimpleFile *file, int param) { } } +bool CPetRoomsSection::isValid(CPetControl *petControl) { + // TODO + return true; +} + + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_rooms_section.h b/engines/titanic/pet_control/pet_rooms_section.h index 66c6e8cc0a..a4bcefe09c 100644 --- a/engines/titanic/pet_control/pet_rooms_section.h +++ b/engines/titanic/pet_control/pet_rooms_section.h @@ -62,6 +62,11 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file, int param); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_save_section.cpp b/engines/titanic/pet_control/pet_save_section.cpp index e513dd3013..8d24fed42c 100644 --- a/engines/titanic/pet_control/pet_save_section.cpp +++ b/engines/titanic/pet_control/pet_save_section.cpp @@ -24,4 +24,9 @@ namespace Titanic { +bool CPetSaveSection::isValid(CPetControl *petControl) { + // TODO + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_save_section.h b/engines/titanic/pet_control/pet_save_section.h index fb9004f47d..502338263f 100644 --- a/engines/titanic/pet_control/pet_save_section.h +++ b/engines/titanic/pet_control/pet_save_section.h @@ -34,7 +34,10 @@ private: CPetControlSub10 _sub10; CPetControlSub10 _sub12; public: - + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp index 321f1fb94f..d531b5d0d7 100644 --- a/engines/titanic/pet_control/pet_section.cpp +++ b/engines/titanic/pet_control/pet_section.cpp @@ -25,10 +25,6 @@ namespace Titanic { -void CPetSection::proc4() { - error("TODO"); -} - void CPetSection::proc16() { error("TODO"); } diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h index 2612d64a19..b08e4d6869 100644 --- a/engines/titanic/pet_control/pet_section.h +++ b/engines/titanic/pet_control/pet_section.h @@ -68,7 +68,11 @@ public: */ virtual void draw(CScreenManager *screenManager) {} - virtual void proc4(); + /** + * Get the bounds for the section + */ + virtual Rect getBounds() { return Rect(); } + virtual void proc5(int val) {} virtual int proc6() { return 0; } virtual int proc7() { return 0; } @@ -85,10 +89,7 @@ public: /** * Returns true if the object is in a valid state */ - virtual bool isValid(CPetControl *petControl) { - // TODO: Switch back to false after implementing all sections - return true; - } + virtual bool isValid(CPetControl *petControl) { return false; } /** * Load the data for the class from file -- cgit v1.2.3