浏览代码

Overhauled keybind remap part of options menu
Fix audio options menu so it correctly save and applies settings

Areloch 5 年之前
父节点
当前提交
11f0ec2c0f

+ 3 - 0
Templates/BaseGame/game/core/Core.cs

@@ -69,6 +69,9 @@ function CoreModule::onCreate(%this)
       ModuleDatabase.scanModules( "tools", false );
       ModuleDatabase.LoadGroup( "Tools" );
    }
+   
+   //This is used to build the remap keybind sets for the different actionMaps.
+   $RemapCount = 0;
 }
 
 function CoreModule::onDestroy(%this)

+ 2 - 1
Templates/BaseGame/game/core/rendering/Core_Rendering.cs

@@ -11,6 +11,7 @@ function Core_Rendering::onCreate(%this)
    
    $pref::ReflectionProbes::BakeResolution = ProjectSettings.value("Rendering/ProbeCaptureResolution", "64");
    
+   exec("./scripts/graphicsOptions.cs");
    exec("./scripts/renderManager.cs");
    exec("./scripts/gfxData/clouds.cs");
    exec("./scripts/gfxData/commonMaterialData.cs");
@@ -42,7 +43,7 @@ function Core_Rendering::initClient(%this)
    
    //Autodetect settings if it's our first time
    if($pref::Video::autoDetect)
-      GraphicsMenu.Autodetect();
+      AutodetectGraphics();
 
    postFXInit();
    

+ 757 - 0
Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.cs

