From eb849853cef9112dc56e21e57233f8d84c477ecc Mon Sep 17 00:00:00 2001 From: aaravamudan2014 Date: Mon, 17 Apr 2017 16:07:03 -0400 Subject: [PATCH 1/6] Added new config file save for vehicle re-mappings --- Templates/Full/game/scripts/client/init.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Templates/Full/game/scripts/client/init.cs b/Templates/Full/game/scripts/client/init.cs index 2df6e2140..e40280a68 100644 --- a/Templates/Full/game/scripts/client/init.cs +++ b/Templates/Full/game/scripts/client/init.cs @@ -111,7 +111,8 @@ function initClient() if (isFile("./config.cs")) exec("./config.cs"); - + if (isFile("./config_vehicle.cs")) + exec("./config_vehicle.cs"); loadMaterials(); // Really shouldn't be starting the networking unless we are From e6788ca7143e0d3f7e86a78d3926bfec4a1df477 Mon Sep 17 00:00:00 2001 From: aaravamudan2014 Date: Mon, 17 Apr 2017 16:11:10 -0400 Subject: [PATCH 2/6] Added gui functionality for vehicle re-mapping --- Templates/Full/game/scripts/gui/optionsDlg.cs | 104 ++++++++++++++---- 1 file changed, 82 insertions(+), 22 deletions(-) diff --git a/Templates/Full/game/scripts/gui/optionsDlg.cs b/Templates/Full/game/scripts/gui/optionsDlg.cs index 3e2ea865f..402203568 100644 --- a/Templates/Full/game/scripts/gui/optionsDlg.cs +++ b/Templates/Full/game/scripts/gui/optionsDlg.cs @@ -23,6 +23,9 @@ /// Returns true if the current quality settings equal /// this graphics quality level. + +// boolean flag for vehicle control remappings +$vehicleMapped = false; function GraphicsQualityLevel::isCurrent( %this ) { // Test each pref to see if the current value @@ -231,6 +234,8 @@ function OptionsDlg::onSleep(%this) { // write out the control config into the rw/config.cs file moveMap.save( "scripts/client/config.cs" ); + // saving vehicle mappings into separate config file + vehicleMap.save("scripts/client/config_vehicle.cs"); } function OptGraphicsDriverMenu::onSelect( %this, %id, %text ) @@ -518,18 +523,38 @@ $RemapCount++; $RemapName[$RemapCount] = "Bring up Options Dialog"; $RemapCmd[$RemapCount] = "bringUpOptions"; $RemapCount++; +// adding manageable vehicle mappingsnto options gui screen +$RemapName[$RemapCount] = "Vehicle Move Forward"; +$RemapCmd[$RemapCount] = "moveforward"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle Move Backward"; +$RemapCmd[$RemapCount] = "moveBackward"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle brake"; +$RemapCmd[$RemapCount] = "brake"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle free look"; +$RemapCmd[$RemapCount] = "toggleFreeLook"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle mouseFire"; +$RemapCmd[$RemapCount] = "mouseFire"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle alt trigger"; +$RemapCmd[$RemapCount] = "altTrigger"; +$RemapCount++; function restoreDefaultMappings() { moveMap.delete(); + vehicleMap.delete(); exec( "scripts/client/default.bind.cs" ); optionsDlg.fillRemapList(); } function getMapDisplayName( %device, %action ) { - if ( %device $= "keyboard" ) + if ( %device $= "keyboard" ) return( %action ); else if ( strstr( %device, "mouse" ) != -1 ) { @@ -582,15 +607,21 @@ function getMapDisplayName( %device, %action ) error( "Unsupported Joystick input object passed to getDisplayMapName!" ); } } - - return( "??" ); + + return( "??" ); } function buildFullMapString( %index ) { %name = $RemapName[%index]; %cmd = $RemapCmd[%index]; - + + // getting exact type of binding based on Remap name + if(getSubStr(%name,0,7) $= "Vehicle" ) + { + %temp = vehicleMap.getBinding( %cmd ); + } + else %temp = moveMap.getBinding( %cmd ); if ( %temp $= "" ) return %name TAB ""; @@ -607,12 +638,12 @@ function buildFullMapString( %index ) %object = getField( %temp, %i + 1 ); %mapString = %mapString @ getMapDisplayName( %device, %object ); } - return %name TAB %mapString; } function OptionsDlg::fillRemapList( %this ) { + %remapList = %this-->OptRemapList; %remapList.clear(); @@ -621,22 +652,30 @@ function OptionsDlg::fillRemapList( %this ) } function OptionsDlg::doRemap( %this ) -{ - %remapList = %this-->OptRemapList; +{ %remapList = %this-->OptRemapList; %selId = %remapList.getSelectedId(); - %name = $RemapName[%selId]; - - RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); + %name = $RemapName[%selId]; + //turning on the vehicle mapping flag if selected item is vehicle remapping + if(getSubStr(%name,0,7) $= "Vehicle") + {$vehicleMapped = true; + } + RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); OptRemapInputCtrl.index = %selId; + Canvas.pushDialog( RemapDlg ); + } function redoMapping( %device, %action, %cmd, %oldIndex, %newIndex ) { //%actionMap.bind( %device, %action, $RemapCmd[%newIndex] ); - moveMap.bind( %device, %action, %cmd ); - + //performing desired remapping based on flag + if(!$vehicleMapped) + moveMap.bind( %device, %action, %cmd ); + else + vehicleMap.bind( %device, %action, %cmd ); + %remapList = %this-->OptRemapList; %remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) ); %remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) ); @@ -656,7 +695,13 @@ function findRemapCmdIndex( %command ) /// particular moveMap %commmand. function unbindExtraActions( %command, %count ) { - %temp = moveMap.getBinding( %command ); + //get current key binding (checking for vehicle mapping) + if(!$vehicleMapped) + %temp = moveMap.getBinding( %command ); + else + %temp = vehicleMap.getBinding( %command ); + + if ( %temp $= "" ) return; @@ -665,15 +710,18 @@ function unbindExtraActions( %command, %count ) { %device = getField( %temp, %i + 0 ); %action = getField( %temp, %i + 1 ); - + //performing desired unbinding of mapped key + if(!$vehicleMapped) moveMap.unbind( %device, %action ); - } + else + vehicleMap.unbind( %device, %action ); + + } } function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) { - //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" ); - Canvas.popDialog( RemapDlg ); + Canvas.popDialog( RemapDlg ); // Test for the reserved keystrokes: if ( %device $= "keyboard" ) @@ -693,15 +741,22 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) // which we'll use when prompting the user below. %mapName = getMapDisplayName( %device, %action ); - // Get the current command this action is mapped to. - %prevMap = moveMap.getCommand( %device, %action ); - + // Get the current command this action is mapped to + if(!$vehicleMapped) + %prevMap = moveMap.getCommand( %device, %action ); + else + %prevMap = vehicleMap.getCommand( %device, %action ); + // If nothing was mapped to the previous command // mapping then it's easy... just bind it. if ( %prevMap $= "" ) { unbindExtraActions( %cmd, 1 ); + // performing desired binding (vehicleMap or moveMap) + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); + else + vehicleMap.bind( %device, %action, %cmd ); optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); return; } @@ -712,10 +767,15 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) if ( %prevMap $= %cmd ) { unbindExtraActions( %cmd, 0 ); + //performing desired binding (vehicleMap or moveMap) + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); - return; + else + vehicleMap.bind( %device, %action, %cmd ); + optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); + return; } + $vehicleMapped = false; // Look for the index of the previous mapping. %prevMapIndex = findRemapCmdIndex( %prevMap ); From ae0fd3d616859f3a6f16a8fcae006883ea1778eb Mon Sep 17 00:00:00 2001 From: aaravamudan2014 Date: Thu, 20 Apr 2017 08:48:43 -0400 Subject: [PATCH 3/6] Update optionsDlg.cs --- Templates/Full/game/scripts/gui/optionsDlg.cs | 104 ++++-------------- 1 file changed, 22 insertions(+), 82 deletions(-) diff --git a/Templates/Full/game/scripts/gui/optionsDlg.cs b/Templates/Full/game/scripts/gui/optionsDlg.cs index 402203568..3e2ea865f 100644 --- a/Templates/Full/game/scripts/gui/optionsDlg.cs +++ b/Templates/Full/game/scripts/gui/optionsDlg.cs @@ -23,9 +23,6 @@ /// Returns true if the current quality settings equal /// this graphics quality level. - -// boolean flag for vehicle control remappings -$vehicleMapped = false; function GraphicsQualityLevel::isCurrent( %this ) { // Test each pref to see if the current value @@ -234,8 +231,6 @@ function OptionsDlg::onSleep(%this) { // write out the control config into the rw/config.cs file moveMap.save( "scripts/client/config.cs" ); - // saving vehicle mappings into separate config file - vehicleMap.save("scripts/client/config_vehicle.cs"); } function OptGraphicsDriverMenu::onSelect( %this, %id, %text ) @@ -523,38 +518,18 @@ $RemapCount++; $RemapName[$RemapCount] = "Bring up Options Dialog"; $RemapCmd[$RemapCount] = "bringUpOptions"; $RemapCount++; -// adding manageable vehicle mappingsnto options gui screen -$RemapName[$RemapCount] = "Vehicle Move Forward"; -$RemapCmd[$RemapCount] = "moveforward"; -$RemapCount++; -$RemapName[$RemapCount] = "Vehicle Move Backward"; -$RemapCmd[$RemapCount] = "moveBackward"; -$RemapCount++; -$RemapName[$RemapCount] = "Vehicle brake"; -$RemapCmd[$RemapCount] = "brake"; -$RemapCount++; -$RemapName[$RemapCount] = "Vehicle free look"; -$RemapCmd[$RemapCount] = "toggleFreeLook"; -$RemapCount++; -$RemapName[$RemapCount] = "Vehicle mouseFire"; -$RemapCmd[$RemapCount] = "mouseFire"; -$RemapCount++; -$RemapName[$RemapCount] = "Vehicle alt trigger"; -$RemapCmd[$RemapCount] = "altTrigger"; -$RemapCount++; function restoreDefaultMappings() { moveMap.delete(); - vehicleMap.delete(); exec( "scripts/client/default.bind.cs" ); optionsDlg.fillRemapList(); } function getMapDisplayName( %device, %action ) { - if ( %device $= "keyboard" ) + if ( %device $= "keyboard" ) return( %action ); else if ( strstr( %device, "mouse" ) != -1 ) { @@ -607,21 +582,15 @@ function getMapDisplayName( %device, %action ) error( "Unsupported Joystick input object passed to getDisplayMapName!" ); } } - - return( "??" ); + + return( "??" ); } function buildFullMapString( %index ) { %name = $RemapName[%index]; %cmd = $RemapCmd[%index]; - - // getting exact type of binding based on Remap name - if(getSubStr(%name,0,7) $= "Vehicle" ) - { - %temp = vehicleMap.getBinding( %cmd ); - } - else + %temp = moveMap.getBinding( %cmd ); if ( %temp $= "" ) return %name TAB ""; @@ -638,12 +607,12 @@ function buildFullMapString( %index ) %object = getField( %temp, %i + 1 ); %mapString = %mapString @ getMapDisplayName( %device, %object ); } + return %name TAB %mapString; } function OptionsDlg::fillRemapList( %this ) { - %remapList = %this-->OptRemapList; %remapList.clear(); @@ -652,30 +621,22 @@ function OptionsDlg::fillRemapList( %this ) } function OptionsDlg::doRemap( %this ) -{ %remapList = %this-->OptRemapList; +{ + %remapList = %this-->OptRemapList; %selId = %remapList.getSelectedId(); - %name = $RemapName[%selId]; - //turning on the vehicle mapping flag if selected item is vehicle remapping - if(getSubStr(%name,0,7) $= "Vehicle") - {$vehicleMapped = true; - } - RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); + %name = $RemapName[%selId]; + + RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); OptRemapInputCtrl.index = %selId; - Canvas.pushDialog( RemapDlg ); - } function redoMapping( %device, %action, %cmd, %oldIndex, %newIndex ) { //%actionMap.bind( %device, %action, $RemapCmd[%newIndex] ); - //performing desired remapping based on flag - if(!$vehicleMapped) - moveMap.bind( %device, %action, %cmd ); - else - vehicleMap.bind( %device, %action, %cmd ); - + moveMap.bind( %device, %action, %cmd ); + %remapList = %this-->OptRemapList; %remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) ); %remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) ); @@ -695,13 +656,7 @@ function findRemapCmdIndex( %command ) /// particular moveMap %commmand. function unbindExtraActions( %command, %count ) { - //get current key binding (checking for vehicle mapping) - if(!$vehicleMapped) - %temp = moveMap.getBinding( %command ); - else - %temp = vehicleMap.getBinding( %command ); - - + %temp = moveMap.getBinding( %command ); if ( %temp $= "" ) return; @@ -710,18 +665,15 @@ function unbindExtraActions( %command, %count ) { %device = getField( %temp, %i + 0 ); %action = getField( %temp, %i + 1 ); - //performing desired unbinding of mapped key - if(!$vehicleMapped) + moveMap.unbind( %device, %action ); - else - vehicleMap.unbind( %device, %action ); - - } + } } function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) { - Canvas.popDialog( RemapDlg ); + //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" ); + Canvas.popDialog( RemapDlg ); // Test for the reserved keystrokes: if ( %device $= "keyboard" ) @@ -741,22 +693,15 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) // which we'll use when prompting the user below. %mapName = getMapDisplayName( %device, %action ); - // Get the current command this action is mapped to - if(!$vehicleMapped) - %prevMap = moveMap.getCommand( %device, %action ); - else - %prevMap = vehicleMap.getCommand( %device, %action ); - + // Get the current command this action is mapped to. + %prevMap = moveMap.getCommand( %device, %action ); + // If nothing was mapped to the previous command // mapping then it's easy... just bind it. if ( %prevMap $= "" ) { unbindExtraActions( %cmd, 1 ); - // performing desired binding (vehicleMap or moveMap) - if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - else - vehicleMap.bind( %device, %action, %cmd ); optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); return; } @@ -767,15 +712,10 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) if ( %prevMap $= %cmd ) { unbindExtraActions( %cmd, 0 ); - //performing desired binding (vehicleMap or moveMap) - if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - else - vehicleMap.bind( %device, %action, %cmd ); - optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); - return; + optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); + return; } - $vehicleMapped = false; // Look for the index of the previous mapping. %prevMapIndex = findRemapCmdIndex( %prevMap ); From 18303f1145f3e9d12d2aa715d094784f1fcd81a8 Mon Sep 17 00:00:00 2001 From: aaravamudan2014 Date: Thu, 20 Apr 2017 09:21:39 -0400 Subject: [PATCH 4/6] Fixed some coding guidelines problem Fix some of the indentation problems (tabs replaced by spaces). Curly bracket guidelines followed. --- Templates/Full/game/scripts/gui/optionsDlg.cs | 90 +++++++++++++++---- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/Templates/Full/game/scripts/gui/optionsDlg.cs b/Templates/Full/game/scripts/gui/optionsDlg.cs index 3e2ea865f..d7c6d0350 100644 --- a/Templates/Full/game/scripts/gui/optionsDlg.cs +++ b/Templates/Full/game/scripts/gui/optionsDlg.cs @@ -23,6 +23,9 @@ /// Returns true if the current quality settings equal /// this graphics quality level. + +// boolean flag for vehicle control remappings +$vehicleMapped = false; function GraphicsQualityLevel::isCurrent( %this ) { // Test each pref to see if the current value @@ -231,6 +234,8 @@ function OptionsDlg::onSleep(%this) { // write out the control config into the rw/config.cs file moveMap.save( "scripts/client/config.cs" ); + // saving vehicle mappings into separate config file + vehicleMap.save("scripts/client/config_vehicle.cs"); } function OptGraphicsDriverMenu::onSelect( %this, %id, %text ) @@ -518,11 +523,31 @@ $RemapCount++; $RemapName[$RemapCount] = "Bring up Options Dialog"; $RemapCmd[$RemapCount] = "bringUpOptions"; $RemapCount++; +// adding manageable vehicle mappings to options gui screen +$RemapName[$RemapCount] = "Vehicle Move Forward"; +$RemapCmd[$RemapCount] = "moveforward"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle Move Backward"; +$RemapCmd[$RemapCount] = "moveBackward"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle brake"; +$RemapCmd[$RemapCount] = "brake"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle free look"; +$RemapCmd[$RemapCount] = "toggleFreeLook"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle mouseFire"; +$RemapCmd[$RemapCount] = "mouseFire"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle alt trigger"; +$RemapCmd[$RemapCount] = "altTrigger"; +$RemapCount++; function restoreDefaultMappings() { moveMap.delete(); + vehicleMap.delete(); exec( "scripts/client/default.bind.cs" ); optionsDlg.fillRemapList(); } @@ -591,6 +616,12 @@ function buildFullMapString( %index ) %name = $RemapName[%index]; %cmd = $RemapCmd[%index]; + // getting exact type of binding based on Remap name + if(getSubStr(%name,0,7) $= "Vehicle" ) + { + %temp = vehicleMap.getBinding( %cmd ); + } + else %temp = moveMap.getBinding( %cmd ); if ( %temp $= "" ) return %name TAB ""; @@ -624,19 +655,27 @@ function OptionsDlg::doRemap( %this ) { %remapList = %this-->OptRemapList; - %selId = %remapList.getSelectedId(); + %selId = %remapList.getSelectedId(); %name = $RemapName[%selId]; - RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); - OptRemapInputCtrl.index = %selId; - Canvas.pushDialog( RemapDlg ); + //turning on the vehicle mapping flag if selected item is vehicle remapping + if(getSubStr(%name,0,7) $= "Vehicle") + $vehicleMapped = true; + + RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); + OptRemapInputCtrl.index = %selId; + Canvas.pushDialog( RemapDlg ); } function redoMapping( %device, %action, %cmd, %oldIndex, %newIndex ) { //%actionMap.bind( %device, %action, $RemapCmd[%newIndex] ); + //performing desired remapping based on flag + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - + else + vehicleMap.bind( %device, %action, %cmd ); + %remapList = %this-->OptRemapList; %remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) ); %remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) ); @@ -656,7 +695,13 @@ function findRemapCmdIndex( %command ) /// particular moveMap %commmand. function unbindExtraActions( %command, %count ) { - %temp = moveMap.getBinding( %command ); + //get current key binding (checking for vehicle mapping) + if(!$vehicleMapped) + %temp = moveMap.getBinding( %command ); + else + %temp = vehicleMap.getBinding( %command ); + + if ( %temp $= "" ) return; @@ -665,14 +710,17 @@ function unbindExtraActions( %command, %count ) { %device = getField( %temp, %i + 0 ); %action = getField( %temp, %i + 1 ); - - moveMap.unbind( %device, %action ); - } + //performing desired unbinding of mapped key + if(!$vehicleMapped) + moveMap.unbind( %device, %action ); + else + vehicleMap.unbind( %device, %action ); + + } } function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) { - //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" ); Canvas.popDialog( RemapDlg ); // Test for the reserved keystrokes: @@ -693,15 +741,22 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) // which we'll use when prompting the user below. %mapName = getMapDisplayName( %device, %action ); - // Get the current command this action is mapped to. - %prevMap = moveMap.getCommand( %device, %action ); - + // Get the current command this action is mapped to + if(!$vehicleMapped) + %prevMap = moveMap.getCommand( %device, %action ); + else + %prevMap = vehicleMap.getCommand( %device, %action ); + // If nothing was mapped to the previous command // mapping then it's easy... just bind it. if ( %prevMap $= "" ) { unbindExtraActions( %cmd, 1 ); + // performing desired binding (vehicleMap or moveMap) + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); + else + vehicleMap.bind( %device, %action, %cmd ); optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); return; } @@ -712,10 +767,15 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) if ( %prevMap $= %cmd ) { unbindExtraActions( %cmd, 0 ); + //performing desired binding (vehicleMap or moveMap) + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); - return; + else + vehicleMap.bind( %device, %action, %cmd ); + optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); + return; } + $vehicleMapped = false; // Look for the index of the previous mapping. %prevMapIndex = findRemapCmdIndex( %prevMap ); From b845cec2c44634579c3666af44827fb9baef3c6f Mon Sep 17 00:00:00 2001 From: aaravamudan2014 Date: Thu, 20 Apr 2017 14:11:41 -0700 Subject: [PATCH 5/6] fixed some indentation problems just noticed a few more indentation problem, my bad. --- Templates/Full/game/scripts/gui/optionsDlg.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Templates/Full/game/scripts/gui/optionsDlg.cs b/Templates/Full/game/scripts/gui/optionsDlg.cs index d7c6d0350..d333afc37 100644 --- a/Templates/Full/game/scripts/gui/optionsDlg.cs +++ b/Templates/Full/game/scripts/gui/optionsDlg.cs @@ -619,7 +619,7 @@ function buildFullMapString( %index ) // getting exact type of binding based on Remap name if(getSubStr(%name,0,7) $= "Vehicle" ) { - %temp = vehicleMap.getBinding( %cmd ); + %temp = vehicleMap.getBinding( %cmd ); } else %temp = moveMap.getBinding( %cmd ); @@ -660,7 +660,7 @@ function OptionsDlg::doRemap( %this ) //turning on the vehicle mapping flag if selected item is vehicle remapping if(getSubStr(%name,0,7) $= "Vehicle") - $vehicleMapped = true; + $vehicleMapped = true; RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); OptRemapInputCtrl.index = %selId; @@ -744,7 +744,7 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) // Get the current command this action is mapped to if(!$vehicleMapped) %prevMap = moveMap.getCommand( %device, %action ); - else + else %prevMap = vehicleMap.getCommand( %device, %action ); // If nothing was mapped to the previous command @@ -754,9 +754,9 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) unbindExtraActions( %cmd, 1 ); // performing desired binding (vehicleMap or moveMap) if(!$vehicleMapped) - moveMap.bind( %device, %action, %cmd ); + moveMap.bind( %device, %action, %cmd ); else - vehicleMap.bind( %device, %action, %cmd ); + vehicleMap.bind( %device, %action, %cmd ); optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); return; } From 170e2ea532982671f9e0a43e3fe5b788142ca2c1 Mon Sep 17 00:00:00 2001 From: aaravamudan2014 Date: Mon, 17 Apr 2017 16:07:03 -0400 Subject: [PATCH 6/6] Added new config file save for vehicle re-mappings Added gui functionality for vehicle re-mapping Update optionsDlg.cs Fixed some coding guidelines problem Fix some of the indentation problems (tabs replaced by spaces). Curly bracket guidelines followed. fixed some indentation problems just noticed a few more indentation problem, my bad. --- Templates/Full/game/scripts/client/init.cs | 3 +- Templates/Full/game/scripts/gui/optionsDlg.cs | 92 +++++++++++++++---- 2 files changed, 78 insertions(+), 17 deletions(-) diff --git a/Templates/Full/game/scripts/client/init.cs b/Templates/Full/game/scripts/client/init.cs index 2df6e2140..e40280a68 100644 --- a/Templates/Full/game/scripts/client/init.cs +++ b/Templates/Full/game/scripts/client/init.cs @@ -111,7 +111,8 @@ function initClient() if (isFile("./config.cs")) exec("./config.cs"); - + if (isFile("./config_vehicle.cs")) + exec("./config_vehicle.cs"); loadMaterials(); // Really shouldn't be starting the networking unless we are diff --git a/Templates/Full/game/scripts/gui/optionsDlg.cs b/Templates/Full/game/scripts/gui/optionsDlg.cs index 3e2ea865f..d333afc37 100644 --- a/Templates/Full/game/scripts/gui/optionsDlg.cs +++ b/Templates/Full/game/scripts/gui/optionsDlg.cs @@ -23,6 +23,9 @@ /// Returns true if the current quality settings equal /// this graphics quality level. + +// boolean flag for vehicle control remappings +$vehicleMapped = false; function GraphicsQualityLevel::isCurrent( %this ) { // Test each pref to see if the current value @@ -231,6 +234,8 @@ function OptionsDlg::onSleep(%this) { // write out the control config into the rw/config.cs file moveMap.save( "scripts/client/config.cs" ); + // saving vehicle mappings into separate config file + vehicleMap.save("scripts/client/config_vehicle.cs"); } function OptGraphicsDriverMenu::onSelect( %this, %id, %text ) @@ -518,11 +523,31 @@ $RemapCount++; $RemapName[$RemapCount] = "Bring up Options Dialog"; $RemapCmd[$RemapCount] = "bringUpOptions"; $RemapCount++; +// adding manageable vehicle mappings to options gui screen +$RemapName[$RemapCount] = "Vehicle Move Forward"; +$RemapCmd[$RemapCount] = "moveforward"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle Move Backward"; +$RemapCmd[$RemapCount] = "moveBackward"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle brake"; +$RemapCmd[$RemapCount] = "brake"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle free look"; +$RemapCmd[$RemapCount] = "toggleFreeLook"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle mouseFire"; +$RemapCmd[$RemapCount] = "mouseFire"; +$RemapCount++; +$RemapName[$RemapCount] = "Vehicle alt trigger"; +$RemapCmd[$RemapCount] = "altTrigger"; +$RemapCount++; function restoreDefaultMappings() { moveMap.delete(); + vehicleMap.delete(); exec( "scripts/client/default.bind.cs" ); optionsDlg.fillRemapList(); } @@ -591,6 +616,12 @@ function buildFullMapString( %index ) %name = $RemapName[%index]; %cmd = $RemapCmd[%index]; + // getting exact type of binding based on Remap name + if(getSubStr(%name,0,7) $= "Vehicle" ) + { + %temp = vehicleMap.getBinding( %cmd ); + } + else %temp = moveMap.getBinding( %cmd ); if ( %temp $= "" ) return %name TAB ""; @@ -624,19 +655,27 @@ function OptionsDlg::doRemap( %this ) { %remapList = %this-->OptRemapList; - %selId = %remapList.getSelectedId(); + %selId = %remapList.getSelectedId(); %name = $RemapName[%selId]; - RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); - OptRemapInputCtrl.index = %selId; - Canvas.pushDialog( RemapDlg ); + //turning on the vehicle mapping flag if selected item is vehicle remapping + if(getSubStr(%name,0,7) $= "Vehicle") + $vehicleMapped = true; + + RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); + OptRemapInputCtrl.index = %selId; + Canvas.pushDialog( RemapDlg ); } function redoMapping( %device, %action, %cmd, %oldIndex, %newIndex ) { //%actionMap.bind( %device, %action, $RemapCmd[%newIndex] ); + //performing desired remapping based on flag + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - + else + vehicleMap.bind( %device, %action, %cmd ); + %remapList = %this-->OptRemapList; %remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) ); %remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) ); @@ -656,7 +695,13 @@ function findRemapCmdIndex( %command ) /// particular moveMap %commmand. function unbindExtraActions( %command, %count ) { - %temp = moveMap.getBinding( %command ); + //get current key binding (checking for vehicle mapping) + if(!$vehicleMapped) + %temp = moveMap.getBinding( %command ); + else + %temp = vehicleMap.getBinding( %command ); + + if ( %temp $= "" ) return; @@ -665,14 +710,17 @@ function unbindExtraActions( %command, %count ) { %device = getField( %temp, %i + 0 ); %action = getField( %temp, %i + 1 ); - - moveMap.unbind( %device, %action ); - } + //performing desired unbinding of mapped key + if(!$vehicleMapped) + moveMap.unbind( %device, %action ); + else + vehicleMap.unbind( %device, %action ); + + } } function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) { - //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" ); Canvas.popDialog( RemapDlg ); // Test for the reserved keystrokes: @@ -693,15 +741,22 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) // which we'll use when prompting the user below. %mapName = getMapDisplayName( %device, %action ); - // Get the current command this action is mapped to. - %prevMap = moveMap.getCommand( %device, %action ); - + // Get the current command this action is mapped to + if(!$vehicleMapped) + %prevMap = moveMap.getCommand( %device, %action ); + else + %prevMap = vehicleMap.getCommand( %device, %action ); + // If nothing was mapped to the previous command // mapping then it's easy... just bind it. if ( %prevMap $= "" ) { unbindExtraActions( %cmd, 1 ); - moveMap.bind( %device, %action, %cmd ); + // performing desired binding (vehicleMap or moveMap) + if(!$vehicleMapped) + moveMap.bind( %device, %action, %cmd ); + else + vehicleMap.bind( %device, %action, %cmd ); optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); return; } @@ -712,10 +767,15 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) if ( %prevMap $= %cmd ) { unbindExtraActions( %cmd, 0 ); + //performing desired binding (vehicleMap or moveMap) + if(!$vehicleMapped) moveMap.bind( %device, %action, %cmd ); - optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); - return; + else + vehicleMap.bind( %device, %action, %cmd ); + optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) ); + return; } + $vehicleMapped = false; // Look for the index of the previous mapping. %prevMapIndex = findRemapCmdIndex( %prevMap );