From 5db9a454581ff9b3f5e8160e401c0c741f321e9c Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Thu, 29 Mar 2018 22:31:11 +0300 Subject: PINK: added ActionTalk implementation --- .../pink/objects/actions/action_play_with_sfx.cpp | 5 +++++ engines/pink/objects/actions/action_play_with_sfx.h | 3 +++ engines/pink/objects/actions/action_sound.cpp | 2 +- engines/pink/objects/actions/action_sound.h | 1 - engines/pink/objects/actions/action_talk.cpp | 21 ++++++++++++++++++++- engines/pink/objects/actions/action_talk.h | 9 +++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) (limited to 'engines/pink') diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp index a28a06768c..8c41176cdb 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.cpp +++ b/engines/pink/objects/actions/action_play_with_sfx.cpp @@ -68,6 +68,11 @@ void ActionPlayWithSfx::updateSound() { } ActionPlayWithSfx::~ActionPlayWithSfx() { + end(); +} + +void ActionPlayWithSfx::end() { + ActionPlay::end(); for (int i = 0; i < _sfxArray.size(); ++i) { delete _sfxArray[i]; } diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h index 7782e913e2..7e4448abbb 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.h +++ b/engines/pink/objects/actions/action_play_with_sfx.h @@ -36,6 +36,9 @@ class ActionPlayWithSfx : public ActionPlay { virtual void toConsole(); virtual void update(); +public: + virtual void end(); + protected: virtual void onStart(); diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp index 44dfda45c7..f1829a1f19 100644 --- a/engines/pink/objects/actions/action_sound.cpp +++ b/engines/pink/objects/actions/action_sound.cpp @@ -32,7 +32,7 @@ namespace Pink { ActionSound::ActionSound() - : _sound(nullptr), _isStopped(1) + : _sound(nullptr) {} ActionSound::~ActionSound(){ diff --git a/engines/pink/objects/actions/action_sound.h b/engines/pink/objects/actions/action_sound.h index 3c71da454e..b13481cb65 100644 --- a/engines/pink/objects/actions/action_sound.h +++ b/engines/pink/objects/actions/action_sound.h @@ -48,7 +48,6 @@ private: uint32 _volume; bool _isLoop; bool _isBackground; - bool _isStopped; }; } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_talk.cpp b/engines/pink/objects/actions/action_talk.cpp index da37204e5d..b9743005c4 100644 --- a/engines/pink/objects/actions/action_talk.cpp +++ b/engines/pink/objects/actions/action_talk.cpp @@ -22,7 +22,9 @@ #include "action_talk.h" #include -#include +#include +#include +#include namespace Pink { @@ -37,4 +39,21 @@ void ActionTalk::toConsole() { _name.c_str(), _fileName.c_str(), _z, _startFrame, _stopFrame, _intro, _style, _vox.c_str()); } +void ActionTalk::onStart() { + ActionPlay::onStart(); + _sound = _actor->getPage()->loadSound(_vox); + _sound->play(Audio::Mixer::SoundType::kSpeechSoundType, 100, 0); +} + +void ActionTalk::update() { + ActionLoop::update(); + if (!_sound->isPlaying()) + _actor->endAction(); +} + +void ActionTalk::end() { + ActionPlay::end(); + delete _sound; +} + } // End of namespace Pink \ No newline at end of file diff --git a/engines/pink/objects/actions/action_talk.h b/engines/pink/objects/actions/action_talk.h index 4c28a6f545..9b6d26fe32 100644 --- a/engines/pink/objects/actions/action_talk.h +++ b/engines/pink/objects/actions/action_talk.h @@ -27,12 +27,21 @@ namespace Pink { +class Sound; + class ActionTalk : public ActionLoop { public: virtual void deserialize(Archive &archive); virtual void toConsole(); + virtual void update(); + + virtual void end(); + +protected: + virtual void onStart(); private: + Sound *_sound; Common::String _vox; }; -- cgit v1.2.3