- Added ability to explicitly execute a guiControl's console and altConsole command

- Fixed formatting of resolution strings for the internal values, allowing them to be properly parsed and applied by the options menu/canvas
- Fixed display of Display Device on option's menu
- Fixed Issue of it not displaying any keybinds in keyboard/gamepad options if there's only a single actionmap
- Added 'hold to scroll' action to optionsMenu
- Added apply button to options menu
- Added remap button to options menu when on keyboard/gamepad keybinds categories
- Fixed up the remap logic so remapping a key only unbinds the matched device being bound, so binds for different devices are untouched
- Made keybinds options properly refresh when keybinds are changed
- Shifted keyboard "go" keybind for menu nav from Enter to Space for easier use
- Removed stick keybinds from gamepad
This commit is contained in:
Areloch 2023-12-31 12:46:48 -06:00
parent f5ab97242f
commit 67ac556ecd
14 changed files with 223 additions and 95 deletions

View file

@ -1,12 +1,36 @@
function OptRemapInputCtrl::onAxisEvent( %this, %device, %action, %axisVal)
{
if(%device $= "mouse")
return;
if(!startsWith(%device,$remapListDevice))
return;
if(%axisVal != 1 && %axisVal != -1) //we want full presses on sticks to be sure
return;
Canvas.popDialog( RemapDlg );
%this.doRemap(%device, %action, %axisVal);
}
function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
{
Canvas.popDialog( RemapDlg );
if ( %device $= "keyboard" && %action $= "escape" )
return;
else if( %device $= "gamepad" && %action $= "btn_start" )
if(!startsWith(%device,$remapListDevice) && %action !$= "escape" && %action !$= "btn_start")
{
return;
}
else
{
Canvas.popDialog( RemapDlg );
if(%action $= "escape" || %action $= "btn_start")
return;
%this.doRemap(%device, %action, 0);
}
}
function OptRemapInputCtrl::doRemap(%this, %device, %action, %axisVal)
{
%cmd = $RemapCmd[%this.index];
%name = $RemapName[%this.index];
%actionMap = $RemapActionMap[%this.index];
@ -21,32 +45,24 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
%prevMap = %actionMap.getCommand( %device, %action );
//TODO: clear all existant keybinds to a command and then bind it so we only have a single one at all times
unbindExtraActions( %cmd, %actionMap, 0 );
unbindExtraActions( %cmd, %actionMap, 1 );
unbindExtraActions( %cmd, %actionMap, %device, 0 );
unbindExtraActions( %cmd, %actionMap, %device, 1 );
// If nothing was mapped to the previous command
// mapping then it's easy... just bind it.
if ( %prevMap $= "" )
// If the previous command is the same as the
// current then they hit the same input as what
// was already assigned.
if ( %prevMap $= "" || %prevMap $= %cmd )
{
//unbindExtraActions( %cmd, %actionMap, 1 );
%actionMap.bind( %device, %action, %cmd );
OptionsMenu.syncGui();
OptionsMenu.populateKBMControls();
OptionsMenu.populateGamepadControls();
return;
}
// If the previous command is the same as the
// current then they hit the same input as what
// was already assigned.
if ( %prevMap $= %cmd )
{
//unbindExtraActions( %cmd, %actionMap, 0 );
%actionMap.bind( %device, %action, %cmd );
OptionsMenu.syncGui();
return;
}
// Look for the index of the previous mapping.
%prevMapIndex = findRemapCmdIndex( %prevMap );
@ -73,5 +89,24 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
%cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");";
%cancelCommand = "";
MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand );
}
MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand );
}
/// This unbinds actions beyond %count associated to the
/// particular actionMap %commmand.
function unbindExtraActions( %command, %actionMap, %device, %count )
{
%temp = %actionMap.getBinding( %command );
if ( %temp $= "" )
return;
%count = getFieldCount( %temp ) - ( %count * 2 );
for ( %i = 0; %i < %count; %i += 2 )
{
%amDevice = getField( %temp, %i + 0 );
%action = getField( %temp, %i + 1 );
if(%device !$= "" || %device $= %amDevice)
%actionMap.unbind( %device, %action );
}
}