diff options
author | whitertandrek | 2018-03-22 17:36:46 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | a22ebbb54e0ff82851e9d54c04b0ff654f848ce3 (patch) | |
tree | add7baf76e5505f85e80dbe65aec0ee08e7cd48c /engines | |
parent | 8874ccb9de1936c7fc1ae83bccd3d85344617285 (diff) | |
download | scummvm-rg350-a22ebbb54e0ff82851e9d54c04b0ff654f848ce3.tar.gz scummvm-rg350-a22ebbb54e0ff82851e9d54c04b0ff654f848ce3.tar.bz2 scummvm-rg350-a22ebbb54e0ff82851e9d54c04b0ff654f848ce3.zip |
PINK: Handlers are implemented, beside handlerMgr, HandlerTimerSequences;
HandlerTimer differs in Peril and Hokus Pokus
Diffstat (limited to 'engines')
-rw-r--r-- | engines/pink/objects/actors/actor.cpp | 4 | ||||
-rw-r--r-- | engines/pink/objects/actors/actor.h | 1 | ||||
-rw-r--r-- | engines/pink/objects/handlers/handler.cpp | 55 | ||||
-rw-r--r-- | engines/pink/objects/handlers/handler.h | 27 | ||||
-rw-r--r-- | engines/pink/objects/handlers/handler_timer.cpp | 55 | ||||
-rw-r--r-- | engines/pink/objects/handlers/handler_timer.h | 21 | ||||
-rw-r--r-- | engines/pink/objects/pages/game_page.cpp | 2 |
7 files changed, 147 insertions, 18 deletions
diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index c02cb67365..14faae1036 100644 --- a/engines/pink/objects/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -107,4 +107,8 @@ Action *Actor::getAction() const { return _action; } +bool Actor::isPlaying() { + return _isActionEnd; +} + } // End of namespace Pink diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index a31f5539d3..7bd65b3f48 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -47,6 +47,7 @@ public: Action *getAction() const; + bool isPlaying(); virtual void init(bool unk); void hide(); void endAction(); diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp index 8b988fb485..c5468e1b8d 100644 --- a/engines/pink/objects/handlers/handler.cpp +++ b/engines/pink/objects/handlers/handler.cpp @@ -51,19 +51,23 @@ void Handler::executeSideEffects(LeadActor *actor) { } } +void Handler::onMessage(LeadActor *actor) { + executeSideEffects(actor); +} + void HandlerSequences::deserialize(Archive &archive) { Handler::deserialize(archive); archive >> _sequences; } -void HandlerSequences::init(LeadActor *actor) { - executeSideEffects(actor); +void HandlerSequences::onMessage(LeadActor *actor) { + Handler::onMessage(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); } @@ -90,4 +94,49 @@ void HandlerStartPage::toConsole() { } } +void HandlerLeftClick::toConsole() { + debug("HandlerLeftClick:"); + + debug("\tSideEffects:"); + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (int i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (int i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } +} + +void HandlerUseClick::deserialize(Archive &archive) { + HandlerSequences::deserialize(archive); +} + +void HandlerUseClick::toConsole() { + debug("HandlerUseClick: _inventoryItem=%s, _recepient=%s", _inventoryItem.c_str(), _recepient.c_str()); + debug("\tSideEffects:"); + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (int i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + + debug("\tSequences:"); + for (int i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } +} + +void HandlerUseClick::handle(Sequence *sequence) { + +} + } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h index c42aaefe98..b2e5fcf2d7 100644 --- a/engines/pink/objects/handlers/handler.h +++ b/engines/pink/objects/handlers/handler.h @@ -37,6 +37,7 @@ class LeadActor; class Handler : public Object { public: virtual void deserialize(Archive &archive); + virtual void onMessage(LeadActor *actor); bool isSuitable(LeadActor *actor); protected: @@ -51,20 +52,40 @@ class Sequence; class HandlerSequences : public Handler { public: virtual void deserialize(Archive &archive); - void init(LeadActor *actor); - virtual void handle(Sequence *sequence) = 0; + virtual void onMessage(LeadActor *actor); protected: + virtual void handle(Sequence *sequence) = 0; + Common::StringArray _sequences; }; class HandlerStartPage : public HandlerSequences { public: - ~HandlerStartPage() {}; + virtual void toConsole(); +private: + virtual void handle(Sequence *sequence); +}; + +class HandlerLeftClick : public HandlerSequences { +public: virtual void toConsole(); +private: + virtual void handle(Sequence *sequence) {} +}; + +class HandlerUseClick : public HandlerSequences { +public: + virtual void deserialize(Archive &archive); + virtual void toConsole(); + +private: virtual void handle(Sequence *sequence); + + Common::String _inventoryItem; + Common::String _recepient; }; } // End of namespace Pink diff --git a/engines/pink/objects/handlers/handler_timer.cpp b/engines/pink/objects/handlers/handler_timer.cpp index 2c6161b46f..b074772d84 100644 --- a/engines/pink/objects/handlers/handler_timer.cpp +++ b/engines/pink/objects/handlers/handler_timer.cpp @@ -20,25 +20,74 @@ * */ + #include "handler_timer.h" +#include <common/debug.h> +#include <engines/pink/archive.h> +#include <engines/pink/objects/condition.h> +#include <engines/pink/objects/sequences/sequence.h> +#include <engines/pink/objects/side_effect.h> +#include <engines/pink/objects/actors/lead_actor.h> namespace Pink { void HandlerTimerActions::deserialize(Archive &archive) { Handler::deserialize(archive); + archive >> _actions; } -void HandlerTimerActions::handle(LeadActor *actor) { +void HandlerTimerActions::toConsole() { + debug("HandlerTimerActions:"); + + debug("\tSideEffects:"); + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (int i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + debug("\tActions:"); + for (int i = 0; i < _actions.size(); ++i) { + debug("\t\t%s", _actions[i].c_str()); + } } -void HandlerTimerSequences::deserialize(Archive &archive) { - Handler::deserialize(archive); +void HandlerTimerActions::onMessage(LeadActor *actor) { + Handler::onMessage(actor); + assert(_actions.size() > 0); + if (!actor->isPlaying()){ + Action *action = actor->findAction(_actions[0]);// we must pick random + assert(action); + actor->setAction(action, 0); + } } + void HandlerTimerSequences::handle(LeadActor *actor) { + debug("HandlerTimerSequences function is not implemented"); +} + +void HandlerTimerSequences::toConsole() { + debug("HandlerTimerSequences:"); + + debug("\tSideEffects:"); + for (int i = 0; i < _sideEffects.size(); ++i) { + _sideEffects[i]->toConsole(); + } + + debug("\tConditions:"); + for (int i = 0; i < _conditions.size(); ++i) { + _conditions[i]->toConsole(); + } + debug("\tSequences:"); + for (int i = 0; i < _sequences.size(); ++i) { + debug("\t\t%s", _sequences[i].c_str()); + } } } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/handlers/handler_timer.h b/engines/pink/objects/handlers/handler_timer.h index 21d9518e04..b355645f99 100644 --- a/engines/pink/objects/handlers/handler_timer.h +++ b/engines/pink/objects/handlers/handler_timer.h @@ -30,25 +30,30 @@ namespace Pink { class LeadActor; -// This class has difference in games +//TODO in Peril create HandlerTimerActions when it is request for HandlerTimer + +// This class has differences in games class HandlerTimer : public Handler { - virtual void handle(LeadActor *actor) = 0; + }; +//in Peril this is HandlerTimer class HandlerTimerActions : public HandlerTimer { +public: + virtual void toConsole(); virtual void deserialize(Archive &archive); - virtual void handle(LeadActor *actor); + virtual void onMessage(LeadActor *actor); private: Common::StringArray _actions; }; -class HandlerTimerSequences : public HandlerTimer { - virtual void deserialize(Archive &archive); - virtual void handle(LeadActor *actor); - +//appear in HokusPokus +class HandlerTimerSequences : public HandlerSequences { //originally it was inherited from HandlerTimer +public: + virtual void toConsole(); private: - Common::StringArray _sequences; + virtual void handle(LeadActor *actor); // very big and hard function }; } // End of namespace Pink diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 9ea91845bd..e29a4f8179 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -70,7 +70,7 @@ void GamePage::init(bool isLoadingSave) { void GamePage::initHandler() { for (uint i = 0; i < _handlers.size(); ++i) { if (_handlers[i]->isSuitable(_leadActor)){ - _handlers[i]->init(_leadActor); + _handlers[i]->onMessage(_leadActor); break; } } |