Merge pull request #265 from Zappaman/music_shuffle_feature_2
add option to not shuffle music, see https://gna.org/bugs/?19653
This commit is contained in:
commit
623484b2be
5 changed files with 32 additions and 10 deletions
|
@ -121,6 +121,8 @@ Version 1.13.0-dev:
|
|||
resolution for OS X to 800 x 600 (bug #20332).
|
||||
* added [effect] apply_to=fearless/healthy which is now used by healty/fearless
|
||||
traits instead of hardcoding the id of those traits in c++.
|
||||
* added support for a shuffle key in the [music] music to allow selecting
|
||||
between random and non-random music play (bug #19653)
|
||||
* Miscellaneous and bug fixes:
|
||||
* replace 'fight_on_without_leader'=yes/no with defeat_condition=no_leader/
|
||||
no_units/always/never which allows the wml developer to decide when a side
|
||||
|
|
|
@ -48,6 +48,10 @@ Version 1.13.0-dev:
|
|||
* Added a new subdialog in Preferences to clean or purge the WML cache.
|
||||
* OS X: Fixed mouse tracking issue for retina displays.
|
||||
|
||||
* WML engine:
|
||||
* Added support for a shuffle key in the [music] music to allow selecting
|
||||
between random and non-random music play (bug #19653)
|
||||
|
||||
* Miscellaneous and bug fixes:
|
||||
* Dropped support for AmigaOS, BeOS, and OS/2.
|
||||
* Fixed halos glitching through locations that become shrouded after the
|
||||
|
|
|
@ -160,6 +160,7 @@ std::vector<std::string> played_before;
|
|||
std::vector<sound::music_track> current_track_list;
|
||||
sound::music_track current_track;
|
||||
sound::music_track last_track;
|
||||
unsigned int current_track_index = 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -224,17 +225,25 @@ static const sound::music_track &choose_track()
|
|||
{
|
||||
assert(!current_track_list.empty());
|
||||
|
||||
unsigned int track = 0;
|
||||
if (current_track_index == current_track_list.size()) {
|
||||
current_track_index = 0;
|
||||
}
|
||||
|
||||
if (current_track_list.size() > 1) {
|
||||
do {
|
||||
track = rand()%current_track_list.size();
|
||||
} while (!track_ok( current_track_list[track].file_path() ));
|
||||
if (current_track_list[current_track_index].shuffle()) {
|
||||
unsigned int track = 0;
|
||||
|
||||
if (current_track_list.size() > 1) {
|
||||
do {
|
||||
track = rand()%current_track_list.size();
|
||||
} while (!track_ok( current_track_list[track].file_path() ));
|
||||
}
|
||||
|
||||
current_track_index = track;
|
||||
}
|
||||
|
||||
//LOG_AUDIO << "Next track will be " << current_track_list[track].file_path() << "\n";
|
||||
played_before.push_back( current_track_list[track].file_path() );
|
||||
return current_track_list[track];
|
||||
played_before.push_back( current_track_list[current_track_index].file_path() );
|
||||
return current_track_list[current_track_index++];
|
||||
}
|
||||
|
||||
static std::string pick_one(const std::string &files)
|
||||
|
|
|
@ -37,7 +37,8 @@ music_track::music_track() :
|
|||
ms_after_(0),
|
||||
once_(false),
|
||||
append_(false),
|
||||
immediate_(false)
|
||||
immediate_(false),
|
||||
shuffle_(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -49,7 +50,8 @@ music_track::music_track(const config& node) :
|
|||
ms_after_(node["ms_after"]),
|
||||
once_(node["play_once"].to_bool()),
|
||||
append_(node["append"].to_bool()),
|
||||
immediate_(node["immediate"].to_bool())
|
||||
immediate_(node["immediate"].to_bool()),
|
||||
shuffle_(node["shuffle"].to_bool(true))
|
||||
{
|
||||
resolve();
|
||||
}
|
||||
|
@ -62,7 +64,8 @@ music_track::music_track(const std::string& v_name) :
|
|||
ms_after_(0),
|
||||
once_(false),
|
||||
append_(false),
|
||||
immediate_(false)
|
||||
immediate_(false),
|
||||
shuffle_(true)
|
||||
{
|
||||
resolve();
|
||||
}
|
||||
|
@ -133,6 +136,8 @@ void music_track::write(config &parent_node, bool append) const
|
|||
if(append) {
|
||||
m["append"] = true;
|
||||
}
|
||||
//default behaviour is to shuffle
|
||||
m["shuffle"] = shuffle_;
|
||||
}
|
||||
|
||||
} /* end namespace sound */
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
bool append() const { return append_; }
|
||||
bool immediate() const { return immediate_; }
|
||||
bool shuffle() const { return shuffle_; }
|
||||
bool play_once() const { return once_; }
|
||||
int ms_before() const { return ms_before_; }
|
||||
int ms_after() const { return ms_after_; }
|
||||
|
@ -59,6 +60,7 @@ private:
|
|||
bool once_;
|
||||
bool append_;
|
||||
bool immediate_;
|
||||
bool shuffle_;
|
||||
};
|
||||
|
||||
} /* end namespace sound */
|
||||
|
|
Loading…
Add table
Reference in a new issue