Ver Fonte

Updated names of some of the input images to match the names of the inputs to simplify lookups
Altered a few of the input images to improve readability of some of the text
Standardizes the menuInputButton set usage to just use the raw action names rather than a middleman naming scheme for simplicity and standardization
Added comments to menuInputButtons.cs
Split out the menuInputButton containers to simplify and stabilize the code on the messageBox dialog
Removed old reference to script/gui files not there anymore
Simplified the input state check in guiGameListMenuCtrl.cpp
Added a check so we don't try exec'ing the selected list item in guiGameListMenuCtrl.cpp if nothing has actually be selected

Areloch há 5 anos atrás
pai
commit
ef4cc8b573

+ 2 - 2
Engine/source/gui/controls/guiGameListMenuCtrl.cpp

@@ -818,7 +818,7 @@ bool GuiGameListMenuCtrl::onInputEvent(const InputEventInfo& event)
       {
          bool isModifier = false;
 
-         bool state = event.action == SI_MAKE ? 1 : 0;
+         bool state = event.action == SI_MAKE;
 
          switch (event.objInst)
          {
@@ -1164,7 +1164,7 @@ void GuiGameListMenuCtrl::changeOption(Row* row, S32 delta)
    static StringTableEntry LEFT = StringTable->insert("LEFT", true);
    static StringTableEntry RIGHT = StringTable->insert("RIGHT", true);
 
-   if (row->mScriptCallback != NULL)
+   if (row->mScriptCallback != NULL && row->mSelectedOption != NO_OPTION)
    {
       setThisControl();
       StringTableEntry direction = NULL;

+ 0 - 3
Templates/BaseGame/game/data/ui/UI.cs

@@ -80,9 +80,6 @@ function UI::initClient(%this)
    exec("./scripts/cursors.cs");
    exec("./scripts/utility.cs");
    
-   exec("./guis/menuGraphics.gui");
-   exec("./guis/menuGraphics.cs");
-   
    loadStartup();
 }
 

+ 2 - 2
Templates/BaseGame/game/data/ui/guis/chooseLevelDlg.cs

@@ -145,8 +145,8 @@ function ChooseLevelDlg::onWake( %this )
 
 function ChooseLevelButtonHolder::onWake(%this)
 {
-   %this-->goButton.set("A", "Enter", "Start Level", "ChooseLevelDlg.beginLevel();");
-   %this-->backButton.set("B", "Esc", "Back", "ChooseLevelDlg.backOut();");
+   %this-->goButton.set("btn_a", "Return", "Start Level", "ChooseLevelDlg.beginLevel();");
+   %this-->backButton.set("btn_b", "Escape", "Back", "ChooseLevelDlg.backOut();");
 }
 
 function ChooseLevelDlg::onSleep( %this )

+ 5 - 5
Templates/BaseGame/game/data/ui/guis/joinServerMenu.cs

@@ -10,11 +10,11 @@ function JoinServerMenu::onWake()
 
 function JoinServerButtonHolder::onWake(%this)
 {
-   %this-->joinButton.set("Start", "Enter", "Join", "JoinServerMenu.join();");
-   %this-->backButton.set("B", "Esc", "Back", "JoinServerMenu.backOut();");
-   %this-->refreshButton.set("Y", "R", "Refresh", "JoinServerMenu.refresh();");
-   %this-->queryLANButton.set("A", "Q", "Query LAN", "JoinServerMenu.queryLan();");
-   %this-->queryInternetButton.set("X", "E", "Query Internet", "JoinServerMenu.query();");
+   %this-->joinButton.set("Start", "Return", "Join", "JoinServerMenu.join();");
+   %this-->backButton.set("btn_b", "escape", "Back", "JoinServerMenu.backOut();");
+   %this-->refreshButton.set("btn_y", "R", "Refresh", "JoinServerMenu.refresh();");
+   %this-->queryLANButton.set("btn_a", "Q", "Query LAN", "JoinServerMenu.queryLan();");
+   %this-->queryInternetButton.set("btn_x", "E", "Query Internet", "JoinServerMenu.query();");
 }
 
 //----------------------------------------

+ 1 - 1
Templates/BaseGame/game/data/ui/guis/mainMenu.cs

@@ -16,7 +16,7 @@ function MainMenuGui::onSleep(%this)
 
 function MainMenuButtonHolder::onWake(%this)
 {
-   %this-->goButton.set("A", "Enter", "Go", "MainMenuButtonList.activateRow();");
+   %this-->goButton.set("btn_a", "Return", "Go", "MainMenuButtonList.activateRow();");
 }
 
 function MainMenuButtonList::onAdd(%this)

+ 44 - 10
Templates/BaseGame/game/data/ui/guis/messageBoxDlg.gui

@@ -112,7 +112,7 @@
          canSave = "1";
          canSaveDynamicFields = "0";
       };
-      new GuiControl(MessageBoxButtonHolder) {
+      new GuiControl(MessageBoxOKButtonHolder) {
          position = "0 285";
          extent = "642 40";
          minExtent = "8 2";
@@ -141,7 +141,7 @@
             groupNum = "-1";
             buttonType = "PushButton";
             useMouseEvents = "0";
-            position = "171 0";
+            position = "251 0";
             extent = "140 40";
             minExtent = "8 2";
             horizSizing = "right";
@@ -153,11 +153,28 @@
             tooltipProfile = "GuiToolTipProfile";
             hovertime = "1000";
             isContainer = "0";
-            internalName = "oc_OKButton";
+            internalName = "OKButton";
             class = "MenuInputButton";
             canSave = "1";
             canSaveDynamicFields = "0";
          };
+      };
+      new GuiControl(MessageBoxOCButtonHolder) {
+         position = "0 285";
+         extent = "642 40";
+         minExtent = "8 2";
+         horizSizing = "center";
+         vertSizing = "top";
+         profile = "GuiDefaultProfile";
+         visible = "1";
+         active = "1";
+         tooltipProfile = "GuiToolTipProfile";
+         hovertime = "1000";
+         isContainer = "1";
+         class = "MenuInputButtonContainer";
+         canSave = "1";
+         canSaveDynamicFields = "0";
+
          new GuiIconButtonCtrl() {
             buttonMargin = "4 4";
             iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter";
@@ -171,7 +188,7 @@
             groupNum = "-1";
             buttonType = "PushButton";
             useMouseEvents = "0";
-            position = "323 0";
+            position = "171 0";
             extent = "140 40";
             minExtent = "8 2";
             horizSizing = "right";
@@ -183,7 +200,7 @@
             tooltipProfile = "GuiToolTipProfile";
             hovertime = "1000";
             isContainer = "0";
-            internalName = "oc_CancelButton";
+            internalName = "OKButton";
             class = "MenuInputButton";
             canSave = "1";
             canSaveDynamicFields = "0";
@@ -201,7 +218,7 @@
             groupNum = "-1";
             buttonType = "PushButton";
             useMouseEvents = "0";
-            position = "251 0";
+            position = "323 0";
             extent = "140 40";
             minExtent = "8 2";
             horizSizing = "right";
@@ -213,11 +230,28 @@
             tooltipProfile = "GuiToolTipProfile";
             hovertime = "1000";
             isContainer = "0";
-            internalName = "OKButton";
+            internalName = "CancelButton";
             class = "MenuInputButton";
             canSave = "1";
             canSaveDynamicFields = "0";
          };
+      };
+      new GuiControl(MessageBoxYNCButtonHolder) {
+         position = "0 285";
+         extent = "642 40";
+         minExtent = "8 2";
+         horizSizing = "center";
+         vertSizing = "top";
+         profile = "GuiDefaultProfile";
+         visible = "1";
+         active = "1";
+         tooltipProfile = "GuiToolTipProfile";
+         hovertime = "1000";
+         isContainer = "1";
+         class = "MenuInputButtonContainer";
+         canSave = "1";
+         canSaveDynamicFields = "0";
+
          new GuiIconButtonCtrl() {
             buttonMargin = "4 4";
             iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter";
@@ -243,7 +277,7 @@
             tooltipProfile = "GuiToolTipProfile";
             hovertime = "1000";
             isContainer = "0";
-            internalName = "ync_yesButton";
+            internalName = "yesButton";
             class = "MenuInputButton";
             canSave = "1";
             canSaveDynamicFields = "0";
@@ -273,7 +307,7 @@
             tooltipProfile = "GuiToolTipProfile";
             hovertime = "1000";
             isContainer = "0";
-            internalName = "ync_noButton";
+            internalName = "noButton";
             class = "MenuInputButton";
             canSave = "1";
             canSaveDynamicFields = "0";
@@ -303,7 +337,7 @@
             tooltipProfile = "GuiToolTipProfile";
             hovertime = "1000";
             isContainer = "0";
-            internalName = "ync_cancelButton";
+            internalName = "CancelButton";
             class = "MenuInputButton";
             canSave = "1";
             canSaveDynamicFields = "0";

+ 5 - 5
Templates/BaseGame/game/data/ui/guis/optionsMenu.cs

@@ -63,11 +63,11 @@ function OptionsMenu::onWake(%this)
 
 function OptionsButtonHolder::onWake(%this)
 {
-   %this-->prevTabButton.set("LB", "", "Prev Tab", "OptionsMenu.prevTab();", true);
-   %this-->nextTabButton.set("RB", "", "Next Tab", "OptionsMenu.nextTab();", true);
-   %this-->resetButton.set("Back", "R", "Reset", "OptionsMenu.resetToDefaults();");
-   %this-->applyButton.set("Start", "Enter", "Apply", "OptionsMenu.apply();");
-   %this-->backButton.set("B", "Esc", "Back", "OptionsMenu.backOut();");
+   %this-->prevTabButton.set("btn_l", "", "Prev Tab", "OptionsMenu.prevTab();", true);
+   %this-->nextTabButton.set("btn_r", "", "Next Tab", "OptionsMenu.nextTab();", true);
+   %this-->resetButton.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();");
+   %this-->applyButton.set("btn_start", "Return", "Apply", "OptionsMenu.apply();");
+   %this-->backButton.set("btn_b", "Escape", "Back", "OptionsMenu.backOut();");
 }
 
 function OptionsMenu::apply(%this)

+ 2 - 2
Templates/BaseGame/game/data/ui/guis/pauseMenu.cs

@@ -45,6 +45,6 @@ function pauseMenuExitToDesktop()
 
 function PauseButtonHolder::onWake(%this)
 {
-   %this-->goButton.set("A", "Enter", "OK", "PauseMenuList.activateRow();", true);
-   %this-->backButton.set("B", "Esc", "Back", "Canvas.popDialog();");
+   %this-->goButton.set("btn_a", "Return", "OK", "PauseMenuList.activateRow();", true);
+   %this-->backButton.set("btn_b", "Escape", "Back", "Canvas.popDialog();");
 }

+ 0 - 0
Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Esc.png → Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Escape.png


+ 0 - 0
Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter.png → Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Return.png


+ 0 - 0
Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter_Alt.png → Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Return_Alt.png


+ 0 - 0
Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter_Tall.png → Templates/BaseGame/game/data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Return_Tall.png


BIN
Templates/BaseGame/game/data/ui/images/Inputs/PS4/PS4_Options.png


BIN
Templates/BaseGame/game/data/ui/images/Inputs/PS4/PS4_Share.png


BIN
Templates/BaseGame/game/data/ui/images/Inputs/Switch/Switch_LB.png


BIN
Templates/BaseGame/game/data/ui/images/Inputs/Switch/Switch_RB.png


+ 130 - 180
Templates/BaseGame/game/data/ui/scripts/menuInputButtons.cs

@@ -1,40 +1,60 @@
-//------------------------------------------------------------------------------
-// global vars
-//------------------------------------------------------------------------------
-
-$BUTTON_A         =  0;
-$BUTTON_B         =  1;
-$BUTTON_X         =  2;
-$BUTTON_Y         =  3;
-$BUTTON_BACK      =  4;
-$BUTTON_START     =  5;
-$BUTTON_LTRIGGER  =  6;
-$BUTTON_RTRIGGER  =  7;
-$BUTTON_LSHOULDER =  8;
-$BUTTON_RSHOULDER =  9;
-$BUTTON_LSTICK    =  10;
-$BUTTON_RSTICK    =  11;
+//==============================================================================
+// Menu Input Buttons
+// This file manages the Menu Input Buttons stuff
+// Any time you have a GUI button that should be clickable AND map to a key input
+// such as a gamepad button, or enter, etc, this stuff can be used
+//==============================================================================
+/*
+Gamepad input reference for 360 controller
+btn_a = A
+btn_b = B
+btn_x = X
+btn_y = Y
+btn_r = Right Bumper
+btn_l = Right Bumper
+upov = Dpad Up
+dpov = Dpad Down
+lpov = Dpad Left
+rpov = Dpad Right
+xaxis = Left Stick | + values = up, - values = down
+yaxis = Left Stick | + values = up, - values = down
+rxaxis = Right Stick | + values = up, - values = down
+ryaxis = Right Stick | + values = up, - values = down
+zaxis = Left Trigger
+rzaxis = Right Trigger
+btn_start = Start
+btn_back = Back/Select
+*/
 
+/// This is used with the main UI menu lists, when a non-axis input event is called
+/// such as pressing a button
+/// It is called from the engine
 function UIMenuButtonList::onInputEvent(%this, %device, %action, %state)
 {
    if(%state)
       $activeMenuButtonContainer.processInputs(%device, %action);
 }
 
+/// This is used with the main UI menu lists, when an axis input event is called
+/// such as moving a joystick
+/// It is called from the engine
 function UIMenuButtonList::onAxisEvent(%this, %device, %action, %axisVal)
 {
+   //Skip out of the value is too low as it could just be noise or miscalibrated defaults
+   if(%axisVal < 0.02)
+      return;
+      
    $activeMenuButtonContainer.processAxisEvent(%device, %action);
 }
 
 /// Sets the command and text for the specified button. If %text and %command
 /// are left empty, the button will be disabled and hidden.
-/// Note: This command is not executed when the A button is pressed. That
-/// command is executed directly from the GuiGameList___Ctrl. This command is
-/// for the graphical hint and to allow a mouse equivalent.
 ///
-/// \param %button (constant) The button to set. See: $BUTTON_A, _B, _X, _Y
+/// \param %gamepadButton (string) The button to set for when using gamepad input. See the input map reference comment at the top of the file
+/// \param %keyboardButton (string) The button to set for when using keyboard/mouse input.
 /// \param %text (string) The text to display next to the A button graphic.
 /// \param %command (string) The command executed when the A button is pressed.
+/// \param %gamepadOnly (bool) If true, will only show the button when working in the gamepad input mode
 function MenuInputButton::set(%this, %gamepadButton, %keyboardButton, %text, %command, %gamepadOnly)
 {
    %set = (! ((%text $= "") && (%command $= "")));
@@ -53,13 +73,13 @@ function MenuInputButton::set(%this, %gamepadButton, %keyboardButton, %text, %co
    %this.Command = %command;
 }
 
+/// Refreshes the specific button, updating it's visbility status and the displayed input image
 function MenuInputButton::refresh(%this)
 {
-
    %set = (! ((%this.text $= "") && (%this.command $= "")));
    
    //Special-case of where we're in keyboard+mouse mode, but the menubutton is gamepad only mode, so we early out
-   if(%this.gamepadOnly && $activeControllerName $= "K&M")
+   if(%this.gamepadOnly && $activeControllerType !$= "gamepad")
       %set = false;
       
    %this.setActive(%set);
@@ -68,7 +88,7 @@ function MenuInputButton::refresh(%this)
    if(!%this.isActive())
       return;
    
-   if($activeControllerName !$= "K&M")
+   if($activeControllerType $= "gamepad")
    {
       if(%this.gamepadButton !$= "")
       {
@@ -77,53 +97,82 @@ function MenuInputButton::refresh(%this)
          { 
             %path = "data/ui/images/inputs/PS4/PS4_";
             
-            if(%this.gamepadButton $= "A")
+            if(%this.gamepadButton $= "btn_a")
                %path = %path @ "Cross";
-            else if(%this.gamepadButton $= "B")
+            else if(%this.gamepadButton $= "btn_b")
                %path = %path @ "Circle";
-            else if(%this.gamepadButton $= "X")
+            else if(%this.gamepadButton $= "btn_x")
                %path = %path @ "Square";
-            else if(%this.gamepadButton $= "Y")
+            else if(%this.gamepadButton $= "btn_y")
                %path = %path @ "Triangle";
-            else if(%this.gamepadButton $= "LB")
+            else if(%this.gamepadButton $= "btn_l")
                %path = %path @ "L1";
-            else if(%this.gamepadButton $= "LT")
+            else if(%this.gamepadButton $= "zaxis")
                %path = %path @ "L2";
-            else if(%this.gamepadButton $= "RB")
+            else if(%this.gamepadButton $= "btn_r")
                %path = %path @ "R1";
-            else if(%this.gamepadButton $= "RT")
+            else if(%this.gamepadButton $= "rzaxis")
                %path = %path @ "R2";
-            //else      
-            //   continue;
+            else if(%this.gamepadButton $= "btn_start")
+               %path = %path @ "Options";
+            else if(%this.gamepadButton $= "btn_back")
+               %path = %path @ "Share";
+            else      
+               continue;
          }
          else if($activeControllerName $= "Nintendo Switch Pro Controller")
          {
             %path = "data/ui/images/inputs/Switch/Switch_";
             
-            if(%this.gamepadButton $= "A")
+            if(%this.gamepadButton $= "btn_a")
                %path = %path @ "B";
-            else if(%this.gamepadButton $= "B")
+            else if(%this.gamepadButton $= "btn_b")
                %path = %path @ "A";
-            else if(%this.gamepadButton $= "X")
+            else if(%this.gamepadButton $= "btn_x")
                %path = %path @ "Y";
-            else if(%this.gamepadButton $= "Y")
+            else if(%this.gamepadButton $= "btn_y")
                %path = %path @ "X";
-            else if(%this.gamepadButton $= "LB")
+            else if(%this.gamepadButton $= "btn_l")
                %path = %path @ "LB";
-            else if(%this.gamepadButton $= "LT")
+            else if(%this.gamepadButton $= "zaxis")
                %path = %path @ "LT";
-            else if(%this.gamepadButton $= "RB")
+            else if(%this.gamepadButton $= "btn_r")
                %path = %path @ "RB";
-            else if(%this.gamepadButton $= "RT")
+            else if(%this.gamepadButton $= "rzaxis")
                %path = %path @ "RT";
-            //else      
-            //   continue;
+            else if(%this.gamepadButton $= "btn_start")
+               %path = %path @ "Plus";
+            else if(%this.gamepadButton $= "btn_back")
+               %path = %path @ "Minus";
+            else      
+               continue;
          }
          else if($activeControllerName !$= "")
          {
             %path = "data/ui/images/inputs/Xbox/Xbox_";
             
-            %path = %path @ %this.gamepadButton;
+            if(%this.gamepadButton $= "btn_a")
+               %path = %path @ "A";
+            else if(%this.gamepadButton $= "btn_b")
+               %path = %path @ "B";
+            else if(%this.gamepadButton $= "btn_x")
+               %path = %path @ "X";
+            else if(%this.gamepadButton $= "btn_y")
+               %path = %path @ "Y";
+            else if(%this.gamepadButton $= "btn_l")
+               %path = %path @ "LB";
+            else if(%this.gamepadButton $= "zaxis")
+               %path = %path @ "LT";
+            else if(%this.gamepadButton $= "btn_r")
+               %path = %path @ "RB";
+            else if(%this.gamepadButton $= "rzaxis")
+               %path = %path @ "RT";
+            else if(%this.gamepadButton $= "btn_start")
+               %path = %path @ "Menu";
+            else if(%this.gamepadButton $= "btn_back")
+               %path = %path @ "Windows";
+            else      
+               continue;
          }
       } 
    }
@@ -140,6 +189,7 @@ function MenuInputButton::refresh(%this)
    return true;
 }
 
+/// Refreshes a menu input container, updating the buttons inside it
 function MenuInputButtonContainer::refresh(%this)
 {
    %count = %this.getCount();
@@ -151,6 +201,8 @@ function MenuInputButtonContainer::refresh(%this)
    }
 }
 
+/// Sets the given MenuInputButtonContainer as the active one. This directs input events
+/// to it's buttons, ensures it's visible, and auto-hides the old active container if it was set
 function MenuInputButtonContainer::setActive(%this)
 {
    if(isObject($activeMenuButtonContainer))
@@ -161,6 +213,8 @@ function MenuInputButtonContainer::setActive(%this)
    $activeMenuButtonContainer.refresh();
 }
 
+/// Checks the input manager for if we have a gamepad active and gets it's name
+/// If we have one, also sets the active input type to gamepad
 function MenuInputButtonContainer::checkGamepad(%this)
 {
    %controllerName = SDLInputManager::JoystickNameForIndex(0);
@@ -168,101 +222,17 @@ function MenuInputButtonContainer::checkGamepad(%this)
    $activeControllerName = %controllerName;
    
    if($activeControllerName $= "")
-      $activeControllerName = "K&M";
+      $activeControllerType = "K&M";
+   else
+      $activeControllerType = "gamepad";     
 }
    
-function MenuInputButtonContainer::refreshButtons(%this)
-{
-   //Set up our basic buttons
-   for(%i=0; %i < %this.getCount(); %i++)
-   {
-      %btn = %this.getObject(%i);
-      
-      %set = (! ((%btn.text $= "") && (%btn.command $= "")));
-      
-      //Special-case of where we're in keyboard+mouse mode, but the menubutton is gamepad only mode, so we early out
-      if(%btn.gamepadOnly && $activeControllerName $= "K&M")
-         %set = false;
-         
-      %btn.setActive(%set);
-      %btn.setVisible(%set);
-      
-      if(!%btn.isActive())
-         continue;
-      
-      if($activeControllerName !$= "K&M")
-      {
-         if(%btn.gamepadButton !$= "")
-         {
-            %path = "";
-            if($activeControllerName $= "PS4 Controller")
-            { 
-               %path = "data/ui/images/inputs/PS4/PS4_";
-               
-               if(%btn.gamepadButton $= "A")
-                  %path = %path @ "Cross";
-               else if(%btn.gamepadButton $= "B")
-                  %path = %path @ "Circle";
-               else if(%btn.gamepadButton $= "X")
-                  %path = %path @ "Square";
-               else if(%btn.gamepadButton $= "Y")
-                  %path = %path @ "Triangle";
-               else if(%btn.gamepadButton $= "LB")
-                  %path = %path @ "L1";
-               else if(%btn.gamepadButton $= "LT")
-                  %path = %path @ "L2";
-               else if(%btn.gamepadButton $= "RB")
-                  %path = %path @ "R1";
-               else if(%btn.gamepadButton $= "RT")
-                  %path = %path @ "R2";
-               else      
-                  continue;
-            }
-            else if($activeControllerName $= "Nintendo Switch Pro Controller")
-            {
-               %path = "data/ui/images/inputs/Switch/Switch_";
-               
-               if(%btn.gamepadButton $= "A")
-                  %path = %path @ "B";
-               else if(%btn.gamepadButton $= "B")
-                  %path = %path @ "A";
-               else if(%btn.gamepadButton $= "X")
-                  %path = %path @ "Y";
-               else if(%btn.gamepadButton $= "Y")
-                  %path = %path @ "X";
-               else if(%btn.gamepadButton $= "LB")
-                  %path = %path @ "LB";
-               else if(%btn.gamepadButton $= "LT")
-                  %path = %path @ "LT";
-               else if(%btn.gamepadButton $= "RB")
-                  %path = %path @ "RB";
-               else if(%btn.gamepadButton $= "RT")
-                  %path = %path @ "RT";
-               else      
-                  continue;
-            }
-            else if($activeControllerName !$= "")
-            {
-               %path = "data/ui/images/inputs/Xbox/Xbox_";
-               
-               %path = %path @ %btn.gamepadButton;
-            }
-         } 
-      }
-      else
-      {
-         if(%btn.keyboardButton !$= "")
-         {
-            %path = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_" @ %btn.keyboardButton;
-         }
-      }
-      
-      %btn.setBitmap(%path);
-   }
-   
-   return true;
-}
-
+/// This is called by the earlier inputs callback that comes from the menu list
+/// this allows us to first check what the input type is, and if the device is different
+/// (such as going from keyboard and mouse to gamepad) we can refresh the buttons to update
+/// the display
+/// Then we process the input to see if it matches to any of the button maps for our 
+/// MenuInputButtons. If we have a match, we execute it's command.
 function MenuInputButtonContainer::processInputs(%this, %device, %action)
 {
    //check to see if our status has changed
@@ -270,25 +240,17 @@ function MenuInputButtonContainer::processInputs(%this, %device, %action)
    
    %oldDevice = $activeControllerName;
    
-   if(startsWith(%device, "Keyboard"))
+   %deviceName = stripTrailingNumber(%device);
+   
+   if(%deviceName $= "keyboard" || %deviceName $= "mouse")
    {
-      if($activeControllerName !$= %device)
+      if($activeControllerName !$= "K&M")
          %changed = true;
          
       $activeControllerName = "K&M";
+      $activeControllerType = "K&M";
       Canvas.showCursor();
    }
-   else if(startsWith(%device, "Mouse"))
-   {
-      if(startsWith(%action, "button"))
-      {
-         if($activeControllerName !$= %device)
-            %changed = true;
-            
-         $activeControllerName = "K&M";
-         Canvas.showCursor();
-      }
-   }
    else
    {
       if(%this.checkGamepad())
@@ -296,7 +258,7 @@ function MenuInputButtonContainer::processInputs(%this, %device, %action)
          Canvas.hideCursor();
       }
       
-      if($activeControllerName !$= %device)
+      if($activeControllerType !$= %oldDevice)
          %changed = true;
    }
    
@@ -312,21 +274,8 @@ function MenuInputButtonContainer::processInputs(%this, %device, %action)
       if(!%btn.isActive())
          continue;
       
-      if($activeControllerName !$= "K&M")
+      if($activeControllerType !$= "K&M")
       {
-         if(%action $= "btn_a")
-            %action = "A";
-         else if(%action $= "btn_b")
-            %action = "B";
-         else if(%action $= "btn_x")
-            %action = "X";
-         else if(%action $= "btn_y")
-            %action = "Y";
-         else if(%action $= "btn_r")
-            %action = "RB";
-         else if(%action $= "btn_l")
-            %action = "LB";
-            
          if(%btn.gamepadButton $= %action)
          {
             eval(%btn.command);
@@ -334,11 +283,6 @@ function MenuInputButtonContainer::processInputs(%this, %device, %action)
       }
       else
       {
-         if(%action $= "return")
-            %action = "enter";
-         else if(%action $= "escape")
-            %action = "esc";
-            
          if(%btn.keyboardButton $= %action)
          {
             eval(%btn.command);
@@ -347,22 +291,27 @@ function MenuInputButtonContainer::processInputs(%this, %device, %action)
    }
 }
 
+/// This is called by the earlier inputs callback that comes from the menu list
+/// this allows us to first check what the input type is, and if the device is different
+/// (such as going from keyboard and mouse to gamepad) we can refresh the buttons to update
+/// the display
 function MenuInputButtonContainer::processAxisEvent(%this, %device, %action, %axisVal)
 {
+   //check to see if our status has changed
    %changed = false;
    
    %oldDevice = $activeControllerName;
    
-   if(startsWith(%device, "Mouse"))
+   %deviceName = stripTrailingNumber(%device);
+   
+   if(%deviceName $= "mouse")
    {
-      if(startsWith(%action, "button"))
-      {
-         if($activeControllerName !$= %device)
-            %changed = true;
-            
-         $activeControllerName = "K&M";
-         Canvas.showCursor();
-      }
+      if($activeControllerName !$= "K&M")
+         %changed = true;
+         
+      $activeControllerName = "K&M";
+      $activeControllerType = "K&M";
+      Canvas.showCursor();
    }
    else
    {
@@ -371,13 +320,14 @@ function MenuInputButtonContainer::processAxisEvent(%this, %device, %action, %ax
          Canvas.hideCursor();
       }
       
-      if($activeControllerName !$= %device)
+      if($activeControllerType !$= %oldDevice)
          %changed = true;
    }
    
    if(%changed)
       %this.refresh();
 }
+
 //
 //
 function onSDLDeviceConnected(%sdlIndex, %deviceName, %deviceType)

+ 25 - 29
Templates/BaseGame/game/data/ui/scripts/messageBoxes.cs

@@ -97,15 +97,13 @@ function MessageBoxOK(%title, %message, %callback)
    Canvas.pushDialog(MessageBoxDlg);
    MessageBoxTitleText.text = %title;
    
-   MessageBoxButtonHolder-->OKButton.set("A", "Enter", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
+   MessageBoxOCButtonHolder.hidden = true;
+   MessageBoxYNCButtonHolder.hidden = true;
+   MessageBoxOKButtonHolder.hidden = false;
    
-   MessageBoxButtonHolder.setActive();
+   MessageBoxOKButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
    
-   MessageBoxButtonHolder-->oc_OKButton.hidden = true;
-   MessageBoxButtonHolder-->oc_CancelButton.hidden = true;
-   MessageBoxButtonHolder-->ync_yesButton.hidden = true;
-   MessageBoxButtonHolder-->ync_noButton.hidden = true;
-   MessageBoxButtonHolder-->ync_CancelButton.hidden = true;
+   MessageBoxOKButtonHolder.setActive();
    
    MBSetText(MessageBoxText, MessageBoxCtrl, %message);
    MessageBoxDlg.callback = %callback;
@@ -121,15 +119,14 @@ function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback)
    Canvas.pushDialog(MessageBoxDlg);
    MessageBoxTitleText.text = %title;
    
-   MessageBoxButtonHolder-->oc_OKButton.set("A", "Enter", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
-   MessageBoxButtonHolder-->oc_CancelButton.set("B", "Esc", "Cancel", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
-
-   MessageBoxButtonHolder.setActive();
+   MessageBoxOCButtonHolder.hidden = false;
+   MessageBoxYNCButtonHolder.hidden = true;
+   MessageBoxOKButtonHolder.hidden = true;
    
-   MessageBoxButtonHolder-->OKButton.hidden = true;
-   MessageBoxButtonHolder-->ync_yesButton.hidden = true;
-   MessageBoxButtonHolder-->ync_noButton.hidden = true;
-   MessageBoxButtonHolder-->ync_CancelButton.hidden = true;
+   MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
+   MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "Cancel", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
+
+   MessageBoxOCButtonHolder.setActive();
    
    MBSetText(MessageBoxText, MessageBoxCtrl, %message);
    MessageBoxDlg.callback = %callback;
@@ -217,15 +214,14 @@ function MessageBoxYesNo(%title, %message, %yesCallback, %noCallback)
    Canvas.pushDialog(MessageBoxDlg);
    MessageBoxTitleText.text = %title;
    
-   MessageBoxButtonHolder-->oc_OKButton.set("A", "Enter", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
-   MessageBoxButtonHolder-->oc_CancelButton.set("B", "Esc", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
+   MessageBoxOCButtonHolder.hidden = false;
+   MessageBoxYNCButtonHolder.hidden = true;
+   MessageBoxOKButtonHolder.hidden = true;
    
-   MessageBoxButtonHolder.setActive();
+   MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
+   MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
    
-   MessageBoxButtonHolder-->OKButton.hidden = true;
-   MessageBoxButtonHolder-->ync_yesButton.hidden = true;
-   MessageBoxButtonHolder-->ync_noButton.hidden = true;
-   MessageBoxButtonHolder-->ync_CancelButton.hidden = true;
+   MessageBoxOCButtonHolder.setActive();
    
    MBSetText(MessageBoxText, MessageBoxCtrl, %message);
    MessageBoxDlg.yesCallBack = %yesCallback;
@@ -237,15 +233,15 @@ function MessageBoxYesNoCancel(%title, %message, %yesCallback, %noCallback, %can
    Canvas.pushDialog(MessageBoxDlg);
    MessageBoxTitleText.text = %title;
    
-   MessageBoxButtonHolder-->ync_yesButton.set("A", "Enter", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
-   MessageBoxButtonHolder-->ync_noButton.set("X", "Backspace", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
-   MessageBoxButtonHolder-->ync_cancelButton.set("B", "Esc", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
+   MessageBoxOCButtonHolder.hidden = true;
+   MessageBoxYNCButtonHolder.hidden = false;
+   MessageBoxOKButtonHolder.hidden = true;
    
-   MessageBoxButtonHolder.setActive();
+   MessageBoxYNCButtonHolder-->yesButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
+   MessageBoxYNCButtonHolder-->noButton.set("btn_x", "backspace", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
+   MessageBoxYNCButtonHolder-->cancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
    
-   MessageBoxButtonHolder-->OKButton.hidden = true;
-   MessageBoxButtonHolder-->oc_OKButton.hidden = true;
-   MessageBoxButtonHolder-->oc_CancelButton.hidden = true;
+   MessageBoxYNCButtonHolder.setActive();
    
    MBSetText(MessageBoxText, MessageBoxCtrl, %message);
    MessageBoxDlg.yesCallBack = %yesCallback;