forked from teamnwah/openmw-tes3coop
add support for some scripting player control switches
This commit is contained in:
parent
ff62770657
commit
16ad97610d
4 changed files with 67 additions and 29 deletions
|
@ -90,6 +90,7 @@ namespace MWInput
|
||||||
|
|
||||||
bool mDragDrop;
|
bool mDragDrop;
|
||||||
|
|
||||||
|
std::map<std::string, bool> mControlSwitch;
|
||||||
|
|
||||||
/* InputImpl Methods */
|
/* InputImpl Methods */
|
||||||
public:
|
public:
|
||||||
|
@ -339,6 +340,14 @@ private:
|
||||||
|
|
||||||
poller.bind(A_Jump, KC_E);
|
poller.bind(A_Jump, KC_E);
|
||||||
poller.bind(A_Crouch, KC_LCONTROL);
|
poller.bind(A_Crouch, KC_LCONTROL);
|
||||||
|
|
||||||
|
mControlSwitch["playercontrols"] = true;
|
||||||
|
mControlSwitch["playerfighting"] = true;
|
||||||
|
mControlSwitch["playerjumping"] = true;
|
||||||
|
mControlSwitch["playerlooking"] = true;
|
||||||
|
mControlSwitch["playermagic"] = true;
|
||||||
|
mControlSwitch["playerviewswitch"] = true;
|
||||||
|
mControlSwitch["vanitymode"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDragDrop(bool dragDrop)
|
void setDragDrop(bool dragDrop)
|
||||||
|
@ -366,33 +375,35 @@ private:
|
||||||
|
|
||||||
// Configure player movement according to keyboard input. Actual movement will
|
// Configure player movement according to keyboard input. Actual movement will
|
||||||
// be done in the physics system.
|
// be done in the physics system.
|
||||||
if (poller.isDown(A_MoveLeft))
|
if (mControlSwitch["playercontrols"]) {
|
||||||
{
|
if (poller.isDown(A_MoveLeft))
|
||||||
player.setAutoMove (false);
|
{
|
||||||
player.setLeftRight (1);
|
player.setAutoMove (false);
|
||||||
}
|
player.setLeftRight (1);
|
||||||
else if (poller.isDown(A_MoveRight))
|
}
|
||||||
{
|
else if (poller.isDown(A_MoveRight))
|
||||||
player.setAutoMove (false);
|
{
|
||||||
player.setLeftRight (-1);
|
player.setAutoMove (false);
|
||||||
}
|
player.setLeftRight (-1);
|
||||||
else
|
}
|
||||||
player.setLeftRight (0);
|
else
|
||||||
|
player.setLeftRight (0);
|
||||||
|
|
||||||
if (poller.isDown(A_MoveForward))
|
if (poller.isDown(A_MoveForward))
|
||||||
{
|
{
|
||||||
player.setAutoMove (false);
|
player.setAutoMove (false);
|
||||||
player.setForwardBackward (1);
|
player.setForwardBackward (1);
|
||||||
|
}
|
||||||
|
else if (poller.isDown(A_MoveBackward))
|
||||||
|
{
|
||||||
|
player.setAutoMove (false);
|
||||||
|
player.setForwardBackward (-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.setForwardBackward (0);
|
||||||
}
|
}
|
||||||
else if (poller.isDown(A_MoveBackward))
|
|
||||||
{
|
|
||||||
player.setAutoMove (false);
|
|
||||||
player.setForwardBackward (-1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
player.setForwardBackward (0);
|
|
||||||
|
|
||||||
if (poller.isDown(A_Jump))
|
if (poller.isDown(A_Jump) && mControlSwitch["playerjumping"])
|
||||||
player.setUpDown (1);
|
player.setUpDown (1);
|
||||||
else if (poller.isDown(A_Crouch))
|
else if (poller.isDown(A_Crouch))
|
||||||
player.setUpDown (-1);
|
player.setUpDown (-1);
|
||||||
|
@ -423,6 +434,24 @@ private:
|
||||||
guiEvents->enabled = false;
|
guiEvents->enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggleControlSwitch(std::string sw, bool value)
|
||||||
|
{
|
||||||
|
if (mControlSwitch[sw] == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/// \note 7 switches at all, if-else is relevant
|
||||||
|
if (sw == "playercontrols") {
|
||||||
|
player.setLeftRight(0);
|
||||||
|
player.setForwardBackward(0);
|
||||||
|
player.setAutoMove(false);
|
||||||
|
} else if (sw == "playerjumping") {
|
||||||
|
/// \fixme maybe crouching at this time
|
||||||
|
player.setUpDown(0);
|
||||||
|
}
|
||||||
|
mControlSwitch[sw] = value;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/***CONSTRUCTOR***/
|
/***CONSTRUCTOR***/
|
||||||
|
@ -471,4 +500,9 @@ private:
|
||||||
if (changeRes)
|
if (changeRes)
|
||||||
impl->adjustMouseRegion(Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video"));
|
impl->adjustMouseRegion(Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MWInputManager::toggleControlSwitch(std::string sw, bool value)
|
||||||
|
{
|
||||||
|
impl->toggleControlSwitch(sw, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ namespace MWInput
|
||||||
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
||||||
|
|
||||||
void setDragDrop(bool dragDrop);
|
void setDragDrop(bool dragDrop);
|
||||||
|
|
||||||
|
void toggleControlSwitch(std::string sw, bool value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
|
|
||||||
|
#include "../mwinput/inputmanager.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
|
|
||||||
|
@ -36,6 +38,10 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWBase::Environment::get()
|
||||||
|
.getInputManager()
|
||||||
|
->toggleControlSwitch(mControl, mEnable);
|
||||||
|
|
||||||
if (mEnable)
|
if (mEnable)
|
||||||
std::cout << "enable: " << mControl << std::endl;
|
std::cout << "enable: " << mControl << std::endl;
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
#include "manualref.hpp"
|
#include "manualref.hpp"
|
||||||
#include "cellfunctors.hpp"
|
#include "cellfunctors.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -1117,8 +1115,6 @@ namespace MWWorld
|
||||||
if (cell.data.flags & ESM::Cell::HasWater == 0) {
|
if (cell.data.flags & ESM::Cell::HasWater == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool res = pos.z < cell.water;
|
return pos.z < cell.water;
|
||||||
std::cout << "World::isUnderwater(" << pos.z << "):" << res << std::endl;
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue