Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
UI|Task Bar|Client: Added the Audio Settings dialog
The Audio Settings dialog replicates the options from the Control Panel's Audio page. Also added a specialized toggle widget for toggling cvars.
- Loading branch information
Showing
13 changed files
with
336 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** @file audiosettingsdialog.h Dialog for audio settings. | ||
* | ||
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_AUDIOSETTINGSDIALOG_H | ||
#define DENG_CLIENT_AUDIOSETTINGSDIALOG_H | ||
|
||
#include "ui/widgets/dialogwidget.h" | ||
|
||
/** | ||
* Dialog for modifying video settings. | ||
*/ | ||
class AudioSettingsDialog : public DialogWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
AudioSettingsDialog(de::String const &name = "audiosettings"); | ||
|
||
public slots: | ||
void resetToDefaults(); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
#endif // DENG_CLIENT_AUDIOSETTINGSDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** @file cvartogglewidget.h Console variable toggle. | ||
* | ||
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_CVARTOGGLEWIDGET_H | ||
#define DENG_CLIENT_CVARTOGGLEWIDGET_H | ||
|
||
#include "togglewidget.h" | ||
|
||
/** | ||
* Console variable toggle for on/off type of cvars (value 0 or 1). | ||
*/ | ||
class CVarToggleWidget : public ToggleWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
CVarToggleWidget(char const *cvarPath); | ||
|
||
public slots: | ||
void updateFromCVar(); | ||
|
||
protected slots: | ||
void setCVarValueFromWidget(); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
#endif // DENG_CLIENT_CVARTOGGLEWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** @file audiosettingsdialog.cpp Dialog for audio settings. | ||
* | ||
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "ui/dialogs/audiosettingsdialog.h" | ||
#include "ui/widgets/cvarsliderwidget.h" | ||
#include "ui/widgets/cvartogglewidget.h" | ||
#include "ui/widgets/choicewidget.h" | ||
|
||
#include "con_main.h" | ||
#include "SignalAction" | ||
|
||
using namespace de; | ||
using namespace ui; | ||
|
||
DENG_GUI_PIMPL(AudioSettingsDialog) | ||
{ | ||
CVarSliderWidget *sfxVolume; | ||
CVarSliderWidget *musicVolume; | ||
CVarSliderWidget *reverbVolume; | ||
CVarToggleWidget *sound3D; | ||
CVarToggleWidget *sound16bit; | ||
ChoiceWidget *sampleRate; | ||
CVarToggleWidget *soundInfo; | ||
|
||
Instance(Public *i) : Base(i) | ||
{ | ||
ScrollAreaWidget &area = self.area(); | ||
|
||
area.add(sfxVolume = new CVarSliderWidget("sound-volume")); | ||
area.add(musicVolume = new CVarSliderWidget("music-volume")); | ||
area.add(reverbVolume = new CVarSliderWidget("sound-reverb-volume")); | ||
area.add(sound3D = new CVarToggleWidget("sound-3d")); | ||
area.add(sound16bit = new CVarToggleWidget("sound-16bit")); | ||
area.add(sampleRate = new ChoiceWidget); | ||
area.add(soundInfo = new CVarToggleWidget("sound-info")); | ||
} | ||
|
||
void fetch() | ||
{ | ||
sfxVolume->updateFromCVar(); | ||
musicVolume->updateFromCVar(); | ||
reverbVolume->updateFromCVar(); | ||
sound3D->updateFromCVar(); | ||
sound16bit->updateFromCVar(); | ||
soundInfo->updateFromCVar(); | ||
|
||
// Update the selected sample rate. | ||
sampleRate->setSelected(sampleRate->items().findData(Con_GetInteger("sound-rate"))); | ||
} | ||
}; | ||
|
||
AudioSettingsDialog::AudioSettingsDialog(String const &name) | ||
: DialogWidget(name, WithHeading), d(new Instance(this)) | ||
{ | ||
heading().setText(tr("Audio Settings")); | ||
|
||
LabelWidget *sfxVolLabel = new LabelWidget; | ||
sfxVolLabel->setText(tr("SFX Volume:")); | ||
area().add(sfxVolLabel); | ||
|
||
LabelWidget *musicVolLabel = new LabelWidget; | ||
musicVolLabel->setText(tr("Music Volume:")); | ||
area().add(musicVolLabel); | ||
|
||
LabelWidget *rvbVolLabel = new LabelWidget; | ||
rvbVolLabel->setText(tr("Reverb Volume:")); | ||
area().add(rvbVolLabel); | ||
|
||
d->sound3D->setText(tr("3D Effects & Reverb")); | ||
d->sound16bit->setText(tr("16-bit Resampling")); | ||
|
||
LabelWidget *rateLabel = new LabelWidget; | ||
rateLabel->setText(tr("Resampling:")); | ||
area().add(rateLabel); | ||
|
||
d->sampleRate->items() | ||
<< new ChoiceItem(tr("1x @ 11025 Hz"), 11025) | ||
<< new ChoiceItem(tr("2x @ 22050 Hz"), 22050) | ||
<< new ChoiceItem(tr("4x @ 44100 Hz"), 44100); | ||
|
||
d->soundInfo->setText(tr("Developer Info")); | ||
|
||
// Layout. | ||
GridLayout layout(area().contentRule().left(), area().contentRule().top()); | ||
layout.setGridSize(2, 0); | ||
layout.setColumnAlignment(0, ui::AlignRight); | ||
layout << *sfxVolLabel << *d->sfxVolume | ||
<< *musicVolLabel << *d->musicVolume | ||
<< *rvbVolLabel << *d->reverbVolume | ||
<< Const(0) << *d->sound3D | ||
<< *rateLabel << *d->sampleRate | ||
<< Const(0) << *d->sound16bit | ||
<< Const(0) << *d->soundInfo; | ||
|
||
area().setContentSize(layout.width(), layout.height()); | ||
|
||
buttons().items() | ||
<< new DialogButtonItem(DialogWidget::Default | DialogWidget::Accept, tr("Close")) | ||
<< new DialogButtonItem(DialogWidget::Action, tr("Reset to Defaults"), | ||
new SignalAction(this, SLOT(resetToDefaults()))); | ||
|
||
d->fetch(); | ||
} | ||
|
||
void AudioSettingsDialog::resetToDefaults() | ||
{ | ||
Con_SetInteger("sound-volume", 255 ); | ||
Con_SetInteger("music-volume", 255 ); | ||
Con_SetFloat ("sound-reverb-volume", 0.5f ); | ||
Con_SetInteger("sound-info", 0 ); | ||
Con_SetInteger("sound-rate", 11025); | ||
Con_SetInteger("sound-16bit", 0 ); | ||
Con_SetInteger("sound-3d", 0 ); | ||
|
||
d->fetch(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** @file cvartogglewidget.cpp Console variable toggle. | ||
* | ||
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "ui/widgets/cvartogglewidget.h" | ||
#include "con_main.h" | ||
|
||
using namespace de; | ||
using namespace ui; | ||
|
||
DENG2_PIMPL_NOREF(CVarToggleWidget) | ||
{ | ||
char const *cvar; | ||
|
||
cvar_t *var() const | ||
{ | ||
cvar_t *cv = Con_FindVariable(cvar); | ||
DENG2_ASSERT(cv != 0); | ||
return cv; | ||
} | ||
}; | ||
|
||
CVarToggleWidget::CVarToggleWidget(char const *cvarPath) : d(new Instance) | ||
{ | ||
d->cvar = cvarPath; | ||
updateFromCVar(); | ||
|
||
connect(this, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), | ||
this, SLOT(setCVarValueFromWidget())); | ||
} | ||
|
||
void CVarToggleWidget::updateFromCVar() | ||
{ | ||
setActive(CVar_Integer(d->var()) != 0); | ||
} | ||
|
||
void CVarToggleWidget::setCVarValueFromWidget() | ||
{ | ||
CVar_SetInteger(d->var(), isActive()? 1 : 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.