Update GameFinder to 4.0.0

This commit is contained in:
trawzified 2023-10-07 14:29:36 +02:00
parent a64e70d9ab
commit 84e55cedef
14 changed files with 58 additions and 54 deletions

View File

@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />

View File

@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />

View File

@ -21,7 +21,7 @@ public class GameMetaData
public int[] SteamIDs { get; internal init; } = Array.Empty<int>();
// to get gog ids: https://www.gogdb.org
public int[] GOGIDs { get; internal init; } = Array.Empty<int>();
public long[] GOGIDs { get; internal init; } = Array.Empty<long>();
// to get these ids, split the numbers from the letters in file names found in
// C:\ProgramData\Origin\LocalContent\{game name)\*.mfst

View File

@ -14,7 +14,7 @@ public static class GameRegistry
{
Game = Game.Morrowind,
SteamIDs = new[] {22320},
GOGIDs = new[] {1440163901, 1435828767},
GOGIDs = new long[] {1440163901, 1435828767},
NexusName = "morrowind",
NexusGameId = 100,
MO2Name = "Morrowind",
@ -38,7 +38,7 @@ public static class GameRegistry
MO2Name = "Oblivion",
MO2ArchiveName = "oblivion",
SteamIDs = new[] {22330},
GOGIDs = new[] {1458058109},
GOGIDs = new long[] {1458058109},
RequiredFiles = new[]
{
"oblivion.exe".ToRelativePath()
@ -56,7 +56,7 @@ public static class GameRegistry
MO2Name = "Fallout 3",
MO2ArchiveName = "fallout3",
SteamIDs = new[] {22300, 22370}, // base game and GotY
GOGIDs = new[] {1454315831}, // GotY edition
GOGIDs = new long[] {1454315831}, // GotY edition
RequiredFiles = new[]
{
"Fallout3.exe".ToRelativePath()
@ -73,7 +73,7 @@ public static class GameRegistry
MO2Name = "New Vegas",
MO2ArchiveName = "falloutnv",
SteamIDs = new[] {22380, 22490}, // normal and RU version
GOGIDs = new[] {1454587428},
GOGIDs = new long[] {1454587428},
RequiredFiles = new[]
{
"FalloutNV.exe".ToRelativePath()
@ -107,7 +107,7 @@ public static class GameRegistry
MO2Name = "Skyrim Special Edition",
MO2ArchiveName = "skyrimse",
SteamIDs = new[] {489830},
GOGIDs = new[]
GOGIDs = new long[]
{
1711230643,// The Elder Scrolls V: Skyrim Special Edition AKA Base Game
1801825368,// The Elder Scrolls V: Skyrim Anniversary Edition AKA The Store Bundle
@ -130,7 +130,7 @@ public static class GameRegistry
MO2Name = "Fallout 4",
MO2ArchiveName = "fallout4",
SteamIDs = new[] {377160},
GOGIDs = new []{1998527297},
GOGIDs = new long[]{1998527297},
RequiredFiles = new[]
{
"Fallout4.exe".ToRelativePath()
@ -183,7 +183,7 @@ public static class GameRegistry
MO2Name = "Enderal Special Edition",
MO2ArchiveName = "enderalse",
SteamIDs = new[] {976620},
GOGIDs = new [] {1708684988},
GOGIDs = new long[] {1708684988},
RequiredFiles = new[]
{
"SkyrimSE.exe".ToRelativePath()
@ -217,7 +217,7 @@ public static class GameRegistry
MO2Name = "Darkest Dungeon",
NexusGameId = 804,
SteamIDs = new[] {262060},
GOGIDs = new[] {1450711444},
GOGIDs = new long[] {1450711444},
EpicGameStoreIDs = new[] {"b4eecf70e3fe4e928b78df7855a3fc2d"},
IsGenericMO2Plugin = true,
RequiredFiles = new[]
@ -236,7 +236,7 @@ public static class GameRegistry
MO2ArchiveName = "dishonored",
NexusGameId = 802,
SteamIDs = new[] {205100},
GOGIDs = new[] {1701063787},
GOGIDs = new long[] {1701063787},
RequiredFiles = new[]
{
@"Binaries\Win32\Dishonored.exe".ToRelativePath()
@ -253,7 +253,7 @@ public static class GameRegistry
MO2Name = "The Witcher: Enhanced Edition",
MO2ArchiveName = "witcher",
SteamIDs = new[] {20900}, // normal and GotY
GOGIDs = new[] {1207658924}, // normal, GotY and both in packages
GOGIDs = new long[] {1207658924}, // normal, GotY and both in packages
RequiredFiles = new[]
{
@"System\witcher.exe".ToRelativePath()
@ -270,7 +270,7 @@ public static class GameRegistry
MO2Name = "The Witcher 3: Wild Hunt",
MO2ArchiveName = "witcher3",
SteamIDs = new[] {292030, 499450}, // normal and GotY
GOGIDs = new[]
GOGIDs = new long[]
{1207664643, 1495134320, 1207664663, 1640424747}, // normal, GotY and both in packages
RequiredFiles = new[]
{
@ -288,7 +288,7 @@ public static class GameRegistry
MO2ArchiveName = "stardewvalley",
NexusGameId = 1303,
SteamIDs = new[] {413150},
GOGIDs = new[] {1453375253},
GOGIDs = new long[] {1453375253},
IsGenericMO2Plugin = true,
RequiredFiles = new[]
{
@ -306,7 +306,7 @@ public static class GameRegistry
MO2ArchiveName = "kingdomcomedeliverance",
NexusGameId = 2298,
SteamIDs = new[] {379430},
GOGIDs = new[] {1719198803},
GOGIDs = new long[] {1719198803},
IsGenericMO2Plugin = true,
RequiredFiles = new[]
{
@ -340,7 +340,7 @@ public static class GameRegistry
NexusGameId = 1634,
MO2Name = "No Man's Sky",
SteamIDs = new[] {275850},
GOGIDs = new[] {1446213994},
GOGIDs = new long[] {1446213994},
RequiredFiles = new[]
{
@"Binaries\NMS.exe".ToRelativePath()
@ -357,7 +357,7 @@ public static class GameRegistry
MO2Name = "Dragon Age: Origins",
SteamIDs = new[] {47810},
OriginIDs = new[] {"DR:169789300", "DR:208591800"},
GOGIDs = new[] {1949616134},
GOGIDs = new long[] {1949616134},
RequiredFiles = new[]
{
@"bin_ship\daorigins.exe".ToRelativePath()
@ -405,7 +405,7 @@ public static class GameRegistry
MO2Name = "Kerbal Space Program",
NexusGameId = 272,
SteamIDs = new[] {220200},
GOGIDs = new[] {1429864849},
GOGIDs = new long[] {1429864849},
IsGenericMO2Plugin = true,
RequiredFiles = new[]
{
@ -433,7 +433,7 @@ public static class GameRegistry
{
Game = Game.Cyberpunk2077,
SteamIDs = new[] {1091500},
GOGIDs = new [] {2093619782, 1423049311},
GOGIDs = new long[] {2093619782, 1423049311},
EpicGameStoreIDs = new[] {"5beededaad9743df90e8f07d92df153f"},
MO2Name = "Cyberpunk 2077",
NexusName = "cyberpunk2077",
@ -467,7 +467,7 @@ public static class GameRegistry
{
Game = Game.DragonsDogma,
SteamIDs = new[] {367500 },
GOGIDs = new []{1242384383},
GOGIDs = new long[]{1242384383},
MO2Name = "Dragon's Dogma: Dark Arisen",
MO2ArchiveName = "dragonsdogma",
NexusName = "dragonsdogma",
@ -521,7 +521,7 @@ public static class GameRegistry
MO2Name = "Mount & Blade II: Bannerlord",
MO2ArchiveName = "mountandblade2bannerlord",
SteamIDs = new[] { 261550 },
GOGIDs = new [] {
GOGIDs = new long[] {
1564781494, //Mount & Blade II: Bannerlord : Game
1681929523, //Mount & Blade II: Bannerlord - Digital Deluxe : Package
1802539526, //Mount & Blade II: Bannerlord : Package

View File

@ -11,7 +11,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Xunit.DependencyInjection.Logging" Version="8.0.1" />

View File

@ -5,6 +5,8 @@ using GameFinder.StoreHandlers.EGS;
using GameFinder.StoreHandlers.GOG;
using GameFinder.StoreHandlers.Origin;
using GameFinder.StoreHandlers.Steam;
using GameFinder.StoreHandlers.Steam.Models;
using GameFinder.StoreHandlers.Steam.Models.ValueTypes;
using Microsoft.Extensions.Logging;
using Wabbajack.DTOs;
using Wabbajack.Paths;
@ -19,10 +21,10 @@ public class GameLocator : IGameLocator
private readonly EGSHandler? _egs;
private readonly OriginHandler? _origin;
private readonly Dictionary<int, AbsolutePath> _steamGames = new();
private readonly Dictionary<long, AbsolutePath> _gogGames = new();
private readonly Dictionary<string, AbsolutePath> _egsGames = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, AbsolutePath> _originGames = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<AppId, AbsolutePath> _steamGames = new();
private readonly Dictionary<GOGGameId, AbsolutePath> _gogGames = new();
private readonly Dictionary<EGSGameId, AbsolutePath> _egsGames = new();
private readonly Dictionary<OriginGameId, AbsolutePath> _originGames = new();
private readonly Dictionary<Game, AbsolutePath> _locationCache;
private readonly ILogger<GameLocator> _logger;
@ -30,19 +32,20 @@ public class GameLocator : IGameLocator
public GameLocator(ILogger<GameLocator> logger)
{
_logger = logger;
var fileSystem = NexusMods.Paths.FileSystem.Shared;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var windowsRegistry = new WindowsRegistry();
_steam = new SteamHandler(windowsRegistry);
_gog = new GOGHandler(windowsRegistry);
_egs = new EGSHandler(windowsRegistry);
_origin = new OriginHandler();
_steam = new SteamHandler(fileSystem, windowsRegistry);
_gog = new GOGHandler(windowsRegistry, fileSystem);
_egs = new EGSHandler(windowsRegistry, fileSystem);
_origin = new OriginHandler(fileSystem);
}
else
{
_steam = new SteamHandler(null);
_steam = new SteamHandler(fileSystem, null);
}
_locationCache = new Dictionary<Game, AbsolutePath>();
@ -54,7 +57,7 @@ public class GameLocator : IGameLocator
{
try
{
FindStoreGames(_steam, _steamGames, game => game.Path);
FindStoreGames(_steam, _steamGames, game => (AbsolutePath)game.Path.GetFullPath());
}
catch (Exception e)
{
@ -63,7 +66,7 @@ public class GameLocator : IGameLocator
try
{
FindStoreGames(_gog, _gogGames, game => game.Path);
FindStoreGames(_gog, _gogGames, game => (AbsolutePath)game.Path.GetFullPath());
}
catch (Exception e)
{
@ -72,7 +75,7 @@ public class GameLocator : IGameLocator
try
{
FindStoreGames(_egs, _egsGames, game => game.InstallLocation);
FindStoreGames(_egs, _egsGames, game => (AbsolutePath)game.InstallLocation.GetFullPath());
}
catch (Exception e)
{
@ -81,7 +84,7 @@ public class GameLocator : IGameLocator
try
{
FindStoreGames(_origin, _originGames, game => game.InstallPath);
FindStoreGames(_origin, _originGames, game => (AbsolutePath)game.InstallPath.GetFullPath());
}
catch (Exception e)
{
@ -92,8 +95,9 @@ public class GameLocator : IGameLocator
private void FindStoreGames<TGame, TId>(
AHandler<TGame, TId>? handler,
Dictionary<TId, AbsolutePath> paths,
Func<TGame, string> getPath)
where TGame : class
Func<TGame, AbsolutePath> getPath)
where TGame : class, IGame
where TId : notnull
{
if (handler is null) return;
@ -103,7 +107,7 @@ public class GameLocator : IGameLocator
{
try
{
var path = getPath(game).ToAbsolutePath();
var path = getPath(game);
if (!path.DirectoryExists())
{
_logger.LogError("Game does not exist: {Game}", game);
@ -160,28 +164,28 @@ public class GameLocator : IGameLocator
foreach (var id in metaData.SteamIDs)
{
if (!_steamGames.TryGetValue(id, out var found)) continue;
if (!_steamGames.TryGetValue(AppId.From((uint)id), out var found)) continue;
path = found;
return true;
}
foreach (var id in metaData.GOGIDs)
{
if (!_gogGames.TryGetValue(id, out var found)) continue;
if (!_gogGames.TryGetValue(GOGGameId.From(id), out var found)) continue;
path = found;
return true;
}
foreach (var id in metaData.EpicGameStoreIDs)
{
if (!_egsGames.TryGetValue(id, out var found)) continue;
if (!_egsGames.TryGetValue(EGSGameId.From(id), out var found)) continue;
path = found;
return true;
}
foreach (var id in metaData.OriginIDs)
{
if (!_originGames.TryGetValue(id, out var found)) continue;
if (!_originGames.TryGetValue(OriginGameId.From(id), out var found)) continue;
path = found;
return true;
}

View File

@ -18,10 +18,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="GameFinder.StoreHandlers.EGS" Version="2.2.2" />
<PackageReference Include="GameFinder.StoreHandlers.GOG" Version="2.2.2" />
<PackageReference Include="GameFinder.StoreHandlers.Origin" Version="2.2.2" />
<PackageReference Include="GameFinder.StoreHandlers.Steam" Version="2.2.2" />
<PackageReference Include="GameFinder.StoreHandlers.EGS" Version="4.0.0" />
<PackageReference Include="GameFinder.StoreHandlers.GOG" Version="4.0.0" />
<PackageReference Include="GameFinder.StoreHandlers.Origin" Version="4.0.0" />
<PackageReference Include="GameFinder.StoreHandlers.Steam" Version="4.0.0" />
</ItemGroup>
</Project>

View File

@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
</ItemGroup>

View File

@ -11,7 +11,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageReference Include="xunit" Version="2.4.2" />

View File

@ -11,7 +11,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

View File

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
</ItemGroup>

View File

@ -12,7 +12,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Xunit.DependencyInjection" Version="8.6.1" />

View File

@ -17,7 +17,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -11,7 +11,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.116" />
<PackageReference Include="Xunit.DependencyInjection" Version="8.6.1" />