diff --git a/Templates/BaseGame/game/core/utility/scripts/input.tscript b/Templates/BaseGame/game/core/utility/scripts/input.tscript index 20a3dbbb7..c37227ce7 100644 --- a/Templates/BaseGame/game/core/utility/scripts/input.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/input.tscript @@ -8,4 +8,23 @@ function getMouseAdjustAmount(%val) { // based on a default camera FOV of 90' return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity; +} + +function addKeyRemap(%name, %actionMap, %device, %command, %description) +{ + if(%name $= "" || + %actionMap $= "" || + %device $= "" || + %command $= "") + { + error("addKeybindRemap() - tried to add a remap entry, but didn't have all the keeded info!"); + return; + } + + $RemapName[$RemapCount] = %name; + $RemapCmd[$RemapCount] = %command; + $RemapActionMap[$RemapCount] = %actionMap; + $RemapDevice[$RemapCount] = %device; + $RemapDescription[$RemapCount] = %description; + $RemapCount++; } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript b/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript index fc79c221f..cb4f84431 100644 --- a/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript +++ b/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript @@ -1,70 +1,21 @@ -$RemapName[$RemapCount] = "Forward"; -$RemapCmd[$RemapCount] = "moveforward"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Forward Movement"; -$RemapCount++; -$RemapName[$RemapCount] = "Backward"; -$RemapCmd[$RemapCount] = "movebackward"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Backward Movement"; -$RemapCount++; -$RemapName[$RemapCount] = "Strafe Left"; -$RemapCmd[$RemapCount] = "moveleft"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Left Strafing Movement"; -$RemapCount++; -$RemapName[$RemapCount] = "Strafe Right"; -$RemapCmd[$RemapCount] = "moveright"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Right Strafing Movement"; -$RemapCount++; -$RemapName[$RemapCount] = "Ascend"; -$RemapCmd[$RemapCount] = "moveup"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Makes the camera ascend"; -$RemapCount++; -$RemapName[$RemapCount] = "Descend"; -$RemapCmd[$RemapCount] = "movedown"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Makes the camera descend"; -$RemapCount++; -$RemapName[$RemapCount] = "Jump"; -$RemapCmd[$RemapCount] = "jump"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "keyboard"; -$RemapDescription[$RemapCount] = "Jump"; -$RemapCount++; +if(!isObject( ExampleMoveMap ) ) +{ + new ActionMap(ExampleMoveMap) + { + humanReadableName = "Example Movement"; + }; +} -$RemapName[$RemapCount] = "Ascend"; -$RemapCmd[$RemapCount] = "moveup"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "gamepad"; -$RemapDescription[$RemapCount] = "Makes the camera ascend"; -$RemapCount++; -$RemapName[$RemapCount] = "Descend"; -$RemapCmd[$RemapCount] = "movedown"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "gamepad"; -$RemapDescription[$RemapCount] = "Makes the camera descend"; -$RemapCount++; -$RemapName[$RemapCount] = "Jump"; -$RemapCmd[$RemapCount] = "jump"; -$RemapActionMap[$RemapCount] = "ExampleMoveMap"; -$RemapDevice[$RemapCount] = "gamepad"; -$RemapDescription[$RemapCount] = "Jump"; -$RemapCount++; - -if ( isObject( ExampleMoveMap ) ) - ExampleMoveMap.delete(); - -new ActionMap(ExampleMoveMap); -ExampleMoveMap.humanReadableName = "Example Movement"; +//------------------------------------------------------------------------------ +// Set up remappable entries +//------------------------------------------------------------------------------ +addKeyRemap("Forward", "ExampleMoveMap", "keyboard", "moveForward", "Forward Movement"); +addKeyRemap("Backward", "ExampleMoveMap", "keyboard", "movebackward", "Backward Movement"); +addKeyRemap("Strafe Left", "ExampleMoveMap", "keyboard", "moveleft", "Left Strafing Movement"); +addKeyRemap("Strafe Right", "ExampleMoveMap", "keyboard", "moveright", "Right Strafing Movement"); +addKeyRemap("Ascend", "ExampleMoveMap", "keyboard", "moveup", "Makes the camera ascend"); +addKeyRemap("Descend", "ExampleMoveMap", "keyboard", "movedown", "Makes the camera descend"); +addKeyRemap("Jump", "ExampleMoveMap", "keyboard", "jump", "Jump"); //------------------------------------------------------------------------------ // Non-remapable binds diff --git a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript index a9cc8c00e..88a8d6cf5 100644 --- a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript @@ -145,6 +145,23 @@ function fillRemapList() %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