Skip to content

Commit

Permalink
Refactor|Client: Applied SettingsRegister for audio and video settings
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 5, 2013
1 parent eb28193 commit f759fb0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 12 deletions.
3 changes: 2 additions & 1 deletion doomsday/client/include/clientapp.h
Expand Up @@ -55,7 +55,8 @@ class ClientApp : public de::GuiApp
static bool haveApp();
static ClientApp &app();
static Updater &updater();
static SettingsRegister &rendererSettings();
static SettingsRegister &rendererSettings(); ///< @todo Belongs in a subsystem.
static SettingsRegister &audioSettings(); ///< @todo Belongs in AudioSystem.
static ServerLink &serverLink();
static InputSystem &inputSystem();
static WindowSystem &windowSystem();
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/ui/dialogs/videosettingsdialog.h
Expand Up @@ -32,6 +32,7 @@ class VideoSettingsDialog : public DialogWidget
VideoSettingsDialog(de::String const &name = "videosettings");

protected slots:
void resetToDefaults();
void changeMode(uint selected);
void changeColorDepth(uint selected);
void showColorAdjustments();
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/include/ui/windowsystem.h
Expand Up @@ -25,6 +25,7 @@

#include <de/System>
#include <de/String>
#include "SettingsRegister"

class ClientWindow;
class Style;
Expand All @@ -46,6 +47,8 @@ class WindowSystem : public de::System
public:
WindowSystem();

SettingsRegister &settings();

/**
* Constructs a new window using the default configuration. Note that the
* default configuration is saved persistently when the engine shuts down
Expand Down
20 changes: 19 additions & 1 deletion doomsday/client/src/clientapp.cpp
Expand Up @@ -37,6 +37,7 @@
#include "dd_main.h"
#include "dd_def.h"
#include "dd_loop.h"
#include "de_audio.h"
#include "con_main.h"
#include "sys_system.h"
#include "audio/s_main.h"
Expand Down Expand Up @@ -116,6 +117,7 @@ DENG2_PIMPL(ClientApp)
{
QScopedPointer<Updater> updater;
SettingsRegister rendererSettings;
SettingsRegister audioSettings;
QMenuBar *menuBar;
InputSystem *inputSys;
QScopedPointer<WidgetActions> widgetActions;
Expand Down Expand Up @@ -181,7 +183,8 @@ DENG2_PIMPL(ClientApp)

void initSettings()
{
// Renderer settings.
/// @todo These belong in their respective subsystems.

rendererSettings
.define(SettingsRegister::FloatCVar, "rend-camera-fov", 95.f)
.define(SettingsRegister::IntCVar, "rend-model-mirror-hud", 0)
Expand All @@ -196,6 +199,16 @@ DENG2_PIMPL(ClientApp)
.define(SettingsRegister::IntCVar, "rend-dev-sector-show-indices", 0)
.define(SettingsRegister::IntCVar, "rend-dev-vertex-show-indices", 0)
.define(SettingsRegister::IntCVar, "rend-dev-generator-show-indices", 0);

audioSettings
.define(SettingsRegister::IntCVar, "sound-volume", 255)
.define(SettingsRegister::IntCVar, "music-volume", 255)
.define(SettingsRegister::FloatCVar, "sound-reverb-volume", 0.5f)
.define(SettingsRegister::IntCVar, "sound-info", 0)
.define(SettingsRegister::IntCVar, "sound-rate", 11025)
.define(SettingsRegister::IntCVar, "sound-16bit", 0)
.define(SettingsRegister::IntCVar, "sound-3d", 0)
.define(SettingsRegister::IntCVar, "music-source", MUSP_EXT);
}
};

Expand Down Expand Up @@ -335,6 +348,11 @@ SettingsRegister &ClientApp::rendererSettings()
return app().d->rendererSettings;
}

SettingsRegister &ClientApp::audioSettings()
{
return app().d->audioSettings;
}

ServerLink &ClientApp::serverLink()
{
ClientApp &a = ClientApp::app();
Expand Down
10 changes: 2 additions & 8 deletions doomsday/client/src/ui/dialogs/audiosettingsdialog.cpp
Expand Up @@ -21,6 +21,7 @@
#include "ui/widgets/cvartogglewidget.h"
#include "ui/widgets/cvarchoicewidget.h"

#include "clientapp.h"
#include "de_audio.h"
#include "con_main.h"
#include "SignalAction"
Expand Down Expand Up @@ -119,14 +120,7 @@ AudioSettingsDialog::AudioSettingsDialog(String const &name)

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 );
Con_SetInteger("music-source", MUSP_EXT);
ClientApp::audioSettings().resetToDefaults();

d->fetch();
}
12 changes: 10 additions & 2 deletions doomsday/client/src/ui/dialogs/videosettingsdialog.cpp
Expand Up @@ -27,8 +27,8 @@
#include "SignalAction"
#include "ui/clientwindow.h"
#include "con_main.h"
#include "clientapp.h"

#include <de/App>
#include <de/DisplayMode>
#include <QPoint>

Expand Down Expand Up @@ -189,7 +189,8 @@ VideoSettingsDialog::VideoSettingsDialog(String const &name)
#endif

buttons().items()
<< new DialogButtonItem(DialogWidget::Action, tr("Reset to Defaults"))
<< new DialogButtonItem(DialogWidget::Action, tr("Reset to Defaults"),
new SignalAction(this, SLOT(resetToDefaults())))
<< new DialogButtonItem(DialogWidget::Action, tr("Color Adjustments..."),
new SignalAction(this, SLOT(showColorAdjustments())));

Expand Down Expand Up @@ -226,6 +227,13 @@ VideoSettingsDialog::VideoSettingsDialog(String const &name)
#endif
}

void VideoSettingsDialog::resetToDefaults()
{
ClientApp::windowSystem().settings().resetToDefaults();

d->fetch();
}

void VideoSettingsDialog::changeMode(uint selected)
{
QPoint res = d->modes->items().at(selected).data().toPoint();
Expand Down
11 changes: 11 additions & 0 deletions doomsday/client/src/ui/windowsystem.cpp
Expand Up @@ -28,6 +28,8 @@ using namespace de;

DENG2_PIMPL(WindowSystem)
{
SettingsRegister settings;

typedef QMap<String, ClientWindow *> Windows;
Windows windows;
Style style;
Expand All @@ -38,6 +40,10 @@ DENG2_PIMPL(WindowSystem)

Instance(Public *i) : Base(i), mouseMoved(false)
{
settings.define(SettingsRegister::ConfigVariable, "window.main.showFps")
.define(SettingsRegister::IntCVar, "vid-fsaa", 1)
.define(SettingsRegister::IntCVar, "vid-vsync", 1);

style.load(App::fileSystem().find("defaultstyle.pack").path());
}

Expand Down Expand Up @@ -67,6 +73,11 @@ WindowSystem::WindowSystem()
ClientWindow::setDefaultGLFormat();
}

SettingsRegister &WindowSystem::settings()
{
return d->settings;
}

ClientWindow *WindowSystem::createWindow(String const &id)
{
DENG2_ASSERT(!d->windows.contains(id));
Expand Down

0 comments on commit f759fb0

Please sign in to comment.