diff --git a/CI.cmd b/CI.cmd index e6a22a1..29d87db 100644 --- a/CI.cmd +++ b/CI.cmd @@ -3,10 +3,13 @@ SET VS2022=%PROGRAMFILES%\Microsoft Visual Studio\2022\Community SET MSBUILD=%VS2022%\Msbuild\Current\Bin\MSBuild.exe +"%MSBUILD%" -t:Build -p:Configuration=Release,Platform=x64 Flint\Flint.vcxproj +Robocopy Flint\x64\Release Qwilight\Assets\x64 Flint.exe +"%MSBUILD%" -t:Build -p:Configuration=Release,Platform=ARM64 Flint\Flint.vcxproj +Robocopy Flint\ARM64\Release Qwilight\Assets\ARM64 Flint.exe + "%MSBUILD%" -t:Build -p:Configuration=Release,Platform=x64 Igniter\Igniter.csproj Robocopy Igniter\bin\x64\Release Qwilight\Assets\x64 Igniter.exe -"%MSBUILD%" -t:Build -p:Configuration=Release,Platform=ARM64 Igniter\Igniter.csproj -Robocopy Igniter\bin\ARM64\Release Qwilight\Assets\ARM64 Igniter.exe "%MSBUILD%" -t:Build -p:Configuration=Release,Platform=x64 NVIDIA\NVIDIA.vcxproj Robocopy NVIDIA\x64\Release Qwilight\Assets\x64 NVIDIA.dll diff --git a/Flint/Flint.cpp b/Flint/Flint.cpp new file mode 100644 index 0000000..ff5c523 --- /dev/null +++ b/Flint/Flint.cpp @@ -0,0 +1,23 @@ +#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING + +#include +#include +#include + +#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") + +using namespace std; + +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) +{ + SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + const auto handle = CreateFileW(L"//./pipe/Qwilight", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (handle == INVALID_HANDLE_VALUE) { + MessageBoxW(NULL, L"Cannot find Qwilight", L"Qwilight", MB_ICONWARNING); + } + else { + const auto lpBuffer = wstring_convert>().to_bytes(wstring(lpCmdLine).c_str()); + WriteFile(handle, lpBuffer.c_str(), (DWORD)lpBuffer.length(), NULL, NULL); + CloseHandle(handle); + } +} \ No newline at end of file diff --git a/Flint/Flint.ico b/Flint/Flint.ico new file mode 100644 index 0000000..6761de8 --- /dev/null +++ b/Flint/Flint.ico Binary files differ diff --git a/Flint/Flint.rc b/Flint/Flint.rc new file mode 100644 index 0000000..b384219 --- /dev/null +++ b/Flint/Flint.rc Binary files differ diff --git a/Flint/Flint.vcxproj b/Flint/Flint.vcxproj new file mode 100644 index 0000000..e004bc0 --- /dev/null +++ b/Flint/Flint.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + ARM64 + + + Debug + x64 + + + Release + ARM64 + + + Release + x64 + + + + 16.0 + Win32Proj + {b884fba6-70f9-49a1-9a87-1bc08a7b769c} + Flint + 10.0 + + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + + + true + $(Platform)\$(Configuration)\ + + + true + $(Platform)\$(Configuration)\ + + + false + $(Platform)\$(Configuration)\ + + + false + $(Platform)\$(Configuration)\ + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + stdcpp20 + stdc17 + + + Windows + true + + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + stdcpp20 + stdc17 + + + Windows + true + MachineARM64 + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + stdcpp20 + stdc17 + + + Windows + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + stdcpp20 + stdc17 + + + Windows + true + true + true + MachineARM64 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flint/resource.h b/Flint/resource.h new file mode 100644 index 0000000..2bf4d0e --- /dev/null +++ b/Flint/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++���� ������ ���� �����Դϴ�. +// Flint.rc���� ���ǰ� �ֽ��ϴ�. +// +#define IDI_ICON1 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Qwilight.sln b/Qwilight.sln index 68f271e..fced342 100644 --- a/Qwilight.sln +++ b/Qwilight.sln @@ -30,6 +30,8 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protobuf", "Protobuf\Protobuf.csproj", "{3CE3D6F4-0F04-495E-ACE8-B77F1811C594}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Flint", "Flint\Flint.vcxproj", "{B884FBA6-70F9-49A1-9A87-1BC08A7B769C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -120,6 +122,14 @@ {3CE3D6F4-0F04-495E-ACE8-B77F1811C594}.Release|ARM64.Build.0 = Release|ARM64 {3CE3D6F4-0F04-495E-ACE8-B77F1811C594}.Release|x64.ActiveCfg = Release|x64 {3CE3D6F4-0F04-495E-ACE8-B77F1811C594}.Release|x64.Build.0 = Release|x64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Debug|ARM64.Build.0 = Debug|ARM64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Debug|x64.ActiveCfg = Debug|x64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Debug|x64.Build.0 = Debug|x64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Release|ARM64.ActiveCfg = Release|ARM64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Release|ARM64.Build.0 = Release|ARM64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Release|x64.ActiveCfg = Release|x64 + {B884FBA6-70F9-49A1-9A87-1BC08A7B769C}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Qwilight/Qwilight.csproj b/Qwilight/Qwilight.csproj index 02c51f9..28299fd 100644 --- a/Qwilight/Qwilight.csproj +++ b/Qwilight/Qwilight.csproj @@ -216,32 +216,11 @@ - - Always - - + Always - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always + + Always Always @@ -270,6 +249,9 @@ Always + + Always + Always diff --git a/Qwilight/System/FlintSystem.cs b/Qwilight/System/FlintSystem.cs index 3040be8..0b06506 100644 --- a/Qwilight/System/FlintSystem.cs +++ b/Qwilight/System/FlintSystem.cs @@ -47,10 +47,6 @@ } }); } - catch (IOException) - { - return; - } catch { } diff --git a/Qwilight/View/QwilightClass.xaml.cs b/Qwilight/View/QwilightClass.xaml.cs index 6cb99b6..0665839 100644 --- a/Qwilight/View/QwilightClass.xaml.cs +++ b/Qwilight/View/QwilightClass.xaml.cs @@ -1,5 +1,4 @@ -using CommandLine; -using Ionic.Zip; +using Ionic.Zip; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.Win32; @@ -8,7 +7,6 @@ using System.ComponentModel; using System.Diagnostics; using System.IO; -using System.IO.Pipes; using System.Runtime; using System.Runtime.InteropServices; using System.Text; @@ -23,95 +21,69 @@ { public sealed partial class QwilightClass { - static SplashScreen _wpfLoadingAsset; + static SplashScreen _wpfLoadingAsset = new("Assets/Drawing/Loading.png"); [STAThread] static void Main(string[] args) { - if (args.Length > 0) + #region COMPATIBLE + Compatible.Compatible.Qwilight(QwilightComponent.QwilightEntryPath); + #endregion + + if (Utility.HasInput(VirtualKey.LeftShift)) { - Parser.Default.ParseArguments(args) - .WithParsed(async o => - { - using var ss = new NamedPipeClientStream(".", "Qwilight", PipeDirection.Out); - try - { - await ss.ConnectAsync(0).ConfigureAwait(false); - await ss.WriteAsync(Encoding.UTF8.GetBytes(string.Join(' ', args))).ConfigureAwait(false); - } - catch (TimeoutException) - { - } - }) - .WithNotParsed(Main); - } - else - { - Main(Enumerable.Empty()); + PInvoke.AllocConsole(); } - void Main(IEnumerable e) + GPUConfigure.Instance.Load(); + switch (GPUConfigure.Instance.GPUModeValue) { - #region COMPATIBLE - Compatible.Compatible.Qwilight(QwilightComponent.QwilightEntryPath); - #endregion - - if (Utility.HasInput(VirtualKey.LeftShift)) - { - PInvoke.AllocConsole(); - } - - GPUConfigure.Instance.Load(); - switch (GPUConfigure.Instance.GPUModeValue) - { - case GPUConfigure.GPUMode.NVIDIA: - NativeLibrary.TryLoad("nvapi64", out _); - break; - } - _wpfLoadingAsset = new("Assets/Drawing/Loading.png"); - _wpfLoadingAsset.Show(true, true); + case GPUConfigure.GPUMode.NVIDIA: + NativeLibrary.TryLoad("nvapi64", out _); + break; + } + _wpfLoadingAsset.Show(true, true); #if DEBUG Environment.SetEnvironmentVariable("ENABLE_XAML_DIAGNOSTICS_SOURCE_INFO", "1"); #endif - Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", QwilightComponent.EdgeEntryPath); + Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", QwilightComponent.EdgeEntryPath); - ProfileOptimization.SetProfileRoot(QwilightComponent.QwilightEntryPath); - ProfileOptimization.StartProfile("Qwilight.$"); + ProfileOptimization.SetProfileRoot(QwilightComponent.QwilightEntryPath); + ProfileOptimization.StartProfile("Qwilight.$"); + try + { + using (var r = Registry.LocalMachine.OpenSubKey("SOFTWARE")?.OpenSubKey("WOW6432Node")?.OpenSubKey("Microsoft")?.OpenSubKey("EdgeUpdate")?.OpenSubKey("Clients")?.OpenSubKey("{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}")) + { + if (string.IsNullOrEmpty(r?.GetValue("pv") as string)) + { + using var exe = Process.Start(Path.Combine(QwilightComponent.AssetsEntryPath, "MicrosoftEdgeWebview2Setup.exe")); + exe.WaitForExit(); + } + } + } + catch + { + } + + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + _ = PInvoke.timeBeginPeriod(1); + ThreadPool.GetMaxThreads(out var tw, out var tIOCP); + ThreadPool.SetMinThreads(tw, tIOCP); + + Application.Start(p => + { + SynchronizationContext.SetSynchronizationContext(new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread())); try { - using (var r = Registry.LocalMachine.OpenSubKey("SOFTWARE")?.OpenSubKey("WOW6432Node")?.OpenSubKey("Microsoft")?.OpenSubKey("EdgeUpdate")?.OpenSubKey("Clients")?.OpenSubKey("{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}")) - { - if (string.IsNullOrEmpty(r?.GetValue("pv") as string)) - { - using var exe = Process.Start(Path.Combine(QwilightComponent.AssetsEntryPath, "MicrosoftEdgeWebview2Setup.exe")); - exe.WaitForExit(); - } - } + new QwilightClass().Run(); } - catch + finally { + Application.Current.Exit(); } - - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - _ = PInvoke.timeBeginPeriod(1); - ThreadPool.GetMaxThreads(out var tw, out var tIOCP); - ThreadPool.SetMinThreads(tw, tIOCP); - - Application.Start(p => - { - SynchronizationContext.SetSynchronizationContext(new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread())); - try - { - new QwilightClass().Run(); - } - finally - { - Application.Current.Exit(); - } - }); - } + }); } readonly ConcurrentDictionary _handledFaultMap = new(); diff --git a/Qwilight/ViewModel/NoteFileViewModel.cs b/Qwilight/ViewModel/NoteFileViewModel.cs index 1981995..05d70d6 100644 --- a/Qwilight/ViewModel/NoteFileViewModel.cs +++ b/Qwilight/ViewModel/NoteFileViewModel.cs @@ -84,7 +84,7 @@ { try { - var qwilightFilePath = Path.Combine(AppContext.BaseDirectory, "Qwilight.exe"); + var flintFilePath = Path.Combine(QwilightComponent.CPUAssetsEntryPath, "Flint.exe"); var noteFilePath = noteFile.NoteFilePath; if (QwilightComponent.BMSNoteFileFormats.Any(format => noteFilePath.IsTailCaselsss(format))) { @@ -113,22 +113,20 @@ var bmscFilePath = Path.Combine(Path.GetDirectoryName(Configure.Instance.BMSEditorFilePath), "iBMSC.Settings.xml"); if (File.Exists(bmseViewerFilePath) && File.Exists(bmseFilePath)) { - var bmseViewerText = (await File.ReadAllTextAsync(bmseViewerFilePath, Encoding.ASCII).ConfigureAwait(false)).Trim(Environment.NewLine.ToCharArray()) + Environment.NewLine; - var bmseViewerData = bmseViewerText.Split(Environment.NewLine).ToList(); - if (!bmseViewerData.Any(line => line == qwilightFilePath)) - { - var data = $""" - - + var bmseViewerData = (await File.ReadAllTextAsync(bmseViewerFilePath, Encoding.ASCII).ConfigureAwait(false)).Trim(Environment.NewLine.ToCharArray()).Split(Environment.NewLine).ToList(); + bmseViewerData.AddRange(Enumerable.Repeat(string.Empty, 6 - bmseViewerData.Count % 6)); + var data = $""" Qwilight -{qwilightFilePath} +{flintFilePath} -P -N0 -P -N -S """; + if (!bmseViewerData.Contains(flintFilePath)) + { bmseViewerData.AddRange(data.Split(Environment.NewLine)); - await File.WriteAllTextAsync(bmseViewerFilePath, bmseViewerText + data, Encoding.UTF8).ConfigureAwait(false); + await File.WriteAllTextAsync(bmseViewerFilePath, string.Join(Environment.NewLine, bmseViewerData) + Environment.NewLine, Encoding.UTF8).ConfigureAwait(false); } var bmseCompiler = new FileIniDataParser(); @@ -136,14 +134,10 @@ using (var sr = File.OpenText(bmseFilePath)) { bmse = bmseCompiler.ReadData(sr); - var flintID = (bmseViewerData.IndexOf(qwilightFilePath) / 6).ToString(); - if (bmse["View"]["ViewerNum"] != flintID) - { - bmse["View"]["ViewerNum"] = flintID; - } + bmse["View"]["ViewerNum"] = (bmseViewerData.IndexOf(flintFilePath) / 6).ToString(); } - using (var fw = File.Open(bmscFilePath, FileMode.Create)) - using (var sw = new StreamWriter(fw, Encoding.UTF8)) + using (var fw = File.Open(bmseFilePath, FileMode.Create)) + using (var sw = new StreamWriter(fw, new UTF8Encoding(false))) { bmseCompiler.WriteData(sw, bmse); } @@ -155,13 +149,13 @@ bmscCompiler.LoadXml(await File.ReadAllTextAsync(bmscFilePath).ConfigureAwait(false)); var nodesViewer = bmscCompiler.SelectNodes("/iBMSC/Player/Player").Cast().ToList(); - var flintID = nodesViewer.FindIndex(node => Utility.EqualsCaseless(node.Attributes["Path"].Value, qwilightFilePath)); + var flintID = nodesViewer.FindIndex(node => Utility.EqualsCaseless(node.Attributes["Path"].Value, flintFilePath)); if (flintID == -1) { flintID = nodesViewer.Count; var flintViewer = bmscCompiler.CreateElement("Player"); flintViewer.SetAttribute("Index", flintID.ToString()); - flintViewer.SetAttribute("Path", qwilightFilePath); + flintViewer.SetAttribute("Path", flintFilePath); flintViewer.SetAttribute("FromBeginning", "-P -N0 \"\""); flintViewer.SetAttribute("FromHere", "-P -N \"\""); flintViewer.SetAttribute("Stop", "-S"); @@ -220,11 +214,11 @@ bms1 = bms1Compiler.ReadData(sr); var targetViewer = bms1["ExternalViewer"]; var targetViewerID = Utility.ToInt32(targetViewer["ViewerCount"]); - qwilightFilePath = qwilightFilePath.Replace(@"\", @"\\"); - if (!Enumerable.Range(0, targetViewerID).Any(i => targetViewer[$@"Viewer{i}\Path"] == qwilightFilePath)) + flintFilePath = flintFilePath.Replace(@"\", @"\\"); + if (!Enumerable.Range(0, targetViewerID).Any(i => targetViewer[$@"Viewer{i}\Path"] == flintFilePath)) { targetViewer[$@"Viewer{targetViewerID}\Name"] = "Qwilight"; - targetViewer[$@"Viewer{targetViewerID}\Path"] = qwilightFilePath; + targetViewer[$@"Viewer{targetViewerID}\Path"] = flintFilePath; targetViewer[$@"Viewer{targetViewerID}\Icon"] = ""; targetViewer[$@"Viewer{targetViewerID}\ArgumentPlayLevy"] = "-P -N0 $(filename)"; targetViewer[$@"Viewer{targetViewerID}\ArgumentPlayHere"] = "-P -N$(measure) $(filename)";