aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-30 23:55:15 -0400
committerPaul Gilbert2016-03-30 23:55:15 -0400
commitc33bdcc09ff9949dec9330fc245bb8f97546875a (patch)
treec896945a15834c4f68b635878f87ca8264d5fcce /engines/titanic
parent948fb5bcca3a8d8594fd9e1f5470dac0448f74a9 (diff)
downloadscummvm-rg350-c33bdcc09ff9949dec9330fc245bb8f97546875a.tar.gz
scummvm-rg350-c33bdcc09ff9949dec9330fc245bb8f97546875a.tar.bz2
scummvm-rg350-c33bdcc09ff9949dec9330fc245bb8f97546875a.zip
TITANIC: Fleshing out CPetFrame
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/module.mk2
-rw-r--r--engines/titanic/pet_control/pet_control.cpp24
-rw-r--r--engines/titanic/pet_control/pet_control.h6
-rw-r--r--engines/titanic/pet_control/pet_control_sub8.cpp44
-rw-r--r--engines/titanic/pet_control/pet_element.h19
-rw-r--r--engines/titanic/pet_control/pet_frame.cpp104
-rw-r--r--engines/titanic/pet_control/pet_frame.h (renamed from engines/titanic/pet_control/pet_control_sub8.h)51
-rw-r--r--engines/titanic/pet_control/pet_section.h23
8 files changed, 197 insertions, 76 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index d0e4164ab2..cc3c186288 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -384,6 +384,7 @@ MODULE_OBJS := \
pet_control/pet_control_list_item2.o \
pet_control/pet_conversation_section.o \
pet_control/pet_element.o \
+ pet_control/pet_frame.o \
pet_control/pet_inventory_section.o \
pet_control/pet_rooms_section.o \
pet_control/pet_remote_section.o \
@@ -391,7 +392,6 @@ MODULE_OBJS := \
pet_control/pet_section.o \
pet_control/pet_control_sub5.o \
pet_control/pet_control_sub7.o \
- pet_control/pet_control_sub8.o \
pet_control/pet_control_sub10.o \
pet_control/pet_control_sub11.o \
pet_control/pet_control_sub12.o \
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index ad1d0b6d2b..4fe0c1d255 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -57,11 +57,15 @@ void CPetControl::load(SimpleFile *file) {
CGameObject::load(file);
}
-bool CPetControl::isValid() const {
- return _convSection.isValid() && _roomsSection.isValid()
- && _remoteSection.isValid() && _invSection.isValid()
- && _sub5.isValid() && _saveSection.isValid()
- && _sub7.isValid() && _sub8.isValid();
+bool CPetControl::isValid() {
+ return _convSection.isValid(this) &&
+ _roomsSection.isValid(this) &&
+ _remoteSection.isValid(this) &&
+ _invSection.isValid(this) &&
+ _sub5.isValid(this) &&
+ _saveSection.isValid(this) &&
+ _sub7.isValid(this) &&
+ _frame.isValid(this);
}
void CPetControl::loadAreas(SimpleFile *file, int param) {
@@ -72,7 +76,7 @@ void CPetControl::loadAreas(SimpleFile *file, int param) {
_sub5.load(file, param);
_saveSection.load(file, param);
_sub7.load(file, param);
- _sub8.load(file, param);
+ _frame.load(file, param);
}
void CPetControl::saveAreas(SimpleFile *file, int indent) const {
@@ -83,7 +87,7 @@ void CPetControl::saveAreas(SimpleFile *file, int indent) const {
_sub5.save(file, indent);
_saveSection.save(file, indent);
_sub7.save(file, indent);
- _sub8.save(file, indent);
+ _frame.save(file, indent);
}
void CPetControl::draw(CScreenManager *screenManager) {
@@ -97,7 +101,7 @@ void CPetControl::draw(CScreenManager *screenManager) {
_fieldC8 = -1;
}
- _sub8.drawFrame(screenManager);
+ _frame.drawFrame(screenManager);
// Draw the specific area that's currently active
switch (_currentArea) {
@@ -148,7 +152,7 @@ void CPetControl::loaded() {
_sub5.postLoad();
_saveSection.postLoad();
_sub7.postLoad();
- _sub8.postLoad();
+ _frame.postLoad();
}
void CPetControl::enterNode(CNodeItem *node) {
@@ -207,7 +211,7 @@ PetArea CPetControl::setArea(PetArea newArea) {
// Change the current area
PetArea oldArea = _currentArea;
- _sub8.setArea(newArea);
+ _frame.setArea(newArea);
_currentArea = newArea;
// Signal to the new view that it's been activated
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 1bb2088e27..4f101caaf5 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -27,13 +27,13 @@
#include "titanic/core/node_item.h"
#include "titanic/core/room_item.h"
#include "titanic/pet_control/pet_conversation_section.h"
+#include "titanic/pet_control/pet_frame.h"
#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_sub7.h"
-#include "titanic/pet_control/pet_control_sub8.h"
namespace Titanic {
@@ -50,7 +50,7 @@ private:
CPetSaveSection _saveSection;
CPetControlSub5 _sub5;
CPetControlSub7 _sub7;
- CPetControlSub8 _sub8;
+ CPetFrame _frame;
CTreeItem *_treeItem1;
CString _string1;
CTreeItem *_treeItem2;
@@ -61,7 +61,7 @@ private:
/**
* Returns true if the control is in a valid state
*/
- bool isValid() const;
+ bool isValid();
/**
* Loads data for the individual areas
diff --git a/engines/titanic/pet_control/pet_control_sub8.cpp b/engines/titanic/pet_control/pet_control_sub8.cpp
deleted file mode 100644
index 7d54b87b06..0000000000
--- a/engines/titanic/pet_control/pet_control_sub8.cpp
+++ /dev/null
@@ -1,44 +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_sub8.h"
-
-namespace Titanic {
-
-static const int INDEXES[6] = { 1, 0, 2, 3, 4, 5 };
-
-int CPetControlSub8::_indexes[6];
-
-CPetControlSub8::CPetControlSub8() {
- for (int idx = 0; idx < 6; ++idx)
- _indexes[INDEXES[idx]] = idx;
-}
-
-void CPetControlSub8::setArea(PetArea newArea) {
- warning("TODO: CPetControlSub8::setArea");
-}
-
-void CPetControlSub8::drawFrame(CScreenManager *screenManager) {
- warning("TODO: CPetControlSub8::drawFrame");
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h
index 330fbf21fa..e5ab8d3fdd 100644
--- a/engines/titanic/pet_control/pet_element.h
+++ b/engines/titanic/pet_control/pet_element.h
@@ -43,12 +43,15 @@ public:
virtual ~CPetElement() {}
/**
- * Load an object into the element
+ * Sets up the element
*/
- virtual void loadObject(PetElementMode mode, const CString &name,
+ virtual void setup(PetElementMode mode, const CString &name,
CPetControl *petControl) {}
- virtual void proc2() {}
+ /**
+ * Sets up the element
+ */
+ virtual void setup() {}
/**
* Draw the item
@@ -107,6 +110,16 @@ public:
virtual void changeMode(PetElementMode newMode) { _mode = newMode; }
void setMode(PetElementMode mode);
+
+ /**
+ * Set the bounds for the element
+ */
+ void setBounds(const Rect &r) { _bounds = r; }
+
+ /**
+ * Translate the position of the element
+ */
+ void translate(int deltaX, int deltaY) { _bounds.translate(deltaX, deltaY); }
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_frame.cpp b/engines/titanic/pet_control/pet_frame.cpp
new file mode 100644
index 0000000000..e94bc6c848
--- /dev/null
+++ b/engines/titanic/pet_control/pet_frame.cpp
@@ -0,0 +1,104 @@
+/* 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_frame.h"
+
+namespace Titanic {
+
+static const int INDEXES[6] = { 1, 0, 2, 3, 4, 5 };
+
+int CPetFrame::_indexes[6];
+
+CPetFrame::CPetFrame() {
+ for (int idx = 0; idx < 6; ++idx)
+ _indexes[INDEXES[idx]] = idx;
+}
+
+bool CPetFrame::setup(CPetControl *petControl) {
+ if (setPetControl(petControl))
+ return setup();
+ return false;
+}
+
+bool CPetFrame::setup() {
+ if (_petControl) {
+ // TODO
+ }
+
+ return true;
+}
+
+bool CPetFrame::isValid(CPetControl *petControl) {
+ bool result = setPetControl(petControl);
+ if (result) {
+ _modeButtons[_indexes[0]].setMode(MODE_0);
+ _modeButtons[_indexes[4]].setMode(MODE_1);
+ }
+
+ return result;
+}
+
+void CPetFrame::postLoad() {
+ setup();
+}
+
+bool CPetFrame::setPetControl(CPetControl *petControl) {
+ if (petControl) {
+ _petControl = petControl;
+
+ // Set the bounds of the individual elements
+ _background.setBounds(Rect(20, 350, 620, 480));
+ _modeBackground.setBounds(Rect(590, 365, 611, 467));
+
+ Rect r(35, 373, 91, 429);
+ for (int idx = 0, xp = 0; xp < 490; ++idx, xp += 70) {
+ _indent[idx].setBounds(r);
+ _indent[idx].translate(xp, 0);
+ }
+
+ r = Rect(590, 365, 606, 381);
+ const int YLIST[] = { 7, 27, 45, 66, 84 };
+ for (int idx = 0; idx < 5; ++idx) {
+ _modeButtons[idx].setBounds(r);
+ _modeButtons[idx].translate(0, YLIST[idx]);
+ }
+ _modeButtons[_indexes[0]].setMode(MODE_1);
+
+ const int XLIST[] = { 73, 54, 85, 109, 38, 71 };
+ for (int idx = 0; idx < 6; ++idx) {
+ _titles[idx].setBounds(Rect(0, 0, 110, 11));
+ _titles[idx].translate(XLIST[idx], 471);
+ }
+ }
+
+ return true;
+}
+
+void CPetFrame::setArea(PetArea newArea) {
+ warning("TODO: CPetFrame::setArea");
+}
+
+void CPetFrame::drawFrame(CScreenManager *screenManager) {
+ warning("TODO: CPetFrame::drawFrame");
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control_sub8.h b/engines/titanic/pet_control/pet_frame.h
index 716a026eaf..53adf1ba07 100644
--- a/engines/titanic/pet_control/pet_control_sub8.h
+++ b/engines/titanic/pet_control/pet_frame.h
@@ -20,33 +20,64 @@
*
*/
-#ifndef TITANIC_PET_CONTROL_SUB8_H
-#define TITANIC_PET_CONTROL_SUB8_H
+#ifndef TITANIC_PET_FRAME_H
+#define TITANIC_PET_FRAME_H
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_val.h"
namespace Titanic {
-class CPetControlSub8 : public CPetSection {
+class CPetFrame : public CPetSection {
private:
static int _indexes[6];
- CPetVal _valArray1[6];
- CPetVal _valArray2[6];
- CPetVal _val1;
+ CPetVal _modeButtons[6];
+ CPetVal _titles[6];
+ CPetVal _modeBackground;
CPetVal _val2;
CPetVal _val3;
- CPetVal _val4;
- CPetVal _valArray3[7];
+ CPetVal _background;
+ CPetVal _indent[7];
+private:
+ /**
+ * Called to set the owning PET instance and set some initial state
+ */
+ bool setPetControl(CPetControl *petControl);
public:
- CPetControlSub8();
+ CPetFrame();
+
+ /**
+ * Sets up the section
+ */
+ virtual bool setup(CPetControl *petControl);
+
+ /**
+ * Sets up the section
+ */
+ virtual bool setup();
+
+ /**
+ * Returns true if the object is in a valid state
+ */
+ virtual bool isValid(CPetControl *petControl);
+
+ /**
+ * Called after a game has been loaded
+ */
+ virtual void postLoad();
+ /**
+ * Called when the current PET area changes
+ */
void setArea(PetArea newArea);
+ /**
+ * Draws the PET frame
+ */
void drawFrame(CScreenManager *screenManager);
};
} // End of namespace Titanic
-#endif /* TITANIC_PET_CONTROL_SUB8_H */
+#endif /* TITANIC_PET_FRAME_H */
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 12e462640c..77535662a6 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -32,6 +32,7 @@ enum PetArea {
PET_ROOMS = 3, PET_SAVE = 4, PET_5 = 5, PET_6 = 6
};
+class CPetControl;
class CScreenManager;
class CRoomItem;
@@ -47,14 +48,26 @@ struct CPetSectionSubData {
class CPetSection {
protected:
- int _field4;
+ CPetControl *_petControl;
public:
- CPetSection() : _field4(0) {}
+ CPetSection() : _petControl(nullptr) {}
virtual ~CPetSection() {}
- virtual int proc1() { return 0; }
- virtual int proc2() { return 0; }
+ /**
+ * Sets up the section
+ */
+ virtual bool setup(CPetControl *petControl) { return false; }
+
+ /**
+ * Sets up the section
+ */
+ virtual bool setup() { return false; }
+
+ /**
+ * Draw the section
+ */
virtual void draw(CScreenManager *screenManager) {}
+
virtual void proc4();
virtual void proc5(int val) {}
virtual int proc6() { return 0; }
@@ -72,7 +85,7 @@ public:
/**
* Returns true if the object is in a valid state
*/
- virtual bool isValid() const { return false; }
+ virtual bool isValid(CPetControl *petControl) { return false; }
/**
* Load the data for the class from file