Merge branch 'master' into quick_keys

actorid
scrawl 13 years ago
commit a4c1d979d6

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

@ -83,7 +83,6 @@ namespace MWInput
virtual void enableDetectingBindingMode (int action); virtual void enableDetectingBindingMode (int action);
virtual void resetToDefaultBindings(); virtual void resetToDefaultBindings();
public: public:
virtual bool keyPressed( const OIS::KeyEvent &arg ); virtual bool keyPressed( const OIS::KeyEvent &arg );
virtual bool keyReleased( const OIS::KeyEvent &arg ); virtual bool keyReleased( const OIS::KeyEvent &arg );
@ -139,6 +138,8 @@ namespace MWInput
float mUISensitivity; float mUISensitivity;
float mCameraYMultiplier; float mCameraYMultiplier;
float mUIYMultiplier; float mUIYMultiplier;
float mPreviewPOVDelay;
float mTimeIdle;
bool mMouseLookEnabled; bool mMouseLookEnabled;
bool mGuiCursorEnabled; bool mGuiCursorEnabled;
@ -146,15 +147,14 @@ namespace MWInput
float mMouseX; float mMouseX;
float mMouseY; float mMouseY;
float mPreviewPOVDelay;
float mTimeIdle;
std::map<std::string, bool> mControlSwitch; std::map<std::string, bool> mControlSwitch;
private: private:
void adjustMouseRegion(int width, int height); void adjustMouseRegion(int width, int height);
void resetIdleTime();
void updateIdleTime(float dt);
private: private:
void toggleMainMenu(); void toggleMainMenu();
void toggleSpell(); void toggleSpell();
@ -175,8 +175,6 @@ namespace MWInput
void loadKeyDefaults(bool force = false); void loadKeyDefaults(bool force = false);
void resetIdleTime();
private: private:
enum Actions enum Actions
{ {

Loading…
Cancel
Save