Skip to content

Commit

Permalink
Support GOG IDs in game install path lookup (#241)
Browse files Browse the repository at this point in the history
* storeFolder

* Update README.md

* Get GOG install paths

* Expand Configuration test to include GOGGameId

* Update README.md
  • Loading branch information
IhateTrains authored May 21, 2023
1 parent 69bfc60 commit e1c212a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Fronter.NET.Tests/Models/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ requiredFolder = {
displayName = IMPFOLDER
tooltip = IMPFOLDERTIP
mandatory = true
searchPathType = steamFolder
searchPathID = 859580
searchPathType = storeFolder
steamGameID = 859580
gogGameID = 2131232214
}
requiredFolder = {
name = ImperatorDocDirectory
Expand All @@ -32,7 +33,7 @@ requiredFolder = {
tooltip = CK3FOLDERTIP
mandatory = true
searchPathType = steamFolder
searchPathID = 1158310
steamGameID = 1158310
}
requiredFolder = {
name = targetGameModPath
Expand Down
1 change: 1 addition & 0 deletions Fronter.NET.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CK/@EntryIndexedValue">CK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GOG/@EntryIndexedValue">GOG</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autolocated/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autolocating/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autolocation/@EntryIndexedValue">True</s:Boolean>
Expand Down
11 changes: 7 additions & 4 deletions Fronter.NET/Models/Configuration/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions Fronter.NET/Models/Configuration/RequiredFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ 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();
}

// 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;
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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

Expand Down

0 comments on commit e1c212a

Please sign in to comment.