MW5 Support

This commit is contained in:
Timothy Baldridge 2020-12-01 15:58:07 -07:00
parent 164a8a4f4f
commit 021cb61563
9 changed files with 140 additions and 14 deletions

View File

@ -21,7 +21,7 @@
<ItemGroup>
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.2.6" />
<PackageReference Include="SharpZipLib" Version="1.3.0" />
<PackageReference Include="SharpZipLib" Version="1.3.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Wabbajack.Common.StoreHandlers;
@ -38,7 +39,8 @@ namespace Wabbajack.Common
Witcher3,
[Description("Stardew Valley")]
StardewValley,
KingdomComeDeliverance
KingdomComeDeliverance,
MechWarrior5Mercenaries
}
public static class GameExtensions
@ -68,6 +70,8 @@ namespace Wabbajack.Common
// to get gog ids: https://www.gogdb.org
public List<int>? GOGIDs { get; internal set; }
public List<string> EpicGameStoreIDs { get; internal set; } = new List<string>();
// to get BethNet IDs: check the registry
public int BethNetID { get; internal set; }
//for BethNet games only!
@ -99,7 +103,16 @@ namespace Wabbajack.Common
if (MainExecutable == null)
throw new NotImplementedException();
return FileVersionInfo.GetVersionInfo((string)gameLoc.Combine(MainExecutable)).ProductVersion;
var info = FileVersionInfo.GetVersionInfo((string)gameLoc.Combine(MainExecutable));
var version = info.ProductVersion;
if (string.IsNullOrWhiteSpace(version))
{
version =
$"{info.ProductMajorPart}.{info.ProductMinorPart}.{info.ProductBuildPart}.{info.ProductPrivatePart}";
return version;
}
return version;
}
}
@ -508,6 +521,23 @@ namespace Wabbajack.Common
},
MainExecutable = @"bin\Win64\KingdomCome.exe"
}
},
{
Game.MechWarrior5Mercenaries, new GameMetaData
{
Game = Game.MechWarrior5Mercenaries,
NexusName = "mechwarrior5mercenaries",
MO2Name = "Mechwarrior 5: Mercenaries",
MO2ArchiveName = "mechwarrior5mercenaries",
NexusGameId = 3099,
EpicGameStoreIDs = new List<string> {"9fd39d8ac72946a2a10a887ce86e6c35"},
IsGenericMO2Plugin = true,
RequiredFiles = new List<string>
{
@"MW5Mercs\Binaries\Win64\MechWarrior-Win64-Shipping.exe"
},
MainExecutable = @"MW5Mercs\Binaries\Win64\MechWarrior-Win64-Shipping.exe"
}
}
};

View File

@ -0,0 +1,80 @@
using System;
using System.Linq;
using Microsoft.Win32;
namespace Wabbajack.Common.StoreHandlers
{
public class EpicGameStoreHandler : AStoreHandler
{
public override StoreType Type { get; internal set; }
public string BaseRegKey = @"SOFTWARE\Epic Games\EOS";
public override bool Init()
{
return true;
}
public override bool LoadAllGames()
{
using var eosKey = Registry.CurrentUser.OpenSubKey(BaseRegKey);
if (eosKey == null)
{
Utils.Log("Epic Game Store is not installed");
return false;
}
var name = eosKey.GetValue("ModSdkMetadataDir");
if (name == null)
{
Utils.Log("Registry key entry does not exist for Epic Game store");
return false;
}
var byID = GameRegistry.Games.SelectMany(g => g.Value.EpicGameStoreIDs
.Select(id => (id, g.Value.Game)))
.GroupBy(t => t.id)
.ToDictionary(t => t.Key, t => t.First().Game);
foreach (var itm in ((AbsolutePath)(string)(name!)).EnumerateFiles(false, "*.item"))
{
var item = itm.FromJson<EpicGameItem>();
Console.WriteLine($"Found Epic Game Store Game: {item.DisplayName} at {item.InstallLocation}");
if (byID.TryGetValue(item.CatalogItemId, out var game))
{
Games.Add(new EpicStoreGame(game, item));
}
}
return true;
}
public class EpicStoreGame : AStoreGame
{
public EpicStoreGame(Game game, EpicGameItem item)
{
Type = StoreType.EpicGameStore;
Game = game;
Path = (AbsolutePath)item.InstallLocation;
Name = game.MetaData().HumanFriendlyGameName;
}
public override Game Game { get; internal set; }
public override StoreType Type { get; internal set; }
}
public class EpicGameItem
{
public string DisplayName { get; set; } = "";
public string InstallationGuid { get; set; } = "";
public string CatalogItemId { get; set; } = "";
public string CatalogNamespace { get; set; } = "";
public string InstallSessionId { get; set; } = "";
public string InstallLocation { get; set; } = "";
}
}
}

