mirror of
https://github.com/4sval/FModel.git
synced 2026-07-02 00:02:32 -05:00
Merge pull request #110 from iAmAsval/better-uwp
Proper UWP game support
This commit is contained in:
commit
3406fdc37c
|
|
@ -131,14 +131,15 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.6.3" />
|
||||
<PackageReference Include="AvalonEdit" Version="6.0.1" />
|
||||
<PackageReference Include="AvalonEdit" Version="6.1.0-preview1" />
|
||||
<PackageReference Include="CSCore" Version="1.2.1.2" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
|
||||
<PackageReference Include="DotNetZip" Version="1.13.8" />
|
||||
<PackageReference Include="EpicManifestParser" Version="1.2.0" />
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.0.1" />
|
||||
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.2.6" />
|
||||
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.2.8-beta" />
|
||||
<PackageReference Include="LZMA-SDK" Version="19.0.0" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NVorbis" Version="0.10.1" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="1.1.0" />
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using PakReader.Parsers.Objects;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using Windows.Management.Deployment;
|
||||
|
||||
namespace FModel.Utils
|
||||
{
|
||||
|
|
@ -46,30 +47,28 @@ namespace FModel.Utils
|
|||
}
|
||||
|
||||
// This method is in testing and is not recommended to be used other than for development purposes
|
||||
public static (string, string) GetUWPPakFilesPath(string game)
|
||||
public static string GetUWPPakFilesPath(string game)
|
||||
{
|
||||
var dir = "C:\\Program Files\\WindowsApps\\";
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(dir))
|
||||
foreach (var pkg in new PackageManager().FindPackagesForUser(string.Empty, game))
|
||||
{
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[WindowsApps]", "Folder as been found");
|
||||
foreach (var directory in Directory.GetDirectories(dir))
|
||||
if (directory.Equals(game))
|
||||
return (game, directory);
|
||||
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[WindowsApps]", $"{game} not found");
|
||||
return (string.Empty, string.Empty);
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Microsoft Store]", $"UWP Game {game} found at {pkg.EffectiveLocation.Name}");
|
||||
return pkg.EffectivePath;
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[WindowsApps]",
|
||||
$"{dir} can't be accessed without permission changes to the folder.");
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Microsoft Store]",
|
||||
$"The WindowsApps folder can't be accessed without permission changes to the folder.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Microsoft Store]", $"An expected error has ocurred.");
|
||||
}
|
||||
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[WindowsApps]", "Folder not found");
|
||||
return (string.Empty, string.Empty);
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Microsoft Store]", $"{game} cannot be found on this system.");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string GetFortnitePakFilesPath()
|
||||
|
|
@ -109,17 +108,20 @@ namespace FModel.Utils
|
|||
public static string GetStateOfDecay2PakFilesPath()
|
||||
{
|
||||
// WIP
|
||||
(_, string sod2UWPPakFilesPath) = (string.Empty, string.Empty);
|
||||
(_, string _, string sod2PakFilesPath) = (string.Empty, string.Empty, string.Empty);
|
||||
if (!GetUWPPakFilesPath("Microsoft.Dayton_1.3544.68.2_x64__8wekyb3d8bbwe").Equals(null))
|
||||
(_, sod2UWPPakFilesPath) = GetUWPPakFilesPath("Microsoft.Dayton_1.3544.68.2_x64__8wekyb3d8bbwe");
|
||||
else
|
||||
(_, _, sod2PakFilesPath) = GetUEGameFilesPath("<Unknown Epic Games Name>");
|
||||
|
||||
if (!string.IsNullOrEmpty(sod2PakFilesPath))
|
||||
return $"{sod2PakFilesPath}\\StateOfDecay2\\Content\\Paks";
|
||||
else if (!string.IsNullOrEmpty(sod2UWPPakFilesPath))
|
||||
var sod2UWPPakFilesPath = GetUWPPakFilesPath("Microsoft.Dayton_8wekyb3d8bbwe");
|
||||
if (!string.IsNullOrEmpty(sod2UWPPakFilesPath))
|
||||
{
|
||||
return $"{sod2UWPPakFilesPath}\\StateOfDecay2\\Content\\Paks";
|
||||
}
|
||||
else
|
||||
{
|
||||
(_, string _, string sod2PakFilesPath) = GetUEGameFilesPath("<Replace when known with EGL name>");
|
||||
if (!string.IsNullOrEmpty(sod2PakFilesPath))
|
||||
{
|
||||
return $"{sod2PakFilesPath}\\StateOfDecay2\\Content\\Paks";
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
@ -158,6 +160,14 @@ namespace FModel.Utils
|
|||
"Minecraft Dungeons not found");
|
||||
}
|
||||
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[launcher_settings.json]", "Launcher version not found, attempting to find Microsoft Store installation.");
|
||||
|
||||
var mcDungeonsUWPPath = GetUWPPakFilesPath("Microsoft.Lovika_8wekyb3d8bbwe");
|
||||
if (!string.IsNullOrEmpty(mcDungeonsUWPPath))
|
||||
{
|
||||
return $"{mcDungeonsUWPPath}\\Dungeons\\Content\\Paks";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace FModel.Windows.Launcher
|
|||
if (!string.IsNullOrEmpty(sod2Path))
|
||||
{
|
||||
// WIP
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[WindowsApps]", $"State of Decay 2 found at {sod2Path}");
|
||||
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[UWP / LauncherInstalled.dat]", $"State of Decay 2 found at {sod2Path}");
|
||||
Globals.gNotifier.ShowCustomMessage("State of Decay 2", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/sod2.ico");
|
||||
ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "State of Decay 2", Property = sod2Path });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user