1196/1217 fix

Fixes an issue where inputs could be processed by both GUI and
gameplay systems. An enabled/disable has been added to OIS
channels, and OpenMW now disables player gameplay hotkeys when
a GUI element has focus. GUI hotkeys are left enabled.
pull/128/head
Fil Krynicki 11 years ago
parent 6cc6172779
commit cd131e7f86

@ -160,6 +160,20 @@ namespace MWInput
delete mInputManager;
}
void InputManager::setPlayerControlsEnabled(bool enabled)
{
int nPlayerChannels = 15;
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};
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)
{
if (mDragDrop)
@ -511,7 +525,10 @@ namespace MWInput
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
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);
}
mInputBinder->keyPressed (arg);
}

@ -172,6 +172,8 @@ namespace MWInput
void resetIdleTime();
void updateIdleTime(float dt);
void setPlayerControlsEnabled(bool enabled);
private:
void toggleMainMenu();
void toggleSpell();

@ -38,6 +38,7 @@ namespace ICS
, mValue(initialValue)
, mSymmetricAt(symmetricAt)
, mBezierStep(bezierStep)
, mEnabled(true)
{
mBezierMidPoint.x = bezierMidPointX;
mBezierMidPoint.y = bezierMidPointY;
@ -45,6 +46,11 @@ namespace ICS
setBezierFunction(bezierMidPointY, bezierMidPointX, symmetricAt, bezierStep);
}
void Channel::setEnabled(bool enabled)
{
mEnabled = enabled;
}
float Channel::getValue()
{
if(mValue == 0 || mValue == 1)
@ -124,6 +130,9 @@ namespace ICS
void Channel::update()
{
if(!mEnabled)
return;
if(this->getControlsCount() == 1)
{
ControlChannelBinderItem ccBinderItem = mAttachedControls.back();

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

Loading…
Cancel
Save