Shell now automatically detects steam directories (prone to bugs).
This commit is contained in:
parent
13c9adf781
commit
d83c16827f
@ -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;
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
SrcMod/Shell/ObjectModels/Steam/LibraryFolder.cs
Normal file
13
SrcMod/Shell/ObjectModels/Steam/LibraryFolder.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user