Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI|Control Panel|Client: Added Input Settings, removed old "Input" page
A new config variable (Config.input.mouse.syncSensitivity) controls whether the X and Y axis sensitivities are always the same when modifying them in Input Settings. Added an option to span cells in GridLayout, and sliders use double values for extra precision. Sliders also support applying a factor to the displayed values (does not affect the actual values).
- Loading branch information
Showing
13 changed files
with
382 additions
and
93 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,45 @@ | ||
/** @file inputsettingsdialog.h Dialog for input 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_INPUTSETTINGSDIALOG_H | ||
#define DENG_CLIENT_INPUTSETTINGSDIALOG_H | ||
|
||
#include "ui/widgets/dialogwidget.h" | ||
|
||
/** | ||
* Dialog for modifying input settings. | ||
*/ | ||
class InputSettingsDialog : public DialogWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
InputSettingsDialog(de::String const &name = "inputsettings"); | ||
|
||
public slots: | ||
void resetToDefaults(); | ||
|
||
protected slots: | ||
void mouseTogglesChanged(); | ||
void mouseSensitivityChanged(double value); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
#endif // DENG_CLIENT_INPUTSETTINGSDIALOG_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
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,185 @@ | ||
/** @file inputettingsdialog.cpp Dialog for input 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/inputsettingsdialog.h" | ||
#include "ui/widgets/cvarsliderwidget.h" | ||
#include "ui/widgets/cvartogglewidget.h" | ||
#include "ui/widgets/variabletogglewidget.h" | ||
|
||
#include "con_main.h" | ||
#include "SignalAction" | ||
#include <de/App> | ||
|
||
using namespace de; | ||
using namespace ui; | ||
|
||
DENG_GUI_PIMPL(InputSettingsDialog) | ||
{ | ||
VariableToggleWidget *syncMouse; | ||
CVarSliderWidget *mouseSensiX; | ||
CVarSliderWidget *mouseSensiY; | ||
ToggleWidget *mouseDisableX; | ||
ToggleWidget *mouseDisableY; | ||
ToggleWidget *mouseInvertX; | ||
ToggleWidget *mouseInvertY; | ||
CVarToggleWidget *joyEnable; | ||
|
||
Instance(Public *i) : Base(i) | ||
{ | ||
ScrollAreaWidget &area = self.area(); | ||
|
||
area.add(syncMouse = new VariableToggleWidget(App::config()["input.mouse.syncSensitivity"])); | ||
area.add(mouseSensiX = new CVarSliderWidget("input-mouse-x-scale")); | ||
area.add(mouseSensiY = new CVarSliderWidget("input-mouse-y-scale")); | ||
area.add(mouseDisableX = new ToggleWidget); | ||
area.add(mouseDisableY = new ToggleWidget); | ||
area.add(mouseInvertX = new ToggleWidget); | ||
area.add(mouseInvertY = new ToggleWidget); | ||
area.add(joyEnable = new CVarToggleWidget("input-joy")); | ||
} | ||
|
||
void fetch() | ||
{ | ||
mouseSensiX->updateFromCVar(); | ||
mouseSensiY->updateFromCVar(); | ||
joyEnable->updateFromCVar(); | ||
|
||
mouseDisableX->setActive(Con_GetInteger("input-mouse-x-flags") & IDA_DISABLED); | ||
mouseDisableY->setActive(Con_GetInteger("input-mouse-y-flags") & IDA_DISABLED); | ||
mouseInvertX->setActive(Con_GetInteger("input-mouse-x-flags") & IDA_INVERT); | ||
mouseInvertY->setActive(Con_GetInteger("input-mouse-y-flags") & IDA_INVERT); | ||
|
||
enableOrDisable(); | ||
} | ||
|
||
void enableOrDisable() | ||
{ | ||
mouseSensiX->disable(mouseDisableX->isActive()); | ||
mouseSensiY->disable(mouseDisableY->isActive()); | ||
mouseInvertX->disable(mouseDisableX->isActive()); | ||
mouseInvertY->disable(mouseDisableY->isActive()); | ||
} | ||
|
||
void updateMouseFlags() | ||
{ | ||
Con_SetInteger("input-mouse-x-flags", | ||
(mouseDisableX->isActive()? IDA_DISABLED : 0) | | ||
(mouseInvertX->isActive()? IDA_INVERT : 0)); | ||
|
||
Con_SetInteger("input-mouse-y-flags", | ||
(mouseDisableY->isActive()? IDA_DISABLED : 0) | | ||
(mouseInvertY->isActive()? IDA_INVERT : 0)); | ||
|
||
enableOrDisable(); | ||
} | ||
}; | ||
|
||
InputSettingsDialog::InputSettingsDialog(String const &name) | ||
: DialogWidget(name, WithHeading), d(new Instance(this)) | ||
{ | ||
heading().setText(tr("Input Settings")); | ||
|
||
d->syncMouse->setText(tr("Uniform Mouse Axis Sensitivity")); | ||
|
||
LabelWidget *mouseXLabel = new LabelWidget; | ||
mouseXLabel->setText(_E(b) + tr("Mouse X")); | ||
area().add(mouseXLabel); | ||
|
||
LabelWidget *mouseYLabel = new LabelWidget; | ||
mouseYLabel->setText(_E(b) + tr("Mouse Y")); | ||
area().add(mouseYLabel); | ||
|
||
mouseXLabel->margins().setTop(style().rules().rule("gap")); | ||
mouseYLabel->margins().setTop(style().rules().rule("gap")); | ||
|
||
// The sensitivity cvars are unlimited. | ||
d->mouseSensiX->setRange(Rangef(.00005f, .0075f)); | ||
d->mouseSensiX->setDisplayFactor(1000); | ||
d->mouseSensiY->setRange(Rangef(.00005f, .0075f)); | ||
d->mouseSensiY->setDisplayFactor(1000); | ||
|
||
connect(d->mouseSensiX, SIGNAL(valueChangedByUser(double)), this, SLOT(mouseSensitivityChanged(double))); | ||
connect(d->mouseSensiY, SIGNAL(valueChangedByUser(double)), this, SLOT(mouseSensitivityChanged(double))); | ||
|
||
d->mouseInvertX->setText(tr("Invert Axis")); | ||
d->mouseDisableX->setText(tr("Disable Axis")); | ||
|
||
d->mouseInvertY->setText(tr("Invert Axis")); | ||
d->mouseDisableY->setText(tr("Disable Axis")); | ||
|
||
connect(d->mouseInvertX, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), this, SLOT(mouseTogglesChanged())); | ||
connect(d->mouseInvertY, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), this, SLOT(mouseTogglesChanged())); | ||
connect(d->mouseDisableX, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), this, SLOT(mouseTogglesChanged())); | ||
connect(d->mouseDisableY, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)), this, SLOT(mouseTogglesChanged())); | ||
|
||
d->joyEnable->setText(tr("Joystick Enabled")); | ||
|
||
// Layout. | ||
GridLayout layout(area().contentRule().left(), area().contentRule().top()); | ||
layout.setGridSize(2, 0); | ||
//layout.setColumnAlignment(0, ui::AlignRight); | ||
layout.append(*d->joyEnable, 2) | ||
.append(*d->syncMouse, 2); | ||
layout << *mouseXLabel << *mouseYLabel | ||
<< *d->mouseSensiX << *d->mouseSensiY | ||
<< *d->mouseInvertX << *d->mouseInvertY | ||
<< *d->mouseDisableX << *d->mouseDisableY; | ||
|
||
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 InputSettingsDialog::resetToDefaults() | ||
{ | ||
Con_SetFloat ("input-mouse-x-scale", .001f); | ||
Con_SetFloat ("input-mouse-y-scale", .001f); | ||
Con_SetInteger("input-mouse-x-flags", 0 ); | ||
Con_SetInteger("input-mouse-y-flags", 0 ); | ||
Con_SetInteger("input-joy", 1 ); | ||
|
||
d->fetch(); | ||
} | ||
|
||
void InputSettingsDialog::mouseTogglesChanged() | ||
{ | ||
d->updateMouseFlags(); | ||
} | ||
|
||
void InputSettingsDialog::mouseSensitivityChanged(double value) | ||
{ | ||
// Keep mouse axes synced? | ||
if(d->syncMouse->isActive()) | ||
{ | ||
if(sender() == d->mouseSensiX) | ||
{ | ||
d->mouseSensiY->setValue(value); | ||
d->mouseSensiY->setCVarValueFromWidget(); | ||
} | ||
else | ||
{ | ||
d->mouseSensiX->setValue(value); | ||
d->mouseSensiX->setCVarValueFromWidget(); | ||
} | ||
} | ||
} |
Oops, something went wrong.