aboutsummaryrefslogtreecommitdiff
path: root/engines/pink/objects
diff options
context:
space:
mode:
Diffstat (limited to 'engines/pink/objects')
-rw-r--r--engines/pink/objects/actions/action_cel.cpp4
-rw-r--r--engines/pink/objects/actions/action_cel.h2
-rw-r--r--engines/pink/objects/actions/action_hide.cpp3
-rw-r--r--engines/pink/objects/actions/action_hide.h2
-rw-r--r--engines/pink/objects/actions/action_play.cpp7
-rw-r--r--engines/pink/objects/actions/action_still.cpp2
-rw-r--r--engines/pink/objects/actors/actor.cpp13
-rw-r--r--engines/pink/objects/actors/actor.h3
-rw-r--r--engines/pink/objects/actors/lead_actor.cpp5
-rw-r--r--engines/pink/objects/actors/supporting_actor.cpp4
-rw-r--r--engines/pink/objects/actors/supporting_actor.h1
-rw-r--r--engines/pink/objects/handlers/handler_mgr.cpp12
-rw-r--r--engines/pink/objects/handlers/handler_mgr.h1
-rw-r--r--engines/pink/objects/module.cpp14
-rw-r--r--engines/pink/objects/pages/game_page.cpp83
-rw-r--r--engines/pink/objects/pages/game_page.h19
-rw-r--r--engines/pink/objects/pages/page.cpp17
-rw-r--r--engines/pink/objects/pages/page.h14
18 files changed, 149 insertions, 57 deletions
diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp
index 938d117015..e9e524726c 100644
--- a/engines/pink/objects/actions/action_cel.cpp
+++ b/engines/pink/objects/actions/action_cel.cpp
@@ -79,4 +79,8 @@ void ActionCEL::update() {
}
}
+ActionCEL::~ActionCEL() {
+ delete _decoder;
+}
+
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/actions/action_cel.h b/engines/pink/objects/actions/action_cel.h
index 43fe8476e0..2ae5308d0e 100644
--- a/engines/pink/objects/actions/action_cel.h
+++ b/engines/pink/objects/actions/action_cel.h
@@ -32,6 +32,8 @@ class CelDecoder;
class ActionCEL : public Action {
public:
+ ~ActionCEL() override;
+
ActionCEL();
virtual void deserialize(Archive &archive);
virtual void start(bool unk);
diff --git a/engines/pink/objects/actions/action_hide.cpp b/engines/pink/objects/actions/action_hide.cpp
index b89d4c9627..ed2c903f1d 100644
--- a/engines/pink/objects/actions/action_hide.cpp
+++ b/engines/pink/objects/actions/action_hide.cpp
@@ -23,7 +23,6 @@
#include "action_hide.h"
#include "engines/pink/objects/actors/actor.h"
#include <engines/pink/archive.h>
-#include <common/debug.h>
namespace Pink {
@@ -45,4 +44,6 @@ void ActionHide::toConsole() {
debug("\tActionHide: _name = %s", _name.c_str());
}
+ActionHide::~ActionHide() {}
+
} //End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/actions/action_hide.h b/engines/pink/objects/actions/action_hide.h
index 414d077409..bc62a5fc5f 100644
--- a/engines/pink/objects/actions/action_hide.h
+++ b/engines/pink/objects/actions/action_hide.h
@@ -29,6 +29,8 @@ namespace Pink {
class ActionHide : public Action {
public:
+ ~ActionHide() override;
+
virtual void deserialize(Archive &archive);
virtual void toConsole();
diff --git a/engines/pink/objects/actions/action_play.cpp b/engines/pink/objects/actions/action_play.cpp
index 969eacf035..d3ded9a45a 100644
--- a/engines/pink/objects/actions/action_play.cpp
+++ b/engines/pink/objects/actions/action_play.cpp
@@ -45,10 +45,13 @@ void ActionPlay::end() {
void ActionPlay::onStart() {
debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str());
- _decoder->seekToFrame(_startFrame);
+ _decoder->start();
+ for (int i = 0; i <= _startFrame; ++i) {
+ _decoder->decodeNextFrame();
+ }
+
if (_stopFrame != -1)
_decoder->setEndFrame(_stopFrame);
- _decoder->start();
}
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp
index 0af57a0fee..fc835f1af5 100644
--- a/engines/pink/objects/actions/action_still.cpp
+++ b/engines/pink/objects/actions/action_still.cpp
@@ -45,7 +45,7 @@ void ActionStill::end() {
void ActionStill::onStart() {
debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str());
- for (int i = 0; i < _startFrame; ++i) {
+ for (int i = 0; i <= _startFrame; ++i) {
_decoder->decodeNextFrame();
}
_decoder->stop();
diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp
index 2bd6af4f82..6a20a46f41 100644
--- a/engines/pink/objects/actors/actor.cpp
+++ b/engines/pink/objects/actors/actor.cpp
@@ -130,8 +130,21 @@ void Actor::onMouseOver(Common::Point point, CursorMgr *mgr) {
Actor::~Actor() {
for (int i = 0; i < _actions.size(); ++i) {
+ _actions[i]->toConsole();
delete _actions[i];
+ _actions[i] = nullptr;
}
}
+void Actor::loadState(Archive &archive) {
+ Common::String actionName;
+ archive >> actionName;
+ _action = findAction(actionName);
+}
+
+void Actor::saveState(Archive &archive) {
+ assert(_action);
+ archive.writeString(_action->getName());
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h
index 270ac99914..69cf37b920 100644
--- a/engines/pink/objects/actors/actor.h
+++ b/engines/pink/objects/actors/actor.h
@@ -60,6 +60,9 @@ public:
void setAction(Action *newAction);
void setAction(Action *newAction, bool unk);
+ void loadState(Archive &archive);
+ void saveState(Archive &archive);
+
bool initPallete(Director *director);
virtual void update() {};
diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp
index 516569faed..d89ecb4f87 100644
--- a/engines/pink/objects/actors/lead_actor.cpp
+++ b/engines/pink/objects/actors/lead_actor.cpp
@@ -115,6 +115,7 @@ void LeadActor::onKeyboardButtonClick(Common::KeyCode code) {
default:
break;
}
+ break;
case kInDialog1:
case kInDialog2:
case kPlayingVideo:
@@ -242,8 +243,8 @@ void LeadActor::onClick() {
}
else {
if (_state == kMoving) {
- this->_recipient = nullptr;
- this->_nextState = nullptr;
+ _recipient = nullptr;
+ _nextState = kReady;
}
}
diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp
index e32c89ff84..735e85ee3a 100644
--- a/engines/pink/objects/actors/supporting_actor.cpp
+++ b/engines/pink/objects/actors/supporting_actor.cpp
@@ -73,4 +73,8 @@ const Common::String &SupportingActor::getLocation() const {
return _location;
}
+SupportingActor::~SupportingActor() {
+
+}
+
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/actors/supporting_actor.h b/engines/pink/objects/actors/supporting_actor.h
index 33b469f8aa..fe6dfce9ef 100644
--- a/engines/pink/objects/actors/supporting_actor.h
+++ b/engines/pink/objects/actors/supporting_actor.h
@@ -33,6 +33,7 @@ class InventoryMgr;
class SupportingActor : public Actor {
public:
+ virtual ~SupportingActor();
virtual void deserialize(Archive &archive);
virtual void toConsole();
diff --git a/engines/pink/objects/handlers/handler_mgr.cpp b/engines/pink/objects/handlers/handler_mgr.cpp
index db53c6a5d2..a8a884699e 100644
--- a/engines/pink/objects/handlers/handler_mgr.cpp
+++ b/engines/pink/objects/handlers/handler_mgr.cpp
@@ -90,4 +90,16 @@ Handler *HandlerMgr::findSuitableHandlerUseClick(Actor *actor) {
return nullptr;
}
+HandlerMgr::~HandlerMgr() {
+ for (int i = 0; i < _leftClickHandlers.size(); ++i) {
+ delete _leftClickHandlers[i];
+ }
+ for (int j = 0; j < _useClickHandlers.size(); ++j) {
+ delete _useClickHandlers[j];
+ }
+ for (int k = 0; k < _timerHandlers.size(); ++k) {
+ delete _timerHandlers[k];
+ }
+}
+
}
diff --git a/engines/pink/objects/handlers/handler_mgr.h b/engines/pink/objects/handlers/handler_mgr.h
index 7ff498ec7c..aa1d33456c 100644
--- a/engines/pink/objects/handlers/handler_mgr.h
+++ b/engines/pink/objects/handlers/handler_mgr.h
@@ -40,6 +40,7 @@ class Actor;
class HandlerMgr : public Object {
public:
+ virtual ~HandlerMgr();
virtual void deserialize(Archive &archive);
virtual void toConsole();
diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp
index dc9a06ec1e..621cd8c790 100644
--- a/engines/pink/objects/module.cpp
+++ b/engines/pink/objects/module.cpp
@@ -36,6 +36,12 @@ Module::Module(PinkEngine *game, const Common::String &name)
: NamedObject(name), _game(game), _page(nullptr)
{}
+Module::~Module() {
+ for (int i = 0; i < _pages.size(); ++i) {
+ delete _pages[i];
+ }
+}
+
void Module::load(Archive &archive){
archive.mapObject(this);
NamedObject::deserialize(archive);
@@ -63,7 +69,7 @@ void Module::changePage(const Common::String &pageName) {
page = findPage(pageName);
assert(_page != page);
- //_page->clear
+ _page->clear();
_page = page;
@@ -95,12 +101,6 @@ InventoryMgr *Module::getInventoryMgr() {
return &_invMgr;
}
-Module::~Module() {
- for (int i = 0; i < _pages.size(); ++i) {
- delete _pages[i];
- }
-}
-
} // End of namespace Pink
diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp
index c878180c4a..d12c034d2a 100644
--- a/engines/pink/objects/pages/game_page.cpp
+++ b/engines/pink/objects/pages/game_page.cpp
@@ -30,6 +30,24 @@
namespace Pink {
+GamePage::GamePage()
+ : _cursorMgr(nullptr), _walkMgr(nullptr), _sequencer(nullptr),
+ _perhapsIsLoaded(false), _memFile(nullptr)
+{}
+
+GamePage::~GamePage() {
+ clear();
+}
+
+void GamePage::toConsole() {
+ Page::toConsole();
+ _walkMgr->toConsole();
+ _sequencer->toConsole();
+ for (int i = 0; i < _handlers.size(); ++i) {
+ _handlers[i]->toConsole();
+ }
+}
+
void GamePage::deserialize(Archive &archive) {
Page::deserialize(archive);
_module = static_cast<Module*>(archive.readObject());
@@ -52,10 +70,9 @@ void GamePage::load(Archive &archive) {
}
void GamePage::init(bool isLoadingSave) {
- if (!isLoadingSave){
- //assert(perhapsIsLoaded == 0);
+ if (!_perhapsIsLoaded)
loadManagers();
- }
+
getGame()->getDirector()->clear();
toConsole();
@@ -91,15 +108,18 @@ bool GamePage::initHandler() {
}
void GamePage::loadManagers() {
- perhapsIsLoaded = true;
+ _perhapsIsLoaded = true;
_cursorMgr = new CursorMgr(_module->getGame(), this);
_walkMgr = new WalkMgr;
_sequencer = new Sequencer(this);
_resMgr.init(_module->getGame(), this);
- // memfile manipulations if from save or page changing
-
+ if (_memFile != nullptr) {
+ loadState();
+ delete _memFile;
+ _memFile = nullptr;
+ }
}
PinkEngine *GamePage::getGame() {
@@ -128,28 +148,49 @@ WalkMgr *GamePage::getWalkMgr() {
return _walkMgr;
}
-void GamePage::toConsole() {
- Page::toConsole();
- _walkMgr->toConsole();
- _sequencer->toConsole();
- for (int i = 0; i < _handlers.size(); ++i) {
- _handlers[i]->toConsole();
+void GamePage::loadState() {
+ Archive archive(static_cast<Common::SeekableReadStream*>(_memFile));
+ archive >> _variables;
+
+ uint16 actorCount;
+ archive >> actorCount;
+
+ Common::String actorName;
+ for (int i = 0; i < actorCount; ++i) {
+ actorName = archive.readString();
+ findActor(actorName)->loadState(archive);
}
}
-GamePage::~GamePage() {
- delete _cursorMgr;
- delete _walkMgr;
- delete _sequencer;
- for (int i = 0; i < _handlers.size(); ++i) {
- delete _handlers[i];
+void GamePage::saveState() {
+ _memFile = new Common::MemoryReadWriteStream(DisposeAfterUse::YES);
+ Archive archive(static_cast<Common::WriteStream*>(_memFile));
+ archive << _variables;
+
+ archive.writeWORD(_actors.size());
+ for (int i = 0; i < _actors.size(); ++i) {
+ archive.writeString(_actors[i]->getName());
+ _actors[i]->saveState(archive);
}
}
-GamePage::GamePage()
- : _cursorMgr(nullptr), _walkMgr(nullptr), _sequencer(nullptr)
-{
+void GamePage::unload() {
+ _leadActor->setAction(_leadActor->findAction("Idle"));
+ saveState();
+ clear();
+}
+void GamePage::clear() {
+ Page::clear();
+ _variables.clear(1);
+ for (int i = 0; i < _handlers.size(); ++i) {
+ delete _handlers[i];
+ }
+ _handlers.clear();
+ delete _cursorMgr;
+ delete _sequencer;
+ delete _walkMgr;
}
+
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/pages/game_page.h b/engines/pink/objects/pages/game_page.h
index 705fb32e22..79a4bee4db 100644
--- a/engines/pink/objects/pages/game_page.h
+++ b/engines/pink/objects/pages/game_page.h
@@ -23,6 +23,7 @@
#ifndef PINK_GAME_PAGE_H
#define PINK_GAME_PAGE_H
+#include <common/memstream.h>
#include "page.h"
namespace Pink {
@@ -36,12 +37,12 @@ class GamePage : public Page {
public:
GamePage();
~GamePage();
+ virtual void toConsole();
virtual void deserialize(Archive &archive);
virtual void load(Archive &archive);
-
+ void unload();
void loadManagers();
-
void init(bool isLoadingSave);
PinkEngine *getGame();
@@ -52,25 +53,21 @@ public:
bool checkValueOfVariable(Common::String &variable, Common::String &value);
void setVariable(Common::String &variable, Common::String &value);
- virtual void toConsole();
+ virtual void clear();
private:
bool initHandler();
+ void loadState();
+ void saveState();
-
- int perhapsIsLoaded;
+ bool _perhapsIsLoaded;
+ Common::MemoryReadWriteStream *_memFile;
Module *_module;
CursorMgr *_cursorMgr;
WalkMgr *_walkMgr;
Sequencer *_sequencer;
Common::Array<HandlerStartPage*> _handlers;
Common::StringMap _variables;
-
- /*
- int cunk_1;
- int memfile;
- int unk;
- */
};
}
diff --git a/engines/pink/objects/pages/page.cpp b/engines/pink/objects/pages/page.cpp
index 471cf8736b..e068367d07 100644
--- a/engines/pink/objects/pages/page.cpp
+++ b/engines/pink/objects/pages/page.cpp
@@ -22,10 +22,15 @@
#include "page.h"
#include "engines/pink/objects/actors/lead_actor.h"
+#include "engines/pink/director.h"
namespace Pink {
+Page::~Page() {
+ clear();
+}
+
void Page::load(Archive &archive) {
archive.mapObject(this);
NamedObject::deserialize(archive);
@@ -65,14 +70,18 @@ void Page::init() {
}
}
-Page::~Page() {
+LeadActor *Page::getLeadActor() {
+ return _leadActor;
+}
+
+void Page::clear() {
for (int i = 0; i < _actors.size(); ++i) {
delete _actors[i];
}
+ _actors.clear();
+ _resMgr.clear();
}
-LeadActor *Page::getLeadActor() {
- return _leadActor;
-}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/pages/page.h b/engines/pink/objects/pages/page.h
index 7eb1a335f3..b9820fea75 100644
--- a/engines/pink/objects/pages/page.h
+++ b/engines/pink/objects/pages/page.h
@@ -37,25 +37,23 @@ class LeadActor;
class Page : public NamedObject {
public:
~Page();
+ virtual void toConsole();
+
void load(Archive &archive);
Actor *findActor(Common::String &name);
+ LeadActor *getLeadActor();
+
Sound *loadSound(Common::String &fileName);
CelDecoder *loadCel(Common::String &fileName);
- virtual void toConsole();
-
- LeadActor *getLeadActor();
+ virtual void clear();
protected:
void init();
+
Common::Array<Actor*> _actors;
ResourceMgr _resMgr;
LeadActor *_leadActor;
-
- /*
- int unk_1;
- CString _str;
- */
};
} // End of namespace Pink