Skip to content

Commit

Permalink
ZVISION: Add subtitles support for MusicNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa-Chan committed Feb 24, 2014
1 parent 8e02e06 commit 1af6f40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions engines/zvision/music_node.cpp
Expand Up @@ -46,6 +46,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
_attenuate = 0;
_pantrack = false;
_pantrack_X = 0;
_sub = NULL;

Audio::RewindableAudioStream *audioStream;

Expand All @@ -69,12 +70,22 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool

if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 1);

Common::String subname = filename;
subname.setChar('s', subname.size() - 3);
subname.setChar('u', subname.size() - 2);
subname.setChar('b', subname.size() - 1);

if (_engine->getSearchManager()->hasFile(subname))
_sub = new Subtitle(_engine, subname);
}

MusicNode::~MusicNode() {
_engine->_mixer->stopHandle(_handle);
if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 2);
if (_sub)
delete _sub;
debug(1, "MusicNode: %d destroyed\n", _key);
}

Expand Down Expand Up @@ -117,6 +128,9 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {

if (_pantrack || _volume != _newvol)
setVolume(_newvol);

if (_sub)
_sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
}
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions engines/zvision/music_node.h
Expand Up @@ -25,6 +25,7 @@

#include "audio/mixer.h"
#include "zvision/sidefx.h"
#include "zvision/subtitles.h"

namespace Common {
class String;
Expand Down Expand Up @@ -64,6 +65,7 @@ class MusicNode : public SideFX {
int32 _crossfade_time;
bool _stereo;
Audio::SoundHandle _handle;
Subtitle *_sub;
};

class PanTrackNode : public SideFX {
Expand Down

0 comments on commit 1af6f40

Please sign in to comment.