mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-24 14:20:39 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using NativeEngine;
|
|
using System.IO;
|
|
|
|
namespace Sandbox.Engine.Settings;
|
|
|
|
/// <summary>
|
|
/// Render quality profiles adjust rendering features to a profile level
|
|
/// </summary>
|
|
class RenderQualityProfiles
|
|
{
|
|
Dictionary<string, Dictionary<string, Dictionary<string, string>>> Profiles { get; }
|
|
|
|
public RenderQualityProfiles()
|
|
{
|
|
Profiles = EngineFileSystem.CoreContent.ReadJsonOrDefault<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>( Path.Combine( "cfg", "quality_profiles.json" ), new() );
|
|
}
|
|
|
|
public void SetDefaults( RenderSettings settings )
|
|
{
|
|
// Set all our convars based on our set profiles as we load
|
|
SetGroupConVars( "TextureQuality", settings.TextureQuality.ToString() );
|
|
SetGroupConVars( "PostProcessQuality", settings.PostProcessQuality.ToString() );
|
|
SetGroupConVars( "VolumetricFogQuality", settings.VolumetricFogQuality.ToString() );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set all the convars for a group based on the level
|
|
/// </summary>
|
|
public void SetGroupConVars( string group, string level )
|
|
{
|
|
if ( !Profiles.ContainsKey( group ) )
|
|
return;
|
|
|
|
if ( !Profiles[group].ContainsKey( level ) )
|
|
return;
|
|
|
|
foreach ( var convar in Profiles[group][level] )
|
|
{
|
|
ConVarSystem.SetValue( convar.Key, convar.Value, true );
|
|
}
|
|
}
|
|
}
|