mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
rename
This commit is contained in:
@@ -100,24 +100,24 @@ internal sealed class LaunchExecutionEnsureGameResourceHandler : ILaunchExecutio
|
||||
|
||||
HoyoPlayClient hoyoPlayClient = context.ServiceProvider.GetRequiredService<HoyoPlayClient>();
|
||||
|
||||
Response<GamePackages> packagesResp = await hoyoPlayClient.GetPackagesAsync(context.Scheme).ConfigureAwait(false);
|
||||
if (!packagesResp.TryGetDataWithoutUINotification(out GamePackages? gamePackages))
|
||||
Response<GamePackagesWrapper> packagesResp = await hoyoPlayClient.GetPackagesAsync(context.Scheme).ConfigureAwait(false);
|
||||
if (!packagesResp.TryGetDataWithoutUINotification(out GamePackagesWrapper? gamePackages))
|
||||
{
|
||||
context.Result.Kind = LaunchExecutionResultKind.GameResourceIndexQueryInvalidResponse;
|
||||
context.Result.ErrorMessage = SH.FormatServiceGameLaunchExecutionGameResourceQueryIndexFailed(packagesResp);
|
||||
return false;
|
||||
}
|
||||
|
||||
Response<ChannelSDKs> sdkResp = await hoyoPlayClient.GetChannelSDKAsync(context.Scheme).ConfigureAwait(false);
|
||||
if (!sdkResp.TryGetDataWithoutUINotification(out ChannelSDKs? channelSDKs))
|
||||
Response<GameChannelSDKsWrapper> sdkResp = await hoyoPlayClient.GetChannelSDKAsync(context.Scheme).ConfigureAwait(false);
|
||||
if (!sdkResp.TryGetDataWithoutUINotification(out GameChannelSDKsWrapper? channelSDKs))
|
||||
{
|
||||
context.Result.Kind = LaunchExecutionResultKind.GameResourceIndexQueryInvalidResponse;
|
||||
context.Result.ErrorMessage = SH.FormatServiceGameLaunchExecutionGameResourceQueryIndexFailed(sdkResp);
|
||||
return false;
|
||||
}
|
||||
|
||||
Response<DeprecatedFileConfigs> deprecatedResp = await hoyoPlayClient.GetDeprecatedFilesAsync(context.Scheme).ConfigureAwait(false);
|
||||
if (!deprecatedResp.TryGetDataWithoutUINotification(out DeprecatedFileConfigs? deprecatedFileConfigs))
|
||||
Response<DeprecatedFileConfigurationsWrapper> deprecatedResp = await hoyoPlayClient.GetDeprecatedFilesAsync(context.Scheme).ConfigureAwait(false);
|
||||
if (!deprecatedResp.TryGetDataWithoutUINotification(out DeprecatedFileConfigurationsWrapper? deprecatedFileConfigs))
|
||||
{
|
||||
context.Result.Kind = LaunchExecutionResultKind.GameResourceIndexQueryInvalidResponse;
|
||||
context.Result.ErrorMessage = SH.FormatServiceGameLaunchExecutionGameResourceQueryIndexFailed(deprecatedResp);
|
||||
@@ -128,7 +128,7 @@ internal sealed class LaunchExecutionEnsureGameResourceHandler : ILaunchExecutio
|
||||
|
||||
if (!context.Scheme.ExecutableMatches(gameFileName))
|
||||
{
|
||||
if (!await packageConverter.EnsureGameResourceAsync(context.Scheme, gamePackages.Packages.Single(), gameFolder, progress).ConfigureAwait(false))
|
||||
if (!await packageConverter.EnsureGameResourceAsync(context.Scheme, gamePackages.GamePackages.Single(), gameFolder, progress).ConfigureAwait(false))
|
||||
{
|
||||
context.Result.Kind = LaunchExecutionResultKind.GameResourcePackageConvertInternalError;
|
||||
context.Result.ErrorMessage = SH.ViewModelLaunchGameEnsureGameResourceFail;
|
||||
@@ -142,7 +142,7 @@ internal sealed class LaunchExecutionEnsureGameResourceHandler : ILaunchExecutio
|
||||
context.Options.UpdateGamePathAndRefreshEntries(Path.Combine(gameFolder, executableName));
|
||||
}
|
||||
|
||||
await packageConverter.EnsureDeprecatedFilesAndSdkAsync(channelSDKs.GameChannelSDKs.SingleOrDefault(), deprecatedFileConfigs.Configs.SingleOrDefault(), gameFolder).ConfigureAwait(false);
|
||||
await packageConverter.EnsureDeprecatedFilesAndSdkAsync(channelSDKs.GameChannelSDKs.SingleOrDefault(), deprecatedFileConfigs.DeprecatedFileConfigurations.SingleOrDefault(), gameFolder).ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ internal sealed partial class PackageConverter
|
||||
// 替换操作等于 先备份国服文件,随后新增国际服文件
|
||||
|
||||
// 准备下载链接
|
||||
string scatteredFilesUrl = gamePackage.Main.Major.ResListUrl;
|
||||
string scatteredFilesUrl = gamePackage.Main.Major.ResourceListUrl;
|
||||
string pkgVersionUrl = $"{scatteredFilesUrl}/{PackageVersion}";
|
||||
|
||||
PackageConverterFileSystemContext context = new(targetScheme.IsOversea, runtimeOptions.GetDataFolderServerCacheFolder(), gameFolder, scatteredFilesUrl);
|
||||
@@ -79,7 +79,7 @@ internal sealed partial class PackageConverter
|
||||
return await ReplaceGameResourceAsync(diffOperations, context, progress).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async ValueTask EnsureDeprecatedFilesAndSdkAsync(ChannelSDK? channelSDK, DeprecatedFileConfig? deprecatedFileConfig, string gameFolder)
|
||||
public async ValueTask EnsureDeprecatedFilesAndSdkAsync(GameChannelSDK? channelSDK, DeprecatedFilesWrapper? deprecatedFileConfig, string gameFolder)
|
||||
{
|
||||
string sdkDllBackup = Path.Combine(gameFolder, YuanShenData, "Plugins\\PCGameSDK.dll.backup");
|
||||
string sdkDll = Path.Combine(gameFolder, YuanShenData, "Plugins\\PCGameSDK.dll");
|
||||
|
||||
@@ -69,7 +69,7 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
||||
|
||||
public List<LaunchScheme> KnownSchemes { get; } = KnownLaunchSchemes.Get();
|
||||
|
||||
[AlsoAsyncSets(nameof(GameAccountsView), nameof(GamePackage))]
|
||||
[AlsoAsyncSets(nameof(GamePackage), nameof(GameAccountsView))]
|
||||
public LaunchScheme? SelectedScheme
|
||||
{
|
||||
get => selectedScheme;
|
||||
@@ -312,14 +312,14 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
||||
}
|
||||
|
||||
await taskContext.SwitchToBackgroundAsync();
|
||||
Web.Response.Response<GamePackages> response = await hoyoPlayClient
|
||||
Web.Response.Response<GamePackagesWrapper> response = await hoyoPlayClient
|
||||
.GetPackagesAsync(scheme)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (response.IsOk())
|
||||
{
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
GamePackage = response.Data.Packages.Single();
|
||||
GamePackage = response.Data.GamePackages.Single();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK;
|
||||
|
||||
internal sealed class ChannelSDK : GameSpecified
|
||||
internal sealed class GameChannelSDK : GameIndexedObject
|
||||
{
|
||||
[JsonPropertyName("channel_sdk_pkg")]
|
||||
public PackageSegment ChannelSdkPackage { get; set; } = default!;
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK;
|
||||
|
||||
internal sealed class ChannelSDKs
|
||||
internal sealed class GameChannelSDKsWrapper
|
||||
{
|
||||
[JsonPropertyName("game_channel_sdks")]
|
||||
public List<ChannelSDK> GameChannelSDKs { get; set; } = default!;
|
||||
public List<GameChannelSDK> GameChannelSDKs { get; set; } = default!;
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile;
|
||||
|
||||
internal sealed class DeprecatedFileConfigs
|
||||
internal sealed class DeprecatedFileConfigurationsWrapper
|
||||
{
|
||||
[JsonPropertyName("deprecated_file_configs")]
|
||||
public List<DeprecatedFileConfig> Configs { get; set; } = default!;
|
||||
public List<DeprecatedFilesWrapper> DeprecatedFileConfigurations { get; set; } = default!;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile;
|
||||
|
||||
internal sealed class DeprecatedFileConfig : GameSpecified
|
||||
internal sealed class DeprecatedFilesWrapper : GameIndexedObject
|
||||
{
|
||||
[JsonPropertyName("deprecated_files")]
|
||||
public List<DeprecatedFile> DeprecatedFiles { get; set; } = default!;
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect;
|
||||
|
||||
internal class GameSpecified
|
||||
internal class GameIndexedObject
|
||||
{
|
||||
[JsonPropertyName("game")]
|
||||
public Game Game { get; set; } = default!;
|
||||
@@ -21,7 +21,7 @@ internal sealed partial class HoyoPlayClient
|
||||
private readonly HttpClient httpClient;
|
||||
private readonly ILogger<HoyoPlayClient> logger;
|
||||
|
||||
public async ValueTask<Response<GamePackages>> GetPackagesAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||
public async ValueTask<Response<GamePackagesWrapper>> GetPackagesAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||
{
|
||||
string url = scheme.IsOversea
|
||||
? ApiOsEndpoints.SgHoyoPlayConnectGamePackages(scheme)
|
||||
@@ -31,14 +31,14 @@ internal sealed partial class HoyoPlayClient
|
||||
.SetRequestUri(url)
|
||||
.Get();
|
||||
|
||||
Response<GamePackages>? resp = await builder
|
||||
.SendAsync<Response<GamePackages>>(httpClient, logger, token)
|
||||
Response<GamePackagesWrapper>? resp = await builder
|
||||
.SendAsync<Response<GamePackagesWrapper>>(httpClient, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
}
|
||||
|
||||
public async ValueTask<Response<ChannelSDKs>> GetChannelSDKAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||
public async ValueTask<Response<GameChannelSDKsWrapper>> GetChannelSDKAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||
{
|
||||
string url = scheme.IsOversea
|
||||
? ApiOsEndpoints.SgHoyoPlayConnectGameChannelSDKs(scheme)
|
||||
@@ -48,14 +48,14 @@ internal sealed partial class HoyoPlayClient
|
||||
.SetRequestUri(url)
|
||||
.Get();
|
||||
|
||||
Response<ChannelSDKs>? resp = await builder
|
||||
.SendAsync<Response<ChannelSDKs>>(httpClient, logger, token)
|
||||
Response<GameChannelSDKsWrapper>? resp = await builder
|
||||
.SendAsync<Response<GameChannelSDKsWrapper>>(httpClient, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
}
|
||||
|
||||
public async ValueTask<Response<DeprecatedFileConfigs>> GetDeprecatedFilesAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||
public async ValueTask<Response<DeprecatedFileConfigurationsWrapper>> GetDeprecatedFilesAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||
{
|
||||
string url = scheme.IsOversea
|
||||
? ApiOsEndpoints.SgHoyoPlayConnectDeprecatedFileConfigs(scheme)
|
||||
@@ -65,8 +65,8 @@ internal sealed partial class HoyoPlayClient
|
||||
.SetRequestUri(url)
|
||||
.Get();
|
||||
|
||||
Response<DeprecatedFileConfigs>? resp = await builder
|
||||
.SendAsync<Response<DeprecatedFileConfigs>>(httpClient, logger, token)
|
||||
Response<DeprecatedFileConfigurationsWrapper>? resp = await builder
|
||||
.SendAsync<Response<DeprecatedFileConfigurationsWrapper>>(httpClient, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||
|
||||
internal sealed class GamePackage : GameSpecified
|
||||
internal sealed class GamePackage : GameIndexedObject
|
||||
{
|
||||
[JsonPropertyName("main")]
|
||||
public GameBranch Main { get; set; } = default!;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||
|
||||
internal sealed class GamePackages
|
||||
internal sealed class GamePackagesWrapper
|
||||
{
|
||||
[JsonPropertyName("game_packages")]
|
||||
public List<GamePackage> Packages { get; set; } = default!;
|
||||
public List<GamePackage> GamePackages { get; set; } = default!;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ internal sealed class Package
|
||||
public List<AudioPackageSegment> AudioPackages { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("res_list_url")]
|
||||
public string ResListUrl { get; set; } = default!;
|
||||
public string ResourceListUrl { get; set; } = default!;
|
||||
|
||||
[JsonIgnore]
|
||||
public List<PackageSegment> AllPackages
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
[HighQuality]
|
||||
[ConstructorGenerated(ResolveHttpClient = true)]
|
||||
[HttpClient(HttpClientConfiguration.Default)]
|
||||
[Obsolete("Use HoyoPlayClient instead.")]
|
||||
internal sealed partial class ResourceClient
|
||||
{
|
||||
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
|
||||
|
||||
Reference in New Issue
Block a user