Shell now automatically detects steam directories (prone to bugs).

This commit is contained in:
That_One_Nerd 2023-05-10 14:07:43 -04:00
parent 13c9adf781
commit d83c16827f
3 changed files with 36 additions and 1 deletions

View File

@ -7,6 +7,7 @@ global using SrcMod.Shell.Extensions;
global using SrcMod.Shell.Interop; global using SrcMod.Shell.Interop;
global using SrcMod.Shell.Modules.ObjectModels; global using SrcMod.Shell.Modules.ObjectModels;
global using SrcMod.Shell.ObjectModels; global using SrcMod.Shell.ObjectModels;
global using SrcMod.Shell.ObjectModels.Steam;
global using System; global using System;
global using System.Collections; global using System.Collections;
global using System.Collections.Generic; global using System.Collections.Generic;

View File

@ -65,7 +65,28 @@ public class Config
internal Config() internal Config()
{ {
// TODO: This won't work if the steam installation is somewhere else.
const string gameDirDataPath = @"C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf";
VkvSerializer serializer = new(new()
{
useEscapeCodes = true,
useQuotes = true
});
FileStream gameDirData = new(gameDirDataPath, FileMode.Open);
LibraryFolder[]? folders = serializer.Deserialize<LibraryFolder[]>(gameDirData);
if (folders is null)
{
Write("[WARNING] Error parsing steam game directories.");
GameDirectories = Array.Empty<string>(); GameDirectories = Array.Empty<string>();
}
else
{
GameDirectories = new string[folders.Length];
for (int i = 0; i < folders.Length; i++) GameDirectories[i] = folders[i].path;
}
RunUnsafeCommands = AskMode.Ask; RunUnsafeCommands = AskMode.Ask;
} }

View File

@ -0,0 +1,13 @@
namespace SrcMod.Shell.ObjectModels.Steam;
public class LibraryFolder
{
public string path;
public Dictionary<int, int> apps;
public LibraryFolder()
{
path = string.Empty;
apps = new();
}
}