mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 01:56:44 +00:00 
			
		
		
		
	Derive sneaking state from character data
This commit is contained in:
		
							parent
							
								
									de83a41de6
								
							
						
					
					
						commit
						60491cc896
					
				
					 2 changed files with 8 additions and 5 deletions
				
			
		| 
						 | 
					@ -37,7 +37,6 @@ namespace MWInput
 | 
				
			||||||
        , mScreenCaptureHandler(screenCaptureHandler)
 | 
					        , mScreenCaptureHandler(screenCaptureHandler)
 | 
				
			||||||
        , mScreenCaptureOperation(screenCaptureOperation)
 | 
					        , mScreenCaptureOperation(screenCaptureOperation)
 | 
				
			||||||
        , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
 | 
					        , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
 | 
				
			||||||
        , mSneaking(false)
 | 
					 | 
				
			||||||
        , mAttemptJump(false)
 | 
					        , mAttemptJump(false)
 | 
				
			||||||
        , mTimeIdle(0.f)
 | 
					        , mTimeIdle(0.f)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -535,15 +534,20 @@ namespace MWInput
 | 
				
			||||||
        Settings::Manager::setBool("always run", "Input", mAlwaysRunActive);
 | 
					        Settings::Manager::setBool("always run", "Input", mAlwaysRunActive);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool ActionManager::isSneaking() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        const MWBase::Environment& env = MWBase::Environment::get();
 | 
				
			||||||
 | 
					        return env.getMechanicsManager()->isSneaking(env.getWorld()->getPlayer().getPlayer());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void ActionManager::toggleSneaking()
 | 
					    void ActionManager::toggleSneaking()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (MWBase::Environment::get().getWindowManager()->isGuiMode())
 | 
					        if (MWBase::Environment::get().getWindowManager()->isGuiMode())
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        if (!MWBase::Environment::get().getInputManager()->getControlSwitch("playercontrols"))
 | 
					        if (!MWBase::Environment::get().getInputManager()->getControlSwitch("playercontrols"))
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        mSneaking = !mSneaking;
 | 
					 | 
				
			||||||
        MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
 | 
					        MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
 | 
				
			||||||
        player.setSneak(mSneaking);
 | 
					        player.setSneak(!isSneaking());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void ActionManager::handleGuiArrowKey(int action)
 | 
					    void ActionManager::handleGuiArrowKey(int action)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ namespace MWInput
 | 
				
			||||||
        float getIdleTime() const { return mTimeIdle; }
 | 
					        float getIdleTime() const { return mTimeIdle; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool isAlwaysRunActive() const { return mAlwaysRunActive; }
 | 
					        bool isAlwaysRunActive() const { return mAlwaysRunActive; }
 | 
				
			||||||
        bool isSneaking() const { return mSneaking; }
 | 
					        bool isSneaking() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void setAttemptJump(bool enabled) { mAttemptJump = enabled; }
 | 
					        void setAttemptJump(bool enabled) { mAttemptJump = enabled; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,6 @@ namespace MWInput
 | 
				
			||||||
        osgViewer::ScreenCaptureHandler::CaptureOperation* mScreenCaptureOperation;
 | 
					        osgViewer::ScreenCaptureHandler::CaptureOperation* mScreenCaptureOperation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool mAlwaysRunActive;
 | 
					        bool mAlwaysRunActive;
 | 
				
			||||||
        bool mSneaking;
 | 
					 | 
				
			||||||
        bool mAttemptJump;
 | 
					        bool mAttemptJump;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        float mTimeIdle;
 | 
					        float mTimeIdle;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue