PINK: use HandlerSequences instead of HandlerStartPage

This commit is contained in:
Andrei Prykhodko 2020-06-04 22:41:39 +03:00
parent 9f3f70c4cd
commit 3de5035018
4 changed files with 10 additions and 45 deletions

View File

@ -148,12 +148,12 @@ static Object *createObject(int objectId) {
case kHandlerLeftClick:
return new HandlerLeftClick;
case kHandlerStartPage:
return new HandlerStartPage;
return new HandlerSequences(true, false);
case kHandlerTimer:
case kHandlerTimerActions:
return new HandlerTimerActions; // hack for Peril, but behavior is correct
case kHandlerTimerSequences:
return new HandlerSequences(true);
return new HandlerSequences(false, true);
case kHandlerUseClick:
return new HandlerUseClick;
case kInventoryActor:

View File

@ -86,36 +86,15 @@ void HandlerSequences::handle(Actor *actor) {
else
sequencer->authorSequence(sequence, false);
execute(sequence);
if (_startPage)
sequence->allowSkipping();
}
HandlerSequences::HandlerSequences(bool parallel) {
HandlerSequences::HandlerSequences(bool startPage, bool parallel) {
_startPage = startPage;
_parallel = parallel;
}
void HandlerStartPage::execute(Sequence *sequence) {
sequence->allowSkipping();
}
void HandlerStartPage::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "HandlerStartPage:");
debugC(6, kPinkDebugLoadingObjects, "\tSideEffects:");
for (uint i = 0; i < _sideEffects.size(); ++i) {
_sideEffects[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tConditions:");
for (uint i = 0; i < _conditions.size(); ++i) {
_conditions[i]->toConsole();
}
debugC(6, kPinkDebugLoadingObjects, "\tSequences:");
for (uint i = 0; i < _sequences.size(); ++i) {
debugC(6, kPinkDebugLoadingObjects, "\t\t%s", _sequences[i].c_str());
}
}
void HandlerLeftClick::toConsole() const {
debugC(6, kPinkDebugLoadingObjects, "HandlerLeftClick:");

View File

@ -52,32 +52,20 @@ class Sequence;
class HandlerSequences : public Handler {
public:
HandlerSequences(bool parallel = false);
HandlerSequences(bool startPage = false, bool parallel = false);
void deserialize(Archive &archive) override;
void handle(Actor *actor) override;
protected:
virtual void execute(Sequence *sequence) {};
StringArray _sequences;
bool _startPage;
bool _parallel;
};
class HandlerStartPage : public HandlerSequences {
public:
void toConsole() const override;
private:
void execute(Sequence *sequence) override;
};
class HandlerLeftClick : public HandlerSequences {
public:
void toConsole() const override;
private:
void execute(Sequence *sequence) override {}
};
class HandlerUseClick : public HandlerSequences {
@ -89,8 +77,6 @@ public:
const Common::String &getRecepient() const { return _recepient; }
private:
void execute(Sequence *sequence) override {};
Common::String _inventoryItem;
Common::String _recepient;
};

View File

@ -30,7 +30,7 @@
namespace Pink {
class CursorMgr;
class HandlerStartPage;
class HandlerSequences;
class GamePage : public Page {
public:
@ -71,7 +71,7 @@ private:
CursorMgr *_cursorMgr;
WalkMgr *_walkMgr;
Sequencer *_sequencer;
Array<HandlerStartPage *> _handlers;
Array<HandlerSequences *> _handlers;
StringMap _variables;
};