Skip to content

Commit

Permalink
Audio|Client: Option for pausing music when focus lost
Browse files Browse the repository at this point in the history
Added a new option to Audio Settings for pausing music when window loses focus.

Reorganized the Audio Settings dialog so SFX and Music are separately grouped.

IssueID #2280
  • Loading branch information
skyjake committed Nov 8, 2018
1 parent 1d742fc commit af6df1a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
Expand Up @@ -137,5 +137,6 @@ def setDefaults(d)
end
record fmod
fmod.speakerMode = '' # defaults to stereo
pauseOnFocus = True
end
end
3 changes: 2 additions & 1 deletion doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -487,7 +487,8 @@ DENG2_PIMPL(ClientApp)
.define(Prof::ConfigVariable, "audio.soundPlugin")
.define(Prof::ConfigVariable, "audio.musicPlugin")
.define(Prof::ConfigVariable, "audio.cdPlugin")
.define(Prof::ConfigVariable, "audio.channels");
.define(Prof::ConfigVariable, "audio.channels")
.define(Prof::ConfigVariable, "audio.pauseOnFocus");
}

#ifdef UNIX
Expand Down
5 changes: 5 additions & 0 deletions doomsday/apps/client/src/ui/clientwindow.cpp
Expand Up @@ -635,6 +635,11 @@ DENG2_PIMPL(ClientWindow)
self().eventHandler().trapMouse();
}

if (Config::get().getb("audio.pauseOnFocus", true))
{
AudioSystem::get().pauseMusic(!hasFocus);
}

// Generate an event about this.
ddevent_t ev; de::zap(ev);
ev.device = -1;
Expand Down
34 changes: 18 additions & 16 deletions doomsday/apps/client/src/ui/dialogs/audiosettingsdialog.cpp
Expand Up @@ -33,6 +33,7 @@
#include <de/GridPopupWidget>
#include <de/VariableChoiceWidget>
#include <de/VariableSliderWidget>
#include <de/VariableToggleWidget>

using namespace de;
using namespace de::ui;
Expand All @@ -51,9 +52,10 @@ DENG_GUI_PIMPL(AudioSettingsDialog)
CVarToggleWidget *soundInfo;
GridPopupWidget *devPopup;
VariableChoiceWidget *fmodSpeakerMode;
VariableSliderWidget *sfxChannels;
VariableToggleWidget *pauseOnFocus;
VariableChoiceWidget *soundPlugin;
VariableChoiceWidget *musicPlugin;
VariableSliderWidget *sfxChannels;
#if defined (WIN32)
VariableChoiceWidget *cdPlugin;
#endif
Expand All @@ -62,6 +64,7 @@ DENG_GUI_PIMPL(AudioSettingsDialog)
Impl(Public *i) : Base(i)
{
ScrollAreaWidget &area = self().area();
area.enableIndicatorDraw(true);

if (DoomsdayApp::isGameLoaded())
{
Expand Down Expand Up @@ -94,9 +97,10 @@ DENG_GUI_PIMPL(AudioSettingsDialog)
devPopup->commit();
}

area.add(sfxChannels = new VariableSliderWidget(App::config("audio.channels"), Ranged(1, 64), 1.0));
area.add(soundPlugin = new VariableChoiceWidget(App::config("audio.soundPlugin"), VariableChoiceWidget::Text));
area.add(musicPlugin = new VariableChoiceWidget(App::config("audio.musicPlugin"), VariableChoiceWidget::Text));
area.add(sfxChannels = new VariableSliderWidget(App::config("audio.channels"), Ranged(1, 64), 1.0));
area.add(pauseOnFocus = new VariableToggleWidget("Pause on Focus Lost", App::config("audio.pauseOnFocus")));
area.add(soundPlugin = new VariableChoiceWidget(App::config("audio.soundPlugin"), VariableChoiceWidget::Text));
area.add(musicPlugin = new VariableChoiceWidget(App::config("audio.musicPlugin"), VariableChoiceWidget::Text));
#if defined (WIN32)
area.add(cdPlugin = new VariableChoiceWidget(App::config("audio.cdPlugin"), VariableChoiceWidget::Text));
#endif
Expand Down Expand Up @@ -209,22 +213,20 @@ AudioSettingsDialog::AudioSettingsDialog(String const &name)
auto *sfLabel = LabelWidget::newWithText(tr("MIDI Sound Font:"), &area());

// Layout.
layout << *sfxVolLabel << *d->sfxVolume
<< *musicVolLabel << *d->musicVolume
<< Const(0) << *d->sound3D
<< *rvbVolLabel << *d->reverbVolume
LabelWidget::appendSeparatorWithText("Sound Effects", &area(), &layout);
layout << *sfxVolLabel << *d->sfxVolume
<< Const(0) << *d->overlapStop
//<< *rateLabel << *d->sampleRate
//<< Const(0) << *d->sound16bit
<< Const(0) << *d->sound3D
<< *rvbVolLabel << *d->reverbVolume;

LabelWidget::appendSeparatorWithText("Music", &area(), &layout);
layout << *musicVolLabel << *d->musicVolume
<< *musSrcLabel << *d->musicSource
<< *sfLabel << *d->musicSoundfont;
<< *sfLabel << *d->musicSoundfont
<< Const(0) << *d->pauseOnFocus;
}

LabelWidget *pluginLabel = LabelWidget::newWithText(_E(D) + tr("Audio Backend"), &area());
pluginLabel->setFont("separator.label");
pluginLabel->margins().setTop("gap");
layout.setCellAlignment(Vector2i(0, layout.gridSize().y), ui::AlignLeft);
layout.append(*pluginLabel, 2);
LabelWidget::appendSeparatorWithText("Audio Backend", &area(), &layout);

layout << *LabelWidget::newWithText(tr("SFX Plugin:" ), &area()) << *d->soundPlugin
<< *LabelWidget::newWithText(tr("Music Plugin:"), &area()) << *d->musicPlugin;
Expand Down

0 comments on commit af6df1a

Please sign in to comment.