@@ -0,0 +1,757 @@
+function GraphicsQualityLevel::isCurrent( %this )
+{
+   // Test each pref to see if the current value
+   // equals our stored value.
+   
+   for ( %i=0; %i < %this.count(); %i++ )
+   {
+      %pref = %this.getKey( %i );
+      %value = %this.getValue( %i );
+      
+      if ( getVariable( %pref ) !$= %value )
+         return false;
+   }
+   
+   return true;
+}
+
+function GraphicsQualityLevel::apply( %this )
+{
+   for ( %i=0; %i < %this.count(); %i++ )
+   {
+      %pref = %this.getKey( %i );
+      %value = %this.getValue( %i );
+      setVariable( %pref, %value );
+   }
+   
+   // If we have an overloaded onApply method then
+   // call it now to finalize the changes.
+   if ( %this.isMethod( "onApply" ) )   
+      %this.onApply();
+   else
+   {
+      %group = %this.getGroup();      
+      if ( isObject( %group ) && %group.isMethod( "onApply" ) )
+         %group.onApply( %this );
+   }   
+}
+
+function GraphicsOptionsMenuGroup::applySetting(%this, %settingName)
+{
+   for(%i=0; %i < %this.getCount(); %i++)
+   {
+      %setting = %this.getObject(%i);
+      if(%setting.displayName $= %settingName)
+      {
+         for ( %s=0; %s < %setting.count(); %s++ )
+         {
+            %pref = %setting.getKey( %s );
+            %value = %setting.getValue( %s );
+            setVariable( %pref, %value );
+         }
+         break;
+      }
+   }
+}
+
+new SimGroup( MeshQualityGroup )
+{ 
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+
+      key["$pref::TS::detailAdjust"] = 1.5;
+      key["$pref::TS::skipRenderDLs"] = 0;      
+   }; 
+   new ArrayObject( )
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::TS::detailAdjust"] = 1.0;
+      key["$pref::TS::skipRenderDLs"] = 0;      
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+            
+      key["$pref::TS::detailAdjust"] = 0.75;
+      key["$pref::TS::skipRenderDLs"] = 0;      
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Lowest";
+      
+      key["$pref::TS::detailAdjust"] = 0.5;
+      key["$pref::TS::skipRenderDLs"] = 1;      
+  };
+};
+
+new SimGroup( TextureQualityGroup )
+{
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+
+      key["$pref::Video::textureReductionLevel"] = 0;
+      key["$pref::Reflect::refractTexScale"] = 1.25;
+   }; 
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::Video::textureReductionLevel"] = 0;
+      key["$pref::Reflect::refractTexScale"] = 1;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+            
+      key["$pref::Video::textureReductionLevel"] = 1;
+      key["$pref::Reflect::refractTexScale"] = 0.75;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Lowest";
+      
+      key["$pref::Video::textureReductionLevel"] = 2;
+      key["$pref::Reflect::refractTexScale"] = 0.5;
+   };
+};
+
+new SimGroup( GroundCoverDensityGroup )
+{ 
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+
+      key["$pref::GroundCover::densityScale"] = 1.0;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::GroundCover::densityScale"] = 0.75;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+            
+      key["$pref::GroundCover::densityScale"] = 0.5;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Lowest";
+
+      key["$pref::GroundCover::densityScale"] = 0.25;
+   };
+};
+
+new SimGroup( DecalLifetimeGroup )
+{ 
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+      
+      key["$pref::decalMgr::enabled"] = true;
+      key["$pref::Decals::lifeTimeScale"] = 1;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+      
+      key["$pref::decalMgr::enabled"] = true;
+      key["$pref::Decals::lifeTimeScale"] = 0.5;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+      
+      key["$pref::decalMgr::enabled"] = true;
+      key["$pref::Decals::lifeTimeScale"] = 0.25;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "None";
+      
+      key["$pref::decalMgr::enabled"] = false;
+   };
+};
+
+new SimGroup( TerrainQualityGroup )
+{ 
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+
+      key["$pref::Terrain::lodScale"] = 0.75;
+      key["$pref::Terrain::detailScale"] = 1.5;
+   }; 
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::Terrain::lodScale"] = 1.0;
+      key["$pref::Terrain::detailScale"] = 1.0;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+            
+      key["$pref::Terrain::lodScale"] = 1.5;
+      key["$pref::Terrain::detailScale"] = 0.75;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Lowest";
+      
+      key["$pref::Terrain::lodScale"] = 2.0;
+      key["$pref::Terrain::detailScale"] = 0.5; 
+   };   
+};
+
+//Shadows and Lighting
+new SimGroup( ShadowQualityList )
+{
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+      
+      key["$pref::lightManager"] = "Advanced Lighting";
+      key["$pref::Shadows::disable"] = false;
+      key["$pref::Shadows::textureScalar"] = 1.0;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::lightManager"] = "Advanced Lighting";
+      key["$pref::Shadows::disable"] = false;
+      key["$pref::Shadows::textureScalar"] = 0.5;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+                  
+      key["$pref::lightManager"] = "Advanced Lighting";
+      key["$pref::Shadows::disable"] = false;
+      key["$pref::Shadows::textureScalar"] = 0.25;
+
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "None";
+      
+      key["$pref::lightManager"] = "Advanced Lighting";
+      key["$pref::Shadows::disable"] = true;
+      key["$pref::Shadows::textureScalar"] = 0.5;
+   };
+};
+
+new SimGroup( ShadowDistanceList )
+{
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Highest";
+      
+      key["$pref::Shadows::drawDistance"] = 2; 
+   }; 
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+      
+      key["$pref::Shadows::drawDistance"] = 1.5;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::Shadows::drawDistance"] = 1; 
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+                  
+      key["$pref::Shadows::drawDistance"] = 0.5;  
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Lowest";
+      
+      key["$pref::Shadows::drawDistance"] = 0.25;
+   };   
+};
+
+new SimGroup( SoftShadowList )
+{
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+                  
+      key["$pref::Shadows::filterMode"] = "SoftShadowHighQuality"; 
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+                  
+      key["$pref::Shadows::filterMode"] = "SoftShadow"; 
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Off";
+      
+      key["$pref::Shadows::filterMode"] = "None"; 
+   };
+};
+
+new SimGroup( LightDistanceList )
+{
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Highest";
+      
+      key["$pref::Lights::drawDistance"] = 2; 
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+      
+      key["$pref::Lights::drawDistance"] = 1.5;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Medium";
+
+      key["$pref::Lights::drawDistance"] = 1; 
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+                  
+      key["$pref::Lights::drawDistance"] = 0.5;  
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Lowest";
+      
+      key["$pref::Lights::drawDistance"] = 0.25;
+   };   
+};
+
+new SimGroup( ShaderQualityGroup )
+{
+   class = "GraphicsOptionsMenuGroup";
+   
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "High";
+      
+      key["$pref::Video::disablePixSpecular"] = false;
+      key["$pref::Video::disableNormalmapping"] = false;
+   };
+   new ArrayObject()
+   {
+      class = "GraphicsQualityLevel";
+      caseSensitive = true;
+      
+      displayName = "Low";
+      
+      key["$pref::Video::disablePixSpecular"] = true;
+      key["$pref::Video::disableNormalmapping"] = true;
+   };
+};
+
+function getCurrentQualityLevel(%qualityGroup)
+{
+   for ( %i=0; %i < %qualityGroup.getCount(); %i++ )
+   {
+      %level = %qualityGroup.getObject( %i );
+      if ( %level.isCurrent() )
+         return %level.displayName;
+   }
+   
+   return "Custom";
+}
+
+function getQualityLevels(%qualityGroup)
+{
+   %qualityLevelsList = "";
+   %qualityLevelCount = %qualityGroup.getCount()-1;
+   
+   for ( %i=%qualityLevelCount; %i >= 0; %i-- )
+   {
+      %level = %qualityGroup.getObject( %i );
+      
+      if(%i == %qualityLevelCount)
+         %qualityLevelsList = %level.displayName;
+      else
+         %qualityLevelsList = %qualityLevelsList @ "\t" @ %level.displayName;
+   }
+   
+   return %qualityLevelsList;
+}
+
+function AutodetectGraphics()
+{
+   $pref::Video::autoDetect = false;
+   
+   %shaderVer = getPixelShaderVersion();
+   %intel = ( strstr( strupr( getDisplayDeviceInformation() ), "INTEL" ) != -1 ) ? true : false;
+   %videoMem = GFXCardProfilerAPI::getVideoMemoryMB();
+   
+   return AutodetectGraphics_Apply( %shaderVer, %intel, %videoMem );
+}
+
+function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem )
+{
+   if ( %shaderVer < 2.0 )
+   {      
+      echo("Your video card does not meet the minimum requirment of shader model 2.0.");
+   }
+   
+   if ( %shaderVer < 3.0 || %intel )
+   {
+      // Allow specular and normals for 2.0a and 2.0b
+      if ( %shaderVer > 2.0 )
+      {
+         MeshQualityGroup.applySetting("Lowest");
+         TextureQualityGroup.applySetting("Lowest");
+         GroundCoverDensityGroup.applySetting("Lowest");
+         DecalLifetimeGroup.applySetting("None");
+         TerrainQualityGroup.applySetting("Lowest");
+         ShaderQualityGroup.applySetting("High");
+         
+         ShadowQualityList.applySetting("None");
+         
+         SoftShadowList.applySetting("Off");
+         
+         $pref::Shadows::useShadowCaching = true;
+         
+         $pref::Water::disableTrueReflections = true;
+         $pref::Video::disableParallaxMapping = true;
+         $pref::PostFX::EnableSSAO = false;
+         $pref::PostFX::EnableHDR = false;
+         $pref::PostFX::EnableDOF = false;
+         $pref::PostFX::EnableLightRays = false;
+         $pref::PostFX::EnableVignette = false;
+         
+         $pref::Video::AA = 0;
+         $pref::Video::disableVerticalSync = 0;
+      }
+      else
+      {
+         MeshQualityGroup.applySetting("Lowest");
+         TextureQualityGroup.applySetting("Lowest");
+         GroundCoverDensityGroup.applySetting("Lowest");
+         DecalLifetimeGroup.applySetting("None");
+         TerrainQualityGroup.applySetting("Lowest");
+         ShaderQualityGroup.applySetting("Low");
+         
+         ShadowQualityList.applySetting("None");
+         
+         SoftShadowList.applySetting("Off");
+         
+         $pref::Shadows::useShadowCaching = true;
+         
+         $pref::Water::disableTrueReflections = true;
+         $pref::Video::disableParallaxMapping = true;
+         $pref::PostFX::EnableSSAO = false;
+         $pref::PostFX::EnableHDR = false;
+         $pref::PostFX::EnableDOF = false;
+         $pref::PostFX::EnableLightRays = false;
+         $pref::PostFX::EnableVignette = false;
+         
+         $pref::Video::AA = 0;
+         $pref::Video::disableVerticalSync = 0;
+      }
+   }   
+   else
+   {
+      if ( %videoMem > 1000 )
+      {
+         MeshQualityGroup.applySetting("High");
+         TextureQualityGroup.applySetting("High");
+         GroundCoverDensityGroup.applySetting("High");
+         DecalLifetimeGroup.applySetting("High");
+         TerrainQualityGroup.applySetting("High");
+         ShaderQualityGroup.applySetting("High");
+         
+         ShadowQualityList.applySetting("High");
+         
+         SoftShadowList.applySetting("High");
+         
+         //Should this default to on in ultra settings?
+         $pref::Shadows::useShadowCaching = true;
+         
+         $pref::Water::disableTrueReflections = false;
+         $pref::Video::disableParallaxMapping = false;
+         $pref::PostFX::EnableSSAO = true;
+         $pref::PostFX::EnableHDR = true;
+         $pref::PostFX::EnableDOF = true;
+         $pref::PostFX::EnableLightRays = true;
+         $pref::PostFX::EnableVignette = true;
+         
+         $pref::Video::AA = 4;
+         $pref::Video::disableVerticalSync = 16;
+      }
+      else if ( %videoMem > 400 || %videoMem == 0 )
+      {
+         MeshQualityGroup.applySetting("Medium");
+         TextureQualityGroup.applySetting("Medium");
+         GroundCoverDensityGroup.applySetting("Medium");
+         DecalLifetimeGroup.applySetting("Medium");
+         TerrainQualityGroup.applySetting("Medium");
+         ShaderQualityGroup.applySetting("High");
+         
+         ShadowQualityList.applySetting("Medium");
+         
+         SoftShadowList.applySetting("Low");
+         
+         $pref::Shadows::useShadowCaching = true;
+         
+         $pref::Water::disableTrueReflections = false;
+         $pref::Video::disableParallaxMapping = true;
+         $pref::PostFX::EnableSSAO = false;
+         $pref::PostFX::EnableHDR = true;
+         $pref::PostFX::EnableDOF = true;
+         $pref::PostFX::EnableLightRays = true;
+         $pref::PostFX::EnableVignette = true;
+         
+         $pref::Video::AA = 4;
+         $pref::Video::disableVerticalSync = 4;
+         
+         if ( %videoMem == 0 )
+            echo("Torque was unable to detect available video memory. Applying 'Medium' quality.");
+      }
+      else
+      {
+         MeshQualityGroup.applySetting("Low");
+         TextureQualityGroup.applySetting("Low");
+         GroundCoverDensityGroup.applySetting("Low");
+         DecalLifetimeGroup.applySetting("Low");
+         TerrainQualityGroup.applySetting("Low");
+         ShaderQualityGroup.applySetting("Low");
+         
+         ShadowQualityList.applySetting("None");
+         
+         SoftShadowList.applySetting("Off");
+         
+         $pref::Shadows::useShadowCaching = true;
+         
+         $pref::Water::disableTrueReflections = false;
+         $pref::Video::disableParallaxMapping = true;
+         $pref::PostFX::EnableSSAO = false;
+         $pref::PostFX::EnableHDR = false;
+         $pref::PostFX::EnableDOF = false;
+         $pref::PostFX::EnableLightRays = false;
+         $pref::PostFX::EnableVignette = false;
+         
+         $pref::Video::AA = 0;
+         $pref::Video::disableVerticalSync = 0;
+      }
+   }
+   
+   //%this.refresh();
+   
+   //%this.apply();
+   
+   //force postFX updates
+   PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO);
+   PostFXManager.settingsEffectSetEnabled(HDRPostFX, $pref::PostFX::EnableHDR);
+   PostFXManager.settingsEffectSetEnabled(DOFPostEffect, $pref::PostFX::EnableDOF);
+   PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays);
+   PostFXManager.settingsEffectSetEnabled(VignettePostEffect, $pref::PostFX::EnableVignette);
+   
+   echo("Graphics quality settings have been auto detected.");
+}
+
+function _makePrettyResString( %resString, %giveAspectRation )
+{
+   %width = getWord( %resString, $WORD::RES_X );
+   %height = getWord( %resString, $WORD::RES_Y );
+   
+   %aspect = %width / %height;
+   %aspect = mRound( %aspect * 100 ) * 0.01;            
+   
+   switch$( %aspect )
+   {
+      case "1.33":
+         %aspect = "4:3";
+      case "1.78":
+         %aspect = "16:9";
+      default:
+         %aspect = "";
+   }
+   
+   %outRes = %width @ " x " @ %height;
+   if ( %giveAspectRation && %aspect !$= "" )
+      %outRes = %outRes @ "  (" @ %aspect @ ")";
+      
+   return %outRes;   
+}
+
+function getScreenResolutionList()
+{
+   %returnsList = "";
+   
+   %resCount = Canvas.getModeCount();
+   for (%i = 0; %i < %resCount; %i++)
+   {
+      %testResString = Canvas.getMode( %i );
+      %testRes = _makePrettyResString( %testResString );
+      
+      //sanitize
+      %found = false;
+      %retCount = getTokenCount(%returnsList, "\t");
+      for (%x = 0; %x < %retCount; %x++)
+      {
+         %existingEntry = getToken(%returnsList, "\t", %x);
+         if(%existingEntry $= %testRes)
+         {
+            %found = true;
+            break;  
+         }
+      }
+      
+      if(%found)
+         continue;
+                     
+      if(%i != 0)
+         %returnsList = %returnsList @ "\t" @ %testRes;
+      else
+         %returnsList = %testRes;
+   }
+   
+   return %returnsList;
+}

