-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
269 additions
and
139 deletions.
There are no files selected for viewing
193 changes: 140 additions & 53 deletions
193
...tao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionEnsureGameResourceHandler.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) DGP Studio. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Snap.Hutao.Core.IO; | ||
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile; | ||
using System.IO; | ||
using System.IO.Compression; | ||
|
||
namespace Snap.Hutao.Service.Game.Package; | ||
|
||
internal abstract class PackageConverter : IPackageConverter | ||
{ | ||
public abstract ValueTask<bool> EnsureGameResourceAsync(PackageConverterContext context); | ||
|
||
public virtual async ValueTask EnsureDeprecatedFilesAndSdkAsync(PackageConverterDeprecationContext context) | ||
{ | ||
// Just try to delete these files, always download from server when needed | ||
string gameDirectory = context.GameFileSystem.GetGameDirectory(); | ||
FileOperation.Delete(Path.Combine(gameDirectory, GameConstants.YuanShenData, "Plugins\\PCGameSDK.dll")); | ||
FileOperation.Delete(Path.Combine(gameDirectory, GameConstants.GenshinImpactData, "Plugins\\PCGameSDK.dll")); | ||
FileOperation.Delete(Path.Combine(gameDirectory, GameConstants.YuanShenData, "Plugins\\EOSSDK-Win64-Shipping.dll")); | ||
FileOperation.Delete(Path.Combine(gameDirectory, GameConstants.GenshinImpactData, "Plugins\\EOSSDK-Win64-Shipping.dll")); | ||
FileOperation.Delete(Path.Combine(gameDirectory, GameConstants.YuanShenData, "Plugins\\PluginEOSSDK.dll")); | ||
FileOperation.Delete(Path.Combine(gameDirectory, GameConstants.GenshinImpactData, "Plugins\\PluginEOSSDK.dll")); | ||
FileOperation.Delete(Path.Combine(gameDirectory, "sdk_pkg_version")); | ||
|
||
if (context.GameChannelSdk is not null) | ||
{ | ||
using (Stream sdkWebStream = await context.HttpClient.GetStreamAsync(context.GameChannelSdk.ChannelSdkPackage.Url).ConfigureAwait(false)) | ||
{ | ||
ZipFile.ExtractToDirectory(sdkWebStream, gameDirectory, true); | ||
} | ||
} | ||
|
||
if (context.DeprecatedFiles is not null) | ||
{ | ||
foreach (DeprecatedFile file in context.DeprecatedFiles.DeprecatedFiles) | ||
{ | ||
string filePath = Path.Combine(gameDirectory, file.Name); | ||
FileOperation.Move(filePath, $"{filePath}.backup", true); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConverterDeprecationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) DGP Studio. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK; | ||
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile; | ||
using System.Net.Http; | ||
|
||
namespace Snap.Hutao.Service.Game.Package; | ||
|
||
internal readonly struct PackageConverterDeprecationContext | ||
{ | ||
public readonly HttpClient HttpClient; | ||
public readonly IGameFileSystem GameFileSystem; | ||
public readonly GameChannelSDK? GameChannelSdk; | ||
public readonly DeprecatedFilesWrapper? DeprecatedFiles; | ||
|
||
public PackageConverterDeprecationContext(HttpClient httpClient, IGameFileSystem gameFileSystem, GameChannelSDK? gameChannelSdk, DeprecatedFilesWrapper? deprecatedFiles) | ||
{ | ||
HttpClient = httpClient; | ||
GameFileSystem = gameFileSystem; | ||
GameChannelSdk = gameChannelSdk; | ||
DeprecatedFiles = deprecatedFiles; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Snap.Hutao/Snap.Hutao/ViewModel/Game/ViewModelSupportLaunchExecutionExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) DGP Studio. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Snap.Hutao.Service.Game; | ||
using Snap.Hutao.Service.Game.PathAbstraction; | ||
|
||
namespace Snap.Hutao.ViewModel.Game; | ||
|
||
internal static class ViewModelSupportLaunchExecutionExtension | ||
{ | ||
public static void SetGamePathEntriesAndSelectedGamePathEntry(this IViewModelSupportLaunchExecution viewModel, IRestrictedGamePathAccess access) | ||
{ | ||
viewModel.SetGamePathEntriesAndSelectedGamePathEntry(access.PerformGamePathEntrySynchronization(out GamePathEntry? selected), selected); | ||
} | ||
} |