View File

@ -9,7 +9,8 @@ namespace Wabbajack.Common.StoreHandlers
{
STEAM,
GOG,
BethNet
BethNet,
EpicGameStore
}
public class StoreHandler
@ -26,6 +27,9 @@ namespace Wabbajack.Common.StoreHandlers
private static readonly Lazy<BethNetHandler> _bethNetHandler = new Lazy<BethNetHandler>(() => new BethNetHandler());
public BethNetHandler BethNetHandler = _bethNetHandler.Value;
private static readonly Lazy<EpicGameStoreHandler> _epicGameStoreHandler = new Lazy<EpicGameStoreHandler>(() => new EpicGameStoreHandler());
public EpicGameStoreHandler EpicGameStoreHandler = _epicGameStoreHandler.Value;
public List<AStoreGame> StoreGames;
public StoreHandler()
@ -67,6 +71,18 @@ namespace Wabbajack.Common.StoreHandlers
{
Utils.Error(new StoreException("Could not Init the BethNetHandler, check previous error messages!"));
}
if (EpicGameStoreHandler.Init())
{
if (EpicGameStoreHandler.LoadAllGames())
StoreGames.AddRange(EpicGameStoreHandler.Games);
else
Utils.Error(new StoreException("Could not load all Games from the EpicGameStoreHandler, check previous error messages!"));
}
else
{
Utils.Error(new StoreException("Could not Init the EpicGameStoreHandler, check previous error messages!"));
}
}
public AbsolutePath? TryGetGamePath(Game game)

View File

@ -56,13 +56,13 @@
<PackageReference Include="Octodiff" Version="1.2.1" />
<PackageReference Include="RocksDbNative" Version="6.2.2" />
<PackageReference Include="RocksDbSharp" Version="6.2.2" />
<PackageReference Include="SharpZipLib" Version="1.3.0" />
<PackageReference Include="SharpZipLib" Version="1.3.1" />
<PackageReference Include="System.Data.HashFunction.xxHash" Version="2.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="5.0.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="YamlDotNet" Version="8.1.2" />
<PackageReference Include="YamlDotNet" Version="9.1.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Serialization\PrimitiveHandlers.cs">

View File

@ -8,10 +8,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CefSharp.Common">
<Version>85.3.130</Version>
<Version>86.0.241</Version>
</PackageReference>
<PackageReference Include="CefSharp.OffScreen">
<Version>85.3.130</Version>
<Version>86.0.241</Version>
</PackageReference>
<PackageReference Include="F23.StringSimilarity">
<Version>3.1.0</Version>

View File

@ -28,8 +28,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CefSharp.Common" Version="85.3.130" />
<PackageReference Include="CefSharp.OffScreen" Version="85.3.130" />
<PackageReference Include="CefSharp.Common" Version="86.0.241" />
<PackageReference Include="CefSharp.OffScreen" Version="86.0.241" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />

View File

@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
<PackageReference Include="K4os.Hash.Crc" Version="1.1.4" />
<PackageReference Include="OMODFramework" Version="2.0.1" />
<PackageReference Include="OMODFramework" Version="2.1.0.2" />
<PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
</ItemGroup>

View File

@ -55,8 +55,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CefSharp.Wpf" Version="85.3.130" />
<PackageReference Include="DynamicData" Version="6.17.14" />
<PackageReference Include="CefSharp.Wpf" Version="86.0.241" />
<PackageReference Include="DynamicData" Version="7.1.1" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.0.1" />
<PackageReference Include="Fody" Version="6.3.0">
<PrivateAssets>all</PrivateAssets>
@ -67,7 +67,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MahApps.Metro" Version="2.3.4" />
<PackageReference Include="MahApps.Metro" Version="2.4.0" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="PInvoke.Gdi32" Version="0.7.78" />
<PackageReference Include="PInvoke.User32" Version="0.7.78" />