+ 1 - 0
Templates/BaseGame/game/core/utility/Core_Utility.cs

@@ -8,6 +8,7 @@ function Core_Utility::onCreate(%this)
    exec("./scripts/persistanceManagement.cs");
    exec("./scripts/module.cs");
    exec("./scripts/scene.cs");
+   exec("./scripts/input.cs");
 }
 
 function Core_Utility::onDestroy(%this)

+ 11 - 0
Templates/BaseGame/game/core/utility/scripts/input.cs

@@ -0,0 +1,11 @@
+function getGamepadAdjustAmount(%val)
+{
+   // based on a default camera FOV of 90'
+   return(%val * ($cameraFov / 90) * 0.01) * 10.0;
+}
+
+function getMouseAdjustAmount(%val)
+{
+   // based on a default camera FOV of 90'
+   return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
+}

+ 66 - 0
Templates/BaseGame/game/data/ExampleModule/scripts/default.keybinds.cs

@@ -20,9 +20,73 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
+$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++;
+
+$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";
 
 //------------------------------------------------------------------------------
 // Non-remapable binds
@@ -61,6 +125,8 @@ ExampleMoveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
 ExampleMoveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
 
 ExampleMoveMap.bind( gamepad, btn_a, jump );
+ExampleMoveMap.bind( gamepad, btn_x, moveup );
+ExampleMoveMap.bind( gamepad, btn_y, movedown );
 ExampleMoveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
 
 //------------------------------------------------------------------------------

+ 2 - 2
Templates/BaseGame/game/data/defaults.cs

@@ -81,11 +81,11 @@ $pref::SFX::autoDetect = true;
 /// this is DirectSound, OpenAL, or XACT.  There is also 
 /// a special Null provider which acts normally, but 
 /// plays no sound.
-$pref::SFX::provider = "";
+$pref::SFX::provider = "OpenAL";
 
 /// The sound device to select from the provider.  Each
 /// provider may have several different devices.
-$pref::SFX::device = "OpenAL";
+$pref::SFX::device = "OpenAL Soft";
 
 /// If true the device will try to use hardware buffers
 /// and sound mixing.  If not it will use software.

+ 1 - 6
Templates/BaseGame/game/data/ui/UI.cs

@@ -75,17 +75,12 @@ function UI::initClient(%this)
    exec("./guis/messageBoxDlg.gui");
    
    //Load scripts
-   exec("./scripts/optionsList.cs");
-   exec("./scripts/displayMenu.cs");
-   exec("./scripts/graphicsMenu.cs");
    exec("./scripts/controlsMenu.cs");
-   exec("./scripts/audioMenu.cs");
    exec("./scripts/messageBoxes.cs");
    exec("./scripts/help.cs");
    exec("./scripts/cursors.cs");
    exec("./scripts/utility.cs");
-   
-   exec("./scripts/keybindEdit.cs");
+   exec("./scripts/default.keybinds.cs");
    
    exec("./guis/menuGraphics.gui");
    exec("./guis/menuGraphics.cs");

+ 89 - 27
Templates/BaseGame/game/data/ui/guis/optionsMenu.cs

@@ -89,6 +89,39 @@ function OptionsMenu::apply(%this)
    {
       %this.applyGraphicsSettings();
    }
+   else if(%this.pageTabIndex == 2)
+   {
+      %this.applyAudioSettings();
+   }
+   else if(%this.pageTabIndex == 3 || %this.pageTabIndex == 4)
+   {
+      %prefPath = getPrefpath();
+      
+      %actionMapCount = ActionMapGroup.getCount();
+   
+      %actionMapList = "";
+      %append = false;
+      for(%i=0; %i < %actionMapCount; %i++)
+      {
+         %actionMap = ActionMapGroup.getObject(%i);
+         
+         if(%actionMap == GlobalActionMap.getId())
+            continue;
+         
+         %actionMap.save( %prefPath @ "/keybinds.cs", %append );
+         
+         if(%append != true)
+            %append = true; 
+      }
+   }
+   
+   %prefPath = getPrefpath();
+   export("$pref::*", %prefPath @ "/clientPrefs.cs", false);
+}
+
+function OptionsMenu::resetToDefaults(%this)
+{
+   MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", "");
 }
 
 function OptionsMenuSettingsList::onChange(%this)
@@ -174,7 +207,7 @@ function OptionsMenu::populateDisplaySettingsList(%this)
    
    %resolutionList = getScreenResolutionList();
    OptionsMenuSettingsList.addOptionRow("Display API", "D3D11\tOpenGL", false, "", -1, -30, true, "The display API used for rendering.", getDisplayDeviceInformation());
-   OptionsMenuSettingsList.addOptionRow("Resolution", %resolutionList, false, "screenResolutionOptionChanged", -1, -30, true, "Resolution of the game window", _makePrettyResString( $pref::Video::mode ));
+   OptionsMenuSettingsList.addOptionRow("Resolution", %resolutionList, false, "", -1, -30, true, "Resolution of the game window", _makePrettyResString( $pref::Video::mode ));
    OptionsMenuSettingsList.addOptionRow("Fullscreen", "No\tYes", false, "", -1, -30, true, "", convertBoolToYesNo($pref::Video::FullScreen));
    OptionsMenuSettingsList.addOptionRow("VSync", "No\tYes", false, "", -1, -30, true, "", convertBoolToYesNo(!$pref::Video::disableVerticalSync));
    
@@ -222,11 +255,6 @@ function OptionsMenu::applyDisplaySettings(%this)
    export("$pref::*", %prefPath @ "/clientPrefs.cs", false);
 }
 
-function screenResolutionOptionChanged()
-{
-   echo("Resolution Changed to: " @ OptionsMenuSettingsList.getCurrentOption(0));
-}
-
 function OptionsMenu::populateGraphicsSettingsList(%this)
 {
    %this.pageTabIndex = 1;
@@ -284,10 +312,10 @@ function OptionsMenu::applyGraphicsSettings(%this)
    $pref::PostFX::EnableVignette = convertOptionToBool(OptionsMenuSettingsList.getCurrentOption(14));
    $pref::PostFX::EnableLightRays = convertOptionToBool(OptionsMenuSettingsList.getCurrentOption(15));
    
-   PostFXManager.settingsEffectSetEnabled("SSAO", $pref::PostFX::EnableSSAO);
-   PostFXManager.settingsEffectSetEnabled("DOF", $pref::PostFX::EnableDOF);
-   PostFXManager.settingsEffectSetEnabled("LightRays", $pref::PostFX::EnableLightRays);
-   PostFXManager.settingsEffectSetEnabled("Vignette", $pref::PostFX::EnableVignette);
+   PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO);
+   PostFXManager.settingsEffectSetEnabled(DOFPostEffect, $pref::PostFX::EnableDOF);
+   PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays);
+   PostFXManager.settingsEffectSetEnabled(vignettePostFX, $pref::PostFX::EnableVignette);
    
    $pref::Video::disableParallaxMapping = !convertOptionToBool(OptionsMenuSettingsList.getCurrentOption(10));
    
