Skip to content

Commit e334415

Browse files
authored
Preview 1.82.9 Hotfix (#640)
# What's new? - 1.82.9 - **[Fix]** Sophon failing to install games, by @bagusnl & @neon-nyan - Errors such as `EnumFailedVersion` or `InvalidOperationException` - Caused by Sophon data got modified mid-flight before the finalization - **[Fix]** App crashing when minimized to tray on certain system, by @bagusnl - This is caused by missing Windows feature causing the method to be missing, please contact your custom ISOs creator if other errors happened caused by similar 'Incorrect function' error - **[Fix]** Error when trying to uninstall games that do not have AppData entry, by @neon-nyan - **[Fix]** Installation starts before audio package is selected, by @neon-nyan & @bagusnl - **[Imp]** Improved Sophon performance by increasing minimum thread pool available for processing files, by @neon-nyan <details> <summary>Changelog Prefixes</summary> ``` **[New]** **[Imp]** **[Fix]** **[Loc]** **[Doc]** ``` </details>
2 parents 8ee9b3f + 53ec959 commit e334415

Some content is hidden

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

46 files changed

+1127
-520
lines changed

CollapseLauncher/App.xaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,13 @@
385385
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
386386
Color="#00000000" />
387387
<SolidColorBrush x:Key="WindowCaptionButtonBackgroundPointerOver"
388-
Color="#10FFFFFF" />
388+
Color="#60000000" />
389389
<SolidColorBrush x:Key="WindowCaptionButtonBackgroundPressed"
390390
Color="#22222222" />
391391
<SolidColorBrush x:Key="WindowCaptionBackgroundClose"
392-
Color="#A0C00000" />
392+
Color="#00E00000" />
393393
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePointerOver"
394-
Color="#FFD00000" />
394+
Color="#FFE00000" />
395395
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePressed"
396396
Color="#A0B00000" />
397397
</ResourceDictionary>
@@ -744,9 +744,9 @@
744744
<SolidColorBrush x:Key="WindowCaptionButtonBackgroundPressed"
745745
Color="#40FFFFFF" />
746746
<SolidColorBrush x:Key="WindowCaptionBackgroundClose"
747-
Color="#90FF6666" />
747+
Color="#00FF6666" />
748748
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePointerOver"
749-
Color="#C0FF0000" />
749+
Color="#FFFF0000" />
750750
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePressed"
751751
Color="#90FF2222" />
752752
</ResourceDictionary>

CollapseLauncher/Classes/Extension/UIElementExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CommunityToolkit.WinUI;
22
using Hi3Helper;
33
using Hi3Helper.CommunityToolkit.WinUI.Controls;
4+
using Hi3Helper.SentryHelper;
45
using Microsoft.UI;
56
using Microsoft.UI.Input;
67
using Microsoft.UI.Text;
@@ -17,7 +18,6 @@
1718
using System.Runtime.CompilerServices;
1819
using Windows.UI;
1920
using Windows.UI.Text;
20-
using Hi3Helper.SentryHelper;
2121

2222
namespace CollapseLauncher.Extension
2323
{

CollapseLauncher/Classes/GameManagement/GameSettings/Genshin/RegistryClass/ScreenManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using CollapseLauncher.GameSettings.Base;
2-
using CollapseLauncher.Helper;
32
using CollapseLauncher.Interfaces;
43
using Hi3Helper;
54
using Hi3Helper.EncTool;
65
using Microsoft.Win32;
6+
using Hi3Helper.Win32.Screen;
77
using System;
88
using System.Drawing;
99
using static CollapseLauncher.GameSettings.Base.SettingsBase;
@@ -17,7 +17,7 @@ internal class ScreenManager : BaseScreenSettingData, IGameSettingsValue<ScreenM
1717
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
1818
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
1919
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Is Fullscreen mode_h3981298716";
20-
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
20+
private static Size currentRes = ScreenProp.CurrentResolution;
2121
#endregion
2222

2323
#region Properties

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using CollapseLauncher.GameSettings.Base;
22
using CollapseLauncher.GameSettings.Honkai.Context;
3-
using CollapseLauncher.Helper;
43
using CollapseLauncher.Interfaces;
54
using Hi3Helper;
65
using Hi3Helper.EncTool;
6+
using Hi3Helper.Win32.Screen;
77
using Microsoft.Win32;
88
using System;
99
using System.Drawing;
@@ -18,11 +18,11 @@ namespace CollapseLauncher.GameSettings.Honkai
1818
internal class ScreenSettingData : BaseScreenSettingData, IGameSettingsValue<ScreenSettingData>
1919
{
2020
#region Fields
21-
private const string _ValueName = "GENERAL_DATA_V2_ScreenSettingData_h1916288658";
21+
private const string _ValueName = "GENERAL_DATA_V2_ScreenSettingData_h1916288658";
2222
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Is Fullscreen mode_h3981298716";
23-
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
24-
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
25-
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
23+
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
24+
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
25+
private static Size currentRes = ScreenProp.CurrentResolution;
2626
#endregion
2727

2828
#region Properties

CollapseLauncher/Classes/GameManagement/GameSettings/StarRail/RegistryClass/PCResolution.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using CollapseLauncher.GameSettings.Base;
22
using CollapseLauncher.GameSettings.StarRail.Context;
3-
using CollapseLauncher.Helper;
43
using CollapseLauncher.Interfaces;
54
using Hi3Helper;
65
using Hi3Helper.EncTool;
@@ -10,6 +9,7 @@
109
using System.Text;
1110
using System.Text.Json.Serialization;
1211
using Hi3Helper.SentryHelper;
12+
using Hi3Helper.Win32.Screen;
1313
using static CollapseLauncher.GameSettings.Base.SettingsBase;
1414
using static Hi3Helper.Logger;
1515

@@ -18,11 +18,11 @@ namespace CollapseLauncher.GameSettings.StarRail
1818
internal class PCResolution : BaseScreenSettingData, IGameSettingsValue<PCResolution>
1919
{
2020
#region Fields
21-
private const string _ValueName = "GraphicsSettings_PCResolution_h431323223";
22-
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
23-
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
21+
private const string _ValueName = "GraphicsSettings_PCResolution_h431323223";
22+
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
23+
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
2424
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Fullscreen mode_h3630240806";
25-
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
25+
private static Size currentRes = ScreenProp.CurrentResolution;
2626
#endregion
2727

2828
#region Properties

CollapseLauncher/Classes/GameManagement/GameSettings/Zenless/RegistryClass/ScreenManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Hi3Helper;
55
using Hi3Helper.EncTool;
66
using Microsoft.Win32;
7+
using Hi3Helper.Win32.Screen;
78
using System;
89
using System.Drawing;
910
using Hi3Helper.SentryHelper;
@@ -20,7 +21,7 @@ internal class ScreenManager : BaseScreenSettingData, IGameSettingsValue<ScreenM
2021
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
2122
private const string _ValueNameScreenManagerHeightDef = "Screenmanager Resolution Height Default_h1380706816";
2223
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Fullscreen mode_h3630240806";
23-
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
24+
private static Size currentRes = ScreenProp.CurrentResolution;
2425
#endregion
2526

2627
#region Enums
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Threading;
3+
4+
namespace CollapseLauncher.Helper
5+
{
6+
/// <summary>
7+
/// Manages the thread pool settings to throttle the number of threads.
8+
/// </summary>
9+
internal partial class ThreadPoolThrottle : IDisposable
10+
{
11+
private readonly int PreviousThreadCount;
12+
private readonly int PreviousCompletionPortThreadCount;
13+
internal readonly int MultipliedThreadCount;
14+
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="ThreadPoolThrottle"/> class.
17+
/// </summary>
18+
/// <param name="previousThreadCount">The previous maximum number of worker threads.</param>
19+
/// <param name="previousCompletionPortThreadCount">The previous maximum number of asynchronous I/O threads.</param>
20+
/// <param name="multipliedThreadCount">The multiplied thread count.</param>
21+
private ThreadPoolThrottle(int previousThreadCount, int previousCompletionPortThreadCount, int multipliedThreadCount)
22+
{
23+
PreviousThreadCount = previousThreadCount;
24+
PreviousCompletionPortThreadCount = previousCompletionPortThreadCount;
25+
MultipliedThreadCount = multipliedThreadCount;
26+
}
27+
28+
/// <summary>
29+
/// Starts the thread pool throttle by setting the maximum number of threads.
30+
/// </summary>
31+
/// <param name="multiply">The factor to multiply the processor count by to determine the maximum number of threads.</param>
32+
/// <returns>A <see cref="ThreadPoolThrottle"/> instance that can be used to restore the previous thread pool settings.</returns>
33+
public static ThreadPoolThrottle Start(int multiply = 4)
34+
{
35+
var threadCount = Environment.ProcessorCount * multiply;
36+
ThreadPool.GetMinThreads(out var workerThreads, out var completionPortThreads);
37+
ThreadPool.SetMinThreads(Math.Max(workerThreads, threadCount),
38+
Math.Max(completionPortThreads, threadCount));
39+
return new ThreadPoolThrottle(workerThreads, completionPortThreads, threadCount);
40+
}
41+
42+
/// <summary>
43+
/// Restores the previous thread pool settings.
44+
/// </summary>
45+
public void Dispose()
46+
{
47+
ThreadPool.SetMaxThreads(PreviousThreadCount, PreviousCompletionPortThreadCount);
48+
}
49+
}
50+
}

CollapseLauncher/Classes/Helper/WindowUtility.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ internal static class WindowUtility
5454
internal static AppWindow? CurrentAppWindow;
5555
internal static WindowId? CurrentWindowId;
5656
internal static OverlappedPresenter? CurrentOverlappedPresenter;
57-
internal static ScreenProp? CurrentScreenProp;
5857

5958
internal static DisplayArea? CurrentWindowDisplayArea
6059
{
@@ -665,15 +664,15 @@ private static IntPtr DesktopSiteBridgeWndProc(IntPtr hwnd, uint msg, UIntPtr wP
665664

666665
internal static void SetWindowSize(int width, int height)
667666
{
668-
if (CurrentScreenProp == null || CurrentWindowPtr == nint.Zero)
667+
if (CurrentWindowPtr == nint.Zero)
669668
return;
670669

671670
// Get the scale factor and calculate the size and offset
672671
double scaleFactor = CurrentWindowMonitorScaleFactor;
673672
int lastWindowWidth = (int)(width * scaleFactor);
674673
int lastWindowHeight = (int)(height * scaleFactor);
675674

676-
Size desktopSize = CurrentScreenProp.GetScreenSize();
675+
Size desktopSize = ScreenProp.CurrentResolution;
677676
int xOff = desktopSize.Width / 2 - lastWindowWidth / 2;
678677
int yOff = desktopSize.Height / 2 - lastWindowHeight / 2;
679678

0 commit comments

Comments
 (0)