Conflicts:
	apps/openmw/mwinput/inputmanagerimp.cpp
deque
scrawl 11 years ago
commit 10758d6297

2
.gitignore vendored

@ -41,7 +41,7 @@ resources
## generated objects ## generated objects
apps/openmw/config.hpp apps/openmw/config.hpp
components/version/version.hpp components/version/version.hpp
Docs/mainpage.hpp docs/mainpage.hpp
moc_*.cxx moc_*.cxx
*.cxx_parameters *.cxx_parameters
*qrc_launcher.cxx *qrc_launcher.cxx

@ -56,7 +56,7 @@ include(OpenMWMacros)
# doxygen main page # doxygen main page
configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/docs/mainpage.hpp")
option(MYGUI_STATIC "Link static build of Mygui into the binaries" FALSE) option(MYGUI_STATIC "Link static build of Mygui into the binaries" FALSE)
option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE) option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE)

@ -118,6 +118,7 @@ namespace MWInput
, mTimeIdle(0.f) , mTimeIdle(0.f)
, mOverencumberedMessageDelay(0.f) , mOverencumberedMessageDelay(0.f)
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
, mAttemptJump(false)
, mControlsDisabled(false) , mControlsDisabled(false)
{ {
@ -165,6 +166,21 @@ namespace MWInput
delete mInputManager; delete mInputManager;
} }
void InputManager::setPlayerControlsEnabled(bool enabled)
{
int nPlayerChannels = 17;
int playerChannels[] = {A_Activate, A_AutoMove, A_AlwaysRun, A_ToggleWeapon,
A_ToggleSpell, A_Rest, A_QuickKey1, A_QuickKey2,
A_QuickKey3, A_QuickKey4, A_QuickKey5, A_QuickKey6,
A_QuickKey7, A_QuickKey8, A_QuickKey9, A_QuickKey10,
A_Use};
for(int i = 0; i < nPlayerChannels; i++) {
int pc = playerChannels[i];
mInputBinder->getChannel(pc)->setEnabled(enabled);
}
}
void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue) void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue)
{ {
if (mDragDrop) if (mDragDrop)
@ -179,6 +195,11 @@ namespace MWInput
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue); mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
} }
if (action == A_Jump)
{
mAttemptJump = (currentValue == 1.0 && previousValue == 0.0);
}
if (currentValue == 1) if (currentValue == 1)
{ {
// trigger action activated // trigger action activated
@ -305,107 +326,107 @@ namespace MWInput
} }
// Disable movement in Gui mode // Disable movement in Gui mode
if (MWBase::Environment::get().getWindowManager()->isGuiMode() if (!(MWBase::Environment::get().getWindowManager()->isGuiMode()
|| MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running) || MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running))
return;
// Configure player movement according to keyboard input. Actual movement will
// be done in the physics system.
if (mControlSwitch["playercontrols"])
{ {
bool triedToMove = false; // Configure player movement according to keyboard input. Actual movement will
if (actionIsActive(A_MoveLeft)) // be done in the physics system.
{ if (mControlSwitch["playercontrols"])
triedToMove = true;
mPlayer->setLeftRight (-1);
}
else if (actionIsActive(A_MoveRight))
{ {
triedToMove = true; bool triedToMove = false;
mPlayer->setLeftRight (1); if (actionIsActive(A_MoveLeft))
} {
triedToMove = true;
mPlayer->setLeftRight (-1);
}
else if (actionIsActive(A_MoveRight))
{
triedToMove = true;
mPlayer->setLeftRight (1);
}
if (actionIsActive(A_MoveForward)) if (actionIsActive(A_MoveForward))
{ {
triedToMove = true; triedToMove = true;
mPlayer->setAutoMove (false); mPlayer->setAutoMove (false);
mPlayer->setForwardBackward (1); mPlayer->setForwardBackward (1);
} }
else if (actionIsActive(A_MoveBackward)) else if (actionIsActive(A_MoveBackward))
{ {
triedToMove = true; triedToMove = true;
mPlayer->setAutoMove (false); mPlayer->setAutoMove (false);
mPlayer->setForwardBackward (-1); mPlayer->setForwardBackward (-1);
} }
else if(mPlayer->getAutoMove()) else if(mPlayer->getAutoMove())
{ {
triedToMove = true; triedToMove = true;
mPlayer->setForwardBackward (1); mPlayer->setForwardBackward (1);
} }
mPlayer->setSneak(actionIsActive(A_Sneak)); mPlayer->setSneak(actionIsActive(A_Sneak));
if (actionIsActive(A_Jump) && mControlSwitch["playerjumping"]) if (mAttemptJump && mControlSwitch["playerjumping"])
{ {
mPlayer->setUpDown (1); mPlayer->setUpDown (1);
triedToMove = true; triedToMove = true;
} }
if (mAlwaysRunActive) if (mAlwaysRunActive)
mPlayer->setRunState(!actionIsActive(A_Run)); mPlayer->setRunState(!actionIsActive(A_Run));
else else
mPlayer->setRunState(actionIsActive(A_Run)); mPlayer->setRunState(actionIsActive(A_Run));
// if player tried to start moving, but can't (due to being overencumbered), display a notification. // if player tried to start moving, but can't (due to being overencumbered), display a notification.
if (triedToMove) if (triedToMove)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
mOverencumberedMessageDelay -= dt;
if (player.getClass().getEncumbrance(player) >= player.getClass().getCapacity(player))
{ {
mPlayer->setAutoMove (false); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
if (mOverencumberedMessageDelay <= 0) mOverencumberedMessageDelay -= dt;
if (player.getClass().getEncumbrance(player) >= player.getClass().getCapacity(player))
{ {
MWBase::Environment::get().getWindowManager ()->messageBox("#{sNotifyMessage59}"); mPlayer->setAutoMove (false);
mOverencumberedMessageDelay = 1.0; if (mOverencumberedMessageDelay <= 0)
{
MWBase::Environment::get().getWindowManager ()->messageBox("#{sNotifyMessage59}");
mOverencumberedMessageDelay = 1.0;
}
} }
} }
}
if (mControlSwitch["playerviewswitch"]) { if (mControlSwitch["playerviewswitch"]) {
// work around preview mode toggle when pressing Alt+Tab // work around preview mode toggle when pressing Alt+Tab
if (actionIsActive(A_TogglePOV) && !mInputManager->isModifierHeld(SDL_Keymod(KMOD_ALT))) { if (actionIsActive(A_TogglePOV) && !mInputManager->isModifierHeld(SDL_Keymod(KMOD_ALT))) {
if (mPreviewPOVDelay <= 0.5 && if (mPreviewPOVDelay <= 0.5 &&
(mPreviewPOVDelay += dt) > 0.5) (mPreviewPOVDelay += dt) > 0.5)
{ {
mPreviewPOVDelay = 1.f; mPreviewPOVDelay = 1.f;
MWBase::Environment::get().getWorld()->togglePreviewMode(true); MWBase::Environment::get().getWorld()->togglePreviewMode(true);
}
} else {
//disable preview mode
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
if (mPreviewPOVDelay > 0.f && mPreviewPOVDelay <= 0.5) {
MWBase::Environment::get().getWorld()->togglePOV();
}
mPreviewPOVDelay = 0.f;
} }
} else {
//disable preview mode
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
if (mPreviewPOVDelay > 0.f && mPreviewPOVDelay <= 0.5) {
MWBase::Environment::get().getWorld()->togglePOV();
}
mPreviewPOVDelay = 0.f;
} }
} }
if (actionIsActive(A_MoveForward) ||
actionIsActive(A_MoveBackward) ||
actionIsActive(A_MoveLeft) ||
actionIsActive(A_MoveRight) ||
actionIsActive(A_Jump) ||
actionIsActive(A_Sneak) ||
actionIsActive(A_TogglePOV))
{
resetIdleTime();
} else {
updateIdleTime(dt);
}
} }
if (actionIsActive(A_MoveForward) || mAttemptJump = false; // Can only jump on first frame input is on
actionIsActive(A_MoveBackward) ||
actionIsActive(A_MoveLeft) ||
actionIsActive(A_MoveRight) ||
actionIsActive(A_Jump) ||
actionIsActive(A_Sneak) ||
actionIsActive(A_TogglePOV))
{
resetIdleTime();
} else {
updateIdleTime(dt);
}
} }
void InputManager::setDragDrop(bool dragDrop) void InputManager::setDragDrop(bool dragDrop)
@ -517,13 +538,15 @@ namespace MWInput
} }
} }
if (!mControlsDisabled)
mInputBinder->keyPressed (arg);
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
if (kc != OIS::KC_UNASSIGNED) if (kc != OIS::KC_UNASSIGNED)
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0); {
bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
setPlayerControlsEnabled(!guiFocus);
}
if (!mControlsDisabled)
mInputBinder->keyPressed (arg);
} }
void InputManager::textInput(const SDL_TextInputEvent &arg) void InputManager::textInput(const SDL_TextInputEvent &arg)
@ -536,36 +559,51 @@ namespace MWInput
void InputManager::keyReleased(const SDL_KeyboardEvent &arg ) void InputManager::keyReleased(const SDL_KeyboardEvent &arg )
{ {
mInputBinder->keyReleased (arg);
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)); setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
mInputBinder->keyReleased (arg);
} }
void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id )
{ {
mInputBinder->mousePressed (arg, id); bool guiMode = false;
if (id != SDL_BUTTON_LEFT && id != SDL_BUTTON_RIGHT) if (id == SDL_BUTTON_LEFT || id == SDL_BUTTON_RIGHT) // MyGUI only uses these mouse events
return; // MyGUI has no use for these events
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id));
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
if (b && b->getEnabled()) guiMode = MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id)) && guiMode;
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f); MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
if (b && b->getEnabled())
{
MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f);
}
} }
} }
setPlayerControlsEnabled(!guiMode);
mInputBinder->mousePressed (arg, id);
} }
void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id )
{ {
mInputBinder->mouseReleased (arg, id);
MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id)); if(mInputBinder->detectingBindingState())
{
mInputBinder->mouseReleased (arg, id);
} else {
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id)) && guiMode;
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
setPlayerControlsEnabled(!guiMode);
mInputBinder->mouseReleased (arg, id);
}
} }
void InputManager::mouseMoved(const SFO::MouseMotionEvent &arg ) void InputManager::mouseMoved(const SFO::MouseMotionEvent &arg )

