diff options
Diffstat (limited to 'engines/pink')
-rw-r--r-- | engines/pink/file.cpp | 1 | ||||
-rw-r--r-- | engines/pink/file.h | 1 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_cel.cpp | 2 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_play_with_sfx.cpp | 57 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_play_with_sfx.h | 19 | ||||
-rw-r--r-- | engines/pink/objects/actions/action_text.cpp | 4 | ||||
-rw-r--r-- | engines/pink/objects/actions/walk_action.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/actors/cursor_actor.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/side_effect.cpp | 9 | ||||
-rw-r--r-- | engines/pink/objects/side_effect.h | 2 |
10 files changed, 73 insertions, 26 deletions
diff --git a/engines/pink/file.cpp b/engines/pink/file.cpp index 2c27dab2d4..b308c5ba6c 100644 --- a/engines/pink/file.cpp +++ b/engines/pink/file.cpp @@ -101,7 +101,6 @@ void OrbFile::seekToObject(const char *name) { seek(desc->objectsOffset); } - ObjectDescription *OrbFile::getObjDesc(const char *name){ ObjectDescription *desc = static_cast<ObjectDescription*>(bsearch(name, _table, _tableSize, sizeof(ObjectDescription), [] (const void *a, const void *b) { diff --git a/engines/pink/file.h b/engines/pink/file.h index ddaba37292..c87fd79ece 100644 --- a/engines/pink/file.h +++ b/engines/pink/file.h @@ -48,7 +48,6 @@ struct ResourceDescription { }; class PinkEngine; - class Object; class OrbFile : public Common::File { diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp index c8d9eb7864..7436c859fe 100644 --- a/engines/pink/objects/actions/action_cel.cpp +++ b/engines/pink/objects/actions/action_cel.cpp @@ -43,8 +43,6 @@ void ActionCEL::deserialize(Archive &archive) { void ActionCEL::start(bool unk) { if (!_decoder) _decoder = _actor->getPage()->loadCel(_fileName); - //if (_fileName =="IT01PP01.CEL") - // initPallete(_actor->getPage()->getGame()->getDirector()); _actor->getPage()->getGame()->getDirector()->addSprite(this); this->onStart(); } diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp index 60ecd2ac9d..a28a06768c 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.cpp +++ b/engines/pink/objects/actions/action_play_with_sfx.cpp @@ -21,7 +21,10 @@ */ #include "action_play_with_sfx.h" -#include <pink/archive.h> +#include <pink/objects/pages/game_page.h> +#include <pink/sound.h> +#include <pink/objects/actors/actor.h> +#include <pink/cel_decoder.h> namespace Pink { @@ -38,14 +41,58 @@ void Pink::ActionPlayWithSfx::toConsole() { } } -void Pink::ActionSfx::deserialize(Pink::Archive &archive) { - archive >> _frame >> _volume >> _sfx; - _action = (ActionPlayWithSfx*) archive.readObject(); +void ActionPlayWithSfx::update() { + if (_decoder->endOfVideo() && _isLoop) { + _decoder->rewind(); + } else if (_decoder->endOfVideo()) { + _decoder->stop(); + _actor->endAction(); + } + updateSound(); +} +void ActionPlayWithSfx::onStart() { + ActionPlay::onStart(); + if (_isLoop) { + _actor->endAction(); + } + updateSound(); +} + +void ActionPlayWithSfx::updateSound() { + for (int i = 0; i < _sfxArray.size(); ++i) { + if (_sfxArray[i]->getFrame() == _decoder->getCurFrame()) { + _sfxArray[i]->play(_actor->getPage()); + } + } +} + +ActionPlayWithSfx::~ActionPlayWithSfx() { + for (int i = 0; i < _sfxArray.size(); ++i) { + delete _sfxArray[i]; + } +} + +void Pink::ActionSfx::deserialize(Pink::Archive &archive) { + archive >> _frame >> _volume >> _sfxName; + archive.readObject(); } void Pink::ActionSfx::toConsole() { - debug("\t\tActionSfx: _sfx = %s, _volume = %u, _frame = %u", _sfx.c_str(), _volume, _frame); + debug("\t\tActionSfx: _sfx = %s, _volume = %u, _frame = %u", _sfxName.c_str(), _volume, _frame); +} + +void ActionSfx::play(GamePage *page) { + _sound = page->loadSound(_sfxName); + _sound->play(Audio::Mixer::SoundType::kSFXSoundType, _volume, 0); +} + +ActionSfx::~ActionSfx() { + delete _sound; +} + +uint32 ActionSfx::getFrame() { + return _frame; } } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h index b558ee1c13..7782e913e2 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.h +++ b/engines/pink/objects/actions/action_play_with_sfx.h @@ -31,26 +31,39 @@ namespace Pink { class ActionSfx; class ActionPlayWithSfx : public ActionPlay { + virtual ~ActionPlayWithSfx(); virtual void deserialize(Archive &archive); virtual void toConsole(); + virtual void update(); + +protected: + virtual void onStart(); private: + void updateSound(); uint32 _isLoop; Common::Array<ActionSfx*> _sfxArray; }; +class Sound; +class GamePage; + class ActionSfx : public Object { public: + virtual ~ActionSfx(); virtual void deserialize(Archive &archive); virtual void toConsole(); + void play(GamePage *page); + uint32 getFrame(); + private: - ActionPlayWithSfx *_action; - Common::String _sfx; + Sound *_sound; + Common::String _sfxName; uint32 _volume; uint32 _frame; }; -} +} // End of namespace Pink #endif diff --git a/engines/pink/objects/actions/action_text.cpp b/engines/pink/objects/actions/action_text.cpp index ef21ef37ef..eaf161117e 100644 --- a/engines/pink/objects/actions/action_text.cpp +++ b/engines/pink/objects/actions/action_text.cpp @@ -40,6 +40,4 @@ void ActionText::toConsole() { _name.c_str(), _text.c_str(), _bounds[0], _bounds[1], _bounds[2], _bounds[3], _centered, _scrollBar, _textColor, _backgroundColor); } - - -}
\ No newline at end of file +} // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/objects/actions/walk_action.h b/engines/pink/objects/actions/walk_action.h index 923811fe47..6dbc6a9059 100644 --- a/engines/pink/objects/actions/walk_action.h +++ b/engines/pink/objects/actions/walk_action.h @@ -37,6 +37,6 @@ private: bool _toCalcFramePositions; }; -} +} // End of namespace Pink #endif diff --git a/engines/pink/objects/actors/cursor_actor.h b/engines/pink/objects/actors/cursor_actor.h index 07616a2586..32e433ff27 100644 --- a/engines/pink/objects/actors/cursor_actor.h +++ b/engines/pink/objects/actors/cursor_actor.h @@ -40,6 +40,6 @@ public: } }; -} +} // End of namespace Pink #endif diff --git a/engines/pink/objects/side_effect.cpp b/engines/pink/objects/side_effect.cpp index 516a509138..124ba8a1a0 100644 --- a/engines/pink/objects/side_effect.cpp +++ b/engines/pink/objects/side_effect.cpp @@ -44,7 +44,6 @@ void SideEffectExit::toConsole() { debug("\t\tSideEffectExit: _nextModule=%s, _nextPage=%s", _nextModule.c_str(), _nextPage.c_str()); } - void SideEffectLocation::deserialize(Archive &archive) { archive >> _location; } @@ -59,7 +58,6 @@ void SideEffectLocation::toConsole() { debug("\t\tSideEffectLocation: _location=%s", _location.c_str()); } - void SideEffectInventoryItemOwner::deserialize(Archive &archive) { archive >> _item >> _owner; } @@ -72,12 +70,10 @@ void SideEffectInventoryItemOwner::toConsole() { debug("\t\tSideEffectInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str()); } - void SideEffectVariable::deserialize(Pink::Archive &archive) { archive >> _name >> _value; } - void SideEffectGameVariable::execute(LeadActor *actor) { actor->getPage()->getGame()->setVariable(_name, _value); } @@ -86,7 +82,6 @@ void SideEffectGameVariable::toConsole() { debug("\t\tSideEffectGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } - void SideEffectModuleVariable::execute(LeadActor *actor) { actor->getPage()->getModule()->setVariable(_name, _value); } @@ -95,7 +90,6 @@ void SideEffectModuleVariable::toConsole() { debug("\t\tSideEffectModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } - void SideEffectPageVariable::execute(LeadActor *actor) { actor->getPage()->setVariable(_name, _value); } @@ -104,13 +98,12 @@ void SideEffectPageVariable::toConsole() { debug("\t\tSideEffectPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str()); } - void SideEffectRandomPageVariable::deserialize(Archive &archive) { archive >> _name >> _values; } void SideEffectRandomPageVariable::execute(LeadActor *actor) { - assert(_values.size()); + assert(!_values.empty()); Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd(); uint index = rnd.getRandomNumber(_values.size() - 1); diff --git a/engines/pink/objects/side_effect.h b/engines/pink/objects/side_effect.h index 51342267f9..4542b7f9e1 100644 --- a/engines/pink/objects/side_effect.h +++ b/engines/pink/objects/side_effect.h @@ -101,9 +101,9 @@ class SideEffectRandomPageVariable : public SideEffect public: virtual void deserialize(Archive &archive); virtual void toConsole(); + virtual void execute(LeadActor *actor); private: - virtual void execute(LeadActor *actor); Common::String _name; Common::StringArray _values; }; |