Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Nuget Package to get Xbox game pass to Wabbajack.Downloaders.Ga… #2527

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### Changelog

#### Version - 3.5.0.2 - 4/18/2024
* Added Xbox Game Pass lookup for Wabbajack.Downloaders.GameFile solution
* Added in Fallout 4 lookup for Xbox Game Pass
* *TODO* Add in other games from game pass that are supported

#### Version - 3.5.0.1 - 1/15/2024
* *HOTFIX* - change the cache file names so files will be auto-rehashed

Expand Down
2 changes: 2 additions & 0 deletions Wabbajack.DTOs/Game/GameMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class GameMetaData

public string[] EpicGameStoreIDs { get; internal init; } = Array.Empty<string>();

public string[] XboxGamePassGameStoreIds { get; set; } = Array.Empty<string>();

// to get BethNet IDs: check the registry
public int BethNetID { get; internal init; }

Expand Down
1 change: 1 addition & 0 deletions Wabbajack.DTOs/Game/GameRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static class GameRegistry
MO2ArchiveName = "fallout4",
SteamIDs = new[] {377160},
GOGIDs = new long[]{1998527297},
XboxGamePassGameStoreIds = new [] {"BethesdaSoftworks.Fallout4-PC"},
RequiredFiles = new[]
{
"Fallout4.exe".ToRelativePath()
Expand Down
20 changes: 20 additions & 0 deletions Wabbajack.Downloaders.GameFile/GameLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using GameFinder.StoreHandlers.Steam;
using GameFinder.StoreHandlers.Steam.Models;
using GameFinder.StoreHandlers.Steam.Models.ValueTypes;
using GameFinder.StoreHandlers.Xbox;
using Microsoft.Extensions.Logging;
using Wabbajack.DTOs;
using Wabbajack.Paths;
Expand All @@ -23,12 +24,15 @@ public class GameLocator : IGameLocator
private readonly EGSHandler? _egs;
private readonly OriginHandler? _origin;
private readonly EADesktopHandler? _eaDesktop;
private readonly XboxHandler? _xboxGP;

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<EADesktopGameId, AbsolutePath> _eaDesktopGames = new();
private readonly Dictionary<XboxGameId, AbsolutePath> _xboxGamePassGames = new();


private readonly Dictionary<Game, AbsolutePath> _locationCache;
private readonly ILogger<GameLocator> _logger;
Expand All @@ -47,6 +51,7 @@ public GameLocator(ILogger<GameLocator> logger)
_egs = new EGSHandler(windowsRegistry, fileSystem);
_origin = new OriginHandler(fileSystem);
_eaDesktop = new EADesktopHandler(fileSystem, new HardwareInfoProvider());
_xboxGP = new XboxHandler(fileSystem);
}
else
{
Expand Down Expand Up @@ -103,6 +108,14 @@ private void FindAllGames()
{
_logger.LogError(e, "While finding games installed with EADesktop");
}
try
{
FindStoreGames(_xboxGP, _xboxGamePassGames, game => (AbsolutePath)game.Path.GetFullPath());
}
catch (Exception e)
{
_logger.LogError(e, "While finding games installed with XBox Game Pass");
}
}

private void FindStoreGames<TGame, TId>(
Expand Down Expand Up @@ -210,6 +223,13 @@ private bool TryFindLocationInner(Game game, out AbsolutePath path)
return true;
}

foreach (var id in metaData.XboxGamePassGameStoreIds)
{
if (!_xboxGamePassGames.TryGetValue(XboxGameId.From(id), out var found)) continue;
path = found;
return true;
}

path = default;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<PackageReference Include="GameFinder.StoreHandlers.GOG" Version="4.1.0" />
<PackageReference Include="GameFinder.StoreHandlers.Origin" Version="4.1.0" />
<PackageReference Include="GameFinder.StoreHandlers.Steam" Version="4.1.0" />
<PackageReference Include="GameFinder.StoreHandlers.Xbox" Version="4.2.0" />
</ItemGroup>

</Project>
Loading