aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-22 12:44:14 -0400
committerPaul Gilbert2016-07-22 12:44:14 -0400
commit41a3c83bc6444550c9e4ea1a5918450403e0e5ee (patch)
tree48d239603882bcc3d39713dabab96db822b1c528
parent4ff421570679621db76cca59315a036bf64a6550 (diff)
downloadscummvm-rg350-41a3c83bc6444550c9e4ea1a5918450403e0e5ee.tar.gz
scummvm-rg350-41a3c83bc6444550c9e4ea1a5918450403e0e5ee.tar.bz2
scummvm-rg350-41a3c83bc6444550c9e4ea1a5918450403e0e5ee.zip
TITANIC: Fleshing out PET RealLife Load functionality
-rw-r--r--engines/titanic/game_manager.cpp7
-rw-r--r--engines/titanic/game_manager.h5
-rw-r--r--engines/titanic/pet_control/pet_load.cpp28
-rw-r--r--engines/titanic/pet_control/pet_load.h5
-rw-r--r--engines/titanic/pet_control/pet_load_save.cpp20
-rw-r--r--engines/titanic/pet_control/pet_load_save.h9
-rw-r--r--engines/titanic/pet_control/pet_save.cpp15
-rw-r--r--engines/titanic/pet_control/pet_save.h7
8 files changed, 73 insertions, 23 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index 06704995bd..2f83bca867 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -47,13 +47,16 @@ CGameManager::CGameManager(CProjectItem *project, CGameView *gameView):
CGameManager::~CGameManager() {
delete _movie;
delete _movieSurface;
+ destroyTreeItem();
+ _project->resetGameManager();
+}
+
+void CGameManager::destroyTreeItem() {
if (_treeItem) {
_treeItem->destroyAll();
_treeItem = nullptr;
}
-
- _project->resetGameManager();
}
void CGameManager::save(SimpleFile *file) {
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 129ce6b175..4808b260b7 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -82,6 +82,11 @@ public:
~CGameManager();
/**
+ * Destroys and allocated tree item
+ */
+ void destroyTreeItem();
+
+ /**
* Save data to a save file
*/
void save(SimpleFile *file);
diff --git a/engines/titanic/pet_control/pet_load.cpp b/engines/titanic/pet_control/pet_load.cpp
index f4be690bd2..cb3514ee56 100644
--- a/engines/titanic/pet_control/pet_load.cpp
+++ b/engines/titanic/pet_control/pet_load.cpp
@@ -22,6 +22,8 @@
#include "titanic/pet_control/pet_load.h"
#include "titanic/pet_control/pet_control.h"
+#include "titanic/core/project_item.h"
+#include "titanic/game_manager.h"
namespace Titanic {
@@ -38,12 +40,36 @@ bool CPetLoad::reset() {
return true;
}
+bool CPetLoad::MouseButtonUpMsg(const Point &pt) {
+ if (_btnLoadSave.MouseButtonUpMsg(pt)) {
+ execute();
+ return true;
+ } else {
+ return false;
+ }
+}
+
void CPetLoad::getTooltip(CPetText *text) {
text->setText("Load the game.");
}
void CPetLoad::execute() {
- warning("TODO: CPetLoad::execute");
+ CPetControl *pet = getPetControl();
+
+ if (_savegameSlotNum >= 0 && _slotInUse[_savegameSlotNum]) {
+ CProjectItem *project = pet ? pet->getRoot() : nullptr;
+ CGameManager *gameManager = project ? project->getGameManager() : nullptr;
+
+ if (project && gameManager) {
+ pet->displayMessage("Loading the selected game, please wait.");
+
+ gameManager->destroyTreeItem();
+ gameManager->initBounds();
+ project->loadGame(_savegameSlotNum);
+ }
+ } else if (pet) {
+ pet->displayMessage("You must select a game to load first.");
+ }
}
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_load.h b/engines/titanic/pet_control/pet_load.h
index f87cd8afb2..ad0b026818 100644
--- a/engines/titanic/pet_control/pet_load.h
+++ b/engines/titanic/pet_control/pet_load.h
@@ -35,6 +35,11 @@ public:
virtual bool reset();
/**
+ * Handles mouse button up messages
+ */
+ virtual bool MouseButtonUpMsg(const Point &pt);
+
+ /**
* Highlight any currently highlighted element
*/
virtual void highlightCurrent() { resetSlots(); }
diff --git a/engines/titanic/pet_control/pet_load_save.cpp b/engines/titanic/pet_control/pet_load_save.cpp
index 17e6f5eee5..77b6126249 100644
--- a/engines/titanic/pet_control/pet_load_save.cpp
+++ b/engines/titanic/pet_control/pet_load_save.cpp
@@ -81,16 +81,6 @@ bool CPetLoadSave::MouseButtonDownMsg(const Point &pt) {
return false;
}
-bool CPetLoadSave::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
- if (_btnLoadSave.MouseButtonUpMsg(msg->_mousePos)) {
- execute();
- resetSlots();
- return true;
- } else {
- return false;
- }
-}
-
bool CPetLoadSave::KeyCharMsg(Common::KeyCode key) {
switch (key) {
case Common::KEYCODE_TAB:
@@ -128,6 +118,7 @@ Rect CPetLoadSave::getSlotBounds(int index) {
void CPetLoadSave::resetSlots() {
for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) {
_slotNames[idx].setText("Empty");
+ _slotInUse[idx] = false;
// Try and open up the savegame for access
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(
@@ -139,16 +130,17 @@ void CPetLoadSave::resetSlots() {
file.open(in);
TitanicSavegameHeader header;
- CProjectItem::readSavegameHeader(&file, header);
+ if (CProjectItem::readSavegameHeader(&file, header)) {
+ _slotInUse[idx] = true;
+ _slotNames[idx].setText(header._saveName);
+ }
+
if (header._thumbnail) {
header._thumbnail->free();
delete header._thumbnail;
}
file.close();
-
- // Set the name text
- _slotNames[idx].setText(header._saveName);
}
}
diff --git a/engines/titanic/pet_control/pet_load_save.h b/engines/titanic/pet_control/pet_load_save.h
index 8f8634dfdf..687bd13e58 100644
--- a/engines/titanic/pet_control/pet_load_save.h
+++ b/engines/titanic/pet_control/pet_load_save.h
@@ -58,6 +58,7 @@ private:
bool isSlotHighlighted(int index, const Point &pt);
protected:
CPetText _slotNames[SAVEGAME_SLOTS_COUNT];
+ bool _slotInUse[SAVEGAME_SLOTS_COUNT];
CPetGfxElement _btnLoadSave;
CPetGfxElement _gutter;
static int _savegameSlotNum;
@@ -88,15 +89,13 @@ public:
virtual bool MouseButtonDownMsg(const Point &pt);
/**
- * Handles mouse button messages
- */
- virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
-
- /**
* Handles keypresses when the glyph is focused
*/
virtual bool KeyCharMsg(Common::KeyCode key);
+ /**
+ * Resets highlighting on the save slots
+ */
virtual void resetSaves() { resetSlots(); }
/**
diff --git a/engines/titanic/pet_control/pet_save.cpp b/engines/titanic/pet_control/pet_save.cpp
index a2e458b52a..341053948e 100644
--- a/engines/titanic/pet_control/pet_save.cpp
+++ b/engines/titanic/pet_control/pet_save.cpp
@@ -38,6 +38,21 @@ bool CPetSave::reset() {
return true;
}
+bool CPetSave::MouseButtonUpMsg(const Point &pt) {
+ if (_btnLoadSave.MouseButtonUpMsg(pt)) {
+ execute();
+ resetSlots();
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void CPetSave::highlightCurrent() {
+ resetSlots();
+ highlightSave(_savegameSlotNum);
+}
+
void CPetSave::getTooltip(CPetText *text) {
text->setText("Save the game.");
}
diff --git a/engines/titanic/pet_control/pet_save.h b/engines/titanic/pet_control/pet_save.h
index 106d499d96..d37f4e3012 100644
--- a/engines/titanic/pet_control/pet_save.h
+++ b/engines/titanic/pet_control/pet_save.h
@@ -35,6 +35,11 @@ public:
virtual bool reset();
/**
+ * Handles mouse button up messages
+ */
+ virtual bool MouseButtonUpMsg(const Point &pt);
+
+ /**
* Unhighlight any currently highlighted element
*/
virtual void unhighlightCurrent() { unhighlightSave(_savegameSlotNum); }
@@ -42,7 +47,7 @@ public:
/**
* Highlight any currently highlighted element
*/
- virtual void highlightCurrent() { highlightSave(_savegameSlotNum); }
+ virtual void highlightCurrent();
/**
* Returns the tooltip text for when the glyph is selected