aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic')
-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
-rw-r--r--engines/titanic/game_manager.cpp14
-rw-r--r--engines/titanic/game_manager.h5
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp4
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h5
8 files changed, 73 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; }
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index 1d34650552..296299a526 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -147,4 +147,18 @@ void CGameManager::updateDiskTicksCount() {
_lastDiskTicksCount = g_vm->_events->getTicksCount();
}
+void CGameManager::viewChange() {
+ delete _videoSurface1;
+ delete _videoSurface2;
+
+ _videoSurface1 = nullptr;
+ _videoSurface2 = CScreenManager::_screenManagerPtr->createSurface(600, 340);
+ _trueTalkManager.viewChange();
+
+ for (CTreeItem *treeItem = _project; treeItem; treeItem = treeItem->scan(_project))
+ treeItem->viewChange();
+
+ initBounds();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 43d0dff025..6404845fa2 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -155,6 +155,11 @@ public:
* Updates the state of the manager
*/
void update();
+
+ /**
+ * Called when the view changes
+ */
+ void viewChange();
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 5afaeb3873..3d4a8ecc9d 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -179,4 +179,8 @@ void CTrueTalkManager::preLoad() {
warning("TODO: CTrueTalkManager::preLoad");
}
+void CTrueTalkManager::viewChange() {
+ warning("CTrueTalkManager::viewChange");
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h
index 8a59655075..4c74ac2bc5 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -98,6 +98,11 @@ public:
void postSave() {}
/**
+ * Called when the view changes
+ */
+ void viewChange();
+
+ /**
* Returns the scripts for the manager
*/
TTScripts &getScripts() { return _scripts; }