@@ -314,14 +342,14 @@ function OptionsMenu::applyGraphicsSettings(%this)
 function updateDisplaySettings()
 {
    //Update the display settings now
-   $pref::Video::Resolution = getWords( Canvas.getMode( GraphicsMenuResolution.getSelected() ), $WORD::RES_X, $WORD::RES_Y );
+   $pref::Video::Resolution = getWord(OptionsMenuSettingsList.getCurrentOption(1), 0) SPC getWord(OptionsMenuSettingsList.getCurrentOption(1), 2);
    %newBpp        = 32; // ... its not 1997 anymore.
-	$pref::Video::FullScreen = GraphicsMenuFullScreen.isStateOn() ? "true" : "false";
-	$pref::Video::RefreshRate    = GraphicsMenuRefreshRate.getSelected();
-	$pref::Video::disableVerticalSync = !GraphicsMenuVSync.isStateOn();	
-	$pref::Video::AA = GraphicsMenuAA.getSelected();
+	$pref::Video::FullScreen = convertOptionToBool(OptionsMenuSettingsList.getCurrentOption(2)) == 0 ? "false" : "true";
+	$pref::Video::RefreshRate    = OptionsMenuSettingsList.getCurrentOption(4);
+	%newVsync = !convertOptionToBool(OptionsMenuSettingsList.getCurrentOption(3));	
+	//$pref::Video::AA = GraphicsMenuAA.getSelected();
 	
-   if ( %newFullScreen $= "false" )
+   /*if ( %newFullScreen $= "false" )
 	{
       // If we're in windowed mode switch the fullscreen check
       // if the resolution is bigger than the desktop.
@@ -334,7 +362,7 @@ function updateDisplaySettings()
          $pref::Video::FullScreen = "true";
          GraphicsMenuFullScreen.setStateOn( true );
       }
-	}
+	}*/
 
    // Build the final mode string.
 	%newMode = $pref::Video::Resolution SPC $pref::Video::FullScreen SPC %newBpp SPC $pref::Video::RefreshRate SPC $pref::Video::AA;
@@ -343,9 +371,6 @@ function updateDisplaySettings()
    if (  %newMode !$= $pref::Video::mode || 
          %newVsync != $pref::Video::disableVerticalSync )
    {
-      if ( %testNeedApply )
-         return true;
-
       $pref::Video::mode = %newMode;
       $pref::Video::disableVerticalSync = %newVsync;      
       configureCanvas();
@@ -364,20 +389,35 @@ function OptionsMenu::populateAudioSettingsList(%this)
    %count = getRecordCount( %buffer );  
    %audioDriverList = "";
     
+   $currentAudioProvider = $currentAudioProvider $= "" ? $pref::SFX::provider : $currentAudioProvider;
+   
    for(%i = 0; %i < %count; %i++)
    {
       %record = getRecord(%buffer, %i);
       %provider = getField(%record, 0);
+      %device = getField(%record, 1);
+      
+      //When the client is actually running, we don't care about null audo devices
+      if(%provider $= "null")
+         continue;
       
-      if(%i == 0)
-         %audioDriverList = %provider;
+      if(%audioProviderList $= "")
+         %audioProviderList = %provider;
       else 
-         %audioDriverList = %audioDriverList @ "\t" @ %provider;
+         %audioProviderList = %audioProviderList @ "\t" @ %provider;
+         
+      if(%provider $= $currentAudioProvider)
+      {
+         if(%audioDeviceList $= "")
+            %audioDeviceList = %device;
+         else 
+            %audioDeviceList = %audioDeviceList @ "\t" @ %device;  
+      }
+         
    }
    
-   %yesNoList = "Yes\tNo";
-   OptionsMenuSettingsList.addOptionRow("Audio Driver", %audioDriverList, false, "", -1, -15, true, "", $pref::SFX::provider);
-   OptionsMenuSettingsList.addOptionRow("Audio Device", %yesNoList, false, "", -1, -15, true, "");
+   OptionsMenuSettingsList.addOptionRow("Audio Provider", %audioProviderList, false, "audioProviderChanged", -1, -15, true, "", $currentAudioProvider);
+   OptionsMenuSettingsList.addOptionRow("Audio Device", %audioDeviceList, false, "", -1, -15, true, $pref::SFX::device);
    
    OptionsMenuSettingsList.addSliderRow("Master Volume", $pref::SFX::masterVolume, 0.1, "0 1", "", -1, -30);
    OptionsMenuSettingsList.addSliderRow("GUI Volume", $pref::SFX::channelVolume[ $GuiAudioType], 0.1, "0 1", "", -1, -30);
@@ -387,14 +427,32 @@ function OptionsMenu::populateAudioSettingsList(%this)
    OptionsMenuSettingsList.refresh();
 }
 
+function audioProviderChanged()
+{
+   //Get the option we have set for the provider
+   %provider = OptionsMenuSettingsList.getCurrentOption(0);
+   $currentAudioProvider = %provider;
+   
+   //And now refresh the list to get the correct devices
+   OptionsMenu.populateAudioSettingsList();
+}
+
 function OptionsMenu::applyAudioSettings(%this)
 {
+   $pref::SFX::masterVolume = OptionsMenuSettingsList.getValue(2);
    sfxSetMasterVolume( $pref::SFX::masterVolume );
    
+   $pref::SFX::channelVolume[ $GuiAudioType ] = OptionsMenuSettingsList.getValue(3);
+   $pref::SFX::channelVolume[ $SimAudioType ] = OptionsMenuSettingsList.getValue(4);
+   $pref::SFX::channelVolume[ $MusicAudioType ] = OptionsMenuSettingsList.getValue(5);
+   
    sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] );
    sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] );
    sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] );
    
+   $pref::SFX::provider = OptionsMenuSettingsList.getCurrentOption(0);
+   $pref::SFX::device = OptionsMenuSettingsList.getCurrentOption(1);
+   
    if ( !sfxCreateDevice(  $pref::SFX::provider, 
                            $pref::SFX::device, 
                            $pref::SFX::useHardware,
@@ -417,7 +475,8 @@ function OptionsMenu::populateKeyboardMouseSettingsList(%this)
    OptionName.setText("");
    OptionDescription.setText("");
    
-   OptionsMenuSettingsList.addKeybindRow("Forward", getButtonBitmap("Keyboard", "W"), "doKeyRemap", -1, -15, true, "Forward butaaaahn");
+   $remapListDevice = "keyboard";
+   fillRemapList();
    
    OptionsMenuSettingsList.refresh();
 }
@@ -430,6 +489,9 @@ function OptionsMenu::populateGamepadSettingsList(%this)
    OptionName.setText("");
    OptionDescription.setText("");
    
+   $remapListDevice = "gamepad";
+   fillRemapList();
+   
    OptionsMenuSettingsList.refresh();
 }
 

+ 121 - 212
Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs

@@ -1,179 +1,12 @@
 // =============================================================================
 // KEYBINDS MENU
 // =============================================================================
