Skip to content

Commit 7681bb5

Browse files
authored
[Emergency Hotfix] Preview 1.83.12 (#814)
# Main Goal Due to a reported recent ban for using this feature, we are disabling it for now by force. While the ban seems to be only applicable for co-op, we are not taking the report lightly and are disabling this feature until we are sure that it is safe to use. If you have similar issue with this feature and/or other feature that causes something to your account, please contact us immediately. If you are from HoYo, thank you, for doing this to your players, I'm sure that game cloud subscription is worth it. The other changes pertain to Honkai: Impact 3rd's switch to the new Sophon downloader system, thus requiring a complete rewrite of the codebase for that game's installation management to support it. - **[Imp]** Update Discord RPC submodule, by @bagusnl - **[New]** Update backend install and repair systems for Honkai: Impact 3rd Sophon changes: - Add fetcher for Block files. This implementation should now accepts patching for block files which are older than current version (e.g. 8.4 -> 8.5) - Re-implement Generic file parsing and updating - Process Audio and Block fetching in parallel simulatneously - Make `KianaDispatch` and `SenadinaFileResult` fetch asynchronously - Improve CDN caching mechanism - Reimplement Audio & Video file parsing and updating - Add mechanism to fix basic asset - `ProgressPerFile` counters are now containing how many bytes of downloadable data instead of the byte size of each of progressing files - Add additional speed counter on `ProgressAll` status to the UI - Simplify `base.ProgressBase` `PopRepairAssetEntry()` - Refactor Unused files checking mechanism - `HonkaiRepairV2` now uses its own new `UpdateProgressCounter()` method to update the `ProgressAll` or `ProgressPerFile` counters - Add matching field exclude mechanism - Use `HashSet` for checking ignored assets - Implement repair for Block/BlockUpdate and Audio/AudioUpdate kind - **[New]** Keep ScreenShot folder post-uninstall for Genshin Impact, by @Cryotechnic - **[Fix]** Use MemoryStream instead of FileStream for image background, by @shatyuka - This prevents file conflict issues when possible - **[Imp]** Use `CDNCacheUtil`'s `GetCachedUrlStatus` to reduce duplicate code, by @neon-nyan - **[Regression]** Disable MobileMode on all games, by @bagusnl - [Loc] Update Localizations by Localizers ❤️ ### Templates <details> <summary>Changelog Prefixes</summary> ``` **[New]** **[Imp]** **[Fix]** **[Loc]** **[Doc]** ``` </details>
2 parents f468565 + 756dae7 commit 7681bb5

File tree

79 files changed

+5205
-1012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5205
-1012
lines changed

CollapseLauncher.slnLaunch

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"Name": "Collapse (No Debugging)",
4+
"Projects": [
5+
{
6+
"Path": "CollapseLauncher\\CollapseLauncher.csproj",
7+
"Action": "StartWithoutDebugging"
8+
}
9+
]
10+
}
11+
]

CollapseLauncher.slnx

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,85 @@
55
<BuildType Name="Release" />
66
<Platform Name="x64" />
77
</Configurations>
8-
<Project Path="CollapseLauncher/CollapseLauncher.csproj" />
8+
<Project Path="CollapseLauncher/CollapseLauncher.csproj">
9+
<Platform Project="x64" />
10+
<Deploy Solution="Release|*" />
11+
</Project>
912
<Project Path="ColorThief/ColorThief/ColorThief.csproj">
10-
<Configuration Solution="Publish|x64" Project="Release|x64" />
13+
<BuildType Solution="Publish|*" Project="Release" />
14+
<Platform Project="x64" />
1115
</Project>
1216
<Project Path="H.NotifyIcon/src/libs/H.GeneratedIcons.System.Drawing/H.GeneratedIcons.System.Drawing.csproj">
13-
<Configuration Solution="Publish|x64" Project="Release|x64" />
17+
<BuildType Solution="Publish|*" Project="Release" />
18+
<Platform Project="x64" />
1419
</Project>
1520
<Project Path="H.NotifyIcon/src/libs/H.NotifyIcon.WinUI/H.NotifyIcon.WinUI.csproj">
16-
<Configuration Solution="Publish|x64" Project="Release|x64" />
21+
<BuildType Solution="Publish|*" Project="Release" />
22+
<Platform Project="x64" />
1723
</Project>
1824
<Project Path="H.NotifyIcon/src/libs/H.NotifyIcon/H.NotifyIcon.csproj">
19-
<Configuration Solution="Publish|x64" Project="Release|x64" />
25+
<BuildType Solution="Publish|*" Project="Release" />
26+
<Platform Project="x64" />
2027
</Project>
2128
<Project Path="Hi3Helper.CommunityToolkit/ImageCropper/Hi3Helper.CommunityToolkit.WinUI.Controls.ImageCropper.csproj">
22-
<Configuration Solution="Publish|x64" Project="Release|x64" />
29+
<BuildType Solution="Publish|*" Project="Release" />
30+
<Platform Project="x64" />
2331
</Project>
2432
<Project Path="Hi3Helper.CommunityToolkit/SettingsControls/Hi3Helper.CommunityToolkit.WinUI.Controls.SettingsControls.csproj">
25-
<Configuration Solution="Publish|x64" Project="Release|x64" />
33+
<BuildType Solution="Publish|*" Project="Release" />
34+
<Platform Project="x64" />
35+
</Project>
36+
<Project Path="Hi3Helper.Core/Hi3Helper.Core.csproj">
37+
<Platform Project="x64" />
2638
</Project>
27-
<Project Path="Hi3Helper.Core/Hi3Helper.Core.csproj" />
2839
<Project Path="Hi3Helper.EncTool.Test/Hi3Helper.EncTool.Test.csproj">
29-
<Configuration Solution="Publish|x64" Project="Release|x64" />
40+
<BuildType Solution="Publish|*" Project="Release" />
41+
<Platform Project="x64" />
42+
<Build Solution="Publish|*" Project="false" />
43+
<Build Solution="Release|*" Project="false" />
3044
</Project>
3145
<Project Path="Hi3Helper.EncTool/Hi3Helper.EncTool.csproj">
32-
<Configuration Solution="Publish|x64" Project="Release|x64" />
46+
<BuildType Solution="Publish|*" Project="Release" />
47+
<Platform Project="x64" />
3348
</Project>
3449
<Project Path="Hi3Helper.Http/Hi3Helper.Http.csproj">
35-
<Configuration Solution="Publish|x64" Project="Release|x64" />
50+
<BuildType Solution="Publish|*" Project="Release" />
51+
<Platform Project="x64" />
3652
</Project>
3753
<Project Path="Hi3Helper.Plugin.Core/Hi3Helper.Plugin.Core.csproj">
38-
<Configuration Solution="Publish|x64" Project="Release|x64" />
54+
<BuildType Solution="Publish|*" Project="Release" />
55+
<Platform Project="x64" />
3956
</Project>
4057
<Project Path="Hi3Helper.SharpDiscordRPC/DiscordRPC/DiscordRPC.csproj">
41-
<Configuration Solution="Publish|x64" Project="Release|x64" />
58+
<BuildType Solution="Publish|*" Project="Release" />
59+
<Platform Project="x64" />
4260
</Project>
4361
<Project Path="Hi3Helper.Sophon/Hi3Helper.Sophon.csproj">
44-
<Configuration Solution="Publish|x64" Project="Release|x64" />
62+
<BuildType Solution="Publish|*" Project="Release" />
63+
<Platform Project="x64" />
4564
</Project>
4665
<Project Path="Hi3Helper.TaskScheduler/Hi3Helper.TaskScheduler.csproj">
47-
<Configuration Solution="Publish|x64" Project="Release|x64" />
66+
<BuildType Solution="Publish|*" Project="Release" />
67+
<Platform Project="x64" />
4868
</Project>
4969
<Project Path="Hi3Helper.Win32/Hi3Helper.Win32.csproj">
50-
<Configuration Solution="Publish|x64" Project="Release|x64" />
70+
<BuildType Solution="Publish|*" Project="Release" />
71+
<Platform Project="x64" />
5172
</Project>
5273
<Project Path="Hi3Helper.Win32/WinRT/Hi3Helper.Win32.WinRT.csproj">
53-
<Configuration Solution="Publish|x64" Project="Release|x64" />
74+
<BuildType Solution="Publish|*" Project="Release" />
75+
<Platform Project="x64" />
5476
</Project>
5577
<Project Path="ImageEx/ImageEx/ImageEx.csproj">
56-
<Configuration Solution="Publish|x64" Project="Release|x64" />
78+
<BuildType Solution="Publish|*" Project="Release" />
79+
<Platform Project="x64" />
5780
</Project>
5881
<Project Path="InnoSetupHelper/InnoSetupHelper.csproj">
59-
<Configuration Solution="Publish|x64" Project="Release|x64" />
82+
<BuildType Solution="Publish|*" Project="Release" />
83+
<Platform Project="x64" />
6084
</Project>
6185
<Project Path="SevenZipExtractor/SevenZipExtractor/SevenZipExtractor.csproj">
62-
<Configuration Solution="Publish|x64" Project="Release|x64" />
86+
<BuildType Solution="Publish|*" Project="Release" />
87+
<Platform Project="x64" />
6388
</Project>
64-
</Solution>
89+
</Solution>

CollapseLauncher/Classes/Extension/TaskExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,17 @@ private static IInitializableTask GetInitializableTask<T>(T instance)
218218

219219
return initTask;
220220
}
221+
222+
internal static async Task GetResultFromAction<T>(this Task<T> task, Action<T> getResultAction)
223+
{
224+
T result = await task;
225+
getResultAction(result);
226+
}
227+
228+
internal static async Task GetResultFromAction<T>(this Task<T> task, Func<T, Task> getResultAction)
229+
{
230+
T result = await task;
231+
await getResultAction(result);
232+
}
221233
}
222234
}

CollapseLauncher/Classes/GameManagement/GameSettings/Honkai/RegistryClass/PersonalAudioSetting.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace CollapseLauncher.GameSettings.Honkai
2323
internal class PersonalAudioSetting : IGameSettingsValue<PersonalAudioSetting>
2424
{
2525
#region Fields
26-
private const string ValueName = "GENERAL_DATA_V2_PersonalAudioSetting_h3869048096";
26+
internal const string ValueName = "GENERAL_DATA_V2_PersonalAudioSetting_h3869048096";
2727
private readonly PersonalAudioSettingVolume _volumeValue = PersonalAudioSettingVolume.Load();
2828

2929
#endregion

CollapseLauncher/Classes/GamePresetProperty.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ internal static GamePresetProperty Create(UIElement uiElementParent, RegionResou
5252
property.GameVersion = new GameTypeHonkaiVersion(apiResourceProp, gameName, gameRegion);
5353
property.GameSettings = new HonkaiSettings(property.GameVersion);
5454
property.GameCache = new HonkaiCache(uiElementParent, property.GameVersion);
55-
property.GameRepair = new HonkaiRepair(uiElementParent, property.GameVersion, property.GameCache, property.GameSettings);
55+
// property.GameRepair = new HonkaiRepair(uiElementParent, property.GameVersion, property.GameCache, property.GameSettings);
56+
property.GameRepair = new HonkaiRepairV2(uiElementParent, property.GameVersion);
5657
property.GameInstall = new HonkaiInstall(uiElementParent, property.GameVersion, property.GameCache);
5758
break;
5859
case GameNameType.StarRail:

CollapseLauncher/Classes/Helper/Background/BackgroundMediaUtility.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ internal enum MediaType
7070

7171
private bool _isCurrentRegistered;
7272

73-
private static FileStream? _alternativeFileStream;
73+
private static MemoryStream? _alternativeImageStream;
7474

7575
private delegate ValueTask AssignDefaultAction<in T>(T element) where T : class;
7676
internal delegate void ThrowExceptionAction(Exception element);
@@ -119,10 +119,10 @@ internal static async Task<BackgroundMediaUtility> CreateInstanceAsync(Framework
119119
{
120120
CurrentAppliedMediaPath = null;
121121
CurrentAppliedMediaType = MediaType.Unknown;
122-
if (_alternativeFileStream != null)
122+
if (_alternativeImageStream != null)
123123
{
124-
await _alternativeFileStream.DisposeAsync();
125-
_alternativeFileStream = null;
124+
await _alternativeImageStream.DisposeAsync();
125+
_alternativeImageStream = null;
126126
}
127127

128128
// Set the parent UI
@@ -188,8 +188,8 @@ public void Dispose()
188188
_loaderStillImage?.Dispose();
189189
_loaderStillImage = null;
190190

191-
_alternativeFileStream?.Dispose();
192-
_alternativeFileStream = null;
191+
_alternativeImageStream?.Dispose();
192+
_alternativeImageStream = null;
193193

194194
_isCurrentRegistered = false;
195195
GC.SuppressFinalize(this);
@@ -496,17 +496,17 @@ internal void Pause()
496496
_loaderStillImage?.Pause();
497497
}
498498

499-
public static FileStream? GetAlternativeFileStream()
499+
public static MemoryStream? GetAlternativeImageStream()
500500
{
501-
FileStream? returnStream = _alternativeFileStream;
502-
_alternativeFileStream = null;
501+
MemoryStream? returnStream = _alternativeImageStream;
502+
_alternativeImageStream = null;
503503
return returnStream;
504504
}
505505

506-
public static void SetAlternativeFileStream(FileStream stream)
506+
public static void SetAlternativeImageStream(MemoryStream stream)
507507
{
508-
_alternativeFileStream?.Dispose();
509-
_alternativeFileStream = stream;
508+
_alternativeImageStream?.Dispose();
509+
_alternativeImageStream = stream;
510510
}
511511

512512
public static MediaType GetMediaType(string mediaPath)

CollapseLauncher/Classes/Helper/Background/Loaders/MediaPlayerLoader.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static bool IsUseVideoBgDynamicColorUpdate
5555
private Grid OverlayTitleBar { get; }
5656
public bool IsBackgroundDimm { get; set; }
5757

58-
private FileStream? _currentMediaStream;
58+
private MemoryStream? _currentMediaStream;
5959
private MediaPlayer? _currentMediaPlayer;
6060
#if USEFFMPEGFORVIDEOBG
6161
private FFmpegMediaSource? _currentFFmpegMediaSource;
@@ -153,7 +153,22 @@ public async Task LoadAsync(string filePath, bool isImageLoadF
153153

154154
await GetPreviewAsColorPalette(filePath);
155155

156-
_currentMediaStream ??= BackgroundMediaUtility.GetAlternativeFileStream() ?? File.Open(filePath, StreamExtension.FileStreamOpenReadOpt);
156+
if (_currentMediaStream == null)
157+
{
158+
var altStream = BackgroundMediaUtility.GetAlternativeImageStream();
159+
if (altStream != null)
160+
{
161+
_currentMediaStream = altStream;
162+
}
163+
else
164+
{
165+
await using var fileStream = File.Open(filePath, StreamExtension.FileStreamOpenReadOpt);
166+
var memoryStream = new MemoryStream();
167+
await fileStream.CopyToAsync(memoryStream, token);
168+
memoryStream.Position = 0;
169+
_currentMediaStream = memoryStream;
170+
}
171+
}
157172

158173
#if !USEFFMPEGFORVIDEOBG
159174
EnsureIfFormatIsDashOrUnsupported(_currentMediaStream);
@@ -571,4 +586,4 @@ public void Pause()
571586
_currentMediaPlayer?.Pause();
572587
}
573588
}
574-
}
589+
}

CollapseLauncher/Classes/Helper/Background/Loaders/StillImageLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public async Task LoadAsync(string filePath,
7676
{
7777
// Get the image stream
7878
token.ThrowIfCancellationRequested();
79-
await using FileStream? imageStream = BackgroundMediaUtility.GetAlternativeFileStream() ??
79+
await using MemoryStream? imageStream = BackgroundMediaUtility.GetAlternativeImageStream() ??
8080
await ImageLoaderHelper.LoadImage(filePath, false,
8181
isImageLoadForFirstTime);
8282
// Return if the stream is null due to cancellation or an error.
@@ -246,4 +246,4 @@ public void Pause()
246246
{
247247
}
248248
}
249-
}
249+
}

CollapseLauncher/Classes/Helper/FileUtility.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,23 @@ public static int GetFileStreamBufferSize(this long fileSize)
125125
<= 100 << 20 => 512 << 10,
126126
_ => 1 << 20
127127
};
128+
129+
public static int GetFileStreamBufferSize(this int fileSize) => GetFileStreamBufferSize((long)fileSize);
130+
131+
public static int GetFileStreamBufferSize(this ulong fileSize)
132+
=> fileSize switch
133+
{
134+
// 128 KiB
135+
<= 128 << 10 => 4 << 10,
136+
// 1 MiB
137+
<= 1 << 20 => 64 << 10,
138+
// 32 MiB
139+
<= 32 << 20 => 128 << 10,
140+
// 100 MiB
141+
<= 100 << 20 => 512 << 10,
142+
_ => 1 << 20
143+
};
144+
145+
public static int GetFileStreamBufferSize(this uint fileSize) => GetFileStreamBufferSize((ulong)fileSize);
128146
}
129147
}

