From 732d76d17ce01919cdb3476d09fbd1ad330c81c0 Mon Sep 17 00:00:00 2001 From: AtomicWalrus Date: Sat, 25 Feb 2023 03:14:30 -0700 Subject: [PATCH] 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. --- Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript | 6 ++++-- .../BaseGame/game/data/UI/scripts/controlsMenu.tscript | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index f7f5593b9..7e0bd629b 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -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); diff --git a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript index 6f51988d3..95df2cebf 100644 --- a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript @@ -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..." ;