Browse Source

Adds a flag to the guiGameListMenuCtrl to allow consuming of key input events. This allows for overriding other active keybinds that may be in play when a menu is active.

Areloch 4 years ago
parent
commit
bca972ae24

+ 23 - 3
Engine/source/gui/controls/guiGameListMenuCtrl.cpp

@@ -37,7 +37,8 @@ GuiGameListMenuCtrl::GuiGameListMenuCtrl()
  : mSelected(NO_ROW),
  : mSelected(NO_ROW),
    mDebugRender(false),
    mDebugRender(false),
    mHighlighted(NO_ROW),
    mHighlighted(NO_ROW),
-   mCallbackOnInputs(false)
+   mCallbackOnInputs(false),
+   mConsumeKeyInputEvents(false)
 {
 {
    VECTOR_SET_ASSOCIATION(mRows);
    VECTOR_SET_ASSOCIATION(mRows);
 
 
@@ -822,6 +823,8 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
       if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
       if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
          return false;
          return false;
 
 
+      StringTableEntry deviceStringEntry = StringTable->insert(deviceString);
+
       if (event.action == SI_MAKE || event.action == SI_BREAK)
       if (event.action == SI_MAKE || event.action == SI_BREAK)
       {
       {
          bool isModifier = false;
          bool isModifier = false;
@@ -847,12 +850,25 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
             if (!ActionMap::getKeyString(event.objInst, keyString))
             if (!ActionMap::getKeyString(event.objInst, keyString))
                return false;
                return false;
 
 
-            onInputEvent_callback(deviceString, keyString, state);
+            onInputEvent_callback(deviceStringEntry, keyString, state);
+
+            if (mConsumeKeyInputEvents)
+            {
+               if(deviceStringEntry == StringTable->insert("keyboard"))
+                  return true;
+            }
+
          }
          }
          else
          else
          {
          {
             const char* actionString = ActionMap::buildActionString(&event);
             const char* actionString = ActionMap::buildActionString(&event);
-            onInputEvent_callback(deviceString, actionString, state);
+            onInputEvent_callback(deviceStringEntry, actionString, state);
+
+            if (mConsumeKeyInputEvents)
+            {
+               if (deviceStringEntry == StringTable->insert("keyboard"))
+                  return true;
+            }
          }
          }
       }
       }
       else if (event.objType == SI_AXIS || event.objType == SI_INT || event.objType == SI_FLOAT)
       else if (event.objType == SI_AXIS || event.objType == SI_INT || event.objType == SI_FLOAT)
@@ -1401,6 +1417,10 @@ void GuiGameListMenuCtrl::initPersistFields()
    addField("callbackOnInputs", TypeBool, Offset(mCallbackOnInputs, GuiGameListMenuCtrl),
    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.");
       "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();
    Parent::initPersistFields();
 }
 }
 
 

+ 1 - 0
Engine/source/gui/controls/guiGameListMenuCtrl.h

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

+ 1 - 0
Templates/BaseGame/game/data/ui/guis/pauseMenu.gui

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