From 7057d5c40c0ecdedd14f4c6ca0145f5df4f66bd7 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 15 Feb 2016 12:38:40 -0800 Subject: [PATCH 1/4] Snap Turn avatar preference. (Still tied to Developer menu item.) --- interface/resources/qml/hifi/MenuOption.qml | 1 - interface/src/ui/PreferencesDialog.cpp | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/MenuOption.qml b/interface/resources/qml/hifi/MenuOption.qml index 3add333236..9ebf5adb54 100644 --- a/interface/resources/qml/hifi/MenuOption.qml +++ b/interface/resources/qml/hifi/MenuOption.qml @@ -35,7 +35,6 @@ QtObject { readonly property string centerPlayerInView: "Center Player In View"; readonly property string chat: "Chat..."; readonly property string collisions: "Collisions"; - readonly property string comfortMode: "Comfort Mode"; readonly property string connexion: "Activate 3D Connexion Devices"; readonly property string console_: "Console..."; readonly property string controlWithSpeech: "Control With Speech"; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index b1812b7bd3..fb39bbc062 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -57,7 +57,11 @@ void setupPreferences() { auto preference = new AvatarPreference(AVATAR_BASICS, "Appearance: ", getter, setter); preferences->addPreference(preference); } - + { + auto getter = []()->bool {return Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode); }; + auto setter = [](bool value) { Menu::getInstance()->setIsOptionChecked(MenuOption::ComfortMode, value); }; + preferences->addPreference(new CheckPreference(AVATAR_BASICS, "Snap Turn", getter, setter)); + } { auto getter = []()->QString { return Snapshot::snapshotsLocation.get(); }; auto setter = [](const QString& value) { Snapshot::snapshotsLocation.set(value); }; From 20406a5a14b76c6707fd03bdc576c70cf3ae2fb6 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 15 Feb 2016 13:26:40 -0800 Subject: [PATCH 2/4] Remove comfortMode menu item, but add a Settings for snapTurn within MyAvatar. --- interface/src/Application.cpp | 2 +- interface/src/Menu.cpp | 1 - interface/src/Menu.h | 1 - interface/src/avatar/MyAvatar.cpp | 2 ++ interface/src/avatar/MyAvatar.h | 4 ++++ interface/src/ui/PreferencesDialog.cpp | 4 ++-- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0faf3b1fe2..c8b2e89432 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -850,7 +850,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : return (float)qApp->getAvatarUpdater()->isHMDMode(); })); _applicationStateDevice->addInputVariant(QString("ComfortMode"), controller::StateController::ReadLambda([]() -> float { - return (float)Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode); + return (float)qApp->getMyAvatar()->getSnapTurn(); })); _applicationStateDevice->addInputVariant(QString("Grounded"), controller::StateController::ReadLambda([]() -> float { return (float)qApp->getMyAvatar()->getCharacterController()->onGround(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 964e660dd0..caab3d52d4 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -490,7 +490,6 @@ Menu::Menu() { avatar, SLOT(setEnableMeshVisible(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::TurnWithHead, 0, false); - addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::UseAnimPreAndPostRotations, 0, false, avatar, SLOT(setUseAnimPreAndPostRotations(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableInverseKinematics, 0, true, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index ce53b11178..6cc6121720 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -177,7 +177,6 @@ namespace MenuOption { const QString CenterPlayerInView = "Center Player In View"; const QString Chat = "Chat..."; const QString Collisions = "Collisions"; - const QString ComfortMode = "Comfort Mode"; const QString Connexion = "Activate 3D Connexion Devices"; const QString Console = "Console..."; const QString ControlWithSpeech = "Control With Speech"; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 0f96f67a7d..56584df44e 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -653,6 +653,7 @@ void MyAvatar::saveData() { settings.setValue("displayName", _displayName); settings.setValue("collisionSoundURL", _collisionSoundURL); + settings.setValue("snapTurn", _useSnapTurn); settings.endGroup(); } @@ -746,6 +747,7 @@ void MyAvatar::loadData() { setDisplayName(settings.value("displayName").toString()); setCollisionSoundURL(settings.value("collisionSoundURL", DEFAULT_AVATAR_COLLISION_SOUND_URL).toString()); + setSnapTurn(settings.value("snapTurn").toBool()); settings.endGroup(); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 3e026398b4..98d25a64c8 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -151,6 +151,9 @@ public: // Removes a handler previously added by addAnimationStateHandler. Q_INVOKABLE void removeAnimationStateHandler(QScriptValue handler) { _rig->removeAnimationStateHandler(handler); } + Q_INVOKABLE bool getSnapTurn() const { return _useSnapTurn; } + Q_INVOKABLE void setSnapTurn(bool on) { _useSnapTurn = on; } + // get/set avatar data void saveData(); void loadData(); @@ -370,6 +373,7 @@ private: QUrl _fullAvatarURLFromPreferences; QString _fullAvatarModelName; QUrl _animGraphUrl {""}; + bool _useSnapTurn { true }; // cache of the current HMD sensor position and orientation // in sensor space. diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index fb39bbc062..9dae995175 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -58,8 +58,8 @@ void setupPreferences() { preferences->addPreference(preference); } { - auto getter = []()->bool {return Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode); }; - auto setter = [](bool value) { Menu::getInstance()->setIsOptionChecked(MenuOption::ComfortMode, value); }; + auto getter = [=]()->bool {return myAvatar->getSnapTurn(); }; + auto setter = [=](bool value) { myAvatar->setSnapTurn(value); }; preferences->addPreference(new CheckPreference(AVATAR_BASICS, "Snap Turn", getter, setter)); } { From 4150d318d318b3747e5d57f8b8d77df6ce958c17 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 15 Feb 2016 13:39:53 -0800 Subject: [PATCH 3/4] "Leave it on by default" (and change name of route variable to SnapTurn). --- interface/resources/controllers/keyboardMouse.json | 6 +++--- interface/resources/controllers/standard.json | 2 +- interface/src/Application.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/resources/controllers/keyboardMouse.json b/interface/resources/controllers/keyboardMouse.json index 5d7930a59b..c76c35b86e 100644 --- a/interface/resources/controllers/keyboardMouse.json +++ b/interface/resources/controllers/keyboardMouse.json @@ -18,7 +18,7 @@ [ "Keyboard.MouseMoveRight" ] ] }, - "when": [ "Application.InHMD", "Application.ComfortMode", "Keyboard.RightMouseButton" ], + "when": [ "Application.SnapTurn", "Keyboard.RightMouseButton" ], "to": "Actions.StepYaw", "filters": [ @@ -34,7 +34,7 @@ [ "Keyboard.TouchpadRight" ] ] }, - "when": [ "Application.InHMD", "Application.ComfortMode" ], + "when": [ "Application.SnapTurn" ], "to": "Actions.StepYaw", "filters": [ @@ -49,7 +49,7 @@ ["Keyboard.D", "Keyboard.Right"] ] }, - "when": [ "Application.InHMD", "Application.ComfortMode" ], + "when": [ "Application.SnapTurn" ], "to": "Actions.StepYaw", "filters": [ diff --git a/interface/resources/controllers/standard.json b/interface/resources/controllers/standard.json index 6a8fc0d803..e1308545a3 100644 --- a/interface/resources/controllers/standard.json +++ b/interface/resources/controllers/standard.json @@ -5,7 +5,7 @@ { "from": "Standard.LX", "to": "Actions.TranslateX" }, { "from": "Standard.RX", - "when": [ "Application.InHMD", "Application.ComfortMode" ], + "when": [ "Application.SnapTurn" ], "to": "Actions.StepYaw", "filters": [ diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c8b2e89432..fd58c5b1da 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -849,7 +849,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _applicationStateDevice->addInputVariant(QString("InHMD"), controller::StateController::ReadLambda([]() -> float { return (float)qApp->getAvatarUpdater()->isHMDMode(); })); - _applicationStateDevice->addInputVariant(QString("ComfortMode"), controller::StateController::ReadLambda([]() -> float { + _applicationStateDevice->addInputVariant(QString("SnapTurn"), controller::StateController::ReadLambda([]() -> float { return (float)qApp->getMyAvatar()->getSnapTurn(); })); _applicationStateDevice->addInputVariant(QString("Grounded"), controller::StateController::ReadLambda([]() -> float { From 6d70584b5a33dcbb1739e3b7d1e87332ee660378 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Tue, 16 Feb 2016 18:09:56 -0800 Subject: [PATCH 4/4] Change name and use only when in HMD. --- interface/resources/controllers/keyboardMouse.json | 6 +++--- interface/resources/controllers/standard.json | 2 +- interface/src/ui/PreferencesDialog.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/resources/controllers/keyboardMouse.json b/interface/resources/controllers/keyboardMouse.json index c76c35b86e..0037e3741d 100644 --- a/interface/resources/controllers/keyboardMouse.json +++ b/interface/resources/controllers/keyboardMouse.json @@ -18,7 +18,7 @@ [ "Keyboard.MouseMoveRight" ] ] }, - "when": [ "Application.SnapTurn", "Keyboard.RightMouseButton" ], + "when": [ "Application.InHMD", "Application.SnapTurn", "Keyboard.RightMouseButton" ], "to": "Actions.StepYaw", "filters": [ @@ -34,7 +34,7 @@ [ "Keyboard.TouchpadRight" ] ] }, - "when": [ "Application.SnapTurn" ], + "when": [ "Application.InHMD", "Application.SnapTurn" ], "to": "Actions.StepYaw", "filters": [ @@ -49,7 +49,7 @@ ["Keyboard.D", "Keyboard.Right"] ] }, - "when": [ "Application.SnapTurn" ], + "when": [ "Application.InHMD", "Application.SnapTurn" ], "to": "Actions.StepYaw", "filters": [ diff --git a/interface/resources/controllers/standard.json b/interface/resources/controllers/standard.json index e1308545a3..5dd6c0641d 100644 --- a/interface/resources/controllers/standard.json +++ b/interface/resources/controllers/standard.json @@ -5,7 +5,7 @@ { "from": "Standard.LX", "to": "Actions.TranslateX" }, { "from": "Standard.RX", - "when": [ "Application.SnapTurn" ], + "when": [ "Application.InHMD", "Application.SnapTurn" ], "to": "Actions.StepYaw", "filters": [ diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 9dae995175..80f2989127 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -60,7 +60,7 @@ void setupPreferences() { { auto getter = [=]()->bool {return myAvatar->getSnapTurn(); }; auto setter = [=](bool value) { myAvatar->setSnapTurn(value); }; - preferences->addPreference(new CheckPreference(AVATAR_BASICS, "Snap Turn", getter, setter)); + preferences->addPreference(new CheckPreference(AVATAR_BASICS, "Snap Turn when in HMD", getter, setter)); } { auto getter = []()->QString { return Snapshot::snapshotsLocation.get(); };