mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 08:06:41 +00:00
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.
This commit is contained in:
parent
6cc6172779
commit
cd131e7f86
4 changed files with 36 additions and 4 deletions
|
@ -160,6 +160,20 @@ namespace MWInput
|
||||||
delete mInputManager;
|
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)
|
void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue)
|
||||||
{
|
{
|
||||||
if (mDragDrop)
|
if (mDragDrop)
|
||||||
|
@ -511,7 +525,10 @@ namespace MWInput
|
||||||
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);
|
||||||
|
}
|
||||||
mInputBinder->keyPressed (arg);
|
mInputBinder->keyPressed (arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,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();
|
||||||
|
|
13
extern/oics/ICSChannel.cpp
vendored
13
extern/oics/ICSChannel.cpp
vendored
|
@ -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)
|
||||||
|
@ -124,7 +130,10 @@ namespace ICS
|
||||||
|
|
||||||
void Channel::update()
|
void Channel::update()
|
||||||
{
|
{
|
||||||
if(this->getControlsCount() == 1)
|
if(!mEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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 +264,4 @@ namespace ICS
|
||||||
t += 1.0f / ((endX-startX)/step);
|
t += 1.0f / ((endX-startX)/step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
extern/oics/ICSChannel.h
vendored
6
extern/oics/ICSChannel.h
vendored
|
@ -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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue