Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ private async Task ConfirmAdditionalInstallDataPackageFiles(

List<SophonManifestBuildIdentity> otherManifestIdentity = installManifestFirst.OtherSophonBuildData!.ManifestIdentityList
.Where(x => !commonPackageMatchingFields.Contains(x.MatchingField, StringComparer.OrdinalIgnoreCase))
.Where(x => x.MatchingField == null || !IsVoicePackMatchingField(x.MatchingField))
.ToList();

if (otherManifestIdentity.Count == 0)
Expand Down Expand Up @@ -653,8 +654,9 @@ protected virtual async Task StartPackageUpdateSophon(GameInstallStateEnum gameS
ResetStatusAndProgress();

// Set the progress bar to indetermined
IsSophonInUpdateMode = !isPreloadMode;
Status.IsIncludePerFileIndicator = !isPreloadMode;
IsSophonInUpdateMode = !isPreloadMode;
IsSophonInPreloadVerifyMode = isPreloadMode && _isSophonPreloadCompleted;
Status.IsIncludePerFileIndicator = !isPreloadMode;
Status.IsProgressPerFileIndetermined = true;
Status.IsProgressAllIndetermined = true;
UpdateStatus();
Expand Down Expand Up @@ -867,8 +869,8 @@ await x.GetDownloadedPreloadSize(
Status.IsProgressPerFileIndetermined = false;
Status.IsProgressAllIndetermined = false;
Status.ActivityStatus = $"{(IsSophonInUpdateMode && !isPreloadMode
? Locale.Lang._Misc.UpdatingAndApplying
: Locale.Lang._Misc.Downloading)}: {string.Format(Locale.Lang._Misc.PerFromTo, ProgressAllCountCurrent,
? Locale.Lang?._Misc?.UpdatingAndApplying
: isSophonPreloadCompleted ? Locale.Lang?._Misc?.Verifying : Locale.Lang?._Misc?.Downloading)}: {string.Format(Locale.Lang?._Misc?.PerFromTo ?? "", ProgressAllCountCurrent,
ProgressAllCountTotal)}";
UpdateStatus();

Expand Down Expand Up @@ -1086,6 +1088,7 @@ private async Task TryGetAdditionalPackageForSophonDiff(HttpClient httpClient,
manifestPair.OtherSophonBuildData!.ManifestIdentityList
.Where(x => !string.IsNullOrEmpty(x.MatchingField) && !CommonSophonPackageMatchingFields.Contains(x.MatchingField, StringComparer.OrdinalIgnoreCase))
.Select(x => x.MatchingField!)
.Where(x => !IsVoicePackMatchingField(x))
.WhereMatchPattern(x => x, true, excludeMatchingFieldsPattern)
.ToList();

Expand Down Expand Up @@ -1266,6 +1269,23 @@ protected virtual int SophonGetHttpHandler()
return Math.Clamp(n, 4, 128);
}

private bool IsVoicePackMatchingField(string matchingField)
{
// Check regular locale code: zh-cn, en-us, etc.
if (IsValidLocaleCode(matchingField))
return true;

// Also check for "mini-xx-xx" format (e.g., mini-zh-cn, mini-en-us)
const string miniPrefix = "mini-";
if (matchingField.Length > miniPrefix.Length &&
matchingField.StartsWith(miniPrefix, StringComparison.OrdinalIgnoreCase))
{
return IsValidLocaleCode(matchingField.AsSpan(miniPrefix.Length));
}

return false;
}

#endregion

#region Sophon Audio/Voice-Packs Locale Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ protected virtual async Task ConfirmAdditionalPatchDataPackageFiles(SophonChunkM

List<SophonManifestPatchIdentity> otherManifestIdentity = patchManifest.OtherSophonPatchData!.ManifestIdentityList
.Where(x => !CommonSophonPackageMatchingFields.Contains(x.MatchingField, StringComparer.OrdinalIgnoreCase))
.Where(x => x.MatchingField == null || !IsVoicePackMatchingField(x.MatchingField))
.ToList();

if (otherManifestIdentity.Count == 0)
Expand Down Expand Up @@ -671,7 +672,7 @@ void UpdateCurrentDownloadStatus()
string perFromToLocale = string.Format(Locale.Lang._Misc.PerFromTo,
ProgressAllCountCurrent,
ProgressAllCountTotal);
Status.ActivityStatus = $"{Locale.Lang._Misc.Downloading}: {perFromToLocale}";
Status.ActivityStatus = $"{(IsSophonInPreloadVerifyMode ? Locale.Lang?._Misc?.Verifying : Locale.Lang?._Misc?.Downloading)}: {perFromToLocale}";
UpdateStatus();
}

Expand Down
14 changes: 7 additions & 7 deletions CollapseLauncher/Classes/Interfaces/Class/ProgressBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public ObservableCollection<IAssetProperty> AssetEntry
private const int RefreshInterval = 100;

public bool IsSophonInUpdateMode { get; protected set; }
public bool IsSophonInPreloadVerifyMode { get; protected set; }
protected bool IsAllowExtractCorruptZip { get; set; }


Expand Down Expand Up @@ -581,10 +582,9 @@ protected void UpdateSophonDownloadStatus(SophonAsset _)
{
Interlocked.Add(ref ProgressAllCountCurrent, 1);
Status.ActivityStatus = $"{(IsSophonInUpdateMode
? Locale.Lang._Misc.Updating
: Locale.Lang._Misc.Downloading)}: {string.Format(Locale.Lang._Misc.PerFromTo, ProgressAllCountCurrent,
ProgressAllCountTotal)}";

? Locale.Lang?._Misc?.Updating
: IsSophonInPreloadVerifyMode ? Locale.Lang?._Misc?.Verifying : Locale.Lang?._Misc?.Downloading)}: {string.Format(Locale.Lang?._Misc?.PerFromTo ?? "", ProgressAllCountCurrent,
ProgressAllCountTotal)}";
UpdateStatus();
}

Expand Down Expand Up @@ -1341,8 +1341,8 @@ protected virtual async Task RunDownloadTask(long assetSize,
if (isUseSelfSpeedLimiter)
{
// Create the speed limiter instance and register the listener
downloadSpeedLimiter = DownloadSpeedLimiter.CreateInstance(LauncherConfig.DownloadSpeedLimitCached);
LauncherConfig.DownloadSpeedLimitChanged += downloadSpeedLimiter.GetListener();
// downloadSpeedLimiter = DownloadSpeedLimiter.CreateInstance(LauncherConfig.DownloadSpeedLimitCached);
// LauncherConfig.DownloadSpeedLimitChanged += downloadSpeedLimiter.GetListener();
}

try
Expand Down Expand Up @@ -1375,7 +1375,7 @@ await downloadClient.DownloadAsync(assetURL,
// If the self speed listener is used, then unregister the listener
if (isUseSelfSpeedLimiter && downloadSpeedLimiter != null)
{
LauncherConfig.DownloadSpeedLimitChanged -= downloadSpeedLimiter.GetListener();
// LauncherConfig.DownloadSpeedLimitChanged -= downloadSpeedLimiter.GetListener();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion CollapseLauncher/Classes/Plugins/PluginInfo.Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async ValueTask Impl(PluginManifestAssetInfo asset, CancellationToken innerToken
{
string filePath = Path.Combine(outputDir, asset.FilePath);
string? fileDir = Path.GetDirectoryName(filePath);
string fileUrl = cdnBaseUrl.CombineUrlFromString(asset.FilePath);
string fileUrl = cdnBaseUrl.CombineUrlFromString(asset.FilePath.Replace('\\', '/'));

if (!string.IsNullOrEmpty(fileDir))
{
Expand All @@ -350,6 +350,7 @@ async ValueTask Impl(PluginManifestAssetInfo asset, CancellationToken innerToken
// ReSharper disable once AccessToDisposedClosure
// Reason: The httpClient will never get disposed until the method is done being executed.
await httpClient.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead, innerToken);
response.EnsureSuccessStatusCode();
await using Stream responseStream = await response.Content.ReadAsStreamAsync(innerToken);
await using FileStream fileStream = File.Create(filePath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task FinalizeCacheFetchAsync(StarRailRepairV2 instance,
tempStream.Position = 0;

// -- Parse manifest and get the first asset from stock metadata
StarRailAssetSignaturelessMetadata metadataLuaV = new(".bytes");
StarRailAssetBytesSignaturelessMetadata metadataLuaV = new();
await metadataLuaV.ParseAsync(tempStream, true, token);

// -- Get stock dictionary asset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public List<FilePropertiesRemote> GetPersistentFiles(
BaseDirs.StreamingVideo,
BaseDirs.PersistentVideo,
BaseUrls.Video,
BaseUrls.Video,
BaseUrls.VideoPersistent,
true,
fileList,
unusedAssets,
Expand All @@ -111,7 +111,7 @@ public List<FilePropertiesRemote> GetPersistentFiles(
BaseDirs.StreamingAudio,
BaseDirs.PersistentAudio,
BaseUrls.Audio,
BaseUrls.Audio,
BaseUrls.AudioPersistent,
true,
fileList,
unusedAssets,
Expand Down Expand Up @@ -141,6 +141,34 @@ public List<FilePropertiesRemote> GetPersistentFiles(
Metadata.RawResV.DataList);
}

if (Metadata.DesignV != null)
{
AddAdditionalAssets(gameDirPath,
BaseDirs.StreamingDesignData,
BaseDirs.PersistentDesignData,
BaseUrls.DesignData,
BaseUrls.DesignData,
false,
fileList,
unusedAssets,
oldDic,
Metadata.DesignV.DataList);
}

if (Metadata.NativeDataV != null)
{
AddAdditionalAssets(gameDirPath,
BaseDirs.StreamingNativeData,
BaseDirs.PersistentNativeData,
BaseUrls.NativeData,
BaseUrls.NativeData,
false,
fileList,
unusedAssets,
oldDic,
Metadata.NativeDataV.DataList);
}

if (Metadata.CacheLua != null)
{
AddAdditionalAssets(gameDirPath,
Expand Down Expand Up @@ -294,12 +322,13 @@ private static void AddAdditionalAssets<T>(

FilePropertiesRemote file = new()
{
RN = url,
N = relPathInPersistent,
S = asset.FileSize,
CRCArray = asset.MD5Checksum,
FT = StarRailRepairV2.DetermineFileTypeFromExtension(asset.Filename ?? ""),
IsHasHashMark = isHashMarked
RN = url,
N = relPathInPersistent,
S = asset.FileSize,
CRCArray = asset.MD5Checksum,
FT = StarRailRepairV2.DetermineFileTypeFromExtension(asset.Filename ?? ""),
IsHasHashMark = isHashMarked,
AssociatedObject = asset,
};
fileDic.TryAdd(relPathInPersistent, file);
fileList.Add(file);
Expand Down
Loading
Loading