diff options
author | whitertandrek | 2018-03-19 10:43:49 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | 3e2106a1c087b2c27f961ce918ad6459670b99fa (patch) | |
tree | 38704c7c5129669a9b32308d9013d41d116eb9f2 /engines | |
parent | 62f84eae96625e778aae63e75b399a50b16363e8 (diff) | |
download | scummvm-rg350-3e2106a1c087b2c27f961ce918ad6459670b99fa.tar.gz scummvm-rg350-3e2106a1c087b2c27f961ce918ad6459670b99fa.tar.bz2 scummvm-rg350-3e2106a1c087b2c27f961ce918ad6459670b99fa.zip |
PINK: Added more Handler methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/pink/actors/actor.cpp | 4 | ||||
-rw-r--r-- | engines/pink/actors/actor.h | 2 | ||||
-rw-r--r-- | engines/pink/handlers/handler.cpp | 11 | ||||
-rw-r--r-- | engines/pink/handlers/handler.h | 3 | ||||
-rw-r--r-- | engines/pink/handlers/handler_sequences.cpp | 9 | ||||
-rw-r--r-- | engines/pink/handlers/handler_sequences.h | 1 | ||||
-rw-r--r-- | engines/pink/page.cpp | 17 | ||||
-rw-r--r-- | engines/pink/page.h | 3 | ||||
-rw-r--r-- | engines/pink/sequences/sequencer.h | 1 | ||||
-rw-r--r-- | engines/pink/side_effects/side_effect.h | 2 | ||||
-rw-r--r-- | engines/pink/side_effects/side_effect_exit.cpp | 4 | ||||
-rw-r--r-- | engines/pink/side_effects/side_effect_exit.h | 2 | ||||
-rw-r--r-- | engines/pink/side_effects/side_effect_module_variable.h | 1 |
13 files changed, 53 insertions, 7 deletions
diff --git a/engines/pink/actors/actor.cpp b/engines/pink/actors/actor.cpp index c7a5a9a94a..340b1c9f16 100644 --- a/engines/pink/actors/actor.cpp +++ b/engines/pink/actors/actor.cpp @@ -35,4 +35,8 @@ void Actor::deserialize(Archive &archive) { archive >> _actions; } +Sequencer *Actor::getSequencer() { + return _page->getSequencer(); +} + } // End of namespace Pink diff --git a/engines/pink/actors/actor.h b/engines/pink/actors/actor.h index f13cfe2659..eb19c4169a 100644 --- a/engines/pink/actors/actor.h +++ b/engines/pink/actors/actor.h @@ -30,11 +30,13 @@ namespace Pink { class GamePage; class Action; +class Sequencer; class Actor : public NamedObject { public: Actor() {}; virtual void deserialize(Archive &archive); + Sequencer *getSequencer(); protected: GamePage *_page; diff --git a/engines/pink/handlers/handler.cpp b/engines/pink/handlers/handler.cpp index 300071beb7..d42d01510c 100644 --- a/engines/pink/handlers/handler.cpp +++ b/engines/pink/handlers/handler.cpp @@ -22,6 +22,7 @@ #include "handler.h" #include "../archive.h" +#include "../side_effects/side_effect.h" namespace Pink { @@ -30,4 +31,14 @@ void Handler::deserialize(Archive &archive) { archive >> _sideEffects; } +bool Handler::initConditions(LeadActor *actor) { + return true; +} + +void Handler::initSideEffects(LeadActor *actor) { + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->init(actor); + } +} + } // End of namespace Pink diff --git a/engines/pink/handlers/handler.h b/engines/pink/handlers/handler.h index 6bcac49567..beca2ffa65 100644 --- a/engines/pink/handlers/handler.h +++ b/engines/pink/handlers/handler.h @@ -29,10 +29,13 @@ namespace Pink { class SideEffect; +class LeadActor; class Handler : public Object { public: virtual void deserialize(Archive &archive); + bool initConditions(LeadActor *actor); + void initSideEffects(LeadActor *actor); protected: //_conditions diff --git a/engines/pink/handlers/handler_sequences.cpp b/engines/pink/handlers/handler_sequences.cpp index 938633876d..52c9254d03 100644 --- a/engines/pink/handlers/handler_sequences.cpp +++ b/engines/pink/handlers/handler_sequences.cpp @@ -21,7 +21,9 @@ */ #include "handler_sequences.h" +#include <engines/pink/sequences/sequencer.h> #include "../archive.h" +#include "../actors/lead_actor.h" namespace Pink { @@ -30,4 +32,11 @@ void HandlerSequences::deserialize(Archive &archive) { archive >> _sequences; } +void HandlerSequences::initSequence(LeadActor *actor) { + initSideEffects(actor); + Sequencer *sequencer = actor->getSequencer(); + Sequence *sequence = sequencer->findSequence(_sequences[0]); //actually we must pick random sequence + //sequencer->authorSequence(sequence, 0); +} + } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/handlers/handler_sequences.h b/engines/pink/handlers/handler_sequences.h index 7641b178da..b55d81ce38 100644 --- a/engines/pink/handlers/handler_sequences.h +++ b/engines/pink/handlers/handler_sequences.h @@ -30,6 +30,7 @@ namespace Pink { class HandlerSequences : public Handler { public: virtual void deserialize(Archive &archive); + void initSequence(LeadActor *actor); protected: StringArray _sequences; diff --git a/engines/pink/page.cpp b/engines/pink/page.cpp index cfc78c8974..77e3bb3c06 100644 --- a/engines/pink/page.cpp +++ b/engines/pink/page.cpp @@ -21,6 +21,8 @@ */ #include <engines/pink/walk/walk_mgr.h> +#include <engines/pink/handlers/handler.h> +#include <engines/pink/handlers/handler_sequences.h> #include "page.h" #include "cursor_mgr.h" #include "actors/lead_actor.h" @@ -60,18 +62,26 @@ void GamePage::load(Archive &archive) { void GamePage::init(bool isLoadingSave) { if (!isLoadingSave){ //assert(perhapsIsLoaded == 0); - loadFields(); + loadManagers(); } //init actor which inits actions if (!isLoadingSave) { + for (int i = 0; i < _handlers.size(); ++i) { + if (_handlers[i]->initConditions(_leadActor)){ + HandlerSequences *handlerSequences = dynamic_cast<HandlerSequences*>(_handlers[i]); + assert(handlerSequences); + handlerSequences->initSequence(_leadActor); + break; + } + } } } -void GamePage::loadFields() { +void GamePage::loadManagers() { perhapsIsLoaded = true; _cursorMgr = new CursorMgr(this); _walkMgr = new WalkMgr; @@ -87,5 +97,8 @@ PinkEngine *GamePage::getGame() { return _module->getGame(); } +Sequencer *GamePage::getSequencer() { + return _sequencer; +} } // End of namespace Pink diff --git a/engines/pink/page.h b/engines/pink/page.h index a408ba81bd..008b0a032b 100644 --- a/engines/pink/page.h +++ b/engines/pink/page.h @@ -59,11 +59,12 @@ class GamePage : public Page { public: virtual void deserialize(Archive &archive); virtual void load(Archive &archive); - void loadFields();; + void loadManagers(); void init(bool isLoadingSave); PinkEngine *getGame(); + Sequencer *getSequencer(); private: int perhapsIsLoaded; diff --git a/engines/pink/sequences/sequencer.h b/engines/pink/sequences/sequencer.h index d125405c1e..93a156fa54 100644 --- a/engines/pink/sequences/sequencer.h +++ b/engines/pink/sequences/sequencer.h @@ -38,6 +38,7 @@ public: virtual void deserialize(Archive &archive); Sequence* findSequence(const Common::String &name); + void authorSequence(Sequence *sequence, bool isFromSave); private: //context diff --git a/engines/pink/side_effects/side_effect.h b/engines/pink/side_effects/side_effect.h index f3d4eec06d..e26a28566a 100644 --- a/engines/pink/side_effects/side_effect.h +++ b/engines/pink/side_effects/side_effect.h @@ -32,7 +32,7 @@ class LeadActor; class SideEffect : public Object { public: virtual ~SideEffect() {}; - virtual void init(LeadActor &_actor) {}; + virtual void init(LeadActor *_actor) {}; }; diff --git a/engines/pink/side_effects/side_effect_exit.cpp b/engines/pink/side_effects/side_effect_exit.cpp index 31efc35271..0871c2f547 100644 --- a/engines/pink/side_effects/side_effect_exit.cpp +++ b/engines/pink/side_effects/side_effect_exit.cpp @@ -33,8 +33,8 @@ void SideEffectExit::deserialize(Archive &archive) { _nextModule.c_str(), _nextPage.c_str()); } -void SideEffectExit::init(LeadActor &_actor) { - _actor.setNextExecutors(_nextPage, _nextModule); +void SideEffectExit::init(LeadActor *_actor) { + _actor->setNextExecutors(_nextPage, _nextModule); } } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/side_effects/side_effect_exit.h b/engines/pink/side_effects/side_effect_exit.h index 5d2076d9bd..a324b8274a 100644 --- a/engines/pink/side_effects/side_effect_exit.h +++ b/engines/pink/side_effects/side_effect_exit.h @@ -31,7 +31,7 @@ class SideEffectExit : public SideEffect { public: virtual void deserialize(Archive &archive); - virtual void init(LeadActor &_actor); + virtual void init(LeadActor *_actor); private: Common::String _nextModule; diff --git a/engines/pink/side_effects/side_effect_module_variable.h b/engines/pink/side_effects/side_effect_module_variable.h index 68156f12ad..4eddeba613 100644 --- a/engines/pink/side_effects/side_effect_module_variable.h +++ b/engines/pink/side_effects/side_effect_module_variable.h @@ -29,6 +29,7 @@ namespace Pink { class SideEffectModuleVariable : public SideEffectVariable { public: virtual void deserialize(Archive &archive); + }; } // End of namespace Pink |