Moved some WML evaluation code from a method in sound.cpp...

...to the music_track class constructor.
This commit is contained in:
Ignacio R. Morelle 2009-07-26 02:19:38 +00:00
parent 35e1c71853
commit 90540e2ecd
3 changed files with 26 additions and 12 deletions

View file

@ -531,15 +531,14 @@ void play_music_config(const config &music_node)
music_track track( music_node );
// If they say play once, we don't alter playlist.
if (utils::string_bool(music_node["play_once"])) {
if (track.play_once()) {
current_track = track;
current_track.set_play_once(true);
play_music();
return;
}
// Clear play list unless they specify append.
if (!utils::string_bool(music_node["append"])) {
if (!track.append()) {
current_track_list = std::vector<music_track>();
}
@ -564,7 +563,7 @@ void play_music_config(const config &music_node)
}
// They can tell us to start playing this list immediately.
if (utils::string_bool(music_node["immediate"])) {
if (track.immediate()) {
current_track = track;
play_music();
}

View file

@ -31,7 +31,9 @@ music_track::music_track() :
file_path_(""),
ms_before_(0),
ms_after_(0),
once_(false)
once_(false),
append_(false),
immediate_(false)
{
//
// The first music_track may be initialized before main()
@ -48,7 +50,9 @@ music_track::music_track(const config& node) :
file_path_(""),
ms_before_(lexical_cast_default<int>(node["ms_before"])),
ms_after_(lexical_cast_default<int>(node["ms_after"])),
once_(false)
once_(utils::string_bool(node["play_once"])),
append_(utils::string_bool(node["append"])),
immediate_(utils::string_bool(node["immediate"]))
{
if(id_.empty()) {
ERR_AUDIO << "empty track filename specified\n";
@ -62,7 +66,9 @@ music_track::music_track(const std::string& v_name) :
file_path_(""),
ms_before_(0),
ms_after_(0),
once_(false)
once_(false),
append_(false),
immediate_(false)
{
if(id_.empty()) {
ERR_AUDIO << "empty track filename specified\n";
@ -71,13 +77,14 @@ music_track::music_track(const std::string& v_name) :
}
}
music_track::music_track(const std::string& v_name,
unsigned int v_ms_before, unsigned int v_ms_after, bool v_once) :
music_track::music_track(const std::string& v_name, unsigned int v_ms_before, unsigned int v_ms_after, bool v_once, bool v_append, bool v_immediate) :
id_(v_name),
file_path_(""),
ms_before_(v_ms_before),
ms_after_(v_ms_after),
once_(v_once)
once_(v_once),
append_(v_append),
immediate_(v_immediate)
{
if(id_.empty()) {
ERR_AUDIO << "empty track filename specified\n";
@ -91,7 +98,9 @@ music_track::music_track(const music_track& mt) :
file_path_(mt.file_path_),
ms_before_(mt.ms_before_),
ms_after_(mt.ms_after_),
once_(mt.once_)
once_(mt.once_),
append_(mt.append_),
immediate_(mt.immediate_)
{
// Assume mt has already been resolved...
}

View file

@ -35,12 +35,16 @@ public:
music_track(const std::string& v_name,
unsigned int v_ms_before,
unsigned int v_ms_after,
bool v_once = false
bool v_once = false,
bool v_append = false,
bool v_immediate = false
);
void write(config& parent_node, bool append);
bool valid() const { return file_path_.empty() != true; }
bool append() const { return append_; }
bool immediate() const { return immediate_; }
bool play_once() const { return once_; }
unsigned int ms_before() const { return ms_before_; }
unsigned int ms_after() const { return ms_after_; }
@ -61,6 +65,8 @@ private:
unsigned int ms_before_, ms_after_;
bool once_;
bool append_;
bool immediate_;
};
} /* end namespace sound */