mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
entering vanity mode
This commit is contained in:
parent
b6954a4e8d
commit
d2b451eb7d
@ -31,6 +31,8 @@ namespace MWBase
|
|||||||
virtual void setDragDrop(bool dragDrop) = 0;
|
virtual void setDragDrop(bool dragDrop) = 0;
|
||||||
|
|
||||||
virtual void toggleControlSwitch (const std::string& sw, bool value) = 0;
|
virtual void toggleControlSwitch (const std::string& sw, bool value) = 0;
|
||||||
|
|
||||||
|
virtual void resetIdleTime() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ namespace MWInput
|
|||||||
std::map<std::string, bool> mControlSwitch;
|
std::map<std::string, bool> mControlSwitch;
|
||||||
|
|
||||||
float mPreviewPOVDelay;
|
float mPreviewPOVDelay;
|
||||||
|
float mTimeIdle;
|
||||||
|
|
||||||
/* InputImpl Methods */
|
/* InputImpl Methods */
|
||||||
public:
|
public:
|
||||||
@ -99,11 +100,34 @@ public:
|
|||||||
{
|
{
|
||||||
input.adjustMouseClippingSize(width, height);
|
input.adjustMouseClippingSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resetIdleTime()
|
||||||
|
{
|
||||||
|
if (mTimeIdle < 0) {
|
||||||
|
MWBase::Environment::get().getWorld()->toggleVanityMode(false, false);
|
||||||
|
}
|
||||||
|
mTimeIdle = 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
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()
|
void toggleSpell()
|
||||||
{
|
{
|
||||||
if (windows.isGuiMode()) return;
|
if (windows.isGuiMode()) return;
|
||||||
|
|
||||||
|
resetIdleTime();
|
||||||
|
|
||||||
MWMechanics::DrawState_ state = player.getDrawState();
|
MWMechanics::DrawState_ state = player.getDrawState();
|
||||||
if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing)
|
if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing)
|
||||||
{
|
{
|
||||||
@ -121,6 +145,8 @@ private:
|
|||||||
{
|
{
|
||||||
if (windows.isGuiMode()) return;
|
if (windows.isGuiMode()) return;
|
||||||
|
|
||||||
|
resetIdleTime();
|
||||||
|
|
||||||
MWMechanics::DrawState_ state = player.getDrawState();
|
MWMechanics::DrawState_ state = player.getDrawState();
|
||||||
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
|
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
|
||||||
{
|
{
|
||||||
@ -200,18 +226,26 @@ private:
|
|||||||
|
|
||||||
void activate()
|
void activate()
|
||||||
{
|
{
|
||||||
|
resetIdleTime();
|
||||||
|
|
||||||
mEngine.activate();
|
mEngine.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleAutoMove()
|
void toggleAutoMove()
|
||||||
{
|
{
|
||||||
if (windows.isGuiMode()) return;
|
if (windows.isGuiMode()) return;
|
||||||
|
|
||||||
|
resetIdleTime();
|
||||||
|
|
||||||
player.setAutoMove (!player.getAutoMove());
|
player.setAutoMove (!player.getAutoMove());
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleWalking()
|
void toggleWalking()
|
||||||
{
|
{
|
||||||
if (windows.isGuiMode()) return;
|
if (windows.isGuiMode()) return;
|
||||||
|
|
||||||
|
resetIdleTime();
|
||||||
|
|
||||||
player.toggleRunning();
|
player.toggleRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +277,8 @@ private:
|
|||||||
windows(_windows),
|
windows(_windows),
|
||||||
mEngine (engine),
|
mEngine (engine),
|
||||||
mDragDrop(false),
|
mDragDrop(false),
|
||||||
mPreviewPOVDelay(0.f)
|
mPreviewPOVDelay(0.f),
|
||||||
|
mTimeIdle(0.f)
|
||||||
{
|
{
|
||||||
using namespace OEngine::Input;
|
using namespace OEngine::Input;
|
||||||
using namespace OEngine::Render;
|
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
|
// Switch between gui modes. Besides controlling the Gui windows
|
||||||
@ -472,11 +520,6 @@ private:
|
|||||||
mControlSwitch[sw] = value;
|
mControlSwitch[sw] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getControlSwitch(const std::string &sw)
|
|
||||||
{
|
|
||||||
return mControlSwitch[sw];
|
|
||||||
}
|
|
||||||
|
|
||||||
void togglePOV()
|
void togglePOV()
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->togglePOV();
|
MWBase::Environment::get().getWorld()->togglePOV();
|
||||||
@ -536,8 +579,8 @@ private:
|
|||||||
impl->toggleControlSwitch(sw, value);
|
impl->toggleControlSwitch(sw, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWInputManager::getControlSwitch(const std::string &sw)
|
void MWInputManager::resetIdleTime()
|
||||||
{
|
{
|
||||||
return impl->getControlSwitch(sw);
|
impl->resetIdleTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,8 @@ namespace MWInput
|
|||||||
virtual void setDragDrop(bool dragDrop);
|
virtual void setDragDrop(bool dragDrop);
|
||||||
|
|
||||||
void toggleControlSwitch(const std::string &sw, bool value);
|
void toggleControlSwitch(const std::string &sw, bool value);
|
||||||
bool getControlSwitch(const std::string &sw);
|
|
||||||
|
void resetIdleTime();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "mouselookevent.hpp"
|
#include "mouselookevent.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/inputmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
@ -17,6 +18,7 @@ void MouseLookEvent::event(Type type, int index, const void *p)
|
|||||||
if (type != EV_MouseMove || mDisabled) {
|
if (type != EV_MouseMove || mDisabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MWBase::Environment::get().getInputManager()->resetIdleTime();
|
||||||
|
|
||||||
MouseEvent *arg = (MouseEvent*)(p);
|
MouseEvent *arg = (MouseEvent*)(p);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user