Key rebinding script fixes

Fixes two issues:
-Bindings after the first page were not pointing to the correct remapping entries when actually remapping. Were populating the name and button image correctly, but first item on every page pointed to first item on first page.
-Keybinds were never being saved to file if your action maps all had long-form ("human readable") names defined.
This commit is contained in:
AtomicWalrus 2023-02-25 03:14:30 -07:00
parent bae7166cc0
commit 732d76d17c
2 changed files with 6 additions and 5 deletions

View file

@ -193,7 +193,7 @@ function OptionsMenu::apply(%this)
if(%actionMap == GlobalActionMap.getId())
continue;
%actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName;
%actionMapName = %actionMap.getName();
if(%actionMapName $= %targetVar)
{
%hasKeybindChanges = true;
@ -959,7 +959,7 @@ function OptionsMenuSettingsList::addSliderRow(%this, %label, %targetPrefVar, %i
%this.add(%option);
}
function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %callback, %enabled, %description)
function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %callback, %enabled, %description, %remapIndex)
{
if(%enabled $= "")
%enabled = true;
@ -978,6 +978,8 @@ function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %cal
useMouseEvents = true;
};
%option.remapIndex = %remapIndex;
%option.setKeybindSetting(%label, %bitmapName, %callback, %enabled, %description);
%this.add(%option);

View file

@ -192,7 +192,7 @@ function fillRemapList()
%buttonImageAsset = getButtonBitmap(%device, getField(%keyMap, 1));
OptionsMenuSettingsList.addKeybindRow(getField(%keyMap, 0), %buttonImageAsset, "doKeyRemap", true, %description);
OptionsMenuSettingsList.addKeybindRow(getField(%keyMap, 0), %buttonImageAsset, "doKeyRemap", true, %description, %i);
}
//OptionsMenuSettingsList.refresh();
@ -207,8 +207,7 @@ function controlSetChanged()
function doKeyRemap( %row )
{
%rowIndex = %row.getParent().getObjectIndex(%row);
%rowIndex--; //Offset the rowIndex to account for controlset option
%rowIndex = %row.remapIndex;
%name = $RemapName[%rowIndex];
RemapDlg-->OptRemapText.text = "Re-bind \"" @ %name @ "\" to..." ;