From d9fde432857846959cb6001595432bd4f92a2144 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Thu, 6 Jan 2022 23:50:32 +0100 Subject: [PATCH] 2.3.0 (#419) * Use public nuget for game libraries * net40 -> net48 * Add support for Windows Store build (#417) * Better game vendor detection (#421) --- nuget.config | 7 ---- .../OWML.Abstractions.csproj | 2 +- src/OWML.Common/OWML.Common.csproj | 6 +-- src/OWML.Common/OwmlConfig.cs | 14 ++++--- src/OWML.GameFinder/BaseFinder.cs | 15 +++++-- src/OWML.GameFinder/PathFinder.cs | 1 + src/OWML.GameFinder/UWPGameFinder.cs | 42 +++++++++++++++++++ src/OWML.Launcher/App.cs | 33 +++++++++++---- src/OWML.Launcher/OWML.Launcher.csproj | 2 +- src/OWML.Launcher/OWML.Manifest.json | 4 +- src/OWML.Logging/OWML.Logging.csproj | 2 +- .../OWML.ModHelper.Assets.csproj | 2 +- .../OWML.ModHelper.Events.csproj | 2 +- .../OWML.ModHelper.Input.csproj | 2 +- .../OWML.ModHelper.Interaction.csproj | 2 +- .../OWML.ModHelper.Menus.csproj | 2 +- src/OWML.ModHelper/OWML.ModHelper.csproj | 2 +- src/OWML.ModHelper/OWML.ModHelper.nuspec | 20 ++++----- src/OWML.ModLoader/OWML.ModLoader.csproj | 2 +- src/OWML.Patcher/OWPatcher.cs | 4 +- src/OWML.Utils/OWML.Utils.csproj | 2 +- .../OWML.EnableDebugMode.csproj | 2 +- .../OWML.EnableDebugMode/manifest.json | 2 +- .../OWML.ExampleAPI/OWML.ExampleAPI.csproj | 2 +- src/SampleMods/OWML.ExampleAPI/manifest.json | 2 +- .../OWML.LoadCustomAssets.csproj | 2 +- .../OWML.LoadCustomAssets/manifest.json | 6 ++- tests/OWML.Launcher.Tests/ReleaseTests.cs | 2 +- 28 files changed, 126 insertions(+), 60 deletions(-) create mode 100644 src/OWML.GameFinder/UWPGameFinder.cs diff --git a/nuget.config b/nuget.config index d1c824b5..94b85f6c 100644 --- a/nuget.config +++ b/nuget.config @@ -3,12 +3,5 @@ - - - - - - - diff --git a/src/OWML.Abstractions/OWML.Abstractions.csproj b/src/OWML.Abstractions/OWML.Abstractions.csproj index 42b7b236..82685daf 100644 --- a/src/OWML.Abstractions/OWML.Abstractions.csproj +++ b/src/OWML.Abstractions/OWML.Abstractions.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.Common/OWML.Common.csproj b/src/OWML.Common/OWML.Common.csproj index 3dcc23a5..9af68acf 100644 --- a/src/OWML.Common/OWML.Common.csproj +++ b/src/OWML.Common/OWML.Common.csproj @@ -1,14 +1,12 @@  - net40 + net48 9.0 - - runtime - + diff --git a/src/OWML.Common/OwmlConfig.cs b/src/OWML.Common/OwmlConfig.cs index ffe988e1..09e1ff39 100644 --- a/src/OWML.Common/OwmlConfig.cs +++ b/src/OWML.Common/OwmlConfig.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.IO; +using Newtonsoft.Json; namespace OWML.Common { @@ -14,16 +15,19 @@ public class OwmlConfig : IOwmlConfig public bool ForceExe { get; set; } [JsonIgnore] - public string DataPath => $"{GamePath}/OuterWilds_Data"; + public bool IsSpaced => Directory.Exists(Path.Combine(GamePath, "Outer Wilds_Data")); [JsonIgnore] - public string ExePath => $"{GamePath}/OuterWilds.exe"; + public string DataPath => Path.Combine(GamePath, IsSpaced ? "Outer Wilds_Data" : "OuterWilds_Data"); [JsonIgnore] - public string ManagedPath => $"{DataPath}/Managed"; + public string ExePath => Path.Combine(GamePath, IsSpaced ? "Outer Wilds.exe" : "OuterWilds.exe"); [JsonIgnore] - public string PluginsPath => $"{DataPath}/Plugins"; + public string ManagedPath => Path.Combine(DataPath, "Managed"); + + [JsonIgnore] + public string PluginsPath => Path.Combine(DataPath, "Plugins"); [JsonProperty("owmlPath")] public string OWMLPath { get; set; } diff --git a/src/OWML.GameFinder/BaseFinder.cs b/src/OWML.GameFinder/BaseFinder.cs index 19f6632e..5007dd05 100644 --- a/src/OWML.GameFinder/BaseFinder.cs +++ b/src/OWML.GameFinder/BaseFinder.cs @@ -5,8 +5,10 @@ namespace OWML.GameFinder { public abstract class BaseFinder { - private const string ManagedPath = "OuterWilds_Data/Managed"; + private readonly string ManagedPath = Path.Combine("OuterWilds_Data", "Managed"); private const string ExePath = "OuterWilds.exe"; + private readonly string SpacedManagedPath = Path.Combine("Outer Wilds_Data", "Managed"); + private const string SpacedExePath = "Outer Wilds.exe"; protected IOwmlConfig Config; protected IModConsole Writer; @@ -22,7 +24,14 @@ protected BaseFinder(IOwmlConfig config, IModConsole writer) protected bool IsValidGamePath(string gamePath) => !string.IsNullOrEmpty(gamePath) && Directory.Exists(gamePath) && - Directory.Exists($"{gamePath}/{ManagedPath}") && - File.Exists($"{gamePath}/{ExePath}"); + (HasGameFiles(gamePath) || HasSpacedGameFiles(gamePath)); + + private bool HasGameFiles(string gamePath) => + Directory.Exists(Path.Combine(gamePath, ManagedPath)) && + File.Exists(Path.Combine(gamePath, ExePath)); + + private bool HasSpacedGameFiles(string gamePath) => + Directory.Exists(Path.Combine(gamePath, SpacedManagedPath)) && + File.Exists(Path.Combine(gamePath, SpacedExePath)); } } \ No newline at end of file diff --git a/src/OWML.GameFinder/PathFinder.cs b/src/OWML.GameFinder/PathFinder.cs index 9789a13c..124faa71 100644 --- a/src/OWML.GameFinder/PathFinder.cs +++ b/src/OWML.GameFinder/PathFinder.cs @@ -18,6 +18,7 @@ public string FindGamePath() => FindPathWith() ?? FindPathWith() ?? FindPathWith() ?? + FindPathWith() ?? FindPathWith() ?? FindPathWith(); diff --git a/src/OWML.GameFinder/UWPGameFinder.cs b/src/OWML.GameFinder/UWPGameFinder.cs new file mode 100644 index 00000000..fa107b24 --- /dev/null +++ b/src/OWML.GameFinder/UWPGameFinder.cs @@ -0,0 +1,42 @@ +using System; +using Microsoft.Win32; +using OWML.Common; + +namespace OWML.GameFinder +{ + public class UWPGameFinder : BaseFinder + { + private const string RegistryPath = @"Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages"; + + public UWPGameFinder(IOwmlConfig config, IModConsole writer) + : base(config, writer) + { + } + + public override string FindGamePath() + { + var appPackages = Registry.CurrentUser.OpenSubKey(RegistryPath); + + var gamePath = ""; + foreach(var appPackageName in appPackages?.GetSubKeyNames()) + { + var appPackageKey = appPackages.OpenSubKey(appPackageName); + var packageDisplayName = (string)appPackageKey.GetValue("DisplayName"); + + if(!String.IsNullOrEmpty(packageDisplayName) && packageDisplayName.Contains("Outer Wilds")) + { + gamePath = (string)appPackageKey.GetValue("PackageRootFolder"); + break; + } + } + + if (IsValidGamePath(gamePath)) + { + return gamePath; + } + + Writer.WriteLine("Game not found in UWP."); + return null; + } + } +} diff --git a/src/OWML.Launcher/App.cs b/src/OWML.Launcher/App.cs index 522e31a0..eb1b207d 100644 --- a/src/OWML.Launcher/App.cs +++ b/src/OWML.Launcher/App.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; using OWML.Common; using OWML.Utils; @@ -167,10 +168,7 @@ private void StartGame() try { void StartGameViaExe() - { - _writer.WriteLine("Starting game via exe..."); - _processHelper.Start(_owmlConfig.ExePath, _argumentHelper.Arguments); - } + => _processHelper.Start(_owmlConfig.ExePath, _argumentHelper.Arguments); if (_owmlConfig.ForceExe) { @@ -178,18 +176,37 @@ void StartGameViaExe() return; } - if (_owmlConfig.GamePath.ToLower().Contains("epic")) + var gameDll = $"{_owmlConfig.ManagedPath}/Assembly-CSharp.dll"; + var assembly = Assembly.LoadFrom(gameDll); + var types = assembly.GetTypes(); + var isEpic = types.Any(x => x.Name == "EpicEntitlementRetriever"); + var isSteam = types.Any(x => x.Name == "SteamEntitlementRetriever"); + var isUWP = types.Any(x => x.Name == "MSStoreEntitlementRetriever"); + + if (isEpic && !isSteam && !isUWP) { - _writer.WriteLine("Starting game via Epic Launcher..."); + _writer.WriteLine("Identified as an Epic install. Launching..."); _processHelper.Start("\"com.epicgames.launcher://apps/starfish%3A601d0668cef146bd8eef75d43c6bbb0b%3AStarfish?action=launch&silent=true\""); } - else if (_owmlConfig.GamePath.ToLower().Contains("steam")) + else if (!isEpic && isSteam && !isUWP) { - _writer.WriteLine("Starting game via Steam..."); + _writer.WriteLine("Identified as a Steam install. Launching..."); _processHelper.Start("steam://rungameid/753640"); } + else if (!isEpic && !isSteam && isUWP) + { + _writer.WriteLine("Identified as an Xbox Game Pass install. Launching..."); + StartGameViaExe(); + } else { + // This should be impossible to get to?! + _writer.WriteLine("This game isn't from Epic, Steam, or the MSStore...? Wha?\r\n" + + "Either this game is really specifically corrupted, or you're running Outer Wilds from a new exciting vendor.\r\n" + + "In any case, this has a 0% chance of appearing in normal use (right now), so I can make this message as long as I want.\r\n" + + "Suck it, command window! You bend to my will now!\r\n" + + "Though, if you *are* using Steam, Epic, or Game Pass, and you're seeing this... please let us know! Because you aren't meant to see this. :P\r\n" + + "Anyway, back to scheduled programming. Launching..."); StartGameViaExe(); } } diff --git a/src/OWML.Launcher/OWML.Launcher.csproj b/src/OWML.Launcher/OWML.Launcher.csproj index 6201514a..9797565f 100644 --- a/src/OWML.Launcher/OWML.Launcher.csproj +++ b/src/OWML.Launcher/OWML.Launcher.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/OWML.Launcher/OWML.Manifest.json b/src/OWML.Launcher/OWML.Manifest.json index 59d20292..688d4b11 100644 --- a/src/OWML.Launcher/OWML.Manifest.json +++ b/src/OWML.Launcher/OWML.Manifest.json @@ -2,7 +2,7 @@ "author": "Alek", "name": "OWML", "uniqueName": "Alek.OWML", - "version": "2.2.0", + "version": "2.3.0", "minGameVersion": "1.1.10.47", - "maxGameVersion": "1.1.11.72" + "maxGameVersion": "1.1.12.125" } diff --git a/src/OWML.Logging/OWML.Logging.csproj b/src/OWML.Logging/OWML.Logging.csproj index 3da1a61a..17c97740 100644 --- a/src/OWML.Logging/OWML.Logging.csproj +++ b/src/OWML.Logging/OWML.Logging.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.ModHelper.Assets/OWML.ModHelper.Assets.csproj b/src/OWML.ModHelper.Assets/OWML.ModHelper.Assets.csproj index ea850e48..5f423652 100644 --- a/src/OWML.ModHelper.Assets/OWML.ModHelper.Assets.csproj +++ b/src/OWML.ModHelper.Assets/OWML.ModHelper.Assets.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.ModHelper.Events/OWML.ModHelper.Events.csproj b/src/OWML.ModHelper.Events/OWML.ModHelper.Events.csproj index 0c45883d..87bb362e 100644 --- a/src/OWML.ModHelper.Events/OWML.ModHelper.Events.csproj +++ b/src/OWML.ModHelper.Events/OWML.ModHelper.Events.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.ModHelper.Input/OWML.ModHelper.Input.csproj b/src/OWML.ModHelper.Input/OWML.ModHelper.Input.csproj index a4344303..8a7df868 100644 --- a/src/OWML.ModHelper.Input/OWML.ModHelper.Input.csproj +++ b/src/OWML.ModHelper.Input/OWML.ModHelper.Input.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.ModHelper.Interaction/OWML.ModHelper.Interaction.csproj b/src/OWML.ModHelper.Interaction/OWML.ModHelper.Interaction.csproj index 0581af14..20ff97ff 100644 --- a/src/OWML.ModHelper.Interaction/OWML.ModHelper.Interaction.csproj +++ b/src/OWML.ModHelper.Interaction/OWML.ModHelper.Interaction.csproj @@ -1,7 +1,7 @@ - net40 + net48 9.0 diff --git a/src/OWML.ModHelper.Menus/OWML.ModHelper.Menus.csproj b/src/OWML.ModHelper.Menus/OWML.ModHelper.Menus.csproj index 5637d3bf..a00199a0 100644 --- a/src/OWML.ModHelper.Menus/OWML.ModHelper.Menus.csproj +++ b/src/OWML.ModHelper.Menus/OWML.ModHelper.Menus.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.ModHelper/OWML.ModHelper.csproj b/src/OWML.ModHelper/OWML.ModHelper.csproj index 8013dc11..a2a49474 100644 --- a/src/OWML.ModHelper/OWML.ModHelper.csproj +++ b/src/OWML.ModHelper/OWML.ModHelper.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 1.1.0 diff --git a/src/OWML.ModHelper/OWML.ModHelper.nuspec b/src/OWML.ModHelper/OWML.ModHelper.nuspec index f2cdb13f..299fe2ab 100644 --- a/src/OWML.ModHelper/OWML.ModHelper.nuspec +++ b/src/OWML.ModHelper/OWML.ModHelper.nuspec @@ -21,14 +21,14 @@ - - - - - - - - - + + + + + + + + + - \ No newline at end of file + diff --git a/src/OWML.ModLoader/OWML.ModLoader.csproj b/src/OWML.ModLoader/OWML.ModLoader.csproj index 80e8b50b..0296e6ed 100644 --- a/src/OWML.ModLoader/OWML.ModLoader.csproj +++ b/src/OWML.ModLoader/OWML.ModLoader.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/OWML.Patcher/OWPatcher.cs b/src/OWML.Patcher/OWPatcher.cs index 7c22a6b7..076f2ff5 100644 --- a/src/OWML.Patcher/OWPatcher.cs +++ b/src/OWML.Patcher/OWPatcher.cs @@ -81,7 +81,7 @@ private void CopyFiles(string[] filesToCopy, string pathPrefix, string destinati { try { - File.Copy($"{pathPrefix}{filename}", $"{destination}/{filename}", true); + File.Copy($"{pathPrefix}{filename}", Path.Combine(destination, filename), true); } catch { @@ -100,7 +100,7 @@ private void PatchAssembly() { _writer.WriteLine("Patching OW assembly..."); - var patcher = new dnpatch.Patcher($"{_owmlConfig.ManagedPath}/Assembly-CSharp.dll"); + var patcher = new dnpatch.Patcher(Path.Combine(_owmlConfig.ManagedPath, "Assembly-CSharp.dll")); var target = new Target { diff --git a/src/OWML.Utils/OWML.Utils.csproj b/src/OWML.Utils/OWML.Utils.csproj index 2895e38f..69119d3a 100644 --- a/src/OWML.Utils/OWML.Utils.csproj +++ b/src/OWML.Utils/OWML.Utils.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/SampleMods/OWML.EnableDebugMode/OWML.EnableDebugMode.csproj b/src/SampleMods/OWML.EnableDebugMode/OWML.EnableDebugMode.csproj index cf4bc9ec..8c0f89d2 100644 --- a/src/SampleMods/OWML.EnableDebugMode/OWML.EnableDebugMode.csproj +++ b/src/SampleMods/OWML.EnableDebugMode/OWML.EnableDebugMode.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/SampleMods/OWML.EnableDebugMode/manifest.json b/src/SampleMods/OWML.EnableDebugMode/manifest.json index 1633f7a8..57378d37 100644 --- a/src/SampleMods/OWML.EnableDebugMode/manifest.json +++ b/src/SampleMods/OWML.EnableDebugMode/manifest.json @@ -4,6 +4,6 @@ "name": "EnableDebugMode", "uniqueName": "Alek.EnableDebugMode", "version": "0.3", - "owmlVersion": "2.2.0", + "owmlVersion": "2.3.0", "description": "Enables the debug mode in Outer Wilds" } diff --git a/src/SampleMods/OWML.ExampleAPI/OWML.ExampleAPI.csproj b/src/SampleMods/OWML.ExampleAPI/OWML.ExampleAPI.csproj index 95011679..a86342f3 100644 --- a/src/SampleMods/OWML.ExampleAPI/OWML.ExampleAPI.csproj +++ b/src/SampleMods/OWML.ExampleAPI/OWML.ExampleAPI.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/SampleMods/OWML.ExampleAPI/manifest.json b/src/SampleMods/OWML.ExampleAPI/manifest.json index b55f1bc6..4097e517 100644 --- a/src/SampleMods/OWML.ExampleAPI/manifest.json +++ b/src/SampleMods/OWML.ExampleAPI/manifest.json @@ -4,6 +4,6 @@ "name": "ExampleAPI", "uniqueName": "_nebula.ExampleAPI", "version": "0.3", - "owmlVersion": "2.2.0", + "owmlVersion": "2.3.0", "description": "Example API for testing OWML.Interaction" } diff --git a/src/SampleMods/OWML.LoadCustomAssets/OWML.LoadCustomAssets.csproj b/src/SampleMods/OWML.LoadCustomAssets/OWML.LoadCustomAssets.csproj index 40cc5edc..77b5f781 100644 --- a/src/SampleMods/OWML.LoadCustomAssets/OWML.LoadCustomAssets.csproj +++ b/src/SampleMods/OWML.LoadCustomAssets/OWML.LoadCustomAssets.csproj @@ -1,7 +1,7 @@  - net40 + net48 9.0 diff --git a/src/SampleMods/OWML.LoadCustomAssets/manifest.json b/src/SampleMods/OWML.LoadCustomAssets/manifest.json index f9808dfa..71c362f0 100644 --- a/src/SampleMods/OWML.LoadCustomAssets/manifest.json +++ b/src/SampleMods/OWML.LoadCustomAssets/manifest.json @@ -4,7 +4,9 @@ "name": "LoadCustomAssets", "uniqueName": "Alek.LoadCustomAssets", "version": "0.7", - "owmlVersion": "2.2.0", + "owmlVersion": "2.3.0", "description": "A mod for testing loading of custom assets", - "dependencies": [ "_nebula.ExampleAPI" ] + "dependencies": [ + "_nebula.ExampleAPI" + ] } diff --git a/tests/OWML.Launcher.Tests/ReleaseTests.cs b/tests/OWML.Launcher.Tests/ReleaseTests.cs index ac24cc36..1078cb43 100644 --- a/tests/OWML.Launcher.Tests/ReleaseTests.cs +++ b/tests/OWML.Launcher.Tests/ReleaseTests.cs @@ -94,7 +94,7 @@ public void ReleaseDoesNotContainGameFiles() private void CopyMod(string modName) { - var fromModPath = $"{OwmlSolutionPath}/src/SampleMods/{modName}/bin/Debug/net40"; + var fromModPath = $"{OwmlSolutionPath}/src/SampleMods/{modName}/bin/Debug/net48"; var toModPath = $"{OwmlReleasePath}/Mods/{modName}"; Directory.CreateDirectory(toModPath); var modFiles = Directory.GetFiles(fromModPath);