diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index d37f3ebce..e231f084e 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -583,7 +583,7 @@ function OptionsMenu::populateAudioSettings(%this) function OptionsMenu::populateKBMControls(%this) { - %this.populateKeybinds("keyboard", KBMControlsList); + %this.populateKeybinds("keyboard" TAB "mouse", KBMControlsList); %this.syncGui(); @@ -599,7 +599,7 @@ function OptionsMenu::populateGamepadControls(%this) GamepadControlsList.syncGui(); } -function OptionsMenu::populateKeybinds(%this, %device, %controlsList) +function OptionsMenu::populateKeybinds(%this, %devices, %controlsList) { %controlsList.clear(); @@ -662,21 +662,30 @@ function OptionsMenu::populateKeybinds(%this, %device, %controlsList) for ( %i = 0; %i < $RemapCount; %i++ ) { - if(%device !$= "" && %device !$= $RemapDevice[%i]) + %entryDevice = ""; + //Check each field of %devices for device matching the remappable action + foreach$(%d in %devices){ + if(%d $= $RemapDevice[%i]) { + %entryDevice = %d; + break; + } + } + //If there was no match go to the next remappable action + if(%entryDevice $= "") continue; - - %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; - + + %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; + if(%currentActionMap !$= %actionMapName) continue; - - %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %device ); + + %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %entryDevice ); %description = $RemapDescription[%i]; - if ($reportKeymapping) - echo("Added ActionMap Entry: " @ %actionMapName @ " | " @ %device @ " | " @ %keymap @ " | " @ %description); - - %remapEntry = addActionMapEntry(%actionMapName, %device, %keyMap, %i, %description); + + echo("Added ActionMap Entry: " @ %actionMapName @ " | " @ %entryDevice @ " | " @ %keymap @ " | " @ %description); + + %remapEntry = addActionMapEntry(%actionMapName, %entryDevice, %keyMap, %i, %description); %controlsList.add(%remapEntry); } } @@ -1132,4 +1141,4 @@ function addActionMapEntry(%actionMap, %device, %keyMap, %index, %description) } return %entry; -} \ No newline at end of file +} diff --git a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript index dcf198969..19daa4ceb 100644 --- a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript @@ -126,85 +126,6 @@ function buildFullMapString( %index, %actionMap, %deviceType ) return %name TAB %mapString; } -function fillRemapList() -{ - %device = $remapListDevice; - - OptionsMenuSettingsList.clear(); - - //build out our list of action maps - %actionMapCount = ActionMapGroup.getCount(); - - %actionMapList = ""; - for(%i=0; %i < %actionMapCount; %i++) - { - %actionMap = ActionMapGroup.getObject(%i); - - if(%actionMap == GlobalActionMap.getId()) - continue; - - %actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName; - - //see if we have any actual listed remappable keys for this movemap. if so, drop it from the listing - %hasRemaps = false; - for ( %r = 0; %r < $RemapCount; %r++ ) - { - %testMapName = $RemapActionMap[%r].humanReadableName $= "" ? $RemapActionMap[%r].getName() : $RemapActionMap[%r].humanReadableName; - - if(%actionMapName $= %testMapName) - { - //got a match to at least one, so we're ok to continue - %hasRemaps = true; - break; - } - } - - if(!%hasRemaps) - continue; - - if(%actionMapList $= "") - %actionMapList = %actionMapName; - else - %actionMapList = %actionMapList TAB %actionMapName; - } - - //If we didn't find any valid actionMaps, then just exit out - if(%actionMapList $= "") - return; - - if($activeRemapControlSet $= "") - $activeRemapControlSet = getField(%actionMapList, 0); - - OptionsMenuSettingsList.addOptionRow("Control Set", "$activeRemapControlSet", %actionMapList, false, "controlSetChanged", true, "Which keybind control set to edit", $activeRemapControlSet); - - for ( %i = 0; %i < $RemapCount; %i++ ) - { - if(%device !$= "" && %device !$= $RemapDevice[%i]) - continue; - - %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; - - if($activeRemapControlSet !$= %actionMapName) - continue; - - %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %device ); - %description = $RemapDescription[%i]; - - %buttonImageAsset = getButtonBitmap(%device, getField(%keyMap, 1)); - - OptionsMenuSettingsList.addKeybindRow(getField(%keyMap, 0), %buttonImageAsset, "doKeyRemap", true, %description, %i); - } - - //OptionsMenuSettingsList.refresh(); - //OptionsMenu.addRow( %i, %this.buildFullMapString( %i ) ); -} - -function controlSetChanged() -{ - $activeRemapControlSet = OptionsMenuSettingsList.getObject(0).getCurrentOption(); - fillRemapList(); -} - function ControlsMenuRebindButton::onClick(%this) { %name = $RemapName[%this.keybindIndex]; @@ -231,5 +152,6 @@ function redoMapping( %device, %actionMap, %action, %cmd, %oldIndex, %newIndex ) //%actionMap.bind( %device, %action, $RemapCmd[%newIndex] ); %actionMap.bind( %device, %action, %cmd ); - fillRemapList(); + OptionsMenu.populateKBMControls(); + OptionsMenu.populateGamepadControls(); } diff --git a/Templates/BaseGame/game/data/UI/scripts/utility.tscript b/Templates/BaseGame/game/data/UI/scripts/utility.tscript index e750d4290..c7648c5b2 100644 --- a/Templates/BaseGame/game/data/UI/scripts/utility.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/utility.tscript @@ -115,7 +115,9 @@ function getButtonBitmap(%device, %button) { if(%button $= "lshift" || %button $= "rshift") %button = "shift"; - + else if(%button $= "lcontrol" || %button $= "rcontrol") + %button = "ctrl"; + %assetId = "UI:Keyboard_Black_" @ %button @ "_image"; } else if(%device !$= "") @@ -192,4 +194,4 @@ function switchLanguage(%language) //use here the #n as it's the order of inclus // swap existing language from the current core langtable and refresh the gui contents getCoreLangTable().setCurrentLanguage(%language); Canvas.setContent(Canvas.getContent()); -} \ No newline at end of file +}