-$RemapCount = 0;
-$RemapName[$RemapCount] = "Forward";
-$RemapCmd[$RemapCount] = "moveforward";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Backward";
-$RemapCmd[$RemapCount] = "movebackward";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Strafe Left";
-$RemapCmd[$RemapCount] = "moveleft";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Strafe Right";
-$RemapCmd[$RemapCount] = "moveright";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Jump";
-$RemapCmd[$RemapCount] = "jump";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-
-$RemapName[$RemapCount] = "Fire Weapon";
-$RemapCmd[$RemapCount] = "mouseFire";
-$RemapGroup[$RemapCount] = "Combat";
-$RemapCount++;
-$RemapName[$RemapCount] = "Adjust Zoom";
-$RemapCmd[$RemapCount] = "setZoomFov";
-$RemapGroup[$RemapCount] = "Combat";
-$RemapCount++;
-$RemapName[$RemapCount] = "Toggle Zoom";
-$RemapCmd[$RemapCount] = "toggleZoom";
-$RemapGroup[$RemapCount] = "Combat";
-$RemapCount++;
-
-$RemapName[$RemapCount] = "Free Look";
-$RemapCmd[$RemapCount] = "toggleFreeLook";
-$RemapGroup[$RemapCount] = "Miscellaneous";
-$RemapCount++;
-$RemapName[$RemapCount] = "Switch 1st/3rd";
-$RemapCmd[$RemapCount] = "toggleFirstPerson";
-$RemapGroup[$RemapCount] = "Miscellaneous";
-$RemapCount++;
-$RemapName[$RemapCount] = "Toggle Camera";
-$RemapCmd[$RemapCount] = "toggleCamera";
-$RemapGroup[$RemapCount] = "Miscellaneous";
-$RemapCount++;
-
-function ControlsMenu::loadSettings(%this)
-{
-   /*ControlSetList.clear();
-   ControlSetList.add( "Movement", "Movement" );
-   ControlSetList.add( "Combat", "Combat" );
-   ControlSetList.add( "Miscellaneous", "Miscellaneous" );*/
-   
-   //ControlSetList.setSelected( "Movement", false );
-   
-   OptionsSettingStack.clear();
-   loadGroupKeybinds("Movement");
-   //ControlsMenuOptionsArray.refresh();
-}
-
-function ControlSetList::onSelect( %this, %id, %text )
-{
-   ControlsMenuOptionsArray.clear();
-   
-   if(%text $= "Movement")
-      loadGroupKeybinds("Movement");
-   else if(%text $= "Combat")
-      loadGroupKeybinds("Combat");
-   else if(%text $= "Miscellaneous")
-      loadGroupKeybinds("Miscellaneous");
-
-    //ControlsMenuOptionsArray.refresh();
-}
-
-function ControlsMenuOKButton::onClick(%this)
-{
-    // write out the control config into the keybinds.cs file
-    %prefPath = getPrefpath();
-    moveMap.save( %prefPath @ "/keybinds.cs" );
-   
-    OptionsMenu.backOut();
-}
-
 function ControlsMenuDefaultsButton::onClick(%this)
 {
    //For this to work with module-style, we have to figure that somewhere, we'll set where our default keybind script is at.
    //This can be hardcoded in your actual project.
-   exec($KeybindPath);
-   ControlsMenu.reload();
-}
-
-function loadGroupKeybinds(%keybindGroup)
-{
-   %optionIndex = 0;
-   for(%i=0; %i < $RemapCount; %i++)
-   {
-      //find and add all the keybinds for the particular group we're looking at
-      if($RemapGroup[%i] $= %keybindGroup)
-      {
-         %temp = getKeybindString(%i);
-         
-         %option = addKeybindOption();
-         %option-->nameText.setText($RemapName[%i]);
-         %option-->rebindButton.setText(%temp);
-         %option-->rebindButton.keybindIndex = %i;
-         %option-->rebindButton.optionIndex = %optionIndex;
-         %optionIndex++;
-      }
-   }
-}
-
-function addKeybindOption()
-{
-    %tamlReader = new Taml();
-   
-    %controlOption = %tamlReader.read("data/ui/guis/controlsMenuSetting.taml");
-    %controlOption.extent.x = OptionsSettingStack.extent.x;
-
-    OptionsSettingStack.add(%controlOption);
-
-    return %graphicsOption;
-}
-
-function getKeybindString(%index )
-{
-   %name       = $RemapName[%index];
-   %cmd        = $RemapCmd[%index];
-
-   %temp = moveMap.getBinding( %cmd );
-   if ( %temp $= "" )
-      return %name TAB "";
-
-   %mapString = "";
-
-   %count = getFieldCount( %temp );
-   for ( %i = 0; %i < %count; %i += 2 )
-   {
-      %device = getField( %temp, %i + 0 );
-      %object = getField( %temp, %i + 1 );
-      
-      %displayName = getMapDisplayName( %device, %object );
-      
-      if(%displayName !$= "")
-      {
-         %tmpMapString = getMapDisplayName( %device, %object );
-         
-         if(%mapString $= "")
-         {
-            %mapString = %tmpMapString;
-         }
-         else
-         {
-            if ( %tmpMapString !$= "")
-            {
-               %mapString = %mapString @ ", " @ %tmpMapString;
-            }
-         }
-      }
-   }
-
-   return %mapString; 
-}
-
-function ControlsMenu::redoMapping( %device, %action, %cmd, %oldIndex, %newIndex )
-{
-	//%actionMap.bind( %device, %action, $RemapCmd[%newIndex] );
-	moveMap.bind( %device, %action, %cmd );
-	
-   %remapList = %this-->OptRemapList;
-	%remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) );
-	%remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) );
+   //exec($KeybindPath);
+   //ControlsMenu.reload();
 }
 
 function getMapDisplayName( %device, %action )
@@ -231,16 +64,41 @@ function getMapDisplayName( %device, %action )
             error( "Unsupported Joystick input object passed to getDisplayMapName!" );
       }
 	}
+	else if ( strstr( %device, "gamepad" ) != -1 )
+	{
+	   return %action;
+	   
+	   %pos = strstr( %action, "button" );
+		if ( %pos != -1 )
+		{
+			%mods = getSubStr( %action, 0, %pos );
+			%object = getSubStr( %action, %pos, 1000 );
+			%instance = getSubStr( %object, strlen( "button" ), 1000 );
+			return( %mods @ "joystick" @ ( %instance + 1 ) );
+		}
+		else
+	   { 
+	      %pos = strstr( %action, "thumb" );
+         if ( %pos != -1 )
+         {
+            //%instance = getSubStr( %action, strlen( "thumb" ), 1000 );
+            //return( "thumb" @ ( %instance + 1 ) );
+            return %action;
+         }
+         else
+            error( "Unsupported gamepad input object passed to getDisplayMapName!" );
+      }
+	}
 		
 	return( "" );		
 }
 
-function ControlsMenu::buildFullMapString( %this, %index )
+function buildFullMapString( %index, %actionMap, %deviceType )
 {
    %name       = $RemapName[%index];
    %cmd        = $RemapCmd[%index];
-
-   %temp = moveMap.getBinding( %cmd );
+   
+   %temp = %actionMap.getBinding( %cmd );
    if ( %temp $= "" )
       return %name TAB "";
 
@@ -250,34 +108,88 @@ function ControlsMenu::buildFullMapString( %this, %index )
    for ( %i = 0; %i < %count; %i += 2 )
    {
       if ( %mapString !$= "" )
-         %mapString = %mapString @ ", ";
-
+         continue;
+         //%mapString = %mapString @ ", ";
+         
       %device = getField( %temp, %i + 0 );
       %object = getField( %temp, %i + 1 );
-      %mapString = %mapString @ %this.getMapDisplayName( %device, %object );
+      
+      if(%deviceType !$= "" && !startsWith(%device, %deviceType))
+         continue;
+         
+      %mapString = %mapString @ getMapDisplayName( %device, %object );
    }
 
    return %name TAB %mapString; 
 }
 
-function ControlsMenu::fillRemapList( %this )
+function fillRemapList()
 {
-   %remapList = %this-->OptRemapList;
+   %device = $remapListDevice;
+   
+	OptionsMenuSettingsList.clearRows();
+
+   //build out our list of action maps
+   %actionMapCount = ActionMapGroup.getCount();
+   
+   %actionMapList = "";
+   for(%i=0; %i < %actionMapCount; %i++)
+   {
+      %actionMap = ActionMapGroup.getObject(%i);
+      
+      if(%actionMap == GlobalActionMap.getId())
+         continue;
+      
+      %actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName;
+      
+      if(%actionMapList $= "")
+         %actionMapList = %actionMapName;
+      else
+         %actionMapList = %actionMapList TAB %actionMapName;
+   }
+   
+   //If we didn't find any valid actionMaps, then just exit out
+   if(%actionMapList $= "")
+      return;
+      
+   if($activeRemapControlSet $= "")
+      $activeRemapControlSet = getField(%actionMapList, 0);
    
-	%remapList.clear();
+   OptionsMenuSettingsList.addOptionRow("Control Set", %actionMapList, false, "controlSetChanged", -1, -30, true, "Which keybind control set to edit", $activeRemapControlSet);
+	
    for ( %i = 0; %i < $RemapCount; %i++ )
-      %remapList.addRow( %i, %this.buildFullMapString( %i ) );
+   {
+      if(%device !$= "" && %device !$= $RemapDevice[%i])
+         continue;
+         
+      %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; 
+         
+      if($activeRemapControlSet !$= %actionMapName)
+         continue;
+         
+      %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %device );
+      %description = $RemapDescription[%i];
+      
+      OptionsMenuSettingsList.addKeybindRow(getField(%keyMap, 0), getButtonBitmap(%device, getField(%keyMap, 1)), "doKeyRemap", -1, -15, true, %description);
+   }
+
+   OptionsMenuSettingsList.refresh();
+      //OptionsMenu.addRow( %i, %this.buildFullMapString( %i ) );
 }
 
-function ControlsMenu::doRemap( %this )
+function controlSetChanged()
 {
-   %remapList = %this-->OptRemapList;
-   
-	%selId = %remapList.getSelectedId();
-   %name = $RemapName[%selId];
+   $activeRemapControlSet = OptionsMenuSettingsList.getCurrentOption(0);
+   fillRemapList();
+}
+
+function doKeyRemap( %rowIndex )
+{
+   %rowIndex--; //Offset the rowIndex to account for controlset option
+   %name = $RemapName[%rowIndex];
 
 	RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." );
-	OptRemapInputCtrl.index = %selId;
+	OptRemapInputCtrl.index = %rowIndex;
 	Canvas.pushDialog( RemapDlg );
 }
 
