aboutsummaryrefslogtreecommitdiff
path: root/engines/pink/objects/actions
diff options
context:
space:
mode:
Diffstat (limited to 'engines/pink/objects/actions')
-rw-r--r--engines/pink/objects/actions/action_cel.cpp2
-rw-r--r--engines/pink/objects/actions/action_play_with_sfx.cpp57
-rw-r--r--engines/pink/objects/actions/action_play_with_sfx.h19
-rw-r--r--engines/pink/objects/actions/action_text.cpp4
-rw-r--r--engines/pink/objects/actions/walk_action.h2
5 files changed, 70 insertions, 14 deletions
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