From ba7fc8609cb2fadda7941431ef7585a64772d0bf Mon Sep 17 00:00:00 2001 From: Ivy Foster Date: Sun, 8 Mar 2015 15:23:46 -0500 Subject: [PATCH] Add toggle sneak option; fix bug #2119 To enable toggle sneak mode, set "toggle sneak = true" in the [Input] section of settings.cfg. Outstanding issues: - In toggle sneak mode, holding the Sneak button causes rapid, repeated toggling. - The button in the settings menu doesn't do anything. --- apps/openmw/mwinput/inputmanagerimp.cpp | 19 ++++++++++++++++++- apps/openmw/mwinput/inputmanagerimp.hpp | 3 +++ files/mygui/openmw_settings_window.layout | 18 ++++++++++++++---- files/settings-default.cfg | 2 ++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 21576785ca..462008b097 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -124,6 +124,8 @@ namespace MWInput , mTimeIdle(0.f) , mOverencumberedMessageDelay(0.f) , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) + , mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input")) + , mSneaking(false) , mAttemptJump(false) , mControlsDisabled(false) , mJoystickLastUsed(false) @@ -522,7 +524,16 @@ namespace MWInput } } - mPlayer->setSneak(actionIsActive(A_Sneak)); + if (mSneakToggles) + { + if (actionIsActive(A_Sneak)) + { + toggleSneaking(); + mPlayer->setSneak(mSneaking); + } + } + else + mPlayer->setSneak(actionIsActive(A_Sneak)); if (mAttemptJump && mControlSwitch["playerjumping"]) { @@ -1089,6 +1100,12 @@ namespace MWInput Settings::Manager::setBool("always run", "Input", mAlwaysRunActive); } + void InputManager::toggleSneaking() + { + if (MWBase::Environment::get().getWindowManager()->isGuiMode()) return; + mSneaking = !mSneaking; + } + void InputManager::resetIdleTime() { if (mTimeIdle < 0) diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 39091b7b11..5588010236 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -180,6 +180,8 @@ namespace MWInput int mMouseWheel; bool mUserFileExists; bool mAlwaysRunActive; + bool mSneakToggles; + bool mSneaking; bool mAttemptJump; std::map mControlSwitch; @@ -208,6 +210,7 @@ namespace MWInput void toggleJournal(); void activate(); void toggleWalking(); + void toggleSneaking(); void toggleAutoMove(); void rest(); void quickLoad(); diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 2efd5841ed..73d05600ab 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -196,10 +196,20 @@ - + + + + + + + + + + + - + @@ -209,11 +219,11 @@ - + - + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 19b570e2ad..de22e1b56b 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -194,6 +194,8 @@ always run = false allow third person zoom = false +toggle sneak = false + [Game] # Always use the most powerful attack when striking with a weapon (chop, slash or thrust) best attack = false