Explorar o código

Merge pull request #1982 from aaravamudan2014/development

Added gui functionality for vehicle re-mapping as per #950
Areloch %!s(int64=8) %!d(string=hai) anos
pai
achega
bb7440ee5a

+ 2 - 1
Templates/Full/game/scripts/client/init.cs

@@ -111,7 +111,8 @@ function initClient()
 
 
    if (isFile("./config.cs"))
    if (isFile("./config.cs"))
       exec("./config.cs");
       exec("./config.cs");
-
+   if (isFile("./config_vehicle.cs"))
+      exec("./config_vehicle.cs");
    loadMaterials();
    loadMaterials();
 
 
    // Really shouldn't be starting the networking unless we are
    // Really shouldn't be starting the networking unless we are

+ 76 - 16
Templates/Full/game/scripts/gui/optionsDlg.cs

@@ -23,6 +23,9 @@
 
 
 /// Returns true if the current quality settings equal
 /// Returns true if the current quality settings equal
 /// this graphics quality level.
 /// this graphics quality level.
+
+// boolean flag for vehicle control remappings
+$vehicleMapped = false;
 function GraphicsQualityLevel::isCurrent( %this )
 function GraphicsQualityLevel::isCurrent( %this )
 {
 {
    // Test each pref to see if the current value
    // 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
    // write out the control config into the rw/config.cs file
    moveMap.save( "scripts/client/config.cs" );
    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 )
 function OptGraphicsDriverMenu::onSelect( %this, %id, %text )
@@ -518,11 +523,31 @@ $RemapCount++;
 $RemapName[$RemapCount] = "Bring up Options Dialog";
 $RemapName[$RemapCount] = "Bring up Options Dialog";
 $RemapCmd[$RemapCount] = "bringUpOptions";
 $RemapCmd[$RemapCount] = "bringUpOptions";
 $RemapCount++;
 $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()
 function restoreDefaultMappings()
 {
 {
    moveMap.delete();
    moveMap.delete();
+   vehicleMap.delete();  
    exec( "scripts/client/default.bind.cs" );
    exec( "scripts/client/default.bind.cs" );
    optionsDlg.fillRemapList();
    optionsDlg.fillRemapList();
 }
 }
@@ -591,6 +616,12 @@ function buildFullMapString( %index )
    %name       = $RemapName[%index];
    %name       = $RemapName[%index];
    %cmd        = $RemapCmd[%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 );
    %temp = moveMap.getBinding( %cmd );
    if ( %temp $= "" )
    if ( %temp $= "" )
       return %name TAB "";
       return %name TAB "";
@@ -624,19 +655,27 @@ function OptionsDlg::doRemap( %this )
 {
 {
    %remapList = %this-->OptRemapList;
    %remapList = %this-->OptRemapList;
    
    
-	%selId = %remapList.getSelectedId();
+   %selId = %remapList.getSelectedId();
    %name = $RemapName[%selId];
    %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 )
 function redoMapping( %device, %action, %cmd, %oldIndex, %newIndex )
 {
 {
 	//%actionMap.bind( %device, %action, $RemapCmd[%newIndex] );
 	//%actionMap.bind( %device, %action, $RemapCmd[%newIndex] );
+	//performing desired remapping based on flag
+    if(!$vehicleMapped)
 	moveMap.bind( %device, %action, %cmd );
 	moveMap.bind( %device, %action, %cmd );
-	
+    else
+	vehicleMap.bind( %device, %action, %cmd );
+    
    %remapList = %this-->OptRemapList;
    %remapList = %this-->OptRemapList;
 	%remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) );
 	%remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) );
 	%remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) );
 	%remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) );
@@ -656,7 +695,13 @@ function findRemapCmdIndex( %command )
 /// particular moveMap %commmand.
 /// particular moveMap %commmand.
 function unbindExtraActions( %command, %count )
 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 $= "" )
    if ( %temp $= "" )
       return;
       return;
 
 
@@ -665,14 +710,17 @@ function unbindExtraActions( %command, %count )
    {
    {
       %device = getField( %temp, %i + 0 );
       %device = getField( %temp, %i + 0 );
       %action = getField( %temp, %i + 1 );
       %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 )
 function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
 {
 {
-   //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" );
    Canvas.popDialog( RemapDlg );
    Canvas.popDialog( RemapDlg );
 
 
    // Test for the reserved keystrokes:
    // Test for the reserved keystrokes:
@@ -693,15 +741,22 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
    // which we'll use when prompting the user below.
    // which we'll use when prompting the user below.
    %mapName = getMapDisplayName( %device, %action );
    %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 
    // If nothing was mapped to the previous command 
    // mapping then it's easy... just bind it.
    // mapping then it's easy... just bind it.
    if ( %prevMap $= "" )
    if ( %prevMap $= "" )
    {
    {
       unbindExtraActions( %cmd, 1 );
       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 ) );
       optionsDlg-->OptRemapList.setRowById( %this.index, buildFullMapString( %this.index ) );
       return;
       return;
    }
    }
@@ -712,10 +767,15 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
    if ( %prevMap $= %cmd )
    if ( %prevMap $= %cmd )
    {
    {
       unbindExtraActions( %cmd, 0 );
       unbindExtraActions( %cmd, 0 );
+     //performing desired binding (vehicleMap or moveMap)
+     if(!$vehicleMapped)
       moveMap.bind( %device, %action, %cmd );
       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.
    // Look for the index of the previous mapping.
    %prevMapIndex = findRemapCmdIndex( %prevMap );
    %prevMapIndex = findRemapCmdIndex( %prevMap );