@ -163,6 +163,7 @@ namespace MWInput
int mMouseWheel; int mMouseWheel;
bool mUserFileExists; bool mUserFileExists;
bool mAlwaysRunActive; bool mAlwaysRunActive;
bool mAttemptJump;
std::map<std::string, bool> mControlSwitch; std::map<std::string, bool> mControlSwitch;
@ -173,6 +174,8 @@ namespace MWInput
void resetIdleTime(); void resetIdleTime();
void updateIdleTime(float dt); void updateIdleTime(float dt);
void setPlayerControlsEnabled(bool enabled);
private: private:
void toggleMainMenu(); void toggleMainMenu();
void toggleSpell(); void toggleSpell();

@ -304,17 +304,33 @@ namespace MWWorld
continue; // velocity updated, calculate nextpos again continue; // velocity updated, calculate nextpos again
} }
// trace to where character would go if there were no obstructions if(!newPosition.positionCloses(nextpos, 0.00000001))
tracer.doTrace(colobj, newPosition, nextpos, engine); {
// trace to where character would go if there were no obstructions
tracer.doTrace(colobj, newPosition, nextpos, engine);
// check for obstructions // check for obstructions
if(tracer.mFraction >= 1.0f) if(tracer.mFraction >= 1.0f)
{
newPosition = tracer.mEndPos; // ok to move, so set newPosition
remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it?
break;
}
}
else
{ {
newPosition = tracer.mEndPos; // ok to move, so set newPosition // The current position and next position are nearly the same, so just exit.
// Note: Bullet can trigger an assert in debug modes if the positions
// are the same, since that causes it to attempt to normalize a zero
// length vector (which can also happen with nearly identical vectors, since
// precision can be lost due to any math Bullet does internally). Since we
// aren't performing any collision detection, we want to reject the next
// position, so that we don't slowly move inside another object.
remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it?
break; break;
} }
Ogre::Vector3 oldPosition = newPosition; Ogre::Vector3 oldPosition = newPosition;
// We hit something. Try to step up onto it. (NOTE: stepMove does not allow stepping over) // We hit something. Try to step up onto it. (NOTE: stepMove does not allow stepping over)
// NOTE: stepMove modifies newPosition if successful // NOTE: stepMove modifies newPosition if successful

