aboutsummaryrefslogtreecommitdiff
path: root/engines/pink/objects/actions
diff options
context:
space:
mode:
authorwhiterandrek2018-06-03 14:24:59 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commitda0adc92a2cc1af0da78a4e612f382e1e5b42bd0 (patch)
tree773ba0a3694c59516b9c38cc3133d3508909eb2f /engines/pink/objects/actions
parent442f725a5d2d36183fdc41d7b050beb4aa4fd8fa (diff)
downloadscummvm-rg350-da0adc92a2cc1af0da78a4e612f382e1e5b42bd0.tar.gz
scummvm-rg350-da0adc92a2cc1af0da78a4e612f382e1e5b42bd0.tar.bz2
scummvm-rg350-da0adc92a2cc1af0da78a4e612f382e1e5b42bd0.zip
PINK: reformat Action's code
Diffstat (limited to 'engines/pink/objects/actions')
-rw-r--r--engines/pink/objects/actions/action.cpp10
-rw-r--r--engines/pink/objects/actions/action.h15
-rw-r--r--engines/pink/objects/actions/action_cel.cpp47
-rw-r--r--engines/pink/objects/actions/action_cel.h21
-rw-r--r--engines/pink/objects/actions/action_hide.cpp12
-rw-r--r--engines/pink/objects/actions/action_hide.h9
-rw-r--r--engines/pink/objects/actions/action_loop.h11
-rw-r--r--engines/pink/objects/actions/action_play.cpp18
-rw-r--r--engines/pink/objects/actions/action_play.h11
-rw-r--r--engines/pink/objects/actions/action_play_with_sfx.cpp30
-rw-r--r--engines/pink/objects/actions/action_play_with_sfx.h27
-rw-r--r--engines/pink/objects/actions/action_sound.cpp2
-rw-r--r--engines/pink/objects/actions/action_sound.h11
-rw-r--r--engines/pink/objects/actions/action_still.cpp2
-rw-r--r--engines/pink/objects/actions/action_still.h12
-rw-r--r--engines/pink/objects/actions/action_talk.cpp12
-rw-r--r--engines/pink/objects/actions/action_talk.h12
-rw-r--r--engines/pink/objects/actions/action_text.cpp8
-rw-r--r--engines/pink/objects/actions/action_text.h3
-rw-r--r--engines/pink/objects/actions/walk_action.h4
20 files changed, 159 insertions, 118 deletions
diff --git a/engines/pink/objects/actions/action.cpp b/engines/pink/objects/actions/action.cpp
index 934d6fc5be..34106f7ee6 100644
--- a/engines/pink/objects/actions/action.cpp
+++ b/engines/pink/objects/actions/action.cpp
@@ -31,4 +31,14 @@ void Action::deserialize(Archive &archive) {
_actor = static_cast<Actor*>(archive.readObject());
}
+bool Action::initPalette(Director *director) {
+ return false;
+}
+
+void Action::pause(bool paused) {}
+
+Actor *Action::getActor() const {
+ return _actor;
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action.h b/engines/pink/objects/actions/action.h
index 9c4e9023e1..40287026fa 100644
--- a/engines/pink/objects/actions/action.h
+++ b/engines/pink/objects/actions/action.h
@@ -32,17 +32,16 @@ class Director;
class Action : public NamedObject {
public:
- virtual void deserialize(Archive &archive);
- virtual void start(bool unk) {};
- virtual void end() {};
- virtual void update() {};
- virtual void toConsole() {};
+ virtual void deserialize(Archive &archive) override;
- virtual bool initPalette(Director *director) { return 0; }
+ virtual bool initPalette(Director *director);
- Actor *getActor() { return _actor; }
+ virtual void start() = 0;
+ virtual void end() = 0;
- virtual void pause(bool paused) {};
+ virtual void pause(bool paused);
+
+ Actor *getActor() const;
protected:
Actor *_actor;
diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp
index 0881542155..e6f262f390 100644
--- a/engines/pink/objects/actions/action_cel.cpp
+++ b/engines/pink/objects/actions/action_cel.cpp
@@ -34,13 +34,29 @@ namespace Pink {
ActionCEL::ActionCEL()
: _decoder(nullptr) {}
+ActionCEL::~ActionCEL() {
+ end();
+}
+
void ActionCEL::deserialize(Archive &archive) {
Action::deserialize(archive);
_fileName = archive.readString();
_z = archive.readDWORD();
}
-void ActionCEL::start(bool unk) {
+bool ActionCEL::initPalette(Director *director) {
+ if (!_decoder)
+ _decoder = _actor->getPage()->loadCel(_fileName);
+ if (_decoder->getCurFrame() == -1) {
+ _decoder->decodeNextFrame();
+ _decoder->rewind();
+ }
+ debug("%u", _decoder->isPaused());
+ director->setPallette(_decoder->getPalette());
+ return true;
+}
+
+void ActionCEL::start() {
if (!_decoder)
_decoder = _actor->getPage()->loadCel(_fileName);
_actor->getPage()->getGame()->getDirector()->addSprite(this);
@@ -54,23 +70,6 @@ void ActionCEL::end() {
_decoder = nullptr;
}
-uint32 ActionCEL::getZ() {
- return _z;
-}
-
-CelDecoder *ActionCEL::getDecoder() {
- return _decoder;
-}
-
-bool ActionCEL::initPalette(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();
@@ -78,12 +77,16 @@ void ActionCEL::update() {
}
}
-ActionCEL::~ActionCEL() {
- end();
-}
-
void ActionCEL::pause(bool paused) {
_decoder->pauseVideo(paused);
}
+uint32 ActionCEL::getZ() {
+ return _z;
+}
+
+CelDecoder *ActionCEL::getDecoder() {
+ return _decoder;
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_cel.h b/engines/pink/objects/actions/action_cel.h
index 60b85e0c64..2623c55c16 100644
--- a/engines/pink/objects/actions/action_cel.h
+++ b/engines/pink/objects/actions/action_cel.h
@@ -31,23 +31,26 @@ class CelDecoder;
class ActionCEL : public Action {
public:
+ ActionCEL();
~ActionCEL() override;
- ActionCEL();
- virtual void deserialize(Archive &archive);
- virtual void start(bool unk);
- virtual void end();
- virtual void update();
+ void deserialize(Archive &archive) override;
- uint32 getZ();
- CelDecoder *getDecoder();
+ bool initPalette(Director *director) override;
- virtual bool initPalette(Director *director);
+ void start() override;
+ void end() override;
+
+ virtual void update();
void pause(bool paused) override;
+ uint32 getZ();
+ CelDecoder *getDecoder();
+
protected:
- virtual void onStart() {};
+ virtual void onStart() = 0;
+
CelDecoder *_decoder;
Common::String _fileName;
uint32 _z;
diff --git a/engines/pink/objects/actions/action_hide.cpp b/engines/pink/objects/actions/action_hide.cpp
index 1732d2d967..a2435c4ab9 100644
--- a/engines/pink/objects/actions/action_hide.cpp
+++ b/engines/pink/objects/actions/action_hide.cpp
@@ -26,11 +26,11 @@
namespace Pink {
-void Pink::ActionHide::deserialize(Archive &archive) {
- Action::deserialize(archive);
+void ActionHide::toConsole() {
+ debug("\tActionHide: _name = %s", _name.c_str());
}
-void ActionHide::start(bool unk_startNow) {
+void ActionHide::start() {
debug("Actor %s has now ActionHide %s", _actor->getName().c_str(), _name.c_str());
_actor->endAction();
}
@@ -39,10 +39,4 @@ void ActionHide::end() {
debug("ActionHide %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
}
-void ActionHide::toConsole() {
- debug("\tActionHide: _name = %s", _name.c_str());
-}
-
-ActionHide::~ActionHide() {}
-
} //End of namespace Pink
diff --git a/engines/pink/objects/actions/action_hide.h b/engines/pink/objects/actions/action_hide.h
index eb2b8da519..7db4be107d 100644
--- a/engines/pink/objects/actions/action_hide.h
+++ b/engines/pink/objects/actions/action_hide.h
@@ -29,13 +29,10 @@ namespace Pink {
class ActionHide : public Action {
public:
- ~ActionHide() override;
+ void toConsole() override;
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
-
- virtual void start(bool unk);
- virtual void end();
+ void start() override;
+ void end() override;
};
} //End of namespace Pink
diff --git a/engines/pink/objects/actions/action_loop.h b/engines/pink/objects/actions/action_loop.h
index 0b8132aa5c..db02544228 100644
--- a/engines/pink/objects/actions/action_loop.h
+++ b/engines/pink/objects/actions/action_loop.h
@@ -29,11 +29,14 @@ namespace Pink {
class ActionLoop : public ActionPlay {
public:
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
- virtual void update();
+ void deserialize(Archive &archive) override;
+
+ void toConsole() override;
+
+ void update() override;
+
protected:
- virtual void onStart();
+ void onStart() override;
enum Style {
kPingPong = 2,
diff --git a/engines/pink/objects/actions/action_play.cpp b/engines/pink/objects/actions/action_play.cpp
index a2b8b0a0a8..9e9c856da4 100644
--- a/engines/pink/objects/actions/action_play.cpp
+++ b/engines/pink/objects/actions/action_play.cpp
@@ -44,6 +44,17 @@ void ActionPlay::end() {
debug("ActionPlay %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
}
+void ActionPlay::update() {
+ if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) {
+ _decoder->stop();
+ _actor->endAction();
+ }
+}
+
+void ActionPlay::pause(bool paused) {
+ ActionCEL::pause(paused);
+}
+
void ActionPlay::onStart() {
debug("Actor %s has now ActionPlay %s", _actor->getName().c_str(), _name.c_str());
_decoder->start();
@@ -53,11 +64,4 @@ void ActionPlay::onStart() {
_decoder->decodeNextFrame();
}
-void ActionPlay::update() {
- if (_decoder->endOfVideo() || _decoder->getCurFrame() == _stopFrame) {
- _decoder->stop();
- _actor->endAction();
- }
-}
-
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_play.h b/engines/pink/objects/actions/action_play.h
index 6553bb1776..cdefc88d46 100644
--- a/engines/pink/objects/actions/action_play.h
+++ b/engines/pink/objects/actions/action_play.h
@@ -29,15 +29,18 @@ namespace Pink {
class ActionPlay : public ActionStill {
public:
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
+ void deserialize(Archive &archive) override;
- virtual void end();
+ void toConsole() override;
+
+ void end() override;
void update() override;
+ void pause(bool paused) override;
+
protected:
- virtual void onStart();
+ void onStart() override;
int32 _stopFrame;
};
diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp
index c4ab139043..056ce6e9b3 100644
--- a/engines/pink/objects/actions/action_play_with_sfx.cpp
+++ b/engines/pink/objects/actions/action_play_with_sfx.cpp
@@ -28,6 +28,13 @@
namespace Pink {
+ActionPlayWithSfx::~ActionPlayWithSfx() {
+ ActionPlay::end();
+ for (uint i = 0; i < _sfxArray.size(); ++i) {
+ delete _sfxArray[i];
+ }
+}
+
void ActionPlayWithSfx::deserialize(Pink::Archive &archive) {
ActionPlay::deserialize(archive);
_isLoop = archive.readDWORD();
@@ -71,11 +78,11 @@ void ActionPlayWithSfx::updateSound() {
}
}
-ActionPlayWithSfx::~ActionPlayWithSfx() {
- ActionPlay::end();
- for (uint i = 0; i < _sfxArray.size(); ++i) {
- delete _sfxArray[i];
- }
+ActionSfx::ActionSfx()
+ : _sound(nullptr) {}
+
+ActionSfx::~ActionSfx() {
+ end();
}
void ActionSfx::deserialize(Pink::Archive &archive) {
@@ -97,20 +104,13 @@ void ActionSfx::play(Page *page) {
_sound->play(Audio::Mixer::kSFXSoundType, _volume, 0);
}
-ActionSfx::~ActionSfx() {
- end();
+void ActionSfx::end() {
+ delete _sound;
+ _sound = nullptr;
}
uint32 ActionSfx::getFrame() {
return _frame;
}
-ActionSfx::ActionSfx()
- : _sound(nullptr) {}
-
-void ActionSfx::end() {
- delete _sound;
- _sound = nullptr;
-}
-
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h
index 8945572548..7e8b0c8ed2 100644
--- a/engines/pink/objects/actions/action_play_with_sfx.h
+++ b/engines/pink/objects/actions/action_play_with_sfx.h
@@ -31,18 +31,22 @@ class ActionSfx;
class ActionPlayWithSfx : public ActionPlay {
public:
- virtual ~ActionPlayWithSfx();
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
- virtual void update();
+ ~ActionPlayWithSfx() override;
+
+ void deserialize(Archive &archive) override;
+
+ void toConsole() override;
+
+ void update() override;
protected:
- virtual void onStart();
+ void onStart() override;
private:
void updateSound();
- uint32 _isLoop;
+
Array<ActionSfx *> _sfxArray;
+ uint32 _isLoop;
};
class Sound;
@@ -51,14 +55,17 @@ class Page;
class ActionSfx : public Object {
public:
ActionSfx();
- virtual ~ActionSfx();
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
+ ~ActionSfx() override;
+
+ void deserialize(Archive &archive) override;
+
+ void toConsole() override;
void play(Page *page);
- uint32 getFrame();
void end();
+ uint32 getFrame();
+
private:
Sound *_sound;
Common::String _sfxName;
diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp
index a80130bffc..d63d57c7f3 100644
--- a/engines/pink/objects/actions/action_sound.cpp
+++ b/engines/pink/objects/actions/action_sound.cpp
@@ -51,7 +51,7 @@ void ActionSound::toConsole() {
" _isBackground = %u", _name.c_str(), _fileName.c_str(), _volume, _isLoop, _isBackground);
}
-void ActionSound::start(bool unk) {
+void ActionSound::start() {
assert(!_sound);
_sound = _actor->getPage()->loadSound(_fileName);
diff --git a/engines/pink/objects/actions/action_sound.h b/engines/pink/objects/actions/action_sound.h
index f5d1401917..c614951557 100644
--- a/engines/pink/objects/actions/action_sound.h
+++ b/engines/pink/objects/actions/action_sound.h
@@ -34,13 +34,14 @@ public:
ActionSound();
~ActionSound();
- virtual void deserialize(Archive &archive);
+ void deserialize(Archive &archive) override;
- virtual void toConsole();
+ void toConsole() override;
- virtual void start(bool unk_startNow);
- virtual void end();
- virtual void update();
+ void start() override;
+ void end() override;
+
+ void update();
void pause(bool paused) override;
diff --git a/engines/pink/objects/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp
index ebdde4ed09..693d1304d4 100644
--- a/engines/pink/objects/actions/action_still.cpp
+++ b/engines/pink/objects/actions/action_still.cpp
@@ -44,6 +44,8 @@ void ActionStill::end() {
debug("ActionStill %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
}
+void ActionStill::pause(bool paused) {}
+
void ActionStill::onStart() {
debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str());
for (uint i = 0; i < _startFrame; ++i) {
diff --git a/engines/pink/objects/actions/action_still.h b/engines/pink/objects/actions/action_still.h
index 90c5c7d01d..a9b2d5209c 100644
--- a/engines/pink/objects/actions/action_still.h
+++ b/engines/pink/objects/actions/action_still.h
@@ -29,14 +29,16 @@ namespace Pink {
class ActionStill : public ActionCEL {
public:
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
+ void deserialize(Archive &archive) override;
- virtual void end();
- virtual void pause(bool paused) {}
+ void toConsole() override;
+
+ void end() override;
+
+ void pause(bool paused) override;
protected:
- virtual void onStart();
+ void onStart() override;
uint32 _startFrame;
};
diff --git a/engines/pink/objects/actions/action_talk.cpp b/engines/pink/objects/actions/action_talk.cpp
index 7ecd40d975..c142dca0e6 100644
--- a/engines/pink/objects/actions/action_talk.cpp
+++ b/engines/pink/objects/actions/action_talk.cpp
@@ -40,12 +40,6 @@ 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::kSpeechSoundType, 100, 0);
-}
-
void ActionTalk::update() {
ActionLoop::update();
if (!_sound->isPlaying()) {
@@ -66,4 +60,10 @@ void ActionTalk::pause(bool paused) {
_sound->pause(paused);
}
+void ActionTalk::onStart() {
+ ActionPlay::onStart();
+ _sound = _actor->getPage()->loadSound(_vox);
+ _sound->play(Audio::Mixer::kSpeechSoundType, 100, 0);
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_talk.h b/engines/pink/objects/actions/action_talk.h
index e14e6bcc87..672e0249a6 100644
--- a/engines/pink/objects/actions/action_talk.h
+++ b/engines/pink/objects/actions/action_talk.h
@@ -31,16 +31,18 @@ class Sound;
class ActionTalk : public ActionLoop {
public:
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
- virtual void update();
+ void deserialize(Archive &archive) override;
- virtual void end();
+ void toConsole() override;
+
+ void update() override;
+
+ void end() override;
void pause(bool paused) override;
protected:
- virtual void onStart();
+ void onStart() override;
private:
Sound *_sound;
diff --git a/engines/pink/objects/actions/action_text.cpp b/engines/pink/objects/actions/action_text.cpp
index f9ef86a1c2..bf080719ad 100644
--- a/engines/pink/objects/actions/action_text.cpp
+++ b/engines/pink/objects/actions/action_text.cpp
@@ -48,4 +48,12 @@ void ActionText::toConsole() {
_name.c_str(), _fileName.c_str(), _xLeft, _yTop, _xRight, _yBottom, _centered, _scrollBar, _textColor, _backgroundColor);
}
+void ActionText::start() {
+
+}
+
+void ActionText::end() {
+
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_text.h b/engines/pink/objects/actions/action_text.h
index e0cc752c4b..bcf0a3520f 100644
--- a/engines/pink/objects/actions/action_text.h
+++ b/engines/pink/objects/actions/action_text.h
@@ -33,6 +33,9 @@ public:
void toConsole() override;
+ void start() override;
+ void end() override;
+
private:
Common::String _fileName;
diff --git a/engines/pink/objects/actions/walk_action.h b/engines/pink/objects/actions/walk_action.h
index d53c8c2bdc..ac41bcb3b0 100644
--- a/engines/pink/objects/actions/walk_action.h
+++ b/engines/pink/objects/actions/walk_action.h
@@ -29,9 +29,9 @@ namespace Pink {
class WalkAction : public ActionCEL {
public:
- virtual void deserialize(Archive &archive);
+ void deserialize(Archive &archive) override;
- virtual void toConsole();
+ void toConsole() override;
protected:
void onStart() override;