Make it a preference whether music should be muted in background

No UI for the preference yet.
This commit is contained in:
Jyrki Vesterinen 2016-06-26 12:45:35 +03:00
parent bf510e7886
commit 31871daa71
3 changed files with 14 additions and 1 deletions

View file

@ -677,6 +677,16 @@ bool set_music(bool ison) {
return true;
}
bool stop_music_in_background()
{
return get("stop_music_in_background", false);
}
void set_stop_music_in_background(bool ison)
{
preferences::set("stop_music_in_background", ison);
}
namespace {
double scroll = 0.2;
}

View file

@ -121,6 +121,9 @@ namespace preferences {
int music_volume();
void set_music_volume(int vol);
bool stop_music_in_background();
void set_stop_music_in_background(bool ison);
bool turn_bell();
bool set_turn_bell(bool ison);

View file

@ -626,7 +626,7 @@ music_muter::music_muter() :
void music_muter::handle_window_event(const SDL_Event& event)
{
if (preferences::music_on())
if (preferences::stop_music_in_background() && preferences::music_on())
{
if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
{