Skip to content

Commit

Permalink
Preview 1.82.9 Hotfix (#640)
Browse files Browse the repository at this point in the history
# 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>
  • Loading branch information
Cryotechnic authored Dec 25, 2024
2 parents 8ee9b3f + 53ec959 commit e334415
Show file tree
Hide file tree
Showing 46 changed files with 1,127 additions and 520 deletions.
10 changes: 5 additions & 5 deletions CollapseLauncher/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,13 @@
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
Color="#00000000" />
<SolidColorBrush x:Key="WindowCaptionButtonBackgroundPointerOver"
Color="#10FFFFFF" />
Color="#60000000" />
<SolidColorBrush x:Key="WindowCaptionButtonBackgroundPressed"
Color="#22222222" />
<SolidColorBrush x:Key="WindowCaptionBackgroundClose"
Color="#A0C00000" />
Color="#00E00000" />
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePointerOver"
Color="#FFD00000" />
Color="#FFE00000" />
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePressed"
Color="#A0B00000" />
</ResourceDictionary>
Expand Down Expand Up @@ -744,9 +744,9 @@
<SolidColorBrush x:Key="WindowCaptionButtonBackgroundPressed"
Color="#40FFFFFF" />
<SolidColorBrush x:Key="WindowCaptionBackgroundClose"
Color="#90FF6666" />
Color="#00FF6666" />
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePointerOver"
Color="#C0FF0000" />
Color="#FFFF0000" />
<SolidColorBrush x:Key="WindowCaptionBackgroundClosePressed"
Color="#90FF2222" />
</ResourceDictionary>
Expand Down
2 changes: 1 addition & 1 deletion CollapseLauncher/Classes/Extension/UIElementExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommunityToolkit.WinUI;
using Hi3Helper;
using Hi3Helper.CommunityToolkit.WinUI.Controls;
using Hi3Helper.SentryHelper;
using Microsoft.UI;
using Microsoft.UI.Input;
using Microsoft.UI.Text;
Expand All @@ -17,7 +18,6 @@
using System.Runtime.CompilerServices;
using Windows.UI;
using Windows.UI.Text;
using Hi3Helper.SentryHelper;

namespace CollapseLauncher.Extension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CollapseLauncher.GameSettings.Base;
using CollapseLauncher.Helper;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using Hi3Helper.Win32.Screen;
using System;
using System.Drawing;
using static CollapseLauncher.GameSettings.Base.SettingsBase;
Expand All @@ -17,7 +17,7 @@ internal class ScreenManager : BaseScreenSettingData, IGameSettingsValue<ScreenM
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Is Fullscreen mode_h3981298716";
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
private static Size currentRes = ScreenProp.CurrentResolution;
#endregion

#region Properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CollapseLauncher.GameSettings.Base;
using CollapseLauncher.GameSettings.Honkai.Context;
using CollapseLauncher.Helper;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Hi3Helper.Win32.Screen;
using Microsoft.Win32;
using System;
using System.Drawing;
Expand All @@ -18,11 +18,11 @@ namespace CollapseLauncher.GameSettings.Honkai
internal class ScreenSettingData : BaseScreenSettingData, IGameSettingsValue<ScreenSettingData>
{
#region Fields
private const string _ValueName = "GENERAL_DATA_V2_ScreenSettingData_h1916288658";
private const string _ValueName = "GENERAL_DATA_V2_ScreenSettingData_h1916288658";
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Is Fullscreen mode_h3981298716";
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
private const string _ValueNameScreenManagerWidth = "Screenmanager Resolution Width_h182942802";
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
private static Size currentRes = ScreenProp.CurrentResolution;
#endregion

#region Properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CollapseLauncher.GameSettings.Base;
using CollapseLauncher.GameSettings.StarRail.Context;
using CollapseLauncher.Helper;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
Expand All @@ -10,6 +9,7 @@
using System.Text;
using System.Text.Json.Serialization;
using Hi3Helper.SentryHelper;
using Hi3Helper.Win32.Screen;
using static CollapseLauncher.GameSettings.Base.SettingsBase;
using static Hi3Helper.Logger;

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

#region Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using Hi3Helper.Win32.Screen;
using System;
using System.Drawing;
using Hi3Helper.SentryHelper;
Expand All @@ -20,7 +21,7 @@ internal class ScreenManager : BaseScreenSettingData, IGameSettingsValue<ScreenM
private const string _ValueNameScreenManagerHeight = "Screenmanager Resolution Height_h2627697771";
private const string _ValueNameScreenManagerHeightDef = "Screenmanager Resolution Height Default_h1380706816";
private const string _ValueNameScreenManagerFullscreen = "Screenmanager Fullscreen mode_h3630240806";
private static Size currentRes = WindowUtility.CurrentScreenProp.CurrentResolution;
private static Size currentRes = ScreenProp.CurrentResolution;
#endregion

#region Enums
Expand Down
50 changes: 50 additions & 0 deletions CollapseLauncher/Classes/Helper/ThreadPoolThrottle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Threading;

namespace CollapseLauncher.Helper
{
/// <summary>
/// Manages the thread pool settings to throttle the number of threads.
/// </summary>
internal partial class ThreadPoolThrottle : IDisposable
{
private readonly int PreviousThreadCount;
private readonly int PreviousCompletionPortThreadCount;
internal readonly int MultipliedThreadCount;

/// <summary>
/// Initializes a new instance of the <see cref="ThreadPoolThrottle"/> class.
/// </summary>
/// <param name="previousThreadCount">The previous maximum number of worker threads.</param>
/// <param name="previousCompletionPortThreadCount">The previous maximum number of asynchronous I/O threads.</param>
/// <param name="multipliedThreadCount">The multiplied thread count.</param>
private ThreadPoolThrottle(int previousThreadCount, int previousCompletionPortThreadCount, int multipliedThreadCount)
{
PreviousThreadCount = previousThreadCount;
PreviousCompletionPortThreadCount = previousCompletionPortThreadCount;
MultipliedThreadCount = multipliedThreadCount;
}

/// <summary>
/// Starts the thread pool throttle by setting the maximum number of threads.
/// </summary>
/// <param name="multiply">The factor to multiply the processor count by to determine the maximum number of threads.</param>
/// <returns>A <see cref="ThreadPoolThrottle"/> instance that can be used to restore the previous thread pool settings.</returns>
public static ThreadPoolThrottle Start(int multiply = 4)
{
var threadCount = Environment.ProcessorCount * multiply;
ThreadPool.GetMinThreads(out var workerThreads, out var completionPortThreads);
ThreadPool.SetMinThreads(Math.Max(workerThreads, threadCount),
Math.Max(completionPortThreads, threadCount));
return new ThreadPoolThrottle(workerThreads, completionPortThreads, threadCount);
}

/// <summary>
/// Restores the previous thread pool settings.
/// </summary>
public void Dispose()
{
ThreadPool.SetMaxThreads(PreviousThreadCount, PreviousCompletionPortThreadCount);
}
}
}
5 changes: 2 additions & 3 deletions CollapseLauncher/Classes/Helper/WindowUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ internal static class WindowUtility
internal static AppWindow? CurrentAppWindow;
internal static WindowId? CurrentWindowId;
internal static OverlappedPresenter? CurrentOverlappedPresenter;
internal static ScreenProp? CurrentScreenProp;

internal static DisplayArea? CurrentWindowDisplayArea
{
Expand Down Expand Up @@ -665,15 +664,15 @@ private static IntPtr DesktopSiteBridgeWndProc(IntPtr hwnd, uint msg, UIntPtr wP

internal static void SetWindowSize(int width, int height)
{
if (CurrentScreenProp == null || CurrentWindowPtr == nint.Zero)
if (CurrentWindowPtr == nint.Zero)
return;

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

Size desktopSize = CurrentScreenProp.GetScreenSize();
Size desktopSize = ScreenProp.CurrentResolution;
int xOff = desktopSize.Width / 2 - lastWindowWidth / 2;
int yOff = desktopSize.Height / 2 - lastWindowHeight / 2;

Expand Down
Loading

0 comments on commit e334415

Please sign in to comment.