Skip to content

Commit 89aef0d

Browse files
authored
Preview 1.82.13 Hotfix (#658)
# What's new ? - 1.82.13 [Hotfix] - **[Loc]** Localization Sync from Transifex, by Localizers <3 - **[Fix]** **[Regression]** False "Obsolete Version" detection on Sophon method while the update is actually available, by @neon-nyan - **[Fix]** Crash due to ``NullReferenceException`` while ``ToastCOM``'s ``NotificationService`` is failing to initialize, by @neon-nyan - **[Imp + Fix]** UI Improvements, by @shatyuka - Update overlay mask on Image Cropping dialog - Hide all invisible system buttons - Implement Taskbar State/Progress API (will be used in the future) - Fix repair status flicker - **[Fix]** **[Regression]** Crash while checking Cache files on Honkai Impact 3rd, by @neon-nyan - **[Fix]** Fix more Issues on Sophon, by @neon-nyan - 0 total size on display while falling back from Update to Install mode on Sophon - Double logging while falling back from Update to Install mode on Sophon - **[Fix]** **[ZZZ GSP]** Wrong index assigned to the resolution list and width rounding issue, by @neon-nyan - If the default resolution exist on the fullscreen resolution list, the index of that resolution will be shifted to the first index. Previously in Collapse, it was manually added to the top while it actually not deleted to the fullscreen list, making it duplicated. Now, it should matches the behaviour - Some resolution which have rounding digits might have displayed incorrectly. ![Untitled-4](https://github.com/user-attachments/assets/c54c4a4d-5983-4833-8478-a727e41b28a6)
2 parents cc38f6e + 2d1ad71 commit 89aef0d

File tree

44 files changed

+800
-450
lines changed

Some content is hidden

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

44 files changed

+800
-450
lines changed
444 Bytes
Loading
632 Bytes
Loading

CollapseLauncher/Classes/AnimatedVisuals/Lottie/NewLogoTitleIntro.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void EnsureImageLoadingStarted()
156156
if (!_isImageLoadingStarted)
157157
{
158158
var eventHandler = new TypedEventHandler<LoadedImageSurface, LoadedImageSourceLoadCompletedEventArgs>(HandleLoadCompleted);
159-
_image_image_0 = LoadedImageSurface.StartLoadFromStream(File.OpenRead(Path.Combine(LauncherConfig.AppFolder, @"Assets\CollapseLauncherLogo.png")).AsRandomAccessStream());
159+
_image_image_0 = LoadedImageSurface.StartLoadFromStream(File.OpenRead(Path.Combine(LauncherConfig.AppExecutableDir, @"Assets\CollapseLauncherLogo.png")).AsRandomAccessStream());
160160
_image_image_0.LoadCompleted += eventHandler;
161161
_isImageLoadingStarted = true;
162162
}

CollapseLauncher/Classes/CachesManagement/Honkai/Fetch.cs

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Hi3Helper.Http;
88
using Hi3Helper.UABT;
99
using System;
10+
using System.Collections.Concurrent;
1011
using System.Collections.Generic;
1112
using System.IO;
1213
using System.Linq;
@@ -17,6 +18,7 @@
1718
using static Hi3Helper.Data.ConverterTool;
1819
using static Hi3Helper.Locale;
1920
using static Hi3Helper.Logger;
21+
// ReSharper disable SwitchStatementHandlesSomeKnownEnumValuesWithDefault
2022

2123
namespace CollapseLauncher
2224
{
@@ -41,34 +43,39 @@ private async Task<List<CacheAsset>> Fetch(CancellationToken token)
4143
await BuildGameRepoURL(downloadClient, token);
4244

4345
// Iterate type and do fetch
44-
foreach (CacheAssetType type in Enum.GetValues<CacheAssetType>())
45-
{
46-
// Skip for unused type
47-
switch (type)
46+
await Parallel.ForEachAsync(
47+
Enum.GetValues<CacheAssetType>(),
48+
new ParallelOptions
4849
{
49-
case CacheAssetType.Unused:
50-
case CacheAssetType.Dispatcher:
51-
case CacheAssetType.Gateway:
52-
case CacheAssetType.General:
53-
case CacheAssetType.IFix:
54-
case CacheAssetType.DesignData:
55-
case CacheAssetType.Lua:
56-
continue;
57-
}
58-
59-
// uint = Count of the assets available
60-
// long = Total size of the assets available
61-
(int, long) count = await FetchByType(type, downloadClient, returnAsset, token);
62-
63-
// Write a log about the metadata
64-
LogWriteLine($"Cache Metadata [T: {type}]:", LogType.Default, true);
65-
LogWriteLine($" Cache Count = {count.Item1}", LogType.NoTag, true);
66-
LogWriteLine($" Cache Size = {SummarizeSizeSimple(count.Item2)}", LogType.NoTag, true);
67-
68-
// Increment the Total Size and Count
69-
_progressAllCountTotal += count.Item1;
70-
_progressAllSizeTotal += count.Item2;
71-
}
50+
MaxDegreeOfParallelism = _threadCount,
51+
CancellationToken = token
52+
},
53+
async (type, ctx) =>
54+
{
55+
switch (type)
56+
{
57+
case CacheAssetType.Data:
58+
case CacheAssetType.Event:
59+
case CacheAssetType.AI:
60+
{
61+
// uint = Count of the assets available
62+
// long = Total size of the assets available
63+
(int, long) count = await FetchByType(type, downloadClient, returnAsset, ctx);
64+
65+
// Write a log about the metadata
66+
LogWriteLine($"Cache Metadata [T: {type}]:", LogType.Default, true);
67+
LogWriteLine($" Cache Count = {count.Item1}", LogType.NoTag, true);
68+
LogWriteLine($" Cache Size = {SummarizeSizeSimple(count.Item2)}", LogType.NoTag, true);
69+
70+
// Increment the Total Size and Count
71+
Interlocked.Add(ref _progressAllCountTotal, count.Item1);
72+
Interlocked.Add(ref _progressAllSizeTotal, count.Item2);
73+
}
74+
break;
75+
default:
76+
return;
77+
}
78+
});
7279

7380
// Return asset index
7481
return returnAsset;
@@ -230,7 +237,7 @@ private IEnumerable<CacheAsset> EnumerateCacheTextAsset(CacheAssetType type, IEn
230237
}
231238
}
232239

233-
private async ValueTask<(int, long)> BuildAssetIndex(CacheAssetType type, string baseURL, Stream stream,
240+
private async ValueTask<ValueTuple<int, long>> BuildAssetIndex(CacheAssetType type, string baseURL, Stream stream,
234241
List<CacheAsset> assetIndex, CancellationToken token)
235242
{
236243
int count = 0;
@@ -258,6 +265,9 @@ private IEnumerable<CacheAsset> EnumerateCacheTextAsset(CacheAssetType type, IEn
258265
.SetAllowedDecompression(DecompressionMethods.None)
259266
.Create();
260267

268+
// Use ConcurrentQueue for adding assets in parallel.
269+
ConcurrentQueue<CacheAsset> assetQueue = [];
270+
261271
// Iterate lines of the TextAsset in parallel
262272
await Parallel.ForEachAsync(EnumerateCacheTextAsset(type, dataTextAsset.GetStringList(), baseURL),
263273
new ParallelOptions
@@ -283,9 +293,18 @@ await Parallel.ForEachAsync(EnumerateCacheTextAsset(type, dataTextAsset.GetStrin
283293
if (!urlStatus.IsSuccessStatusCode) return;
284294
}
285295

286-
assetIndex.Add(content);
296+
// Append the content to the queue
297+
assetQueue.Enqueue(content);
298+
299+
// Increment the count and size
300+
Interlocked.Increment(ref count);
301+
Interlocked.Add(ref size, content.CS);
287302
});
288303

304+
// Take out from the ConcurrentQueue
305+
assetIndex.AddRange(assetQueue);
306+
assetQueue.Clear();
307+
289308
// Return the count and the size
290309
return (count, size);
291310
}

CollapseLauncher/Classes/FileDialog/FileDialogHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private static bool IsProgramFilesPath(ReadOnlySpan<char> path)
150150

151151
private static bool IsCollapseProgramPath(ReadOnlySpan<char> path)
152152
{
153-
string collapseProgramPath = LauncherConfig.AppFolder;
153+
string collapseProgramPath = LauncherConfig.AppExecutableDir;
154154
if (path.StartsWith(collapseProgramPath))
155155
return true;
156156

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Preset(string presetJSONPath, JsonTypeInfo<Dictionary<string, T1>?> jsonT
6868
/// <returns>The instance of preset</returns>
6969
public static Preset<T1, TObjectType> LoadPreset(GameNameType gameType, JsonTypeInfo<Dictionary<string, T1>?> jsonType)
7070
{
71-
string presetPath = Path.Combine(AppFolder, $"Assets\\Presets\\{gameType}\\", $"{typeof(T1).Name}.json");
71+
string presetPath = Path.Combine(AppExecutableDir, $"Assets\\Presets\\{gameType}\\", $"{typeof(T1).Name}.json");
7272
return new Preset<T1, TObjectType>(presetPath, jsonType);
7373
}
7474

CollapseLauncher/Classes/Helper/HttpClientBuilder.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Hi3Helper.Shared.Region;
33
using System;
44
using System.Collections.Generic;
5-
using System.Diagnostics;
65
using System.Net;
76
using System.Net.Http;
87
using System.Net.Security;
@@ -15,23 +14,23 @@ public class HttpClientBuilder : HttpClientBuilder<SocketsHttpHandler>;
1514

1615
public class HttpClientBuilder<THandler> where THandler : HttpMessageHandler, new()
1716
{
18-
private const int _maxConnectionsDefault = 32;
19-
private const double _httpTimeoutDefault = 90; // in Seconds
17+
private const int MaxConnectionsDefault = 32;
18+
private const double HttpTimeoutDefault = 90; // in Seconds
2019

2120
private bool IsUseProxy { get; set; } = true;
2221
private bool IsUseSystemProxy { get; set; } = true;
2322
private bool IsAllowHttpRedirections { get; set; }
2423
private bool IsAllowHttpCookies { get; set; }
2524
private bool IsAllowUntrustedCert { get; set; }
2625

27-
private int MaxConnections { get; set; } = _maxConnectionsDefault;
26+
private int MaxConnections { get; set; } = MaxConnectionsDefault;
2827
private DecompressionMethods DecompressionMethod { get; set; } = DecompressionMethods.All;
2928
private WebProxy? ExternalProxy { get; set; }
3029
private Version HttpProtocolVersion { get; set; } = HttpVersion.Version30;
3130
private string? HttpUserAgent { get; set; } = GetDefaultUserAgent();
3231
private string? HttpAuthHeader { get; set; }
3332
private HttpVersionPolicy HttpProtocolVersionPolicy { get; set; } = HttpVersionPolicy.RequestVersionOrLower;
34-
private TimeSpan HttpTimeout { get; set; } = TimeSpan.FromSeconds(_httpTimeoutDefault);
33+
private TimeSpan HttpTimeout { get; set; } = TimeSpan.FromSeconds(HttpTimeoutDefault);
3534
private Uri? HttpBaseUri { get; set; }
3635
private Dictionary<string, string?> HttpHeaders { get; set; } = new(StringComparer.OrdinalIgnoreCase);
3736

@@ -45,12 +44,11 @@ public HttpClientBuilder<THandler> UseProxy(bool isUseSystemProxy = true)
4544
private static string GetDefaultUserAgent()
4645
{
4746
Version operatingSystemVer = Environment.OSVersion.Version;
48-
FileVersionInfo winAppSDKVer = FileVersionInfo.GetVersionInfo("Microsoft.ui.xaml.dll");
4947

5048
return $"Mozilla/5.0 (Windows NT {operatingSystemVer}; Win64; x64) "
5149
+ $"{RuntimeInformation.FrameworkDescription.Replace(' ', '/')} (KHTML, like Gecko) "
5250
+ $"Collapse/{LauncherUpdateHelper.LauncherCurrentVersionString}-{(LauncherConfig.IsPreview ? "Preview" : "Stable")} "
53-
+ $"WinAppSDK/{winAppSDKVer.ProductVersion}";
51+
+ $"WinAppSDK/{LauncherConfig.WindowsAppSdkVersion}";
5452
}
5553

5654
public HttpClientBuilder<THandler> UseExternalProxy(string host, string? username = null, string? password = null)
@@ -81,7 +79,7 @@ public HttpClientBuilder<THandler> UseExternalProxy(Uri hostUri, string? usernam
8179
return this;
8280
}
8381

84-
public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = _maxConnectionsDefault)
82+
public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = MaxConnectionsDefault)
8583
{
8684
bool lIsUseProxy = LauncherConfig.GetAppConfigValue("IsUseProxy").ToBool();
8785
bool lIsAllowHttpRedirections = LauncherConfig.GetAppConfigValue("IsAllowHttpRedirections").ToBool();
@@ -112,7 +110,7 @@ public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = _maxCo
112110
return this;
113111
}
114112

115-
public HttpClientBuilder<THandler> SetMaxConnection(int maxConnections = _maxConnectionsDefault)
113+
public HttpClientBuilder<THandler> SetMaxConnection(int maxConnections = MaxConnectionsDefault)
116114
{
117115
if (maxConnections < 2)
118116
maxConnections = 2;
@@ -160,18 +158,18 @@ public HttpClientBuilder<THandler> SetHttpVersion(Version? version = null, HttpV
160158
return this;
161159
}
162160

163-
public HttpClientBuilder<THandler> SetTimeout(double fromSeconds = _httpTimeoutDefault)
161+
public HttpClientBuilder<THandler> SetTimeout(double fromSeconds = HttpTimeoutDefault)
164162
{
165163
if (double.IsNaN(fromSeconds) || double.IsInfinity(fromSeconds))
166-
fromSeconds = _httpTimeoutDefault;
164+
fromSeconds = HttpTimeoutDefault;
167165

168166
return SetTimeout(TimeSpan.FromSeconds(fromSeconds));
169167
}
170168

171169
public HttpClientBuilder<THandler> SetTimeout(TimeSpan? timeout = null)
172170
{
173-
timeout ??= TimeSpan.FromSeconds(_httpTimeoutDefault);
174-
HttpTimeout = timeout.Value;
171+
timeout ??= TimeSpan.FromSeconds(HttpTimeoutDefault);
172+
HttpTimeout = timeout.Value;
175173
return this;
176174
}
177175

CollapseLauncher/Classes/Helper/Image/ImageLoaderHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ private static Waifu2X CreateWaifu2X()
8989
{
9090
waifu2X.SetParam(Param.Noise, -1);
9191
waifu2X.SetParam(Param.Scale, 2);
92-
waifu2X.Load(Path.Combine(AppFolder!, @"Assets\Waifu2X_Models\scale2.0x_model.param.bin"),
93-
Path.Combine(AppFolder!, @"Assets\Waifu2X_Models\scale2.0x_model.bin"));
92+
waifu2X.Load(Path.Combine(AppExecutableDir, @"Assets\Waifu2X_Models\scale2.0x_model.param.bin"),
93+
Path.Combine(AppExecutableDir, @"Assets\Waifu2X_Models\scale2.0x_model.bin"));
9494
_cachedStatus = waifu2X.Status;
9595
}
9696
return waifu2X;
@@ -179,7 +179,7 @@ private static async Task<FileStream> SpawnImageCropperDialog(string filePath, s
179179
imageCropper.Opacity = 0;
180180

181181
// Path of image
182-
Uri overlayImageUri = new Uri(Path.Combine(AppFolder!, @"Assets\Images\ImageCropperOverlay",
182+
Uri overlayImageUri = new Uri(Path.Combine(AppExecutableDir, @"Assets\Images\ImageCropperOverlay",
183183
GetAppConfigValue("WindowSizeProfile").ToString() == "Small" ? "small.png" : "normal.png"));
184184

185185
// Why not use ImageBrush?

CollapseLauncher/Classes/Helper/Image/Waifu2X.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static Waifu2XPInvoke()
2828

2929
private static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
3030
{
31-
appDirPath ??= LauncherConfig.AppFolder;
31+
appDirPath ??= LauncherConfig.AppExecutableDir;
3232

3333
if (DllImportSearchPath.AssemblyDirectory != searchPath
3434
&& DllImportSearchPath.ApplicationDirectory != searchPath)

CollapseLauncher/Classes/Helper/TaskSchedulerHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private static async Task<int> GetInvokeCommandReturnCode(string argument)
233233
const string retValMark = "RETURNVAL_";
234234

235235
// Get the applet path and check if the file exist
236-
string appletPath = Path.Combine(LauncherConfig.AppFolder, "Lib", "win-x64", "Hi3Helper.TaskScheduler.exe");
236+
string appletPath = Path.Combine(LauncherConfig.AppExecutableDir, "Lib", "win-x64", "Hi3Helper.TaskScheduler.exe");
237237
if (!File.Exists(appletPath))
238238
{
239239
Logger.LogWriteLine($"Task Scheduler Applet does not exist in this path: {appletPath}", LogType.Error, true);

0 commit comments

Comments
 (0)