Merge pull request #381 from Areloch/PauseMenuFix

Pause Menu toggle fix
This commit is contained in:
Brian Roberts 2020-11-21 03:05:20 -06:00 committed by GitHub
commit 77ac215464
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 7 deletions

View file

@ -37,7 +37,8 @@ GuiGameListMenuCtrl::GuiGameListMenuCtrl()
: mSelected(NO_ROW),
mDebugRender(false),
mHighlighted(NO_ROW),
mCallbackOnInputs(false)
mCallbackOnInputs(false),
mConsumeKeyInputEvents(false)
{
VECTOR_SET_ASSOCIATION(mRows);
@ -818,10 +819,12 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
{
if (mCallbackOnInputs)
{
char deviceString[32];
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
char deviceStr[32];
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceStr))
return false;
String deviceString = deviceStr;
if (event.action == SI_MAKE || event.action == SI_BREAK)
{
bool isModifier = false;
@ -847,12 +850,24 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
if (!ActionMap::getKeyString(event.objInst, keyString))
return false;
onInputEvent_callback(deviceString, keyString, state);
onInputEvent_callback(deviceString.c_str(), keyString, state);
if (mConsumeKeyInputEvents)
{
if(deviceString.startsWith("keyboard"))
return true;
}
}
else
{
const char* actionString = ActionMap::buildActionString(&event);
onInputEvent_callback(deviceString, actionString, state);
onInputEvent_callback(deviceString.c_str(), actionString, state);
if (mConsumeKeyInputEvents)
{
if (deviceString.startsWith("keyboard") || deviceString.startsWith("gamepad"))
return true;
}
}
}
else if (event.objType == SI_AXIS || event.objType == SI_INT || event.objType == SI_FLOAT)
@ -861,12 +876,12 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
if (event.objType == SI_INT)
fValue = (F32)event.iValue;
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceStr))
return false;
const char* actionString = ActionMap::buildActionString(&event);
onAxisEvent_callback(deviceString, actionString, fValue);
onAxisEvent_callback(deviceStr, actionString, fValue);
}
}
@ -1401,6 +1416,10 @@ void GuiGameListMenuCtrl::initPersistFields()
addField("callbackOnInputs", TypeBool, Offset(mCallbackOnInputs, GuiGameListMenuCtrl),
"Script callback when any inputs are detected, even if they aren't the regular 4 face buttons. Useful for secondary/speciality handling of menu navigation.");
addField("consumeKeyInputEvents", TypeBool, Offset(mConsumeKeyInputEvents, GuiGameListMenuCtrl),
"When callbackOnInputs is active, this indicates if the input event should be consumed, or allowed 'through' to let other things respond to the event as well.");
Parent::initPersistFields();
}

View file

@ -428,6 +428,7 @@ private:
S32 mHighlighted; ///< index of the currently highlighted row
bool mCallbackOnInputs;
bool mConsumeKeyInputEvents;
};
/// \class GuiGameListMenuProfile

View file

@ -53,6 +53,7 @@
new GuiGameListMenuCtrl(PauseMenuList) {
debugRender = "0";
callbackOnInputs = "1";
consumeKeyInputEvents = "1";
position = "0 0";
extent = "700 320";
minExtent = "8 2";