Skip to content

Commit

Permalink
Configure grahpics driver from settings.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Mar 21, 2024
1 parent 3ae9e35 commit e4ecc5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CentrED/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static void Main(string[] args)
_loadContext = AssemblyLoadContext.Default;
_loadContext.ResolvingUnmanagedDll += ResolveUnmanagedDll;
_loadContext.Resolving += ResolveAssembly;
Config.Initialize();

using (CEDGame = new CentrEDGame())
{
Expand Down
9 changes: 6 additions & 3 deletions CentrED/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ConfigRoot
public string ServerConfigPath = "cedserver.xml";
public bool PreferTexMaps;
public bool LegacyMouseScroll;
public string GraphicsDriver = "D3D11";
public Dictionary<string, WindowState> Layout = new();
}

Expand All @@ -18,13 +19,14 @@ public static class Config
private static DateTime LastConfigSave = DateTime.Now;
private static readonly JsonSerializerOptions SerializerOptions = new()
{
IncludeFields = true
IncludeFields = true,
WriteIndented = true,
};

public static ConfigRoot Instance;
private static string _configFilePath = "settings.json";
static Config()

public static void Initialize()
{
if (!File.Exists(_configFilePath))
{
Expand All @@ -34,6 +36,7 @@ static Config()

var jsonText = File.ReadAllText(_configFilePath);
Instance = JsonSerializer.Deserialize<ConfigRoot>(jsonText, SerializerOptions);
Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", Instance.GraphicsDriver);
}

public static void AutoSave()
Expand Down

0 comments on commit e4ecc5b

Please sign in to comment.