diff options
author | whitertandrek | 2018-03-22 08:50:02 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | be415cd46f7f5c87e221270ec43f050565bdd3e8 (patch) | |
tree | db5fa370755e0238d95c189758abbd219fec5813 /engines/pink/objects | |
parent | 467d3f1ab890bfca77629dd239b670ee4797bfe8 (diff) | |
download | scummvm-rg350-be415cd46f7f5c87e221270ec43f050565bdd3e8.tar.gz scummvm-rg350-be415cd46f7f5c87e221270ec43f050565bdd3e8.tar.bz2 scummvm-rg350-be415cd46f7f5c87e221270ec43f050565bdd3e8.zip |
PINK: small fixes
Diffstat (limited to 'engines/pink/objects')
-rw-r--r-- | engines/pink/objects/handlers/handler.cpp | 8 | ||||
-rw-r--r-- | engines/pink/objects/handlers/handler.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/pages/game_page.cpp | 103 | ||||
-rw-r--r-- | engines/pink/objects/pages/game_page.h | 5 | ||||
-rw-r--r-- | engines/pink/objects/pages/page.cpp | 102 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequencer.cpp | 1 |
6 files changed, 116 insertions, 105 deletions
diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp index 6a53832d4a..8b988fb485 100644 --- a/engines/pink/objects/handlers/handler.cpp +++ b/engines/pink/objects/handlers/handler.cpp @@ -45,7 +45,7 @@ bool Handler::isSuitable(LeadActor *actor) { return true; } -void Handler::prepareForNextHandler(LeadActor *actor) { +void Handler::executeSideEffects(LeadActor *actor) { for (int i = 0; i < _sideEffects.size(); ++i) { _sideEffects[i]->execute(actor); } @@ -57,10 +57,14 @@ void HandlerSequences::deserialize(Archive &archive) { } void HandlerSequences::init(LeadActor *actor) { - prepareForNextHandler(actor); + executeSideEffects(actor); Sequencer *sequencer = actor->getSequencer(); + Sequence *sequence = sequencer->findSequence(_sequences[0]); //actually we must pick random sequence + assert(sequence); + sequencer->authorSequence(sequence, 0); + handle(sequence); } void HandlerStartPage::handle(Sequence *sequence) { diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h index 4f8cc28779..c42aaefe98 100644 --- a/engines/pink/objects/handlers/handler.h +++ b/engines/pink/objects/handlers/handler.h @@ -40,7 +40,7 @@ public: bool isSuitable(LeadActor *actor); protected: - void prepareForNextHandler(LeadActor *actor); + void executeSideEffects(LeadActor *actor); Common::Array<Condition*> _conditions; Common::Array<SideEffect*> _sideEffects; diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 58d8830ddc..f4a7a084de 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -20,6 +20,109 @@ * */ +#include <engines/pink/objects/handlers/handler.h> +#include "game_page.h" +#include <engines/pink/objects/walk/walk_mgr.h> +#include "engines/pink/cursor_mgr.h" +#include "engines/pink/objects/actors/lead_actor.h" +#include "engines/pink/objects/sequences/sequencer.h" + + namespace Pink { +void GamePage::deserialize(Archive &archive) { + Page::deserialize(archive); + _module = static_cast<Module*>(archive.readObject()); + assert(dynamic_cast<Module*>(_module) != 0); +} + +void GamePage::load(Archive &archive) { + archive.mapObject(_cursorMgr); + archive.mapObject(_walkMgr); + archive.mapObject(_sequencer); + + Page::load(archive); + + _leadActor = static_cast<LeadActor*>(archive.readObject()); + + _walkMgr->deserialize(archive); + + _sequencer->deserialize(archive); + archive >> _handlers; +} + +void GamePage::init(bool isLoadingSave) { + + if (!isLoadingSave){ + //assert(perhapsIsLoaded == 0); + loadManagers(); + } + + toConsole(); + + for (int i = 0; i < _actors.size(); ++i) { + _actors[i]->init(0); + } + + if (!isLoadingSave) + prepareHandler(); + + +} + +void GamePage::prepareHandler() { + for (uint i = 0; i < _handlers.size(); ++i) { + if (_handlers[i]->isSuitable(_leadActor)){ + _handlers[i]->init(_leadActor); + break; + } + } +} + +void GamePage::loadManagers() { + perhapsIsLoaded = true; + _cursorMgr = new CursorMgr(this); + _walkMgr = new WalkMgr; + _sequencer = new Sequencer(this); + + _resMgr.init(_module->getGame(), this); + + // memfile manipulations if from save or page changing + +} + +PinkEngine *GamePage::getGame() { + return _module->getGame(); +} + +Sequencer *GamePage::getSequencer() { + return _sequencer; +} + +Module *GamePage::getModule() const { + return _module; +} + +bool GamePage::checkValueOfVariable(Common::String &variable, Common::String &value) { + assert(_variables.contains(variable)); + return _variables[variable] == value; +} + +void GamePage::setVariable(Common::String &variable, Common::String &value) { + _variables[variable] = value; +} + +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(); + } +} + } // 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 f92a9662cc..04371605f9 100644 --- a/engines/pink/objects/pages/game_page.h +++ b/engines/pink/objects/pages/game_page.h @@ -53,12 +53,15 @@ public: virtual void toConsole(); private: + void prepareHandler(); + + int perhapsIsLoaded; Module *_module; CursorMgr *_cursorMgr; WalkMgr *_walkMgr; Sequencer *_sequencer; - Common::Array<Handler *> _handlers; + Common::Array<HandlerStartPage*> _handlers; Common::StringMap _variables; /* diff --git a/engines/pink/objects/pages/page.cpp b/engines/pink/objects/pages/page.cpp index 6eb9ff2b8b..36910ec87b 100644 --- a/engines/pink/objects/pages/page.cpp +++ b/engines/pink/objects/pages/page.cpp @@ -20,12 +20,9 @@ * */ -#include <engines/pink/objects/walk/walk_mgr.h> -#include <engines/pink/objects/handlers/handler.h> -#include "game_page.h" -#include "engines/pink/cursor_mgr.h" +#include "page.h" #include "engines/pink/objects/actors/lead_actor.h" -#include "engines/pink/objects/sequences/sequencer.h" + namespace Pink { @@ -53,99 +50,4 @@ void Page::toConsole() { } } - -void GamePage::deserialize(Archive &archive) { - Page::deserialize(archive); - _module = static_cast<Module*>(archive.readObject()); - assert(dynamic_cast<Module*>(_module) != 0); -} - -void GamePage::load(Archive &archive) { - archive.mapObject(_cursorMgr); - archive.mapObject(_walkMgr); - archive.mapObject(_sequencer); - - Page::load(archive); - - _leadActor = static_cast<LeadActor*>(archive.readObject()); - - _walkMgr->deserialize(archive); - - _sequencer->deserialize(archive); - archive >> _handlers; -} - -void GamePage::init(bool isLoadingSave) { - - if (!isLoadingSave){ - //assert(perhapsIsLoaded == 0); - loadManagers(); - } - - toConsole(); - - for (int i = 0; i < _actors.size(); ++i) { - _actors[i]->init(0); - } - - if (!isLoadingSave) { - for (uint i = 0; i < _handlers.size(); ++i) { - if (_handlers[i]->isSuitable(_leadActor)){ - HandlerSequences *handlerSequences = dynamic_cast<HandlerSequences*>(_handlers[i]); - assert(handlerSequences); - handlerSequences->init(_leadActor); - break; - } - } - - } - -} - -void GamePage::loadManagers() { - perhapsIsLoaded = true; - _cursorMgr = new CursorMgr(this); - _walkMgr = new WalkMgr; - _sequencer = new Sequencer(this); - - _resMgr.init(_module->getGame(), this); - - // memfile manipulations if from save or page changing - -} - -PinkEngine *GamePage::getGame() { - return _module->getGame(); -} - -Sequencer *GamePage::getSequencer() { - return _sequencer; -} - -Module *GamePage::getModule() const { - return _module; -} - -bool GamePage::checkValueOfVariable(Common::String &variable, Common::String &value) { - assert(_variables.contains(variable)); - return _variables[variable] == value; -} - -void GamePage::setVariable(Common::String &variable, Common::String &value) { - _variables[variable] = value; -} - -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(); - } -} - } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 2bddcbd4f3..d97e8f504b 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -42,7 +42,6 @@ void Sequencer::deserialize(Archive &archive) { archive >> _sequences; archive.readCount();// intro have 0 timers; //serialize timers; - } Sequence *Sequencer::findSequence(const Common::String &name) { |