@@ -309,24 +221,27 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
 
    %cmd  = $RemapCmd[%this.index];
    %name = $RemapName[%this.index];
+   %actionMap = $RemapActionMap[%this.index];
 
    // Grab the friendly display name for this action
    // which we'll use when prompting the user below.
-   %mapName = ControlsMenu.getMapDisplayName( %device, %action );
+   %mapName = getMapDisplayName( %device, %action );
    
    // Get the current command this action is mapped to.
-   %prevMap = moveMap.getCommand( %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 );
 
    // If nothing was mapped to the previous command 
    // mapping then it's easy... just bind it.
    if ( %prevMap $= "" )
    {
-      ControlsMenu.unbindExtraActions( %cmd, 1 );
-      moveMap.bind( %device, %action, %cmd );
+      //unbindExtraActions( %cmd, %actionMap, 1 );
+      %actionMap.bind( %device, %action, %cmd );
       
-      //ControlsMenu.reload();
-      %newCommands = getField(ControlsMenu.buildFullMapString( %this.index ), 1);
-      ControlsMenuOptionsArray.getObject(%this.optionIndex)-->rebindButton.setText(%newCommands);
+      fillRemapList();
       return;
    }
 
@@ -335,17 +250,15 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
    // was already assigned.
    if ( %prevMap $= %cmd )
    {
-      ControlsMenu.unbindExtraActions( %cmd, 0 );
-      moveMap.bind( %device, %action, %cmd );
+      //unbindExtraActions( %cmd, %actionMap, 0 );
+      %actionMap.bind( %device, %action, %cmd );
 
-      //ControlsMenu.reload();
-      %newCommands = getField(ControlsMenu.buildFullMapString( %this.index ), 1);
-      ControlsMenuOptionsArray.getObject(%this.optionIndex)-->rebindButton.setText(%newCommands);
+      fillRemapList();
       return;   
    }
 
    // Look for the index of the previous mapping.
-   %prevMapIndex = ControlsMenu.findRemapCmdIndex( %prevMap );
+   %prevMapIndex = findRemapCmdIndex( %prevMap );
    
    // If we get a negative index then the previous 
    // mapping was to an item that isn't included in
@@ -357,7 +270,7 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
    }
 
    // Setup the forced remapping callback command.
-   %callback = "redoMapping(" @ %device @ ", \"" @ %action @ "\", \"" @
+   %callback = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @
                               %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");";
    
    // Warn that we're about to remove the old mapping and
@@ -367,7 +280,7 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
    
    RemapConfirmationText.setText("\"" @ %mapName @ "\" is already bound to \""
       @ %prevCmdName @ "\"! Do you wish to replace this mapping?");
-   RemapConfirmationYesButton.command = "ControlsMenu.redoMapping(" @ %device @ ", \"" @ %action @ "\", \"" @
+   RemapConfirmationYesButton.command = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @
                               %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ "); Canvas.popDialog();";
    RemapConfirmationNoButton.command = "Canvas.popDialog();";
    
@@ -377,7 +290,7 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
        %callback, "" );*/
 }
 
-function ControlsMenu::findRemapCmdIndex( %this, %command )
+function findRemapCmdIndex( %command )
 {
 	for ( %i = 0; %i < $RemapCount; %i++ )
 	{
@@ -388,10 +301,10 @@ function ControlsMenu::findRemapCmdIndex( %this, %command )
 }
 
 /// This unbinds actions beyond %count associated to the
-/// particular moveMap %commmand.
-function ControlsMenu::unbindExtraActions( %this, %command, %count )
+/// particular actionMap %commmand.
+function unbindExtraActions( %command, %actionMap, %count )
 {
-   %temp = moveMap.getBinding( %command );
+   %temp = %actionMap.getBinding( %command );
    if ( %temp $= "" )
       return;
 
@@ -401,18 +314,14 @@ function ControlsMenu::unbindExtraActions( %this, %command, %count )
       %device = getField( %temp, %i + 0 );
       %action = getField( %temp, %i + 1 );
       
-      moveMap.unbind( %device, %action );
+      %actionMap.unbind( %device, %action );
    }
 }
 
-function ControlsMenu::redoMapping( %this, %device, %action, %cmd, %oldIndex, %newIndex )
+function redoMapping( %device, %actionMap, %action, %cmd, %oldIndex, %newIndex )
 {
 	//%actionMap.bind( %device, %action, $RemapCmd[%newIndex] );
-	moveMap.bind( %device, %action, %cmd );
-	
-   %remapList = %this-->OptRemapList;
-	%remapList.setRowById( %oldIndex, %this.buildFullMapString( %oldIndex ) );
-	%remapList.setRowById( %newIndex, %this.buildFullMapString( %newIndex ) );
+	%actionMap.bind( %device, %action, %cmd );
 	
-	%this.changeSettingsPage();
+	fillRemapList();
 }

+ 103 - 0
Templates/BaseGame/game/data/ui/scripts/default.keybinds.cs

@@ -0,0 +1,103 @@
+$movementSpeed = 1; // m/s
+
+function moveleft(%val)
+{
+   $mvLeftAction = %val * $movementSpeed;
+}
+
+function moveright(%val)
+{
+   $mvRightAction = %val * $movementSpeed;
+}
+
+function moveforward(%val)
+{
+   $mvForwardAction = %val * $movementSpeed;
+}
+
+function movebackward(%val)
+{
+   $mvBackwardAction = %val * $movementSpeed;
+}
+
+function gamePadMoveX( %val )
+{
+   if(%val > 0)
+   {
+      $mvRightAction = %val * $movementSpeed;
+      $mvLeftAction = 0;
+   }
+   else
+   {
+      $mvRightAction = 0;
+      $mvLeftAction = -%val * $movementSpeed;
+   }
+}
+
+function gamePadMoveY( %val )
+{
+   if(%val > 0)
+   {
+      $mvForwardAction = %val * $movementSpeed;
+      $mvBackwardAction = 0;
+   }
+   else
+   {
+      $mvForwardAction = 0;
+      $mvBackwardAction = -%val * $movementSpeed;
+   }
+}
+
+function gamepadYaw(%val)
+{
+   %yawAdj = getGamepadAdjustAmount(%val);
+   if(ServerConnection.isControlObjectRotDampedCamera())
+   {
+      // Clamp and scale
+      %yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
+      %yawAdj *= 0.5;
+   }
+
+   if(%yawAdj > 0)
+   {
+      $mvYawLeftSpeed = %yawAdj;
+      $mvYawRightSpeed = 0;
+   }
+   else
+   {
+      $mvYawLeftSpeed = 0;
+      $mvYawRightSpeed = -%yawAdj;
+   }
+}
+
+function gamepadPitch(%val)
+{
+   %pitchAdj = getGamepadAdjustAmount(%val);
+   if(ServerConnection.isControlObjectRotDampedCamera())
+   {
+      // Clamp and scale
+      %pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
+      %pitchAdj *= 0.5;
+   }
+
+   if(%pitchAdj > 0)
+   {
+      $mvPitchDownSpeed = %pitchAdj;
+      $mvPitchUpSpeed = 0;
+   }
+   else
+   {
+      $mvPitchDownSpeed = 0;
+      $mvPitchUpSpeed = -%pitchAdj;
+   }
+}
+
+moveMap.bind( keyboard, a, moveleft );
+moveMap.bind( keyboard, d, moveright );
+moveMap.bind( keyboard, w, moveforward );
+moveMap.bind( keyboard, s, movebackward );
+
+moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
+moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
+moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
+moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );

+ 0 - 401
Templates/BaseGame/game/data/ui/scripts/keybindEdit.cs

