diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 7daafc726..f5dd8dee5 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -48,6 +48,8 @@ namespace MWInput , mUISensitivity (Settings::Manager::getFloat("ui sensitivity", "Input")) , mCameraYMultiplier (Settings::Manager::getFloat("camera y multiplier", "Input")) , mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input")) + , mPreviewPOVDelay(0.f) + , mTimeIdle(0.f) { Ogre::RenderWindow* window = ogre.getWindow (); size_t windowHnd; @@ -152,7 +154,6 @@ namespace MWInput if (currentValue == 1) { // trigger action activated - switch (action) { case A_GameMenu: @@ -171,24 +172,30 @@ namespace MWInput toggleConsole (); break; case A_Activate: + resetIdleTime(); activate(); break; case A_Journal: toggleJournal (); break; case A_AutoMove: + resetIdleTime(); toggleAutoMove (); break; case A_ToggleSneak: /// \todo implement + resetIdleTime(); break; case A_ToggleWalk: + resetIdleTime(); toggleWalking (); break; case A_ToggleWeapon: + resetIdleTime(); toggleWeapon (); break; case A_ToggleSpell: + resetIdleTime(); toggleSpell (); break; case A_QuickKey1: @@ -305,29 +312,18 @@ namespace MWInput } } } - - if (actionIsActive(A_MoveLeft) - || actionIsActive(A_MoveRight) - || actionIsActive(A_MoveForward) - || actionIsActive(A_MoveBackward) - || actionIsActive(A_Jump) - || actionIsActive(A_Crouch) - || actionIsActive(A_TogglePOV)) - - { - resetIdleTime (); - } - else + if (actionIsActive(A_MoveForward) || + actionIsActive(A_MoveBackward) || + actionIsActive(A_MoveLeft) || + actionIsActive(A_MoveRight) || + actionIsActive(A_Jump) || + actionIsActive(A_Crouch) || + actionIsActive(A_TogglePOV)) { - if (mTimeIdle >= 0.f) { - mTimeIdle += dt; - } - if (mTimeIdle > 30.f && !mWindows.isGuiMode()) { - MWBase::Environment::get().getWorld()->toggleVanityMode(true, false); - mTimeIdle = -1.f; - } + resetIdleTime(); + } else { + updateIdleTime(dt); } - } void InputManager::setDragDrop(bool dragDrop) @@ -348,10 +344,8 @@ namespace MWInput } else { - // Start mouse-looking again if allowed. - if (mControlSwitch["playerlooking"]) { - mMouseLookEnabled = true; - } + // Enable mouse look + mMouseLookEnabled = true; // Disable GUI events mGuiCursorEnabled = false; @@ -396,24 +390,14 @@ namespace MWInput } else if (sw == "playerjumping" && !value) { /// \fixme maybe crouching at this time mPlayer.setUpDown(0); + } else if (sw == "vanitymode") { + MWBase::Environment::get().getWorld()->allowVanityMode(value); } else if (sw == "playerlooking") { - if (value) { - mMouseLookEnabled = true; - } else { - mMouseLookEnabled = false; - } + MWBase::Environment::get().getWorld()->togglePlayerLooking(value); } mControlSwitch[sw] = value; } - void InputManager::resetIdleTime () - { - if (mTimeIdle < 0) { - MWBase::Environment::get().getWorld()->toggleVanityMode(false, false); - } - mTimeIdle = 0.f; - } - void InputManager::adjustMouseRegion(int width, int height) { const OIS::MouseState &ms = mMouse->getMouseState(); @@ -495,6 +479,8 @@ namespace MWInput if (mMouseLookEnabled) { + resetIdleTime(); + float x = arg.state.X.rel * mCameraSensitivity * 0.2; float y = arg.state.Y.rel * mCameraSensitivity * 0.2 * (mInvertY ? -1 : 1) * mUIYMultiplier; @@ -632,6 +618,25 @@ namespace MWInput Ogre::Root::getSingleton().queueEndRendering (); } + void InputManager::resetIdleTime() + { + if (mTimeIdle < 0) { + MWBase::Environment::get().getWorld()->toggleVanityMode(false, false); + } + mTimeIdle = 0.f; + } + + void InputManager::updateIdleTime(float dt) + { + if (mTimeIdle >= 0.f) { + mTimeIdle += dt; + } + if (mTimeIdle > 30.f) { + MWBase::Environment::get().getWorld()->toggleVanityMode(true, false); + mTimeIdle = -1.f; + } + } + bool InputManager::actionIsActive (int id) { return mInputCtrl->getChannel (id)->getValue () == 1; diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index a7a2df852..ffa222f44 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -83,7 +83,6 @@ namespace MWInput virtual void enableDetectingBindingMode (int action); virtual void resetToDefaultBindings(); - public: virtual bool keyPressed( const OIS::KeyEvent &arg ); virtual bool keyReleased( const OIS::KeyEvent &arg ); @@ -139,6 +138,8 @@ namespace MWInput float mUISensitivity; float mCameraYMultiplier; float mUIYMultiplier; + float mPreviewPOVDelay; + float mTimeIdle; bool mMouseLookEnabled; bool mGuiCursorEnabled; @@ -146,15 +147,14 @@ namespace MWInput float mMouseX; float mMouseY; - float mPreviewPOVDelay; - float mTimeIdle; - std::map mControlSwitch; - private: void adjustMouseRegion(int width, int height); + void resetIdleTime(); + void updateIdleTime(float dt); + private: void toggleMainMenu(); void toggleSpell(); @@ -175,8 +175,6 @@ namespace MWInput void loadKeyDefaults(bool force = false); - void resetIdleTime(); - private: enum Actions {