Merge remote-tracking branch 'filkry/bug1196jumpdialog'

deque
Marc Zinnschlag 11 years ago
commit b717e3fcb8

@ -118,6 +118,7 @@ namespace MWInput
, mTimeIdle(0.f) , mTimeIdle(0.f)
, mOverencumberedMessageDelay(0.f) , mOverencumberedMessageDelay(0.f)
, mAlwaysRunActive(false) , mAlwaysRunActive(false)
, 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,11 +326,9 @@ 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 // Configure player movement according to keyboard input. Actual movement will
// be done in the physics system. // be done in the physics system.
if (mControlSwitch["playercontrols"]) if (mControlSwitch["playercontrols"])
@ -347,7 +366,7 @@ namespace MWInput
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;
@ -407,6 +426,8 @@ namespace MWInput
updateIdleTime(dt); updateIdleTime(dt);
} }
} }
mAttemptJump = false; // Can only jump on first frame input is on
}
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,21 +559,20 @@ 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 {
guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id)); guiMode = MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id)) && guiMode;
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0) if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
@ -561,11 +583,27 @@ namespace MWInput
} }
} }
setPlayerControlsEnabled(!guiMode);
mInputBinder->mousePressed (arg, id);
}
void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id )
{
if(mInputBinder->detectingBindingState())
{ {
mInputBinder->mouseReleased (arg, id); 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
MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI(id)); 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();

@ -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);
} }

@ -89,6 +89,8 @@ namespace ICS
IntervalList& getIntervals(){ return mIntervals; }; IntervalList& getIntervals(){ return mIntervals; };
void setEnabled(bool enabled);
protected: protected:
int mNumber; int mNumber;
@ -114,6 +116,8 @@ namespace ICS
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