@@ -1,401 +0,0 @@
-// =============================================================================
-// KEYBINDS MENU
-// =============================================================================
-$RemapCount = 0;
-$RemapName[$RemapCount] = "Forward";
-$RemapCmd[$RemapCount] = "moveforward";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Backward";
-$RemapCmd[$RemapCount] = "movebackward";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Strafe Left";
-$RemapCmd[$RemapCount] = "moveleft";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Strafe Right";
-$RemapCmd[$RemapCount] = "moveright";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-$RemapName[$RemapCount] = "Jump";
-$RemapCmd[$RemapCount] = "jump";
-$RemapGroup[$RemapCount] = "Movement";
-$RemapCount++;
-
-$RemapName[$RemapCount] = "Fire Weapon";
-$RemapCmd[$RemapCount] = "mouseFire";
-$RemapGroup[$RemapCount] = "Combat";
-$RemapCount++;
-$RemapName[$RemapCount] = "Adjust Zoom";
-$RemapCmd[$RemapCount] = "setZoomFov";
-$RemapGroup[$RemapCount] = "Combat";
-$RemapCount++;
-$RemapName[$RemapCount] = "Toggle Zoom";
-$RemapCmd[$RemapCount] = "toggleZoom";
-$RemapGroup[$RemapCount] = "Combat";
-$RemapCount++;
-
-$RemapName[$RemapCount] = "Free Look";
-$RemapCmd[$RemapCount] = "toggleFreeLook";
-$RemapGroup[$RemapCount] = "Miscellaneous";
-$RemapCount++;
-$RemapName[$RemapCount] = "Switch 1st/3rd";
-$RemapCmd[$RemapCount] = "toggleFirstPerson";
-$RemapGroup[$RemapCount] = "Miscellaneous";
-$RemapCount++;
-$RemapName[$RemapCount] = "Toggle Camera";
-$RemapCmd[$RemapCount] = "toggleCamera";
-$RemapGroup[$RemapCount] = "Miscellaneous";
-$RemapCount++;
-
-function ControlSetList::onSelect( %this, %id, %text )
-{
-   ControlsMenuOptionsArray.clear();
-   
-   if(%text $= "Movement")
-      loadGroupKeybinds("Movement");
-   else if(%text $= "Combat")
-      loadGroupKeybinds("Combat");
-   else if(%text $= "Miscellaneous")
-      loadGroupKeybinds("Miscellaneous");
-
-    //ControlsMenuOptionsArray.refresh();
-}
-
-function ControlsMenuOKButton::onClick(%this)
-{
-    // write out the control config into the keybinds.cs file
-    %prefPath = getPrefpath();
-    moveMap.save( %prefPath @ "/keybinds.cs" );
-   
-    OptionsMenu.backOut();
-}
-
-function ControlsMenuDefaultsButton::onClick(%this)
-{
-   //For this to work with module-style, we have to figure that somewhere, we'll set where our default keybind script is at.
-   //This can be hardcoded in your actual project.
-   exec($KeybindPath);
-   ControlsMenu.reload();
-}
-
-function loadGroupKeybinds(%keybindGroup)
-{
-   %optionIndex = 0;
-   for(%i=0; %i < $RemapCount; %i++)
-   {
-      //find and add all the keybinds for the particular group we're looking at
-      if($RemapGroup[%i] $= %keybindGroup)
-      {
-         %temp = getKeybindString(%i);
-         
-         %option = addKeybindOption();
-         %option-->nameText.setText($RemapName[%i]);
-         %option-->rebindButton.setText(%temp);
-         %option-->rebindButton.keybindIndex = %i;
-         %option-->rebindButton.optionIndex = %optionIndex;
-         %optionIndex++;
-      }
-   }
-}
-
-function addKeybindOption()
-{
-    %tamlReader = new Taml();
-   
-    %controlOption = %tamlReader.read("data/ui/guis/controlsMenuSetting.taml");
-    %controlOption.extent.x = OptionsSettingStack.extent.x;
-
-    OptionsSettingStack.add(%controlOption);
-
-    return %graphicsOption;
-}
-
-function getKeybindString(%index )
-{
-   %name       = $RemapName[%index];
-   %cmd        = $RemapCmd[%index];
-
-   %temp = moveMap.getBinding( %cmd );
-   if ( %temp $= "" )
-      return %name TAB "";
-
-   %mapString = "";
-
-   %count = getFieldCount( %temp );
-   for ( %i = 0; %i < %count; %i += 2 )
-   {
-      %device = getField( %temp, %i + 0 );
-      %object = getField( %temp, %i + 1 );
-      
-      %displayName = getMapDisplayName( %device, %object );
-      
-      if(%displayName !$= "")
-      {
-         %tmpMapString = getMapDisplayName( %device, %object );
-         
-         if(%mapString $= "")
-         {
-            %mapString = %tmpMapString;
-         }
-         else
-         {
-            if ( %tmpMapString !$= "")
-            {
-               %mapString = %mapString @ ", " @ %tmpMapString;
-            }
-         }
-      }
-   }
-
-   return %mapString; 
-}
-
-function ControlsMenu::redoMapping( %device, %action, %cmd, %oldIndex, %newIndex )
-{
-	//%actionMap.bind( %device, %action, $RemapCmd[%newIndex] );
-	moveMap.bind( %device, %action, %cmd );
-	
-   %remapList = %this-->OptRemapList;
-	%remapList.setRowById( %oldIndex, buildFullMapString( %oldIndex ) );
-	%remapList.setRowById( %newIndex, buildFullMapString( %newIndex ) );
-}
-
-function getMapDisplayName( %device, %action )
-{
-	if ( %device $= "keyboard" )
-		return( %action );		
-	else if ( strstr( %device, "mouse" ) != -1 )
-	{
-		// Substitute "mouse" for "button" in the action string:
-		%pos = strstr( %action, "button" );
-		if ( %pos != -1 )
-		{
-			%mods = getSubStr( %action, 0, %pos );
-			%object = getSubStr( %action, %pos, 1000 );
-			%instance = getSubStr( %object, strlen( "button" ), 1000 );
-			return( %mods @ "mouse" @ ( %instance + 1 ) );
-		}
-		else
-			error( "Mouse input object other than button passed to getDisplayMapName!" );
-	}
-	else if ( strstr( %device, "joystick" ) != -1 )
-	{
-		// Substitute "joystick" for "button" in the action string:
-		%pos = strstr( %action, "button" );
-		if ( %pos != -1 )
-		{
-			%mods = getSubStr( %action, 0, %pos );
-			%object = getSubStr( %action, %pos, 1000 );
-			%instance = getSubStr( %object, strlen( "button" ), 1000 );
-			return( %mods @ "joystick" @ ( %instance + 1 ) );
-		}
-		else
-	   { 
-	      %pos = strstr( %action, "pov" );
-         if ( %pos != -1 )
-         {
-            %wordCount = getWordCount( %action );
-            %mods = %wordCount > 1 ? getWords( %action, 0, %wordCount - 2 ) @ " " : "";
-            %object = getWord( %action, %wordCount - 1 );
-            switch$ ( %object )
-            {
-               case "upov":   %object = "POV1 up";
-               case "dpov":   %object = "POV1 down";
-               case "lpov":   %object = "POV1 left";
-               case "rpov":   %object = "POV1 right";
-               case "upov2":  %object = "POV2 up";
-               case "dpov2":  %object = "POV2 down";
-               case "lpov2":  %object = "POV2 left";
-               case "rpov2":  %object = "POV2 right";
-               default:       %object = "";
-            }
-            return( %mods @ %object );
-         }
-         else
-            error( "Unsupported Joystick input object passed to getDisplayMapName!" );
-      }
-	}
-		
-	return( "" );		
-}
-
-function ControlsMenu::buildFullMapString( %this, %index )
-{
-   %name       = $RemapName[%index];
-   %cmd        = $RemapCmd[%index];
-
-   %temp = moveMap.getBinding( %cmd );
-   if ( %temp $= "" )
-      return %name TAB "";
-
-   %mapString = "";
-
-   %count = getFieldCount( %temp );
-   for ( %i = 0; %i < %count; %i += 2 )
-   {
-      if ( %mapString !$= "" )
-         %mapString = %mapString @ ", ";
-
-      %device = getField( %temp, %i + 0 );
-      %object = getField( %temp, %i + 1 );
-      %mapString = %mapString @ %this.getMapDisplayName( %device, %object );
-   }
-
-   return %name TAB %mapString; 
-}
-
-function ControlsMenu::fillRemapList( %this )
-{
-   %remapList = %this-->OptRemapList;
-   
-	%remapList.clear();
-   for ( %i = 0; %i < $RemapCount; %i++ )
-      %remapList.addRow( %i, %this.buildFullMapString( %i ) );
-}
-
-function doKeyRemap( %rowIndex )
-{
-   %name = $RemapName[%rowIndex];
-
-	RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." );
-	OptRemapInputCtrl.index = %rowIndex;
-	Canvas.pushDialog( RemapDlg );
-}
-
-function ControlsMenuRebindButton::onClick(%this)
-{
-   %name = $RemapName[%this.keybindIndex];
-   RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." );
-   
-   OptRemapInputCtrl.index = %this.keybindIndex;
-   OptRemapInputCtrl.optionIndex = %this.optionIndex;
-   Canvas.pushDialog( RemapDlg );
-}
-
-function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
-{
-   //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" );
-   Canvas.popDialog( RemapDlg );
-
-   // Test for the reserved keystrokes:
-   if ( %device $= "keyboard" )
-   {
-      // Cancel...
-      if ( %action $= "escape" )
-      {
-         // Do nothing...
-         return;
-      }
-   }
-
-   %cmd  = $RemapCmd[%this.index];
-   %name = $RemapName[%this.index];
-
-   // Grab the friendly display name for this action
-   // which we'll use when prompting the user below.
-   %mapName = ControlsMenu.getMapDisplayName( %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 $= "" )
-   {
-      ControlsMenu.unbindExtraActions( %cmd, 1 );
-      moveMap.bind( %device, %action, %cmd );
-      
-      //ControlsMenu.reload();
-      %newCommands = getField(ControlsMenu.buildFullMapString( %this.index ), 1);
-      ControlsMenuOptionsArray.getObject(%this.optionIndex)-->rebindButton.setText(%newCommands);
-      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 )
-   {
-      ControlsMenu.unbindExtraActions( %cmd, 0 );
-      moveMap.bind( %device, %action, %cmd );
-
-      //ControlsMenu.reload();
-      %newCommands = getField(ControlsMenu.buildFullMapString( %this.index ), 1);
-      ControlsMenuOptionsArray.getObject(%this.optionIndex)-->rebindButton.setText(%newCommands);
-      return;   
-   }
-
-   // Look for the index of the previous mapping.
-   %prevMapIndex = ControlsMenu.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 @ ", \"" @ %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 );
-   
-   RemapConfirmationText.setText("\"" @ %mapName @ "\" is already bound to \""
-      @ %prevCmdName @ "\"! Do you wish to replace this mapping?");
-   RemapConfirmationYesButton.command = "ControlsMenu.redoMapping(" @ %device @ ", \"" @ %action @ "\", \"" @
-                              %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ "); Canvas.popDialog();";
-   RemapConfirmationNoButton.command = "Canvas.popDialog();";
-   
-   /*MessageBoxYesNo( "Warning",
-      "\"" @ %mapName @ "\" is already bound to \""
-      @ %prevCmdName @ "\"!\nDo you wish to replace this mapping?",
-       %callback, "" );*/
-}
-
-function ControlsMenu::findRemapCmdIndex( %this, %command )
-{
-	for ( %i = 0; %i < $RemapCount; %i++ )
-	{
-		if ( %command $= $RemapCmd[%i] )
-			return( %i );			
-	}
-	return( -1 );	
-}
-
-/// This unbinds actions beyond %count associated to the
-/// particular moveMap %commmand.
-function ControlsMenu::unbindExtraActions( %this, %command, %count )
-{
-   %temp = moveMap.getBinding( %command );
-   if ( %temp $= "" )
-      return;
-
-   %count = getFieldCount( %temp ) - ( %count * 2 );
-   for ( %i = 0; %i < %count; %i += 2 )
-   {
-      %device = getField( %temp, %i + 0 );
-      %action = getField( %temp, %i + 1 );
-      
-      moveMap.unbind( %device, %action );
-   }
-}
-
-function ControlsMenu::redoMapping( %this, %device, %action, %cmd, %oldIndex, %newIndex )
-{
-	//%actionMap.bind( %device, %action, $RemapCmd[%newIndex] );
-	moveMap.bind( %device, %action, %cmd );
-	
-   %remapList = %this-->OptRemapList;
-	%remapList.setRowById( %oldIndex, %this.buildFullMapString( %oldIndex ) );
-	%remapList.setRowById( %newIndex, %this.buildFullMapString( %newIndex ) );
-	
-	%this.changeSettingsPage();
-}

