diff options
Diffstat (limited to 'engines/pink/objects')
-rw-r--r-- | engines/pink/objects/actions/action_cel.cpp | 9 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_cel.h | 1 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_sound.cpp | 9 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_still.cpp | 4 | ||||
-rw-r--r-- | engines/pink/objects/actions/walk_action.cpp | 3 | ||||
-rw-r--r-- | engines/pink/objects/actors/actor.cpp | 5 | ||||
-rw-r--r-- | engines/pink/objects/actors/actor.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/actors/lead_actor.cpp | 14 | ||||
-rw-r--r-- | engines/pink/objects/actors/lead_actor.h | 1 | ||||
-rw-r--r-- | engines/pink/objects/module.cpp | 59 | ||||
-rw-r--r-- | engines/pink/objects/module.h | 6 | ||||
-rw-r--r-- | engines/pink/objects/pages/game_page.cpp | 18 | ||||
-rw-r--r-- | engines/pink/objects/pages/game_page.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequence.cpp | 23 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequence.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequencer.cpp | 10 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequencer.h | 7 |
17 files changed, 114 insertions, 61 deletions
diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp index abfc59373e..dc18ee3a39 100644 --- a/engines/pink/objects/actions/action_cel.cpp +++ b/engines/pink/objects/actions/action_cel.cpp @@ -64,8 +64,17 @@ CelDecoder *ActionCEL::getDecoder() { bool ActionCEL::initPallete(Director *director) { _decoder = _actor->getPage()->loadCel(_fileName); _decoder->decodeNextFrame(); + _decoder->rewind(); director->setPallette(_decoder->getPalette()); + return 1; } +void ActionCEL::update() { + if (_decoder->endOfVideo()){ + _decoder->stop(); + _actor->endAction(); + } +} + } // 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 4dc37724df..7c0f7505d4 100644 --- a/engines/pink/objects/actions/action_cel.h +++ b/engines/pink/objects/actions/action_cel.h @@ -36,6 +36,7 @@ public: virtual void deserialize(Archive &archive); virtual void start(bool unk); virtual void end(); + virtual void update(); uint32 getZ(); CelDecoder *getDecoder(); diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp index 38f8687d33..42d279553b 100644 --- a/engines/pink/objects/actions/action_sound.cpp +++ b/engines/pink/objects/actions/action_sound.cpp @@ -26,6 +26,7 @@ #include <engines/pink/objects/actors/actor.h> #include <engines/pink/objects/pages/game_page.h> #include <engines/pink/sound.h> +#include "engines/pink/pink.h" namespace Pink { @@ -53,6 +54,10 @@ void ActionSound::start(bool unk) { Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::SoundType::kMusicSoundType : Audio::Mixer::SoundType::kSpeechSoundType; + + Director *director = _actor->getPage()->getGame()->getDirector(); + director->addSound(this); + _sound->play(soundType, _volume, _isLoop); if (_isLoop) _actor->endAction(); @@ -62,6 +67,10 @@ void ActionSound::start(bool unk) { void ActionSound::end() { debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); + + Director *director = _actor->getPage()->getGame()->getDirector(); + director->removeSound(this); + _sound->stop(); delete _sound; _sound = nullptr; diff --git a/engines/pink/objects/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp index 563af93c28..c49e52ae1d 100644 --- a/engines/pink/objects/actions/action_still.cpp +++ b/engines/pink/objects/actions/action_still.cpp @@ -34,8 +34,8 @@ void ActionStill::deserialize(Archive &archive) { } void ActionStill::toConsole() { - debug("\tActionStill: _name = %s, _fileName = %s, _startFrame = %u", - _name.c_str(), _fileName.c_str(), _startFrame); + debug("\tActionStill: _name = %s, _fileName = %s, _z =%u _startFrame = %u", + _name.c_str(), _fileName.c_str(), _z, _startFrame); } void ActionStill::end() { diff --git a/engines/pink/objects/actions/walk_action.cpp b/engines/pink/objects/actions/walk_action.cpp index 39be8f4443..7b7c3e39e3 100644 --- a/engines/pink/objects/actions/walk_action.cpp +++ b/engines/pink/objects/actions/walk_action.cpp @@ -22,14 +22,13 @@ #include "walk_action.h" #include <engines/pink/archive.h> -#include <common/debug.h> namespace Pink { void WalkAction::deserialize(Archive &archive) { ActionCEL::deserialize(archive); uint32 calcFramePositions = archive.readDWORD(); - _toCalcFramePositions = calcFramePositions ? true : false; + _toCalcFramePositions = calcFramePositions; } void WalkAction::toConsole() { diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp index e612c83ae6..ba270ff7a5 100644 --- a/engines/pink/objects/actors/actor.cpp +++ b/engines/pink/objects/actors/actor.cpp @@ -108,14 +108,15 @@ Action *Actor::getAction() const { } bool Actor::isPlaying() { - return _isActionEnded; + return !_isActionEnded; } bool Actor::initPallete(Director *director) { for (int i = 0; i < _actions.size(); ++i) { if (_actions[i]->initPallete(director)) - break; + return true; } + return false; } } // End of namespace Pink diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h index dd75183251..2dc9769275 100644 --- a/engines/pink/objects/actors/actor.h +++ b/engines/pink/objects/actors/actor.h @@ -59,6 +59,8 @@ public: bool initPallete(Director *director); + void update() {}; + protected: GamePage *_page; Action *_action; diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index 88c579c5c2..43e144be1f 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -50,6 +50,7 @@ void LeadActor::init(bool unk) { _state = kReady; } _page->getModule()->getInventoryMgr()->setLeadActor(this); + _page->getGame()->setLeadActor(this); Actor::init(unk); } @@ -64,6 +65,19 @@ LeadActor::State LeadActor::getState() const { return _state; } +void LeadActor::update() { + switch (_state) { + case kPlayingVideo: + _sequencer->update(); + if (!_sequencer->_context){ + _state = kUnk_Loading; + _page->getGame()->changeScene(_page); + } + default: + break; + } +} + void ParlSqPink::toConsole() { debug("ParlSqPink: _name = %s", _name.c_str()); for (int i = 0; i < _actions.size(); ++i) { diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index 319c3f7deb..d7c45e02bd 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -54,6 +54,7 @@ public: State getState() const; void start(bool isHandler); + void update(); private: State _state; diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp index 97f78d4637..d1e16f37ee 100644 --- a/engines/pink/objects/module.cpp +++ b/engines/pink/objects/module.cpp @@ -22,6 +22,7 @@ #include "module.h" #include "engines/pink/objects/pages/game_page.h" +#include "pink/pink.h" namespace Pink { @@ -45,52 +46,36 @@ void Module::load(Archive &archive){ archive >> _pages; } -void Module::init(bool isLoadingSave, const Common::String *pageName) { - // debugging original +void Module::init(bool isLoadingSave, const Common::String &pageName) { // 0 0 - new game // 0 1 - module changed // 1 0 - from save - - // 1 1 - haven't seen those values - - //this func will be rewrited after testing - - if (_page) { - debug("loading from save"); - } - if (pageName){ - debug("module changed"); - } - assert(_pages.size() != 0); - - if (pageName) { - uint i; - for (i = 0; i < _pages.size(); ++i) { - if(*pageName == _pages[i]->getName()) { - _page = _pages[i]; - } - } - assert(i < _pages.size()); - } - - if (_page) { - _page->init(isLoadingSave); // module changed or from save - return; + if (!pageName.empty()) { + _page = findPage(pageName); } - if (_page != _pages[0]) { - if (_page) { - assert(0); // in original code there is call to page func but I've never seen it - return; - } + if (!_page) _page = _pages[0]; - _page->init(isLoadingSave); // new game - return; - } - assert(0); + _page->init(isLoadingSave); +} + +void Module::changePage(const Common::String &pageName) { + GamePage *page = nullptr; + page = findPage(pageName); + assert(_page != page); + //_page->clear + page->init(kLoadingNewGame); } +GamePage *Module::findPage(const Common::String &pageName) const { + return *Common::find_if(_pages.begin(), _pages.end(), [&pageName] + (GamePage* page) { + return pageName == page->getName(); + }); +} + + PinkEngine *Module::getGame() const { return _game; } diff --git a/engines/pink/objects/module.h b/engines/pink/objects/module.h index 214ff2a473..959f886a83 100644 --- a/engines/pink/objects/module.h +++ b/engines/pink/objects/module.h @@ -45,13 +45,13 @@ public: Module(PinkEngine *game, const Common::String &name); void load(Archive &archive); - void init(bool isLoadingSave, const Common::String *pageName); + void init(bool isLoadingSave, const Common::String &pageName); + void changePage(const Common::String &pageName); void OnLeftButtonDown(); void OnMouseMove(); void OnKeyboardButtonClick(); - PinkEngine *getGame() const; InventoryMgr *getInventoryMgr(); @@ -59,6 +59,8 @@ public: void setVariable(Common::String &variable, Common::String &value); private: + GamePage *findPage(const Common::String &pageName) const; + PinkEngine *_game; GamePage *_page; Common::Array<GamePage*> _pages; diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp index 465b1fc1b8..5acc1f1858 100644 --- a/engines/pink/objects/pages/game_page.cpp +++ b/engines/pink/objects/pages/game_page.cpp @@ -64,27 +64,29 @@ void GamePage::init(bool isLoadingSave) { break; } - LeadActor::State state = _leadActor->getState(); - bool unk = (state == LeadActor::kInventory || state == LeadActor::kPDA); + bool startNow = !(state == LeadActor::kInventory || state == LeadActor::kPDA); for (int i = 0; i < _actors.size(); ++i) { - _actors[i]->init(unk); + _actors[i]->init(startNow); } - if (!isLoadingSave) - initHandler(); - + bool isHandler = 0; + if (!isLoadingSave) { + isHandler = initHandler(); + } + //_leadActor->start(isHandler); } -void GamePage::initHandler() { +bool GamePage::initHandler() { for (uint i = 0; i < _handlers.size(); ++i) { if (_handlers[i]->isSuitable(_leadActor)){ _handlers[i]->onMessage(_leadActor); - break; + return true; } } + return false; } void GamePage::loadManagers() { diff --git a/engines/pink/objects/pages/game_page.h b/engines/pink/objects/pages/game_page.h index 74d19766b7..94bff54200 100644 --- a/engines/pink/objects/pages/game_page.h +++ b/engines/pink/objects/pages/game_page.h @@ -53,7 +53,7 @@ public: virtual void toConsole(); private: - void initHandler(); + bool initHandler(); int perhapsIsLoaded; diff --git a/engines/pink/objects/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index efc0c01ede..80f5c58e5b 100644 --- a/engines/pink/objects/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -69,17 +69,15 @@ void Sequence::init(int unk) { start(unk); } -class Action; - void Sequence::start(int unk) { - if (_context->_nextItemIndex > _items.size()){ - debug("Sequence %s ended", _name); - //TODO destroy context + if (_context->_nextItemIndex >= _items.size()){ + debug("Sequence %s ended", _name.c_str()); + end(); return; } if (!_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ - //destroy context; + assert(0); } uint i; @@ -98,6 +96,19 @@ void Sequence::start(int unk) { _context->_index++; } +void Sequence::update() { + if (!_context->_actor->isPlaying()){ + debug("Sequence step ended"); + start(0); + } +} + +void Sequence::end() { + _context->_actor = 0; + _unk = 1; + _sequencer->removeContext(_context); +} + void SequenceAudio::deserialize(Archive &archive) { Sequence::deserialize(archive); archive >> _sound; diff --git a/engines/pink/objects/sequences/sequence.h b/engines/pink/objects/sequences/sequence.h index 5fca545e66..3975acf915 100644 --- a/engines/pink/objects/sequences/sequence.h +++ b/engines/pink/objects/sequences/sequence.h @@ -45,7 +45,9 @@ public: void setContext(SequenceContext *context); void init(int unk); void start(int unk); + void end(); + void update(); public: SequenceContext *_context; diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 0667f2bfd2..fea28e5f52 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -25,6 +25,7 @@ #include "sequencer.h" #include "sequence.h" #include "sequence_context.h" +#include "pink/objects/actors/actor.h" #include "engines/pink/archive.h" namespace Pink { @@ -71,4 +72,13 @@ void Sequencer::toConsole() { } } +void Sequencer::update() { + _context->_sequence->update(); +} + +void Sequencer::removeContext(SequenceContext *context) { + delete _context; + _context = 0; +} + } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/sequences/sequencer.h b/engines/pink/objects/sequences/sequencer.h index 36e9ba0c74..55e8529988 100644 --- a/engines/pink/objects/sequences/sequencer.h +++ b/engines/pink/objects/sequences/sequencer.h @@ -45,9 +45,14 @@ public: Sequence* findSequence(const Common::String &name); void authorSequence(Sequence *sequence, bool unk); + void removeContext(SequenceContext *context); + + void update(); + + public: SequenceContext *_context; - // unknown objects array + // context array Common::Array<Sequence*> _sequences; Common::String _currentSequenceName; Common::Array<SeqTimer*> _timers; |