Files
sbox-public/engine/Sandbox.Engine/Systems/Render/Settings/RenderQualityProfiles.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

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 );
}
}
}