Skip to content

Commit 7c0eb89

Browse files
committed
[Win32] Restructure + Add Customizable Toast API
1 parent b129063 commit 7c0eb89

File tree

21 files changed

+83
-94
lines changed

21 files changed

+83
-94
lines changed

CollapseLauncher/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using Hi3Helper;
44
using Hi3Helper.SentryHelper;
55
using Hi3Helper.Shared.Region;
6-
using Hi3Helper.Win32.Native;
76
using Hi3Helper.Win32.Native.Enums;
7+
using Hi3Helper.Win32.Native.LibraryImport;
88
using Microsoft.UI;
99
using Microsoft.UI.Xaml;
1010
using Microsoft.UI.Xaml.Media;

CollapseLauncher/Classes/GamePropertyVault.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using Hi3Helper;
1414
using Hi3Helper.SentryHelper;
1515
using Hi3Helper.Shared.ClassStruct;
16-
using Hi3Helper.Win32.Native;
16+
using Hi3Helper.Win32.Native.ManagedTools;
1717
using Microsoft.UI.Xaml;
1818
using System;
1919
using System.Collections.Generic;
@@ -117,7 +117,7 @@ internal string _GameExecutableNameWithoutExtension
117117

118118
internal bool IsGameRunning
119119
{
120-
get => PInvoke.IsProcessExist(_GameExecutableName, out _, out _, Path.Combine(_GameVersion?.GameDirPath ?? "", _GameExecutableName), ILoggerHelper.GetILogger());
120+
get => ProcessChecker.IsProcessExist(_GameExecutableName, out _, out _, Path.Combine(_GameVersion?.GameDirPath ?? "", _GameExecutableName), ILoggerHelper.GetILogger());
121121
}
122122

123123
#nullable enable
@@ -136,7 +136,7 @@ internal bool IsGameRunning
136136
Process process = processArr[i];
137137
int processId = process.Id;
138138

139-
string? processPath = PInvoke.GetProcessPathByProcessId(processId, ILoggerHelper.GetILogger());
139+
string? processPath = ProcessChecker.GetProcessPathByProcessId(processId, ILoggerHelper.GetILogger());
140140
string expectedProcessPath = Path.Combine(_GameVersion?.GameDirPath ?? "", _GameExecutableName);
141141
if (string.IsNullOrEmpty(processPath) || !expectedProcessPath.Equals(processPath, StringComparison.OrdinalIgnoreCase)
142142
|| process.MainWindowHandle == IntPtr.Zero)

CollapseLauncher/Classes/Helper/WindowUtility.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
using Hi3Helper.SentryHelper;
66
using Hi3Helper.Shared.Region;
77
using Hi3Helper.Win32.FileDialogCOM;
8-
using Hi3Helper.Win32.Native;
98
using Hi3Helper.Win32.Native.Enums;
9+
using Hi3Helper.Win32.Native.LibraryImport;
10+
using Hi3Helper.Win32.Native.ManagedTools;
1011
using Hi3Helper.Win32.Native.Structs;
1112
using Hi3Helper.Win32.Screen;
1213
using Microsoft.Graphics.Display;
@@ -557,7 +558,7 @@ internal static void SetWindowTitlebarIcon(nint smallIconPtr, nint largeIconPtr)
557558
return;
558559
}
559560

560-
PInvoke.SetWindowIcon(CurrentWindowPtr, smallIconPtr, largeIconPtr);
561+
Windowing.SetWindowIcon(CurrentWindowPtr, smallIconPtr, largeIconPtr);
561562
}
562563

563564
#endregion

CollapseLauncher/Classes/Properties/InnerLauncherConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using CollapseLauncher.Pages;
55
using Hi3Helper;
66
using Hi3Helper.Shared.ClassStruct;
7-
using Hi3Helper.Win32.Native;
7+
using Hi3Helper.Win32.Native.LibraryImport;
88
using Microsoft.UI.Text;
99
using Microsoft.UI.Xaml;
1010
using Microsoft.UI.Xaml.Controls;

CollapseLauncher/Classes/RegistryMonitor/RegistryMonitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
using Hi3Helper;
1313
using Hi3Helper.SentryHelper;
14-
using Hi3Helper.Win32.Native;
1514
using Hi3Helper.Win32.Native.Enums;
15+
using Hi3Helper.Win32.Native.LibraryImport;
1616
using Microsoft.Win32;
1717
using System;
1818
using System.ComponentModel;