CollapseLauncher/Classes/Helper/Image/ImageLoaderHelper.cs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static void DestroyWaifu2X()
115115
}
116116
#endregion
117117

118-
internal static async Task<FileStream> LoadImage(string path, bool isUseImageCropper = false, bool overwriteCachedImage = false)
118+
internal static async Task<MemoryStream> LoadImage(string path, bool isUseImageCropper = false, bool overwriteCachedImage = false)
119119
{
120120
if (string.IsNullOrEmpty(path) || !File.Exists(path)) return null;
121121
double aspectRatioX = InnerLauncherConfig.m_actualMainFrameSize.Width;
@@ -128,6 +128,7 @@ internal static async Task<FileStream> LoadImage(string path, bool isUseImageCro
128128
if (!Directory.Exists(AppGameImgCachedFolder)) Directory.CreateDirectory(AppGameImgCachedFolder!);
129129

130130
FileStream resizedImageFileStream = null;
131+
MemoryStream imageStream = null;
131132

132133
try
133134
{
@@ -136,18 +137,17 @@ internal static async Task<FileStream> LoadImage(string path, bool isUseImageCro
136137
if (resizedFileInfo!.Exists && resizedFileInfo.Length > 1 << 15 && !overwriteCachedImage)
137138
{
138139
resizedImageFileStream = resizedFileInfo.Open(StreamExtension.FileStreamOpenReadOpt);
139-
return resizedImageFileStream;
140140
}
141-
142-
if (isUseImageCropper)
141+
else if (isUseImageCropper)
143142
{
144143
resizedImageFileStream = await SpawnImageCropperDialog(path, resizedFileInfo.FullName,
145144
targetSourceImageWidth, targetSourceImageHeight);
146-
return resizedImageFileStream;
147145
}
148-
149-
resizedImageFileStream = await GenerateCachedStream(inputFileInfo, targetSourceImageWidth,
150-
targetSourceImageHeight);
146+
else
147+
{
148+
resizedImageFileStream = await GenerateCachedStream(inputFileInfo, targetSourceImageWidth,
149+
targetSourceImageHeight);
150+
}
151151
}
152152
catch
153153
{
@@ -159,10 +159,18 @@ internal static async Task<FileStream> LoadImage(string path, bool isUseImageCro
159159
if (isError && resizedImageFileStream != null)
160160
{
161161
await resizedImageFileStream.DisposeAsync();
162+
resizedImageFileStream = null;
163+
}
164+
if (resizedImageFileStream != null)
165+
{
166+
imageStream = new MemoryStream();
167+
await resizedImageFileStream.CopyToAsync(imageStream);
168+
imageStream.Position = 0;
169+
await resizedImageFileStream.DisposeAsync();
162170
}
163171
}
164172

165-
return resizedImageFileStream;
173+
return imageStream;
166174
}
167175

168176
private static async Task<FileStream> SpawnImageCropperDialog(string filePath, string cachedFilePath,
@@ -372,12 +380,12 @@ await Task.Run(() =>
372380
Bitmap bitmapRet;
373381
BitmapImage bitmapImageRet;
374382

375-
FileStream cachedFileStream = await LoadImage(filePath);
376-
if (cachedFileStream == null) return (null, null);
377-
await using (cachedFileStream)
383+
var cachedImageStream = await LoadImage(filePath);
384+
if (cachedImageStream == null) return (null, null);
385+
await using (cachedImageStream)
378386
{
379-
bitmapRet = await Task.Run(() => Stream2Bitmap(cachedFileStream.AsRandomAccessStream()));
380-
bitmapImageRet = await Stream2BitmapImage(cachedFileStream.AsRandomAccessStream());
387+
bitmapRet = await Task.Run(() => Stream2Bitmap(cachedImageStream.AsRandomAccessStream()));
388+
bitmapImageRet = await Stream2BitmapImage(cachedImageStream.AsRandomAccessStream());
381389
}
382390

383391
return (bitmapRet, bitmapImageRet);

0 commit comments

Comments
 (0)