1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-19 20:53:52 +00:00

entering vanity mode

This commit is contained in:
greye 2012-08-17 23:25:29 +04:00
parent b6954a4e8d
commit d2b451eb7d
4 changed files with 57 additions and 9 deletions

View file

@ -31,6 +31,8 @@ namespace MWBase
virtual void setDragDrop(bool dragDrop) = 0;
virtual void toggleControlSwitch (const std::string& sw, bool value) = 0;
virtual void resetIdleTime() = 0;
};
}

View file

@ -92,6 +92,7 @@ namespace MWInput
std::map<std::string, bool> mControlSwitch;
float mPreviewPOVDelay;
float mTimeIdle;
/* InputImpl Methods */
public:
@ -99,11 +100,34 @@ public:
{
input.adjustMouseClippingSize(width, height);
}
void resetIdleTime()
{
if (mTimeIdle < 0) {
MWBase::Environment::get().getWorld()->toggleVanityMode(false, false);
}
mTimeIdle = 0.f;
}
private:
void updateIdleTime(float dt)
{
if (mTimeIdle >= 0.f) {
mTimeIdle += dt;
}
if (mTimeIdle > 30.f) {
MWBase::Environment::get().getWorld()->toggleVanityMode(true, false);
mTimeIdle = -1.f;
}
}
void toggleSpell()
{
if (windows.isGuiMode()) return;
resetIdleTime();
MWMechanics::DrawState_ state = player.getDrawState();
if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing)
{
@ -121,6 +145,8 @@ private:
{
if (windows.isGuiMode()) return;
resetIdleTime();
MWMechanics::DrawState_ state = player.getDrawState();
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
{
@ -200,18 +226,26 @@ private:
void activate()
{
resetIdleTime();
mEngine.activate();
}
void toggleAutoMove()
{
if (windows.isGuiMode()) return;
resetIdleTime();
player.setAutoMove (!player.getAutoMove());
}
void toggleWalking()
{
if (windows.isGuiMode()) return;
resetIdleTime();
player.toggleRunning();
}
@ -243,7 +277,8 @@ private:
windows(_windows),
mEngine (engine),
mDragDrop(false),
mPreviewPOVDelay(0.f)
mPreviewPOVDelay(0.f),
mTimeIdle(0.f)
{
using namespace OEngine::Input;
using namespace OEngine::Render;
@ -426,6 +461,19 @@ private:
}
}
}
// Idle time update despite of control switches
if (poller.isDown(A_MoveLeft) ||
poller.isDown(A_MoveRight) ||
poller.isDown(A_MoveForward) ||
poller.isDown(A_MoveBackward) ||
poller.isDown(A_Jump) ||
poller.isDown(A_Crouch) ||
poller.isDown(A_TogglePOV))
{
resetIdleTime();
} else {
updateIdleTime(duration);
}
}
// Switch between gui modes. Besides controlling the Gui windows
@ -472,11 +520,6 @@ private:
mControlSwitch[sw] = value;
}
bool getControlSwitch(const std::string &sw)
{
return mControlSwitch[sw];
}
void togglePOV()
{
MWBase::Environment::get().getWorld()->togglePOV();
@ -536,8 +579,8 @@ private:
impl->toggleControlSwitch(sw, value);
}
bool MWInputManager::getControlSwitch(const std::string &sw)
void MWInputManager::resetIdleTime()
{
return impl->getControlSwitch(sw);
impl->resetIdleTime();
}
}

View file

@ -61,7 +61,8 @@ namespace MWInput
virtual void setDragDrop(bool dragDrop);
void toggleControlSwitch(const std::string &sw, bool value);
bool getControlSwitch(const std::string &sw);
void resetIdleTime();
};
}
#endif

View file

@ -1,6 +1,7 @@
#include "mouselookevent.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
@ -17,6 +18,7 @@ void MouseLookEvent::event(Type type, int index, const void *p)
if (type != EV_MouseMove || mDisabled) {
return;
}
MWBase::Environment::get().getInputManager()->resetIdleTime();
MouseEvent *arg = (MouseEvent*)(p);