@ -19,8 +19,8 @@ Alexander Olofsson (Ace)
Artem Kotsynyak (greye) Artem Kotsynyak (greye)
Arthur Moore (EmperorArthur) Arthur Moore (EmperorArthur)
athile athile
Bret Curtis (psi29a)
Britt Mathis (galdor557) Britt Mathis (galdor557)
BrotherBrick
cc9cii cc9cii
Chris Boyce (slothlife) Chris Boyce (slothlife)
Chris Robinson (KittyCat) Chris Robinson (KittyCat)
@ -36,6 +36,7 @@ Eli2
Emanuel Guével (potatoesmaster) Emanuel Guével (potatoesmaster)
Fil Krynicki (filkry) Fil Krynicki (filkry)
gugus/gus gugus/gus
Hallfaer Tuilinn
Jacob Essex (Yacoby) Jacob Essex (Yacoby)
Jannik Heller (scrawl) Jannik Heller (scrawl)
Jason Hooks (jhooks) Jason Hooks (jhooks)
@ -78,7 +79,7 @@ Torben Leif Carrington (TorbenC)
Packagers: Packagers:
Alexander Olofsson (Ace) - Windows Alexander Olofsson (Ace) - Windows
BrotherBrick - Ubuntu Linux Bret Curtis (psi29a) - Ubuntu Linux
Edmondo Tommasina (edmondo) - Gentoo Linux Edmondo Tommasina (edmondo) - Gentoo Linux
Julian Ospald (hasufell) - Gentoo Linux Julian Ospald (hasufell) - Gentoo Linux
Karl-Felix Glatzer (k1ll) - Linux Binaries Karl-Felix Glatzer (k1ll) - Linux Binaries

