mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Most of the keybind/remap stuff finished
Fixed up most of the options apply logic
This commit is contained in:
parent
55697cffdb
commit
70e121595f
6 changed files with 217 additions and 147 deletions
77
Templates/BaseGame/game/data/UI/guis/remapDlg.tscript
Normal file
77
Templates/BaseGame/game/data/UI/guis/remapDlg.tscript
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
|
||||
{
|
||||
Canvas.popDialog( RemapDlg );
|
||||
|
||||
if ( %device $= "keyboard" && %action $= "escape" )
|
||||
return;
|
||||
else if( %device $= "gamepad" && %action $= "btn_start" )
|
||||
return;
|
||||
|
||||
%cmd = $RemapCmd[%this.index];
|
||||
%name = $RemapName[%this.index];
|
||||
%actionMap = $RemapActionMap[%this.index];
|
||||
|
||||
echo("OptRemapInputCtrl::onInputEvent() - remapping details: " @ %cmd @ ", " @ %name @ ", " @ %actionMap @ " remapped to: " @ %device @ ", " @ %action);
|
||||
|
||||
// Grab the friendly display name for this action
|
||||
// which we'll use when prompting the user below.
|
||||
%mapName = getMapDisplayName( %device, %action );
|
||||
|
||||
// Get the current command this action is mapped to.
|
||||
%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 );
|
||||
|
||||
// If nothing was mapped to the previous command
|
||||
// mapping then it's easy... just bind it.
|
||||
if ( %prevMap $= "" )
|
||||
{
|
||||
//unbindExtraActions( %cmd, %actionMap, 1 );
|
||||
%actionMap.bind( %device, %action, %cmd );
|
||||
|
||||
OptionsMenu.syncGui();
|
||||
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 );
|
||||
|
||||
// If we get a negative index then the previous
|
||||
// mapping was to an item that isn't included in
|
||||
// the mapping list... so we cannot unmap it.
|
||||
if ( %prevMapIndex == -1 )
|
||||
{
|
||||
MessageBoxOK( "Remap Failed", "\"" @ %mapName @ "\" is already bound to a non-remappable command!" );
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup the forced remapping callback command.
|
||||
%callback = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @
|
||||
%cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");";
|
||||
|
||||
// Warn that we're about to remove the old mapping and
|
||||
// replace it with another.
|
||||
%prevCmdName = $RemapName[%prevMapIndex];
|
||||
//Canvas.pushDialog( RemapConfirmDlg );
|
||||
|
||||
%remapWarnText = "\"" @ %mapName @ "\" is already bound to \"" @ %prevCmdName @ "\"! Do you wish to replace this mapping?";
|
||||
%doRemapCommand = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @
|
||||
%cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");";
|
||||
%cancelCommand = "";
|
||||
|
||||
MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue