From e0602c4851ab42763cc66858fed8d05496040498 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 29 Mar 2016 21:57:09 -0400 Subject: TITANIC: More PET renaming, implemented setArea --- engines/titanic/core/game_object.h | 20 +++--- engines/titanic/module.mk | 6 +- engines/titanic/pet_control/pet_control.cpp | 77 ++++++++++++++++++++++-- engines/titanic/pet_control/pet_control.h | 18 ++++-- engines/titanic/pet_control/pet_control_sub6.cpp | 27 --------- engines/titanic/pet_control/pet_control_sub6.h | 42 ------------- engines/titanic/pet_control/pet_control_sub8.cpp | 4 ++ engines/titanic/pet_control/pet_control_sub8.h | 1 + engines/titanic/pet_control/pet_save_section.cpp | 27 +++++++++ engines/titanic/pet_control/pet_save_section.h | 42 +++++++++++++ engines/titanic/pet_control/pet_section.h | 17 +++++- 11 files changed, 188 insertions(+), 93 deletions(-) delete mode 100644 engines/titanic/pet_control/pet_control_sub6.cpp delete mode 100644 engines/titanic/pet_control/pet_control_sub6.h create mode 100644 engines/titanic/pet_control/pet_save_section.cpp create mode 100644 engines/titanic/pet_control/pet_save_section.h (limited to 'engines') diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index dccef71cfe..9a07cd1c98 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -53,16 +53,6 @@ private: void loadImage(const CString &name, bool pendingFlag = true); void processClipList2(); - - /** - * Marks the area in the passed rect as dirty, and requiring re-rendering - */ - void makeDirty(const Rect &r); - - /** - * Marks the area occupied by the object as dirty, requiring re-rendering - */ - void makeDirty(); protected: Rect _bounds; double _field34; @@ -109,6 +99,16 @@ protected: */ bool checkStartDragging(CMouseDragStartMsg *msg); + /** + * Marks the area in the passed rect as dirty, and requiring re-rendering + */ + void makeDirty(const Rect &r); + + /** + * Marks the area occupied by the object as dirty, requiring re-rendering + */ + void makeDirty(); + bool soundFn1(int val); void soundFn2(int val, int val2); void setVisible(bool val); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 3e018a25c5..a72e80d408 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -383,12 +383,12 @@ MODULE_OBJS := \ pet_control/pet_control_list_item.o \ pet_control/pet_control_list_item2.o \ pet_control/pet_conversation_section.o \ - pet_control/pet_section.o \ + pet_control/pet_inventory_section.o \ pet_control/pet_rooms_section.o \ pet_control/pet_remote_section.o \ - pet_control/pet_inventory_section.o \ + pet_control/pet_save_section.o \ + pet_control/pet_section.o \ pet_control/pet_control_sub5.o \ - pet_control/pet_control_sub6.o \ pet_control/pet_control_sub7.o \ pet_control/pet_control_sub8.o \ pet_control/pet_control_sub10.o \ diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 7ef4c1494b..63a1da450b 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -28,7 +28,7 @@ namespace Titanic { void CPetControl::save(SimpleFile *file, int indent) const { file->writeNumberLine(0, indent); - file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_currentArea, indent); file->writeQuotedLine(_string1, indent); file->writeQuotedLine(_string2, indent); @@ -41,7 +41,7 @@ void CPetControl::load(SimpleFile *file) { isValid(); if (!val) { - _fieldBC = file->readNumber(); + _currentArea = (PetArea)file->readNumber(); _string1 = file->readString(); _string2 = file->readString(); @@ -54,7 +54,7 @@ void CPetControl::load(SimpleFile *file) { bool CPetControl::isValid() const { return _convSection.isValid() && _roomsSection.isValid() && _remoteSection.isValid() && _invSection.isValid() - && _sub5.isValid() && _sub6.isValid() + && _sub5.isValid() && _saveSection.isValid() && _sub7.isValid() && _sub8.isValid(); } @@ -64,7 +64,7 @@ void CPetControl::loadSubObjects(SimpleFile *file, int param) { _remoteSection.load(file, param); _invSection.load(file, param); _sub5.load(file, param); - _sub6.load(file, param); + _saveSection.load(file, param); _sub7.load(file, param); _sub8.load(file, param); } @@ -75,7 +75,7 @@ void CPetControl::saveSubObjects(SimpleFile *file, int indent) const { _remoteSection.save(file, indent); _invSection.save(file, indent); _sub5.save(file, indent); - _sub6.save(file, indent); + _saveSection.save(file, indent); _sub7.save(file, indent); _sub8.save(file, indent); } @@ -119,4 +119,71 @@ void CPetControl::fn4() { warning("TODO: CPetControl::fn4"); } +PetArea CPetControl::setArea(PetArea newArea) { + if (newArea == _currentArea || !canChangeArea()) + return _currentArea; + + // Signal the currently active area that it's being left + switch (_currentArea) { + case PET_INVENTORY: + _invSection.leave(); + break; + case PET_CONVERSATION: + _convSection.leave(); + break; + case PET_REMOTE: + _remoteSection.leave(); + break; + case PET_ROOMS: + _roomsSection.leave(); + break; + case PET_SAVE: + _saveSection.leave(); + break; + case PET_5: + _sub5.leave(); + break; + case PET_6: + _sub7.leave(); + break; + default: + break; + } + + // Change the current area + PetArea oldArea = _currentArea; + _sub8.setArea(newArea); + _currentArea = newArea; + + // Signal to the new view that it's been activated + switch (newArea) { + case PET_INVENTORY: + _invSection.enter(oldArea); + + break; + case PET_CONVERSATION: + _convSection.enter(oldArea); + break; + case PET_REMOTE: + _remoteSection.enter(oldArea); + break; + case PET_ROOMS: + _roomsSection.enter(oldArea); + break; + case PET_SAVE: + _saveSection.enter(oldArea); + break; + case PET_5: + _sub5.enter(oldArea); + break; + case PET_6: + _sub7.enter(oldArea); + break; + default: + break; + } + + makeDirty(); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index d6fc9d01a2..ce40eba177 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -30,8 +30,8 @@ #include "titanic/pet_control/pet_inventory_section.h" #include "titanic/pet_control/pet_remote_section.h" #include "titanic/pet_control/pet_rooms_section.h" +#include "titanic/pet_control/pet_save_section.h" #include "titanic/pet_control/pet_control_sub5.h" -#include "titanic/pet_control/pet_control_sub6.h" #include "titanic/pet_control/pet_control_sub7.h" #include "titanic/pet_control/pet_control_sub8.h" @@ -39,16 +39,16 @@ namespace Titanic { class CPetControl : public CGameObject { private: - int _fieldBC; + PetArea _currentArea; int _fieldC0; - int _fieldC4; + int _locked; int _fieldC8; CPetConversationSection _convSection; CPetInventorySection _invSection; CPetRemoteSection _remoteSection; CPetRoomsSection _roomsSection; + CPetSaveSection _saveSection; CPetControlSub5 _sub5; - CPetControlSub6 _sub6; CPetControlSub7 _sub7; CPetControlSub8 _sub8; int _field1384; @@ -107,6 +107,16 @@ public: void fn3(int val); void fn4(); + + /** + * Sets the currently viewed area within the PET + */ + PetArea setArea(PetArea newSection); + + /** + * Returns true if the current area can be changed + */ + bool canChangeArea() const { return _locked == 0; } }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub6.cpp b/engines/titanic/pet_control/pet_control_sub6.cpp deleted file mode 100644 index d017e81d9e..0000000000 --- a/engines/titanic/pet_control/pet_control_sub6.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "titanic/pet_control/pet_control_sub6.h" - -namespace Titanic { - -} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub6.h b/engines/titanic/pet_control/pet_control_sub6.h deleted file mode 100644 index 208d6f2b6d..0000000000 --- a/engines/titanic/pet_control/pet_control_sub6.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef TITANIC_PET_CONTROL_SUB6_H -#define TITANIC_PET_CONTROL_SUB6_H - -#include "titanic/pet_control/pet_section.h" -#include "titanic/pet_control/pet_control_sub10.h" -#include "titanic/pet_control/pet_control_sub12.h" - -namespace Titanic { - -class CPetControlSub6 : public CPetSection { -private: - CPetControlSub10 _sub10; - CPetControlSub10 _sub12; -public: - -}; - -} // End of namespace Titanic - -#endif /* TITANIC_PET_CONTROL_SUB6_H */ diff --git a/engines/titanic/pet_control/pet_control_sub8.cpp b/engines/titanic/pet_control/pet_control_sub8.cpp index 18c68c7ddb..bc577e3cdf 100644 --- a/engines/titanic/pet_control/pet_control_sub8.cpp +++ b/engines/titanic/pet_control/pet_control_sub8.cpp @@ -33,4 +33,8 @@ CPetControlSub8::CPetControlSub8() { _indexes[INDEXES[idx]] = idx; } +void CPetControlSub8::setArea(PetArea newArea) { + warning("TODO: CPetControlSub8::setArea"); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub8.h b/engines/titanic/pet_control/pet_control_sub8.h index a3d9fab3b9..20d260d13b 100644 --- a/engines/titanic/pet_control/pet_control_sub8.h +++ b/engines/titanic/pet_control/pet_control_sub8.h @@ -42,6 +42,7 @@ private: public: CPetControlSub8(); + void setArea(PetArea newArea); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_save_section.cpp b/engines/titanic/pet_control/pet_save_section.cpp new file mode 100644 index 0000000000..e513dd3013 --- /dev/null +++ b/engines/titanic/pet_control/pet_save_section.cpp @@ -0,0 +1,27 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_save_section.h" + +namespace Titanic { + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_save_section.h b/engines/titanic/pet_control/pet_save_section.h new file mode 100644 index 0000000000..fb9004f47d --- /dev/null +++ b/engines/titanic/pet_control/pet_save_section.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SAVE_SECTION_H +#define TITANIC_PET_SAVE_SECTION_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_control_sub10.h" +#include "titanic/pet_control/pet_control_sub12.h" + +namespace Titanic { + +class CPetSaveSection : public CPetSection { +private: + CPetControlSub10 _sub10; + CPetControlSub10 _sub12; +public: + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SAVE_SECTION_H */ diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h index d3006f5ad6..ceada29709 100644 --- a/engines/titanic/pet_control/pet_section.h +++ b/engines/titanic/pet_control/pet_section.h @@ -28,6 +28,11 @@ namespace Titanic { +enum PetArea { + PET_INVENTORY = 0, PET_CONVERSATION = 1, PET_REMOTE = 2, + PET_ROOMS = 3, PET_SAVE = 4, PET_5 = 5, PET_6 = 6 +}; + struct CPetSectionSubData { int _field0; int _field4; @@ -79,8 +84,16 @@ public: */ virtual void save(SimpleFile *file, int indent) const {} - virtual void proc21() {} - virtual void proc22() {} + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea) {} + + /** + * Called when a section is being left, to switch to another area + */ + virtual void leave() {} + virtual void proc23() {} /** -- cgit v1.2.3