diff options
33 files changed, 404 insertions, 137 deletions
diff --git a/engines/pink/cel_decoder.cpp b/engines/pink/cel_decoder.cpp new file mode 100644 index 0000000000..5d20e415d3 --- /dev/null +++ b/engines/pink/cel_decoder.cpp @@ -0,0 +1,25 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +namespace Pink { + +}
\ No newline at end of file diff --git a/engines/pink/cel_decoder.h b/engines/pink/cel_decoder.h new file mode 100644 index 0000000000..0e8d6120e6 --- /dev/null +++ b/engines/pink/cel_decoder.h @@ -0,0 +1,38 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef PINK_CEL_DECODER_H +#define PINK_CEL_DECODER_H + + +#include <video/flic_decoder.h> + +namespace Pink { + +class CelDecoder : public Video::FlicDecoder { + + +}; + +} + +#endif diff --git a/engines/pink/director.cpp b/engines/pink/director.cpp index e34e0bc698..cdc60c8aa4 100644 --- a/engines/pink/director.cpp +++ b/engines/pink/director.cpp @@ -20,7 +20,44 @@ * */ +#include "director.h" +#include <engines/pink/objects/actions/action_cel.h> +#include "graphics/surface.h" +#include "graphics/palette.h" + namespace Pink { +Director::Director(OSystem *system) + : _system(system) {} + +void Director::draw() { + bool needUpdate = 0; + for (int i = 0; i < _sprites.size(); ++i) { + Video::FlicDecoder *decoder = _sprites[i]->getDecoder(); + if (decoder->needsUpdate()) { + const Graphics::Surface *surface = decoder->decodeNextFrame(); + _system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h); + needUpdate = 1; + } + } + if (needUpdate) + _system->updateScreen(); +} + +void Director::addSprite(ActionCEL *sprite) { + _sprites.push_back(sprite); //TODO impl sorting +} + +void Director::removeSprite(ActionCEL *sprite) { + for (int i = 0; i < _sprites.size(); ++i) { + if (sprite == _sprites[i]) { + _sprites.remove_at(i); + break; + } + } +} +void Director::setPallette(const byte *pallete) { + _system->getPaletteManager()->setPalette(pallete, 0, 256); +} }
\ No newline at end of file diff --git a/engines/pink/director.h b/engines/pink/director.h index 882164902d..0bd44f41aa 100644 --- a/engines/pink/director.h +++ b/engines/pink/director.h @@ -23,16 +23,28 @@ #ifndef PINK_DIRECTOR_H #define PINK_DIRECTOR_H +#include <common/array.h> +#include <common/system.h> + namespace Pink { +class ActionCEL; + class Director { public: + Director(OSystem *system); //void addSoundObject(); //void removeSound(); //void updateSoundAction - //CActor *getActorByCoords(); -private: + //CActor *getActorByCoords() + void draw(); + void addSprite(ActionCEL *sprite); + void removeSprite(ActionCEL *sprite); + void setPallette(const byte *pallete); +private: + OSystem *_system; + Common::Array<ActionCEL*> _sprites; }; } // End of namespace Pink diff --git a/engines/pink/module.mk b/engines/pink/module.mk index ff38c8a5e7..1b833738b3 100644 --- a/engines/pink/module.mk +++ b/engines/pink/module.mk @@ -36,6 +36,7 @@ MODULE_OBJS = \ objects/pages/game_page.o \ objects/sequences/seq_timer.o \ objects/sequences/sequence.o \ + objects/sequences/sequence_context.o \ objects/sequences/sequence_item.o \ objects/sequences/sequencer.o \ objects/walk/walk_mgr.o \ diff --git a/engines/pink/objects/actions/action.h b/engines/pink/objects/actions/action.h index 5b164a3052..3b79be205f 100644 --- a/engines/pink/objects/actions/action.h +++ b/engines/pink/objects/actions/action.h @@ -28,6 +28,7 @@ namespace Pink { class Actor; +class Director; class Action : public NamedObject { public: @@ -37,6 +38,8 @@ public: virtual void update() {}; virtual void toConsole() {}; + virtual bool initPallete(Director *director) { return 0;} + protected: Actor *_actor; }; diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp index f1c350473f..5385386b39 100644 --- a/engines/pink/objects/actions/action_cel.cpp +++ b/engines/pink/objects/actions/action_cel.cpp @@ -22,13 +22,49 @@ #include <common/debug.h> #include "action_cel.h" +#include <pink/objects/actors/actor.h> #include "engines/pink/archive.h" +#include "engines/pink/objects/pages/game_page.h" +#include "pink/pink.h" namespace Pink { +ActionCEL::ActionCEL() + : _flicDecoder(nullptr) { + +} + void ActionCEL::deserialize(Archive &archive) { Action::deserialize(archive); archive >> _fileName >> _z; } +void ActionCEL::start(bool unk) { + if (!_flicDecoder) + _flicDecoder = _actor->getPage()->loadCel(_fileName); + _actor->getPage()->getGame()->getDirector()->addSprite(this); + this->onStart(); +} + +void ActionCEL::end() { + _actor->getPage()->getGame()->getDirector()->removeSprite(this); + delete _flicDecoder; + _flicDecoder = nullptr; +} + +uint32 ActionCEL::getZ() { + return _z; +} + +Video::FlicDecoder *ActionCEL::getDecoder() { + return _flicDecoder; +} + +bool ActionCEL::initPallete(Director *director) { + _flicDecoder = _actor->getPage()->loadCel(_fileName); + _flicDecoder->decodeNextFrame(); + director->setPallette(_flicDecoder->getPalette()); + return 1; +} + } // 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 8c6a61a405..92986fb1bc 100644 --- a/engines/pink/objects/actions/action_cel.h +++ b/engines/pink/objects/actions/action_cel.h @@ -23,15 +23,26 @@ #ifndef PINK_ACTION_CEL_H #define PINK_ACTION_CEL_H +#include <video/flic_decoder.h> #include "action.h" namespace Pink { class ActionCEL : public Action { public: + ActionCEL(); virtual void deserialize(Archive &archive); + virtual void start(bool unk); + virtual void end(); + + uint32 getZ(); + Video::FlicDecoder *getDecoder(); + + virtual bool initPallete(Director *director); protected: + virtual void onStart() {} ; + Video::FlicDecoder *_flicDecoder; Common::String _fileName; uint32 _z; }; diff --git a/engines/pink/objects/actions/action_hide.h b/engines/pink/objects/actions/action_hide.h index 2e52fdc331..414d077409 100644 --- a/engines/pink/objects/actions/action_hide.h +++ b/engines/pink/objects/actions/action_hide.h @@ -30,10 +30,9 @@ namespace Pink { class ActionHide : public Action { public: virtual void deserialize(Archive &archive); - virtual void toConsole(); - virtual void start(bool unk_startNow); + virtual void start(bool unk); virtual void end(); }; diff --git a/engines/pink/objects/actions/action_play.cpp b/engines/pink/objects/actions/action_play.cpp index 051f3c42fe..3945fe62a2 100644 --- a/engines/pink/objects/actions/action_play.cpp +++ b/engines/pink/objects/actions/action_play.cpp @@ -37,12 +37,17 @@ void ActionPlay::toConsole() { " _endFrame = %u", _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame); } -void ActionPlay::start(bool unk) { - debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str()); -} - void ActionPlay::end() { + ActionCEL::end(); debug("ActionPlay %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); } +void ActionPlay::onStart() { + debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str()); + _flicDecoder->seekToFrame(_startFrame); + if (_stopFrame != -1) + _flicDecoder->setEndFrame(_stopFrame); + _flicDecoder->start(); +} + } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_play.h b/engines/pink/objects/actions/action_play.h index f5c6357fc5..a2f0ae3c9f 100644 --- a/engines/pink/objects/actions/action_play.h +++ b/engines/pink/objects/actions/action_play.h @@ -33,10 +33,11 @@ public: virtual void deserialize(Archive &archive); virtual void toConsole(); - virtual void start(bool unk); virtual void end(); protected: + virtual void onStart(); + uint32 _stopFrame; }; diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h index 0a9307b2af..6a10edd0ba 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.h +++ b/engines/pink/objects/actions/action_play_with_sfx.h @@ -30,7 +30,7 @@ namespace Pink { class ActionSfx; -class ActionPlayWithSfx : ActionPlay { +class ActionPlayWithSfx : public ActionPlay { virtual void deserialize(Archive &archive); virtual void toConsole(); @@ -39,7 +39,7 @@ private: Common::Array<ActionSfx*> _sfxArray; }; -class ActionSfx : Object { +class ActionSfx : public Object { public: virtual void deserialize(Archive &archive); virtual void toConsole(); diff --git a/engines/pink/objects/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp index ca5793b503..8e90c836bb 100644 --- a/engines/pink/objects/actions/action_still.cpp +++ b/engines/pink/objects/actions/action_still.cpp @@ -37,12 +37,14 @@ void ActionStill::toConsole() { _name.c_str(), _fileName.c_str(), _startFrame); } -void ActionStill::start(bool unk) { - debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str()); -} - void ActionStill::end() { + ActionCEL::end(); debug("ActionStill %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); } +void ActionStill::onStart() { + debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str()); + _flicDecoder->seekToFrame(_startFrame); +} + } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/actions/action_still.h b/engines/pink/objects/actions/action_still.h index d77706103b..7568c9ba3d 100644 --- a/engines/pink/objects/actions/action_still.h +++ b/engines/pink/objects/actions/action_still.h @@ -32,11 +32,11 @@ public: virtual void deserialize(Archive &archive); virtual void toConsole(); - virtual void start(bool unk); - virtual void end(); protected: + virtual void onStart(); + uint32 _startFrame; }; diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index 14faae1036..e612c83ae6 100644 --- a/engines/pink/objects/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -61,10 +61,10 @@ void Actor::init(bool unk) { } if (!_action) { - _isActionEnd = 1; + _isActionEnded = 1; } else { - _isActionEnd = 0; + _isActionEnded = 0; _action->start(unk); } } @@ -74,7 +74,7 @@ void Actor::hide() { } void Actor::endAction() { - _isActionEnd = 1; + _isActionEnded = 1; } void Actor::setAction(const Common::String &name) { @@ -84,11 +84,11 @@ void Actor::setAction(const Common::String &name) { void Actor::setAction(Action *newAction) { if (_action) { - _isActionEnd = 1; + _isActionEnded = 1; _action->end(); } if (newAction) { - _isActionEnd = 0; + _isActionEnded = 0; _action = newAction; _action->start(0); } @@ -97,7 +97,7 @@ void Actor::setAction(Action *newAction) { void Actor::setAction(Action *newAction, bool unk) { if (unk){ assert(0); // want to see this - _isActionEnd = 1; + _isActionEnded = 1; _action = newAction; } else setAction(newAction); @@ -108,7 +108,14 @@ Action *Actor::getAction() const { } bool Actor::isPlaying() { - return _isActionEnd; + return _isActionEnded; +} + +bool Actor::initPallete(Director *director) { + for (int i = 0; i < _actions.size(); ++i) { + if (_actions[i]->initPallete(director)) + break; + } } } // End of namespace Pink diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index 7bd65b3f48..dd75183251 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -31,12 +31,13 @@ namespace Pink { class GamePage; class Action; class Sequencer; +class Director; class Actor : public NamedObject { public: Actor() : _page(nullptr), _action(nullptr), - _isActionEnd(1) + _isActionEnded(1) {}; virtual void deserialize(Archive &archive); @@ -46,7 +47,6 @@ public: GamePage *getPage() const; Action *getAction() const; - bool isPlaying(); virtual void init(bool unk); void hide(); @@ -57,11 +57,13 @@ public: void setAction(Action *newAction); void setAction(Action *newAction, bool unk); + bool initPallete(Director *director); + protected: GamePage *_page; Action *_action; Common::Array<Action*> _actions; - bool _isActionEnd; + bool _isActionEnded; }; } // End of namespace Pink diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index b511f4010d..319c3f7deb 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -53,6 +53,8 @@ public: State getState() const; + void start(bool isHandler); + private: State _state; CursorMgr *_cursorMgr; diff --git a/engines/pink/objects/handlers/handler_timer.cpp b/engines/pink/objects/handlers/handler_timer.cpp index 4954f01ea4..44d58c2b32 100644 --- a/engines/pink/objects/handlers/handler_timer.cpp +++ b/engines/pink/objects/handlers/handler_timer.cpp @@ -72,7 +72,7 @@ void HandlerTimerActions::onMessage(LeadActor *actor) { } -void HandlerTimerSequences::handle(LeadActor *actor) { +void HandlerTimerSequences::handle(Sequence *sequence) { debug("HandlerTimerSequences function is not implemented"); } diff --git a/engines/pink/objects/handlers/handler_timer.h b/engines/pink/objects/handlers/handler_timer.h index d40dd6f6c7..1147431e4b 100644 --- a/engines/pink/objects/handlers/handler_timer.h +++ b/engines/pink/objects/handlers/handler_timer.h @@ -52,8 +52,8 @@ private: class HandlerTimerSequences : public HandlerSequences { //originally it was inherited from HandlerTimer public: virtual void toConsole(); -private: - virtual void handle(LeadActor *actor); // very big and hard function +protected: + virtual void handle(Sequence *sequence); // 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 16f918d060..465b1fc1b8 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -26,7 +26,7 @@ #include "engines/pink/cursor_mgr.h" #include "engines/pink/objects/actors/lead_actor.h" #include "engines/pink/objects/sequences/sequencer.h" - +#include "pink/pink.h" namespace Pink { @@ -59,7 +59,18 @@ void GamePage::init(bool isLoadingSave) { toConsole(); - Page::init(); + for (int j = 0; j < _actors.size(); ++j) { + if (_actors[j]->initPallete(_module->getGame()->getDirector())) + break; + } + + + LeadActor::State state = _leadActor->getState(); + bool unk = (state == LeadActor::kInventory || state == LeadActor::kPDA); + + for (int i = 0; i < _actors.size(); ++i) { + _actors[i]->init(unk); + } if (!isLoadingSave) initHandler(); diff --git a/engines/pink/objects/pages/page.cpp b/engines/pink/objects/pages/page.cpp index e7ea030867..dc2bb43c51 100644 --- a/engines/pink/objects/pages/page.cpp +++ b/engines/pink/objects/pages/page.cpp @@ -44,6 +44,12 @@ Sound *Page::loadSound(Common::String &fileName) { return _resMgr.loadSound(fileName); } + +Video::FlicDecoder *Page::loadCel(Common::String &fileName) { + return _resMgr.loadCEL(fileName); +} + + void Page::toConsole() { for (int i = 0; i < _actors.size(); ++i) { _actors[i]->toConsole(); diff --git a/engines/pink/objects/pages/page.h b/engines/pink/objects/pages/page.h index 208364c1c2..5244ed9ae9 100644 --- a/engines/pink/objects/pages/page.h +++ b/engines/pink/objects/pages/page.h @@ -23,6 +23,7 @@ #ifndef PINK_PAGE_H #define PINK_PAGE_H +#include <video/flic_decoder.h> #include "engines/pink/objects/object.h" #include "engines/pink/objects/module.h" #include "engines/pink/resource_mgr.h" @@ -39,6 +40,7 @@ public: void load(Archive &archive); Actor *findActor(Common::String &name); Sound* loadSound(Common::String &fileName); + Video::FlicDecoder *loadCel(Common::String &fileName); virtual void toConsole(); diff --git a/engines/pink/objects/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index 984da5e702..efc0c01ede 100644 --- a/engines/pink/objects/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -27,6 +27,7 @@ #include "engines/pink/archive.h" #include "engines/pink/objects/pages/game_page.h" #include "engines/pink/objects/actors/actor.h" +#include "sequence_context.h" namespace Pink { @@ -77,7 +78,7 @@ void Sequence::start(int unk) { return; } - if (!_items[_context->_nextItemIndex]->execute(_context->_unk, this, unk)){ + if (!_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ //destroy context; } @@ -85,26 +86,16 @@ void Sequence::start(int unk) { for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){ if (_items[i]->isLeader()) break; - _items[i]->execute(_context->_unk, this, unk); + _items[i]->execute(_context->_index, this, unk); } _context->_nextItemIndex = i; Common::Array<SequenceActorState> &states = _context->_states; for (uint j = 0; j < states.size(); ++j) { - if (states[j]._unk != _context->_unk && - !states[j]._actionName.empty()) { - Actor *actor; - Action *action; - actor = _sequencer->_page->findActor(states[j]._actorName); - assert(actor); - action = actor->findAction(states[j]._actionName); - assert(action); - if (actor->getAction() != action) - actor->setAction(action, unk); - } + states[j].check(_context->_index, this, unk); } - _context->_unk++; + _context->_index++; } void SequenceAudio::deserialize(Archive &archive) { @@ -120,41 +111,4 @@ void SequenceAudio::toConsole() { } } - - -SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer) - : _sequence(sequence), _sequencer(sequencer), - _nextItemIndex(0), _unk(1), _actor(nullptr) -{ - sequence->setContext(this); - Common::Array<SequenceItem*> &items = sequence->getItems(); - debug("SequenceContext for %s", _sequence->getName().c_str()); - - for (uint i = 0; i < items.size(); ++i) { - bool found = 0; - for (uint j = 0; j < _states.size(); ++j) { - if (items[i]->getActor() == _states[j].getActor()){ - found = 1; - break; - } - } - if (!found) { - debug(items[i]->getActor().c_str()); - _states.push_back({items[i]->getActor()}); - } - } -} - -SequenceContext::~SequenceContext() { - -} - -SequenceActorState::SequenceActorState(const Common::String &name) - :_actorName(name), _unk(0) -{} - -const Common::String &SequenceActorState::getActor() const { - return _actorName; -} - } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/sequences/sequence.h b/engines/pink/objects/sequences/sequence.h index a5522dae52..5fca545e66 100644 --- a/engines/pink/objects/sequences/sequence.h +++ b/engines/pink/objects/sequences/sequence.h @@ -46,6 +46,7 @@ public: void init(int unk); void start(int unk); + public: SequenceContext *_context; Sequencer *_sequencer; @@ -65,34 +66,6 @@ private: int _unk2; }; -class SequenceActorState { -public: - SequenceActorState(const Common::String &name); - - const Common::String &getActor() const; - -public: - Common::String _actorName; - Common::String _actionName; - int _unk; -}; - -class Actor; - -class SequenceContext { -public: - SequenceContext(Sequence *sequence, Sequencer* sequencer); - ~SequenceContext(); - -public: - Sequence *_sequence; - Sequencer *_sequencer; - int _nextItemIndex; - Actor *_actor; - Common::Array<SequenceActorState> _states; - int _unk; -}; - } // End of namespace Pink #endif diff --git a/engines/pink/objects/sequences/sequence_context.cpp b/engines/pink/objects/sequences/sequence_context.cpp new file mode 100644 index 0000000000..007213c537 --- /dev/null +++ b/engines/pink/objects/sequences/sequence_context.cpp @@ -0,0 +1,74 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include <common/debug.h> +#include "sequence_context.h" +#include "sequence.h" +#include "sequence_item.h" +#include "sequencer.h" +#include "engines/pink/objects/pages/game_page.h" +#include "engines/pink/objects/actors/actor.h" + +namespace Pink { + +SequenceActorState::SequenceActorState(const Common::String &name) + :_actorName(name), _index(0) +{} + +const Common::String &SequenceActorState::getActor() const { + return _actorName; +} + +void SequenceActorState::check(int index, Sequence *sequence, bool unk) { + Actor *actor = sequence->_sequencer->_page->findActor(_actorName); + debug("%s %s", _actorName.c_str(), _actionName.c_str()); + if (_index != index && !_actionName.empty()){ + Action *action = actor->findAction(_actionName); + if (actor->getAction() != action) + actor->setAction(action, unk); + } +} + +SequenceContext::SequenceContext(Sequence *sequence, Sequencer *sequencer) + : _sequence(sequence), _sequencer(sequencer), + _nextItemIndex(0), _index(1), _actor(nullptr) +{ + sequence->setContext(this); + Common::Array<SequenceItem*> &items = sequence->getItems(); + debug("SequenceContext for %s", _sequence->getName().c_str()); + + for (uint i = 0; i < items.size(); ++i) { + bool found = 0; + for (uint j = 0; j < _states.size(); ++j) { + if (items[i]->getActor() == _states[j].getActor()){ + found = 1; + break; + } + } + if (!found) { + debug(items[i]->getActor().c_str()); + _states.push_back({items[i]->getActor()}); + } + } +} + +} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/sequences/sequence_context.h b/engines/pink/objects/sequences/sequence_context.h new file mode 100644 index 0000000000..0727127097 --- /dev/null +++ b/engines/pink/objects/sequences/sequence_context.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef PINK_SEQUENCE_CONTEXT_H +#define PINK_SEQUENCE_CONTEXT_H + +#include <common/array.h> + +namespace Pink { + +class Sequence; +class Sequencer; + +class SequenceActorState { +public: + SequenceActorState(const Common::String &name); + + const Common::String &getActor() const; + void check(int index, Sequence *sequence, bool unk); + +public: + Common::String _actorName; + Common::String _actionName; + int _index; +}; + +class Actor; + +class SequenceContext { +public: + SequenceContext(Sequence *sequence, Sequencer* sequencer); + + +public: + Sequence *_sequence; + Sequencer *_sequencer; + int _nextItemIndex; + Actor *_actor; + Common::Array<SequenceActorState> _states; + int _index; +}; + +} + +#endif diff --git a/engines/pink/objects/sequences/sequence_item.cpp b/engines/pink/objects/sequences/sequence_item.cpp index 732424a075..3644261c0a 100644 --- a/engines/pink/objects/sequences/sequence_item.cpp +++ b/engines/pink/objects/sequences/sequence_item.cpp @@ -28,6 +28,7 @@ #include "engines/pink/archive.h" #include "engines/pink/objects/pages/game_page.h" #include "engines/pink/objects/actors/actor.h" +#include "sequence_context.h" namespace Pink { @@ -47,7 +48,7 @@ const Common::String &SequenceItem::getAction() const { return _action; } -bool SequenceItem::execute(int unk, Sequence *sequence, bool unk2) { +bool SequenceItem::execute(int index, Sequence *sequence, bool unk2) { Actor *actor; Action *action; if (!(actor = sequence->_sequencer->_page->findActor(_actor)) || @@ -60,7 +61,7 @@ bool SequenceItem::execute(int unk, Sequence *sequence, bool unk2) { Common::Array<SequenceActorState> &states = sequence->_context->_states; for (int i = 0; i < sequence->_context->_states.size(); ++i) { if (states[i]._actorName == _actor){ - states[i]._unk = unk; + states[i]._index = index; sequence->_context->_actor = isLeader() ? actor : sequence->_context->_actor; break; } @@ -91,7 +92,7 @@ void SequenceItemLeaderAudio::toConsole() { debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); } -bool SequenceItemDefaultAction::execute(int unk, Sequence *sequence, bool unk2) { +bool SequenceItemDefaultAction::execute(int index, Sequence *sequence, bool unk2) { Common::Array<SequenceActorState> &actorStates = sequence->_context->_states; for (int i = 0; i < actorStates.size(); ++i) { if (actorStates[i]._actorName == _actor){ diff --git a/engines/pink/objects/sequences/sequence_item.h b/engines/pink/objects/sequences/sequence_item.h index 1507aa8890..197280fb7f 100644 --- a/engines/pink/objects/sequences/sequence_item.h +++ b/engines/pink/objects/sequences/sequence_item.h @@ -38,7 +38,7 @@ public: const Common::String &getActor() const; const Common::String &getAction() const; - virtual bool execute(int unk, Sequence *sequence, bool unk2); + virtual bool execute(int index, Sequence *sequence, bool unk2); virtual bool isLeader(); protected: @@ -64,7 +64,7 @@ private: class SequenceItemDefaultAction : public SequenceItem { public: - virtual bool execute(int unk, Sequence *sequence, bool unk2); + virtual bool execute(int index, Sequence *sequence, bool unk2); virtual void toConsole(); }; diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 1f667cf3cc..0667f2bfd2 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -24,6 +24,7 @@ #include <common/debug.h> #include "sequencer.h" #include "sequence.h" +#include "sequence_context.h" #include "engines/pink/archive.h" namespace Pink { diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp index ec0ad26be8..afcae8c593 100644 --- a/engines/pink/pink.cpp +++ b/engines/pink/pink.cpp @@ -32,7 +32,7 @@ namespace Pink { Pink::PinkEngine::PinkEngine(OSystem *system, const ADGameDescription *desc) : Engine(system), _console(nullptr), _rnd("pink"), - _desc(*desc), _bro(nullptr), _module(nullptr) + _desc(*desc), _bro(nullptr), _module(nullptr), _director(_system) { debug("PinkEngine constructed"); @@ -87,13 +87,8 @@ Common::Error Pink::PinkEngine::run() { return error; } - Video::FlicDecoder flicDecoder; - Common::File anim; - anim.open("WANDRBOY.CEL"); - flicDecoder.loadStream(&anim); - flicDecoder.start(); - _system->updateScreen(); - const Graphics::Surface *surface = flicDecoder.decodeNextFrame(); + + int i = 0; while(!shouldQuit()){ Common::Event event; while(_eventMan->pollEvent(event)){ @@ -118,12 +113,8 @@ Common::Error Pink::PinkEngine::run() { break; } } - //update(); - surface = flicDecoder.needsUpdate() ? flicDecoder.decodeNextFrame() : surface; - if (surface) { - _system->copyRectToScreen(surface->getPixels(), surface->pitch, 0, 0, surface->w, surface->h); - _system->updateScreen(); - } + + _director.draw(); _system->delayMillis(10); } diff --git a/engines/pink/pink.h b/engines/pink/pink.h index e5dc3d5dd4..f592a89e7e 100644 --- a/engines/pink/pink.h +++ b/engines/pink/pink.h @@ -28,6 +28,7 @@ #include "gui/EventRecorder.h" #include "gui/debugger.h" #include "file.h" +#include "director.h" /* @@ -76,6 +77,7 @@ public: OrbFile *getOrb() { return &_orb; } BroFile *getBro() { return _bro; } Common::RandomSource &getRnd(); + Director *getDirector() { return &_director;} bool checkValueOfVariable(Common::String &variable, Common::String &value); void setVariable(Common::String &variable, Common::String &value); @@ -93,6 +95,8 @@ private: OrbFile _orb; BroFile *_bro; + Director _director; + Module *_module; Common::Array<NamedObject*> _modules; diff --git a/engines/pink/resource_mgr.cpp b/engines/pink/resource_mgr.cpp index 208b206c50..b367a52e36 100644 --- a/engines/pink/resource_mgr.cpp +++ b/engines/pink/resource_mgr.cpp @@ -53,7 +53,7 @@ Sound *ResourceMgr::loadSound(Common::String &name) { return new Sound(_game->_mixer, getResourceStream(name)); } -Common::SeekableReadStream *ResourceMgr::getResourceStream(Common::String &name) { +Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(Common::String &name) { Common::SeekableReadStream *stream; uint i; for (i = 0; i < _resCount; ++i) { @@ -69,7 +69,7 @@ Common::SeekableReadStream *ResourceMgr::getResourceStream(Common::String &name) stream->seek(_resDescTable[i].offset); - return new Common::SeekableSubReadStream(stream, _resDescTable[i].offset, + return new Common::SafeSeekableSubReadStream(stream, _resDescTable[i].offset, _resDescTable[i].offset + _resDescTable[i].size); } @@ -77,4 +77,10 @@ PinkEngine *ResourceMgr::getGame() const { return _game; } +Video::FlicDecoder *ResourceMgr::loadCEL(Common::String &name) { + Video::FlicDecoder *decoder = new Video::FlicDecoder(); + decoder->loadStream(getResourceStream(name)); + return decoder; +} + } // End of namespace Pink diff --git a/engines/pink/resource_mgr.h b/engines/pink/resource_mgr.h index 1188c1226a..8d04ec7df7 100644 --- a/engines/pink/resource_mgr.h +++ b/engines/pink/resource_mgr.h @@ -21,7 +21,7 @@ */ #include <common/scummsys.h> -#include <common/stream.h> +#include <common/substream.h> #ifndef PINK_RESOURCE_MGR_H #define PINK_RESOURCE_MGR_H @@ -46,15 +46,14 @@ public: ~ResourceMgr(); void init(PinkEngine *game, GamePage *page); - //move methods to page - //compiler must do RVO + //Common::String loadText(Common::String &name); Sound *loadSound(Common::String &name); - // loadCEL(); + Video::FlicDecoder *loadCEL(Common::String &name); PinkEngine *getGame() const; private: - Common::SeekableReadStream *getResourceStream(Common::String &name); + Common::SafeSeekableSubReadStream *getResourceStream(Common::String &name); PinkEngine *_game; ResourceDescription *_resDescTable; |