aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/core
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-19 09:29:11 -0400
committerPaul Gilbert2016-03-19 09:29:11 -0400
commitabb5e0a5c123ada15d77380a1a9d5253306c36bb (patch)
tree51a5a095355eb7cd6b2c80f4c8abc6db55bf4079 /engines/titanic/core
parent2665e0e08f0f1c8e70738dad793de20176e0d9c4 (diff)
downloadscummvm-rg350-abb5e0a5c123ada15d77380a1a9d5253306c36bb.tar.gz
scummvm-rg350-abb5e0a5c123ada15d77380a1a9d5253306c36bb.tar.bz2
scummvm-rg350-abb5e0a5c123ada15d77380a1a9d5253306c36bb.zip
TITANIC: Added CGameManager::viewChange
Diffstat (limited to 'engines/titanic/core')
-rw-r--r--engines/titanic/core/project_item.cpp15
-rw-r--r--engines/titanic/core/project_item.h10
-rw-r--r--engines/titanic/core/tree_item.cpp20
-rw-r--r--engines/titanic/core/tree_item.h10
4 files changed, 45 insertions, 10 deletions
diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp
index 90e6d06ed1..7546f20936 100644
--- a/engines/titanic/core/project_item.cpp
+++ b/engines/titanic/core/project_item.cpp
@@ -189,10 +189,15 @@ void CProjectItem::saveGame(int slotId) {
Common::String::format("slot%d.gam", slotId));
file.open(saveFile);
+ // Signal the game is being saved
+ preSave();
+
// Save the contents out
saveData(&file, this);
+ // Close the file and signal that the saving has finished
file.close();
+ postSave();
}
void CProjectItem::clear() {
@@ -288,6 +293,16 @@ void CProjectItem::postLoad() {
petControl->postLoad();
}
+void CProjectItem::preSave() {
+ if (_gameManager)
+ _gameManager->preSave(this);
+}
+
+void CProjectItem::postSave() {
+ if (_gameManager)
+ _gameManager->postSave();
+}
+
CPetControl *CProjectItem::getPetControl() const {
CDontSaveFileItem *fileItem = getDontSaveFileItem();
CTreeItem *treeItem;
diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h
index 87dfc3f0dd..ef7ccb65f9 100644
--- a/engines/titanic/core/project_item.h
+++ b/engines/titanic/core/project_item.h
@@ -89,6 +89,16 @@ private:
void postLoad();
/**
+ * Called when a game is about to be saved
+ */
+ void preSave();
+
+ /**
+ * Called when a game has finished being saved
+ */
+ void postSave();
+
+ /**
* Finds the first child instance of a given class type
*/
CTreeItem *findChildInstance(ClassDef *classDef) const;
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index 72c158d103..a1dcce1abe 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -59,6 +59,16 @@ CString CTreeItem::dumpItem(int indent) const {
return result;
}
+void CTreeItem::save(SimpleFile *file, int indent) const {
+ file->writeNumberLine(0, indent);
+ CMessageTarget::save(file, indent);
+}
+
+void CTreeItem::load(SimpleFile *file) {
+ file->readNumber();
+ CMessageTarget::load(file);
+}
+
bool CTreeItem::isFileItem() const {
return isInstanceOf(CFileItem::_type);
}
@@ -91,16 +101,6 @@ bool CTreeItem::isGameObjectDescItem() const {
return isInstanceOf(CGameObjectDescItem::_type);
}
-void CTreeItem::save(SimpleFile *file, int indent) const {
- file->writeNumberLine(0, indent);
- CMessageTarget::save(file, indent);
-}
-
-void CTreeItem::load(SimpleFile *file) {
- file->readNumber();
- CMessageTarget::load(file);
-}
-
CGameManager *CTreeItem::getGameManager() const {
return _parent ? _parent->getGameManager() : nullptr;
}
diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h
index aea22ffa40..a4156d6ad1 100644
--- a/engines/titanic/core/tree_item.h
+++ b/engines/titanic/core/tree_item.h
@@ -120,6 +120,16 @@ public:
virtual int compareTo(const CString &name, int maxLen) const { return false; }
/**
+ * Gets the bounds occupied by the item
+ */
+ virtual Common::Rect getBounds() { return Common::Rect(); }
+
+ /**
+ * Called when the view changes
+ */
+ virtual void viewChange() {}
+
+ /**
* Get the parent for the given item
*/
CTreeItem *getParent() const { return _parent; }