CollapseLauncher/Classes/RepairManagement/Genshin/Check.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Hi3Helper.Data;
55
using Hi3Helper.EncTool.Parser.AssetIndex;
66
using Hi3Helper.SentryHelper;
7-
using Hi3Helper.Win32.Native;
7+
using Hi3Helper.Win32.Native.ManagedTools;
88
using System;
99
using System.Buffers;
1010
using System.Collections.Concurrent;
@@ -49,7 +49,7 @@ private async Task Check(List<PkgVersionProperties> assetIndex, CancellationToke
4949
try
5050
{
5151
var threadCount = _threadCount;
52-
var isSsd = PInvoke.IsDriveSsd(_gameStreamingAssetsPath, ILoggerHelper.GetILogger());
52+
var isSsd = DriveTypeChecker.IsDriveSsd(_gameStreamingAssetsPath, ILoggerHelper.GetILogger());
5353
if (!isSsd)
5454
{
5555
threadCount = 1;

CollapseLauncher/Classes/RepairManagement/StarRail/Check.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Hi3Helper.Data;
33
using Hi3Helper.SentryHelper;
44
using Hi3Helper.Shared.ClassStruct;
5-
using Hi3Helper.Win32.Native;
5+
using Hi3Helper.Win32.Native.LibraryImport;
66
using System;
77
using System.Collections.Generic;
88
using System.IO;

CollapseLauncher/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
using Hi3Helper.Data;
66
using Hi3Helper.Http.Legacy;
77
using Hi3Helper.Shared.ClassStruct;
8-
using Hi3Helper.Win32.Native;
8+
using Hi3Helper.Win32.Native.LibraryImport;
9+
using Hi3Helper.Win32.Native.ManagedTools;
910
using Hi3Helper.Win32.ShellLinkCOM;
1011
using InnoSetupHelper;
1112
using Microsoft.UI.Dispatching;
@@ -184,7 +185,7 @@ public static void Main(params string[] args)
184185

185186
AppDomain.CurrentDomain.ProcessExit += OnProcessExit!;
186187

187-
InstanceCount = PInvoke.EnumerateInstances(ILoggerHelper.GetILogger());
188+
InstanceCount = ProcessChecker.EnumerateInstances(ILoggerHelper.GetILogger());
188189

189190
AppActivation.Enable();
190191
if (!AppActivation.DecideRedirection())

CollapseLauncher/XAMLs/MainApp/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using Hi3Helper;
1111
using Hi3Helper.SentryHelper;
1212
using Hi3Helper.Shared.Region;
13-
using Hi3Helper.Win32.Native;
13+
using Hi3Helper.Win32.Native.LibraryImport;
1414
using Microsoft.UI.Composition;
1515
using Microsoft.UI.Input;
1616
using Microsoft.UI.Windowing;

CollapseLauncher/XAMLs/MainApp/Pages/CachesPage.xaml.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#if !DISABLEDISCORD
2-
using CollapseLauncher.DiscordPresence;
2+
using CollapseLauncher.DiscordPresence;
33
#endif
4-
using CollapseLauncher.Helper;
5-
using CollapseLauncher.Statics;
6-
using Hi3Helper;
7-
using Hi3Helper.Shared.ClassStruct;
8-
using Hi3Helper.Win32.Native;
9-
using Microsoft.UI.Xaml;
10-
using Microsoft.UI.Xaml.Controls;
11-
using Microsoft.UI.Xaml.Controls.Primitives;
12-
using System;
13-
using System.Threading.Tasks;
14-
using static CollapseLauncher.InnerLauncherConfig;
15-
using static Hi3Helper.Locale;
16-
using static Hi3Helper.Logger;
17-
using static Hi3Helper.Shared.Region.LauncherConfig;
18-
19-
namespace CollapseLauncher.Pages
4+
using CollapseLauncher.Helper;
5+
using CollapseLauncher.Statics;
6+
using Hi3Helper;
7+
using Hi3Helper.Shared.ClassStruct;
8+
using Hi3Helper.Win32.Native.ManagedTools;
9+
using Microsoft.UI.Xaml;
10+
using Microsoft.UI.Xaml.Controls;
11+
using Microsoft.UI.Xaml.Controls.Primitives;
12+
using System;
13+
using System.Threading.Tasks;
14+
using static CollapseLauncher.InnerLauncherConfig;
15+
using static Hi3Helper.Locale;
16+
using static Hi3Helper.Logger;
17+
using static Hi3Helper.Shared.Region.LauncherConfig;
18+
19+
namespace CollapseLauncher.Pages
2020
{
2121
public sealed partial class CachesPage
2222
{
@@ -58,7 +58,7 @@ public async void RunCheckRoutine(object sender, bool isFast, bool isMainButton)
5858

5959
try
6060
{
61-
PInvoke.PreventSleep(ILoggerHelper.GetILogger());
61+
Sleep.PreventSleep(ILoggerHelper.GetILogger());
6262
AddEvent();
6363

6464
bool IsNeedUpdate = await CurrentGameProperty._GameCache.StartCheckRoutine(isFast);
@@ -97,7 +97,7 @@ public async void RunCheckRoutine(object sender, bool isFast, bool isMainButton)
9797
finally
9898
{
9999
RemoveEvent();
100-
PInvoke.RestoreSleep();
100+
Sleep.RestoreSleep();
101101
}
102102
}
103103

@@ -108,7 +108,7 @@ public async void StartCachesUpdate(object sender, RoutedEventArgs e)
108108

109109
try
110110
{
111-
PInvoke.PreventSleep(ILoggerHelper.GetILogger());
111+
Sleep.PreventSleep(ILoggerHelper.GetILogger());
112112
AddEvent();
113113

114114
int assetCount = CurrentGameProperty._GameCache.AssetEntry.Count;
@@ -146,7 +146,7 @@ public async void StartCachesUpdate(object sender, RoutedEventArgs e)
146146
}
147147
finally
148148
{
149-
PInvoke.RestoreSleep();
149+
Sleep.RestoreSleep();
150150
RemoveEvent();
151151
}
152152
}

0 commit comments

Comments
 (0)