aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-29 21:57:09 -0400
committerPaul Gilbert2016-03-29 21:57:09 -0400
commite0602c4851ab42763cc66858fed8d05496040498 (patch)
tree30f19c267243e163c2c4cc8e9c8478507e2211da /engines/titanic
parent8a45f47c2e1e483b5a17b2d4abe22473eaf1e143 (diff)
downloadscummvm-rg350-e0602c4851ab42763cc66858fed8d05496040498.tar.gz
scummvm-rg350-e0602c4851ab42763cc66858fed8d05496040498.tar.bz2
scummvm-rg350-e0602c4851ab42763cc66858fed8d05496040498.zip
TITANIC: More PET renaming, implemented setArea
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/core/game_object.h20
-rw-r--r--engines/titanic/module.mk6
-rw-r--r--engines/titanic/pet_control/pet_control.cpp77
-rw-r--r--engines/titanic/pet_control/pet_control.h18
-rw-r--r--engines/titanic/pet_control/pet_control_sub8.cpp4
-rw-r--r--engines/titanic/pet_control/pet_control_sub8.h1
-rw-r--r--engines/titanic/pet_control/pet_save_section.cpp (renamed from engines/titanic/pet_control/pet_control_sub6.cpp)2
-rw-r--r--engines/titanic/pet_control/pet_save_section.h (renamed from engines/titanic/pet_control/pet_control_sub6.h)8
-rw-r--r--engines/titanic/pet_control/pet_section.h17
9 files changed, 124 insertions, 29 deletions
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_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_control_sub6.cpp b/engines/titanic/pet_control/pet_save_section.cpp
index d017e81d9e..e513dd3013 100644
--- a/engines/titanic/pet_control/pet_control_sub6.cpp
+++ b/engines/titanic/pet_control/pet_save_section.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "titanic/pet_control/pet_control_sub6.h"
+#include "titanic/pet_control/pet_save_section.h"
namespace Titanic {
diff --git a/engines/titanic/pet_control/pet_control_sub6.h b/engines/titanic/pet_control/pet_save_section.h
index 208d6f2b6d..fb9004f47d 100644
--- a/engines/titanic/pet_control/pet_control_sub6.h
+++ b/engines/titanic/pet_control/pet_save_section.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TITANIC_PET_CONTROL_SUB6_H
-#define TITANIC_PET_CONTROL_SUB6_H
+#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"
@@ -29,7 +29,7 @@
namespace Titanic {
-class CPetControlSub6 : public CPetSection {
+class CPetSaveSection : public CPetSection {
private:
CPetControlSub10 _sub10;
CPetControlSub10 _sub12;
@@ -39,4 +39,4 @@ public:
} // End of namespace Titanic
-#endif /* TITANIC_PET_CONTROL_SUB6_H */
+#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() {}
/**