From bb462fbf9babae29375e29ec6833d8b595b3ab27 Mon Sep 17 00:00:00 2001 From: erri120 Date: Tue, 10 Dec 2024 15:09:03 +0100 Subject: [PATCH] Add BuildId to GOG and Heroic (GOG) --- CHANGELOG.md | 6 +++++- src/GameFinder.Launcher.Heroic/HeroicGOGGame.cs | 3 ++- src/GameFinder.Launcher.Heroic/HeroicGOGHandler.cs | 2 +- src/GameFinder.StoreHandlers.GOG/GOGGame.cs | 5 +---- src/GameFinder.StoreHandlers.GOG/GOGHandler.cs | 8 +++++++- .../GameFinder.StoreHandlers.GOG.Tests/ArrangeHelpers.cs | 5 +++-- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be35c238..ab4ba47a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased](https://github.com/erri120/GameFinder/compare/v4.2.4...HEAD) +## [Unreleased](https://github.com/erri120/GameFinder/compare/v4.4.0...HEAD) ## [Released](https://github.com/erri120/GameFinder/releases) +## [4.4.0](https://github.com/erri120/GameFinder/compare/v4.3.4...v4.4.0) - 2024-12-10 + +- GOG & Heroic (GOG): Add `BuildId` + ## [4.3.3](https://github.com/erri120/GameFinder/compare/v4.3.2...v4.3.3) - 2024-10-31 - Wine: `users` instead of `Users` diff --git a/src/GameFinder.Launcher.Heroic/HeroicGOGGame.cs b/src/GameFinder.Launcher.Heroic/HeroicGOGGame.cs index 5d356dc8..e1a7fa00 100644 --- a/src/GameFinder.Launcher.Heroic/HeroicGOGGame.cs +++ b/src/GameFinder.Launcher.Heroic/HeroicGOGGame.cs @@ -8,8 +8,9 @@ public record HeroicGOGGame( GOGGameId Id, string Name, AbsolutePath Path, + string BuildId, AbsolutePath WinePrefixPath, - DTOs.WineVersion WineVersion) : GOGGame(Id, Name, Path) + DTOs.WineVersion WineVersion) : GOGGame(Id, Name, Path, BuildId) { public WinePrefix GetWinePrefix() { diff --git a/src/GameFinder.Launcher.Heroic/HeroicGOGHandler.cs b/src/GameFinder.Launcher.Heroic/HeroicGOGHandler.cs index 154c0b7b..4a5c493c 100644 --- a/src/GameFinder.Launcher.Heroic/HeroicGOGHandler.cs +++ b/src/GameFinder.Launcher.Heroic/HeroicGOGHandler.cs @@ -119,7 +119,7 @@ internal static OneOf Parse( var path = fileSystem.FromUnsanitizedFullPath(installed.InstallPath); var winePrefixPath = fileSystem.FromUnsanitizedFullPath(gameConfig.WinePrefix); - return new HeroicGOGGame(GOGGameId.From(id), installed.AppName, path, winePrefixPath, gameConfig.WineVersion); + return new HeroicGOGGame(GOGGameId.From(id), installed.AppName, path, installed.BuildId, winePrefixPath, gameConfig.WineVersion); } internal static AbsolutePath GetGamesConfigJsonFile(AbsolutePath configPath, string name) diff --git a/src/GameFinder.StoreHandlers.GOG/GOGGame.cs b/src/GameFinder.StoreHandlers.GOG/GOGGame.cs index c9718ec1..6387472a 100644 --- a/src/GameFinder.StoreHandlers.GOG/GOGGame.cs +++ b/src/GameFinder.StoreHandlers.GOG/GOGGame.cs @@ -7,8 +7,5 @@ namespace GameFinder.StoreHandlers.GOG; /// /// Represents a game installed with GOG Galaxy. /// -/// -/// -/// [PublicAPI] -public record GOGGame(GOGGameId Id, string Name, AbsolutePath Path) : IGame; +public record GOGGame(GOGGameId Id, string Name, AbsolutePath Path, string BuildId) : IGame; diff --git a/src/GameFinder.StoreHandlers.GOG/GOGHandler.cs b/src/GameFinder.StoreHandlers.GOG/GOGHandler.cs index e2275cdf..9d3fe4f8 100644 --- a/src/GameFinder.StoreHandlers.GOG/GOGHandler.cs +++ b/src/GameFinder.StoreHandlers.GOG/GOGHandler.cs @@ -117,10 +117,16 @@ private OneOf ParseSubKey(IRegistryKey gogKey, string sub return new ErrorMessage($"{subKey.GetName()} doesn't have a string value \"path\""); } + if (!subKey.TryGetString("buildId", out var buildId)) + { + return new ErrorMessage($"{subKey.GetName()} doesn't have a string value \"buildId\""); + } + var game = new GOGGame( GOGGameId.From(id), name, - _fileSystem.FromUnsanitizedFullPath(path) + _fileSystem.FromUnsanitizedFullPath(path), + buildId ); return game; diff --git a/tests/GameFinder.StoreHandlers.GOG.Tests/ArrangeHelpers.cs b/tests/GameFinder.StoreHandlers.GOG.Tests/ArrangeHelpers.cs index b7553b9f..242dc839 100644 --- a/tests/GameFinder.StoreHandlers.GOG.Tests/ArrangeHelpers.cs +++ b/tests/GameFinder.StoreHandlers.GOG.Tests/ArrangeHelpers.cs @@ -18,7 +18,7 @@ public static IEnumerable SetupGames(IFileSystem fileSystem, InMemoryRe var fixture = new Fixture(); fixture.Customize(composer => composer - .FromFactory((id, name) => + .FromFactory((id, name, buildId) => { var path = fileSystem .GetKnownPath(KnownPath.TempDirectory) @@ -28,8 +28,9 @@ public static IEnumerable SetupGames(IFileSystem fileSystem, InMemoryRe gameKey.AddValue("gameID", id.ToString(CultureInfo.InvariantCulture)); gameKey.AddValue("gameName", name); gameKey.AddValue("path", path.GetFullPath()); + gameKey.AddValue("buildId", buildId); - return new GOGGame(GOGGameId.From(id), name, path); + return new GOGGame(GOGGameId.From(id), name, path, buildId); }) .OmitAutoProperties());