TITANIC: Added CGameManager::viewChange

This commit is contained in:
Paul Gilbert 2016-03-19 09:29:11 -04:00
parent 2665e0e08f
commit abb5e0a5c1
8 changed files with 73 additions and 10 deletions

View File

@ -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;

View File

@ -88,6 +88,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
*/

View File

@ -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;
}

View File

@ -119,6 +119,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
*/

View File

@ -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

View File

@ -155,6 +155,11 @@ public:
* Updates the state of the manager
*/
void update();
/**
* Called when the view changes
*/
void viewChange();
};
} // End of namespace Titanic

View File

@ -179,4 +179,8 @@ void CTrueTalkManager::preLoad() {
warning("TODO: CTrueTalkManager::preLoad");
}
void CTrueTalkManager::viewChange() {
warning("CTrueTalkManager::viewChange");
}
} // End of namespace Titanic

View File

@ -97,6 +97,11 @@ public:
*/
void postSave() {}
/**
* Called when the view changes
*/
void viewChange();
/**
* Returns the scripts for the manager
*/