@ -576,7 +576,7 @@ WARN_LOGFILE =
INPUT = apps \ INPUT = apps \
components \ components \
libs \ libs \
Docs docs
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is

@ -576,7 +576,7 @@ WARN_LOGFILE =
INPUT = apps \ INPUT = apps \
components \ components \
libs \ libs \
Docs docs
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is

@ -38,6 +38,7 @@ namespace ICS
, mValue(initialValue) , mValue(initialValue)
, mSymmetricAt(symmetricAt) , mSymmetricAt(symmetricAt)
, mBezierStep(bezierStep) , mBezierStep(bezierStep)
, mEnabled(true)
{ {
mBezierMidPoint.x = bezierMidPointX; mBezierMidPoint.x = bezierMidPointX;
mBezierMidPoint.y = bezierMidPointY; mBezierMidPoint.y = bezierMidPointY;
@ -45,6 +46,11 @@ namespace ICS
setBezierFunction(bezierMidPointY, bezierMidPointX, symmetricAt, bezierStep); setBezierFunction(bezierMidPointY, bezierMidPointX, symmetricAt, bezierStep);
} }
void Channel::setEnabled(bool enabled)
{
mEnabled = enabled;
}
float Channel::getValue() float Channel::getValue()
{ {
if(mValue == 0 || mValue == 1) if(mValue == 0 || mValue == 1)
@ -78,7 +84,7 @@ namespace ICS
mValue = value; mValue = value;
if(previousValue != value) if(previousValue != value && mEnabled)
{ {
notifyListeners(previousValue); notifyListeners(previousValue);
} }
@ -124,7 +130,7 @@ namespace ICS
void Channel::update() void Channel::update()
{ {
if(this->getControlsCount() == 1) if(this->getControlsCount() == 1)
{ {
ControlChannelBinderItem ccBinderItem = mAttachedControls.back(); ControlChannelBinderItem ccBinderItem = mAttachedControls.back();
float diff = ccBinderItem.control->getValue() - ccBinderItem.control->getInitialValue(); float diff = ccBinderItem.control->getValue() - ccBinderItem.control->getInitialValue();
@ -255,4 +261,4 @@ namespace ICS
t += 1.0f / ((endX-startX)/step); t += 1.0f / ((endX-startX)/step);
} }
} }
} }

@ -89,6 +89,8 @@ namespace ICS
IntervalList& getIntervals(){ return mIntervals; }; IntervalList& getIntervals(){ return mIntervals; };
void setEnabled(bool enabled);
protected: protected:
int mNumber; int mNumber;
@ -112,7 +114,9 @@ namespace ICS
std::vector<ControlChannelBinderItem> mAttachedControls; std::vector<ControlChannelBinderItem> mAttachedControls;
std::list<ChannelListener* > mListeners; std::list<ChannelListener* > mListeners;
void notifyListeners(float previousValue); void notifyListeners(float previousValue);
bool mEnabled;
}; };

@ -796,6 +796,11 @@ namespace ICS
mMouseAxisBindingInitialValues[0] = ICS_MOUSE_AXIS_BINDING_NULL_VALUE; mMouseAxisBindingInitialValues[0] = ICS_MOUSE_AXIS_BINDING_NULL_VALUE;
} }
bool InputControlSystem::detectingBindingState()
{
return mDetectingBindingControl != NULL;
}
void InputControlSystem::cancelDetectingBindingState() void InputControlSystem::cancelDetectingBindingState()
{ {
mDetectingBindingControl = NULL; mDetectingBindingControl = NULL;

@ -146,6 +146,7 @@ namespace ICS
void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction); void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction);
void cancelDetectingBindingState(); void cancelDetectingBindingState();
bool detectingBindingState();
bool save(std::string fileName = ""); bool save(std::string fileName = "");

Loading…
Cancel
Save