+ 74 - 13
Templates/BaseGame/game/data/ui/scripts/utility.cs

@@ -1,17 +1,27 @@
 function getButtonBitmap(%device, %button)
 {
+   if(%device $= "gamepad")
+   {
+      //In the event we passed in a generic gamepad device name, we'll try fetching the actual device here
+      %device = SDLInputManager::JoystickNameForIndex(0);
+      
+      //If we couldn't figure out what it was, just use the generic Xbox images
+      if(%device $= "")
+         %device = "Xbox";
+   }
+   
    %path = "";
    if(%device $= "PS4")
    { 
       %path = "data/ui/images/inputs/PS4/PS4_";
       
-      if(%button $= "A")
+      if(%button $= "A" || %button $= "btn_a")
          %path = %path @ "Cross";
-      else if(%button $= "B")
+      else if(%button $= "B" || %button $= "btn_b")
          %path = %path @ "Circle";
-      else if(%button $= "X")
+      else if(%button $= "X" || %button $= "btn_x")
          %path = %path @ "Square";
-      else if(%button $= "Y")
+      else if(%button $= "Y" || %button $= "btn_y")
          %path = %path @ "Triangle";
       else if(%button $= "LB")
          %path = %path @ "L1";
@@ -21,20 +31,34 @@ function getButtonBitmap(%device, %button)
          %path = %path @ "R1";
       else if(%button $= "RT")
          %path = %path @ "R2";
-      else      
-         continue;
+      else if(%button $= "thumbrx" || %button $= "thumbry")
+         %path = %path @ "Right_Stick";
+      else if(%button $= "thumblx" || %button $= "thumbly")
+         %path = %path @ "Left_Stick";
+      else if(%button $= "start")
+         %path = %path @ "Options";
+      else if(%button $= "back")
+         %path = %path @ "Share";   
+      else if(%button $= "dpadu")
+         %path = %path @ "Dpad_Up";  
+      else if(%button $= "dpadd")
+         %path = %path @ "Dpad_Down";  
+      else if(%button $= "dpadl")
+         %path = %path @ "Dpad_Left";  
+      else if(%button $= "dpadr")
+         %path = %path @ "Dpad_Right";  
    }
    else if(%device $= "Switch")
    {
       %path = "data/ui/images/inputs/Switch/Switch_";
       
-      if(%button $= "A")
+      if(%button $= "A" || %button $= "btn_a")
          %path = %path @ "B";
-      else if(%button $= "B")
+      else if(%button $= "B" || %button $= "btn_b")
          %path = %path @ "A";
-      else if(%button $= "X")
+      else if(%button $= "X" || %button $= "btn_x")
          %path = %path @ "Y";
-      else if(%button $= "Y")
+      else if(%button $= "Y" || %button $= "btn_y")
          %path = %path @ "X";
       else if(%button $= "LB")
          %path = %path @ "LB";
@@ -44,8 +68,22 @@ function getButtonBitmap(%device, %button)
          %path = %path @ "RB";
       else if(%button $= "RT")
          %path = %path @ "RT";
-      else      
-         continue;
+      else if(%button $= "thumbrx" || %button $= "thumbry")
+         %path = %path @ "Right_Stick";
+      else if(%button $= "thumblx" || %button $= "thumbly")
+         %path = %path @ "Left_Stick";
+      else if(%button $= "start")
+         %path = %path @ "Plus";
+      else if(%button $= "back")
+         %path = %path @ "Minus";   
+      else if(%button $= "dpadu")
+         %path = %path @ "Dpad_Up";  
+      else if(%button $= "dpadd")
+         %path = %path @ "Dpad_Down";  
+      else if(%button $= "dpadl")
+         %path = %path @ "Dpad_Left";  
+      else if(%button $= "dpadr")
+         %path = %path @ "Dpad_Right"; 
    }
    else if(%device $= "Keyboard" || %device $= "Mouse")
    {
@@ -58,7 +96,30 @@ function getButtonBitmap(%device, %button)
    {
       %path = "data/ui/images/inputs/Xbox/Xbox_";
       
-      %path = %path @ %button;
+      if(%button $= "btn_a")
+         %path = %path @ "B";
+      else if(%button $= "btn_b")
+         %path = %path @ "A";
+      else if(%button $= "btn_x")
+         %path = %path @ "Y";
+      else if(%button $= "btn_y")
+         %path = %path @ "X";
+      else if(%button $= "thumbrx" || %button $= "thumbry")
+         %path = %path @ "Right_Stick";
+      else if(%button $= "thumblx" || %button $= "thumbly")
+         %path = %path @ "Left_Stick";
+      else if(%button $= "start")
+         %path = %path @ "Menu";
+      else if(%button $= "back")
+         %path = %path @ "Windows";   
+      else if(%button $= "dpadu")
+         %path = %path @ "Dpad_Up";  
+      else if(%button $= "dpadd")
+         %path = %path @ "Dpad_Down";  
+      else if(%button $= "dpadl")
+         %path = %path @ "Dpad_Left";  
+      else if(%button $= "dpadr")
+         %path = %path @ "Dpad_Right"; 
    }
    
    return %path;