Fix #2602: music doesn't change immediately on loading a save
This time I added an option to disable the feature to allow the currently
playing track to finish when changing the playlist. This allows more
fine-grained control of distinct use cases.
In wesnoth.cpp:do_gameloop(), I reversed the order of the title screen
music and default music because otherwise adding the default music would
enable play_once for the title screen music and prevent instant music
change when the player loads a save. I play title screen music with
immediate=yes, so it's still played first.
(cherry-picked from commit 91afbfd586
)
This commit is contained in:
parent
de1bdba769
commit
bcc914bfe8
5 changed files with 12 additions and 9 deletions
|
@ -223,7 +223,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
|
|||
|
||||
// Start music.
|
||||
for(const config &m : level.child_range("music")) {
|
||||
sound::play_music_config(m);
|
||||
sound::play_music_config(m, true);
|
||||
}
|
||||
sound::commit_music_changes();
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ static int impl_music_set(lua_State* L) {
|
|||
// Remove the track at that index and add the new one in its place
|
||||
// It's a little inefficient though...
|
||||
sound::remove_track(i);
|
||||
sound::play_music_config(cfg, i);
|
||||
sound::play_music_config(cfg, false, i);
|
||||
}
|
||||
} else {
|
||||
lua_music_track& track = *get_track(L, 3);
|
||||
|
@ -206,7 +206,7 @@ static int intf_music_add(lua_State* L) {
|
|||
return luaL_argerror(L, i, "unrecognized argument");
|
||||
}
|
||||
}
|
||||
sound::play_music_config(cfg, index);
|
||||
sound::play_music_config(cfg, false, index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -663,7 +663,7 @@ void play_music_repeatedly(const std::string& id)
|
|||
last_track.reset();
|
||||
}
|
||||
|
||||
void play_music_config(const config& music_node, int i)
|
||||
void play_music_config(const config& music_node, bool allow_interrupt_current_track, int i)
|
||||
{
|
||||
//
|
||||
// FIXME: there is a memory leak somewhere in this function, seemingly related to the shared_ptrs
|
||||
|
@ -720,7 +720,8 @@ void play_music_config(const config& music_node, int i)
|
|||
current_track = *iter;
|
||||
current_track_index = iter - current_track_list.begin();
|
||||
play_music();
|
||||
} else if(!track.append() && current_track) { // Make sure the current track is finished
|
||||
} else if(!track.append() && !allow_interrupt_current_track && current_track) {
|
||||
// Make sure the current track will finish first
|
||||
current_track->set_play_once(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ void stop_UI_sound();
|
|||
void stop_bell();
|
||||
|
||||
// Read config entry, alter track list accordingly.
|
||||
void play_music_config(const config &music_node, int i = -1);
|
||||
void play_music_config(const config &music_node, bool allow_interrupt_current_track = false, int i = -1);
|
||||
// Act on any track list changes from above.
|
||||
void commit_music_changes();
|
||||
|
||||
|
|
|
@ -749,13 +749,15 @@ static int do_gameloop(const std::vector<std::string>& args)
|
|||
if(!game->is_loading()) {
|
||||
const config& cfg = config_manager.game_config().child("titlescreen_music");
|
||||
if(cfg) {
|
||||
sound::play_music_repeatedly(game_config::title_music);
|
||||
|
||||
for(const config& i : cfg.child_range("music")) {
|
||||
sound::play_music_config(i);
|
||||
}
|
||||
|
||||
sound::commit_music_changes();
|
||||
config title_music_config;
|
||||
title_music_config["name"] = game_config::title_music;
|
||||
title_music_config["append"] = true;
|
||||
title_music_config["immediate"] = true;
|
||||
sound::play_music_config(title_music_config);
|
||||
} else {
|
||||
sound::empty_playlist();
|
||||
sound::stop_music();
|
||||
|
|
Loading…
Add table
Reference in a new issue