From e1c212a7a06a40a94c92fddccb5a3b7354bd1eba Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sun, 21 May 2023 15:42:15 +0200 Subject: [PATCH] Support GOG IDs in game install path lookup (#241) * storeFolder * Update README.md * Get GOG install paths * Expand Configuration test to include GOGGameId * Update README.md --- Fronter.NET.Tests/Models/ConfigurationTests.cs | 3 +++ .../TestFiles/Configuration/fronter-configuration.txt | 7 ++++--- Fronter.NET.sln.DotSettings | 1 + Fronter.NET/Models/Configuration/Configuration.cs | 11 +++++++---- Fronter.NET/Models/Configuration/RequiredFolder.cs | 6 ++++-- README.md | 7 ++++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Fronter.NET.Tests/Models/ConfigurationTests.cs b/Fronter.NET.Tests/Models/ConfigurationTests.cs index 165819bc..460419e7 100644 --- a/Fronter.NET.Tests/Models/ConfigurationTests.cs +++ b/Fronter.NET.Tests/Models/ConfigurationTests.cs @@ -26,6 +26,9 @@ public void RequiredFoldersAndFilesAreLoaded() { folder => { Assert.Equal("ImperatorDirectory", folder.Name); Assert.Equal("IMPFOLDER", folder.DisplayName); + Assert.Equal("storeFolder", folder.SearchPathType); + Assert.Equal("859580", folder.SteamGameId); + Assert.Equal("2131232214", folder.GOGGameId); }, folder => { Assert.Equal("ImperatorDocDirectory", folder.Name); diff --git a/Fronter.NET.Tests/TestFiles/Configuration/fronter-configuration.txt b/Fronter.NET.Tests/TestFiles/Configuration/fronter-configuration.txt index f87201d0..8ef64a0c 100644 --- a/Fronter.NET.Tests/TestFiles/Configuration/fronter-configuration.txt +++ b/Fronter.NET.Tests/TestFiles/Configuration/fronter-configuration.txt @@ -15,8 +15,9 @@ requiredFolder = { displayName = IMPFOLDER tooltip = IMPFOLDERTIP mandatory = true - searchPathType = steamFolder - searchPathID = 859580 + searchPathType = storeFolder + steamGameID = 859580 + gogGameID = 2131232214 } requiredFolder = { name = ImperatorDocDirectory @@ -32,7 +33,7 @@ requiredFolder = { tooltip = CK3FOLDERTIP mandatory = true searchPathType = steamFolder - searchPathID = 1158310 + steamGameID = 1158310 } requiredFolder = { name = targetGameModPath diff --git a/Fronter.NET.sln.DotSettings b/Fronter.NET.sln.DotSettings index adf11f2f..4f9723e9 100644 --- a/Fronter.NET.sln.DotSettings +++ b/Fronter.NET.sln.DotSettings @@ -1,5 +1,6 @@  CK + GOG True True True diff --git a/Fronter.NET/Models/Configuration/Configuration.cs b/Fronter.NET/Models/Configuration/Configuration.cs index 80d0e7ec..c3401f0e 100644 --- a/Fronter.NET/Models/Configuration/Configuration.cs +++ b/Fronter.NET/Models/Configuration/Configuration.cs @@ -182,12 +182,15 @@ public void InitializePaths() { if (folder.SearchPathType == "windowsUsersFolder") { initialValue = Path.Combine(documentsDir, folder.SearchPath); - } else if (folder.SearchPathType == "steamFolder") { - if (!int.TryParse(folder.SearchPathId, out int steamId)) { - continue; + } else if (folder.SearchPathType == "storeFolder") { + string? possiblePath = null; + if (int.TryParse(folder.SteamGameId, out int steamId)) { + possiblePath = CommonFunctions.GetSteamInstallPath(steamId); + } + if (possiblePath is null && long.TryParse(folder.GOGGameId, out long gogId)) { + possiblePath = CommonFunctions.GetGOGInstallPath(gogId); } - var possiblePath = CommonFunctions.GetSteamInstallPath(steamId); if (possiblePath is null) { continue; } diff --git a/Fronter.NET/Models/Configuration/RequiredFolder.cs b/Fronter.NET/Models/Configuration/RequiredFolder.cs index 471d659f..d5ca560a 100644 --- a/Fronter.NET/Models/Configuration/RequiredFolder.cs +++ b/Fronter.NET/Models/Configuration/RequiredFolder.cs @@ -23,7 +23,8 @@ private void RegisterKeys(Parser parser) { parser.RegisterKeyword("outputtable", reader => Outputtable = reader.GetString() == "true"); parser.RegisterKeyword("searchPathType", reader => SearchPathType = reader.GetString()); - parser.RegisterKeyword("searchPathID", reader => SearchPathId = reader.GetString()); + parser.RegisterKeyword("steamGameID", reader => SteamGameId = reader.GetString()); + parser.RegisterKeyword("gogGameID", reader => GOGGameId = reader.GetString()); parser.RegisterKeyword("searchPath", reader => SearchPath = reader.GetString()); parser.IgnoreAndLogUnregisteredItems(); } @@ -31,7 +32,8 @@ private void RegisterKeys(Parser parser) { // If we have folders listed, they are generally required. Override with false in conf file. public override bool Outputtable { get; protected set; } = true; - public string SearchPathId { get; private set; } = string.Empty; + public string? SteamGameId { get; private set; } + public string? GOGGameId { get; private set; } public override string Value { get => base.Value; diff --git a/README.md b/README.md index 785ac38e..877a5d16 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,9 @@ requiredFolder = { displayName = FOLDER1 tooltip = FOLDER1TIP mandatory = true - searchPathType = steamFolder - searchPathID = 203770 + searchPathType = storeFolder + steamGameID = 203770 + gogGameID = 2131232214 # GOG ID for Imperator: Rome, CK2 is not on GOG } requiredFolder = { @@ -62,7 +63,7 @@ autoGenerateModsFrom: searchPathType: - converterFolder - looks in the provided converterFolder in current directory -- steamFolder - uses searchPathID to look for an "installation path" from Windows/Steam registry. If there's a match it will also append searchPath at the end so you can use this for Vic2installdir/mods. +- storeFolder - uses steamGameID and gogGameID to look for an "installation path" from Steam/GOG registry. If there's a match it will also append searchPath at the end so you can use this for Vic2 installdir/mods. - windowsUsersFolder - looks in $USERHOMEDIR$\Documents folder - direct - copies over an absolute path from searchPath