diff options
Diffstat (limited to 'engines/pink/objects/sequences/sequence.cpp')
-rw-r--r-- | engines/pink/objects/sequences/sequence.cpp | 174 |
1 files changed, 87 insertions, 87 deletions
diff --git a/engines/pink/objects/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index 1e08bb5c02..5eeae68657 100644 --- a/engines/pink/objects/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -34,158 +34,158 @@ namespace Pink { Sequence::Sequence() - : _unk(0), _context(nullptr), - _sequencer(nullptr) {} + : _unk(0), _context(nullptr), + _sequencer(nullptr) {} Sequence::~Sequence() { - for (uint i = 0; i < _items.size(); ++i) { - delete _items[i]; - } + for (uint i = 0; i < _items.size(); ++i) { + delete _items[i]; + } } void Sequence::deserialize(Archive &archive) { - NamedObject::deserialize(archive); - _sequencer = static_cast<Sequencer*>(archive.readObject()); - _items.deserialize(archive); + NamedObject::deserialize(archive); + _sequencer = static_cast<Sequencer*>(archive.readObject()); + _items.deserialize(archive); } void Sequence::toConsole() { - debug("\t\tSequence %s", _name.c_str()); - debug("\t\t\tItems:"); - for (uint i = 0; i < _items.size(); ++i) { - _items[i]->toConsole(); - } + debug("\t\tSequence %s", _name.c_str()); + debug("\t\t\tItems:"); + for (uint i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } } Common::Array<SequenceItem*> &Sequence::getItems() { - return _items; + return _items; } void Sequence::setContext(SequenceContext *context) { - _context = context; + _context = context; } void Sequence::init(int unk) { - assert(_items.size()); - assert(dynamic_cast<SequenceItemLeader*>(_items[0])); // first item must always be a leader - start(unk); + assert(_items.size()); + assert(dynamic_cast<SequenceItemLeader*>(_items[0])); // first item must always be a leader + start(unk); } void Sequence::start(int unk) { - if (_context->_nextItemIndex >= _items.size() || !_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ - debug("Sequence %s ended", _name.c_str()); - end(); - return; - } + if (_context->_nextItemIndex >= _items.size() || !_items[_context->_nextItemIndex]->execute(_context->_index, this, unk)){ + debug("Sequence %s ended", _name.c_str()); + end(); + return; + } - uint i; - for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){ - if (_items[i]->isLeader()) - break; - _items[i]->execute(_context->_index, this, unk); - } - _context->_nextItemIndex = i; + uint i; + for (i = _context->_nextItemIndex + 1; i <_items.size(); ++i){ + if (_items[i]->isLeader()) + break; + _items[i]->execute(_context->_index, this, unk); + } + _context->_nextItemIndex = i; - Common::Array<SequenceActorState> &states = _context->_states; - for (uint j = 0; j < states.size(); ++j) { - states[j].check(_context->_index, this, unk); - } - _context->_index++; + Common::Array<SequenceActorState> &states = _context->_states; + for (uint j = 0; j < states.size(); ++j) { + states[j].check(_context->_index, this, unk); + } + _context->_index++; } void Sequence::update() { - if (!_context->_actor->isPlaying()){ - debug("Sequence step ended"); - start(0); - } + if (!_context->_actor->isPlaying()){ + debug("Sequence step ended"); + start(0); + } } void Sequence::end() { - _context->_actor = 0; - _unk = 1; - _sequencer->removeContext(_context); + _context->_actor = 0; + _unk = 1; + _sequencer->removeContext(_context); } void Sequence::restart() { - _context->setNextItemIndex(0); - _context->clearActionsFromActorStates(); - start(0); + _context->setNextItemIndex(0); + _context->clearActionsFromActorStates(); + start(0); } void Sequence::skipToLastSubSequence() { - if (_unk && _context->getNextItemIndex() < _items.size()){ - int i = _items.size() - 1; - while(i >= 0 && !_items[--i]->isLeader()); - assert(i >= 0); - _context->setNextItemIndex(i); - _context->clearActionsFromActorStates(); - skipItemsTo(i); - start(0); - } + if (_unk && _context->getNextItemIndex() < _items.size()){ + int i = _items.size() - 1; + while(i >= 0 && !_items[--i]->isLeader()); + assert(i >= 0); + _context->setNextItemIndex(i); + _context->clearActionsFromActorStates(); + skipItemsTo(i); + start(0); + } } void Sequence::skipItemsTo(int index) { - for(int i = 0; i < index; ++i){ - _items[i]->skip(this); - } + for(int i = 0; i < index; ++i){ + _items[i]->skip(this); + } } void Sequence::skipSubSequence() { - if (_context->getNextItemIndex() < _context->getSequence()->getItems().size()) - _context->getSequence()->start(0); + if (_context->getNextItemIndex() < _context->getSequence()->getItems().size()) + _context->getSequence()->start(0); } void SequenceAudio::deserialize(Archive &archive) { - Sequence::deserialize(archive); - _soundName = archive.readString(); + Sequence::deserialize(archive); + _soundName = archive.readString(); } void SequenceAudio::toConsole() { - debug("\t\tSequenceAudio %s : _sound = %s", _name.c_str(), _soundName.c_str()); - debug("\t\t\tItems:"); - for (uint i = 0; i < _items.size(); ++i) { - _items[i]->toConsole(); - } + debug("\t\tSequenceAudio %s : _sound = %s", _name.c_str(), _soundName.c_str()); + debug("\t\t\tItems:"); + for (uint i = 0; i < _items.size(); ++i) { + _items[i]->toConsole(); + } } void SequenceAudio::start(int unk) { - Sequence::start(unk); - uint index = _context->getNextItemIndex(); - if (index < _items.size()) { - SequenceItemLeaderAudio* leaderAudio = (SequenceItemLeaderAudio*) _items[index]; - _sample = leaderAudio->getSample(); - } + Sequence::start(unk); + uint index = _context->getNextItemIndex(); + if (index < _items.size()) { + SequenceItemLeaderAudio* leaderAudio = (SequenceItemLeaderAudio*) _items[index]; + _sample = leaderAudio->getSample(); + } } void SequenceAudio::end() { - delete _sound; - _sound = nullptr; - Sequence::end(); + delete _sound; + _sound = nullptr; + Sequence::end(); } void SequenceAudio::update() { - if (!_sound->isPlaying()) - end(); - else if (_sample <= _sound->getCurrentSample()){ - start(0); - } + if (!_sound->isPlaying()) + end(); + else if (_sample <= _sound->getCurrentSample()){ + start(0); + } } void SequenceAudio::init(int unk) { - _sample = 0; - _sound = _sequencer->_page->loadSound(_soundName); - _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); - Sequence::init(unk); + _sample = 0; + _sound = _sequencer->_page->loadSound(_soundName); + _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); + Sequence::init(unk); } void SequenceAudio::restart() { - _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); - Sequence::restart(); + _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); + Sequence::restart(); } void SequenceAudio::skipToLastSubSequence() { - end(); + end(); } } // End of namespace Pink |