diff --git a/Starward.sln b/Starward.sln index b764bc90c..50ba3a807 100644 --- a/Starward.sln +++ b/Starward.sln @@ -10,40 +10,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starward.Core", "src\Starward.Core\Starward.Core.csproj", "{E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starward", "src\Starward\Starward.csproj", "{CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Starward.Launcher", "src\Starward.Launcher\Starward.Launcher.vcxproj", "{BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starward.Language", "src\Starward.Language\Starward.Language.csproj", "{5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starward", "src\Starward\Starward.csproj", "{220135C7-EED3-4847-9927-55E809797EF8}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug_Package|Any CPU = Debug_Package|Any CPU - Debug_Package|ARM64 = Debug_Package|ARM64 - Debug_Package|x64 = Debug_Package|x64 - Debug_Package|x86 = Debug_Package|x86 Debug|Any CPU = Debug|Any CPU Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release_Package|Any CPU = Release_Package|Any CPU - Release_Package|ARM64 = Release_Package|ARM64 - Release_Package|x64 = Release_Package|x64 - Release_Package|x86 = Release_Package|x86 Release|Any CPU = Release|Any CPU Release|ARM64 = Release|ARM64 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|Any CPU.ActiveCfg = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|Any CPU.Build.0 = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|ARM64.ActiveCfg = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|ARM64.Build.0 = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|x64.ActiveCfg = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|x64.Build.0 = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|x86.ActiveCfg = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug_Package|x86.Build.0 = Debug|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug|Any CPU.Build.0 = Debug|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -52,14 +36,6 @@ Global {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug|x64.Build.0 = Debug|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug|x86.ActiveCfg = Debug|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Debug|x86.Build.0 = Debug|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|Any CPU.ActiveCfg = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|Any CPU.Build.0 = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|ARM64.ActiveCfg = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|ARM64.Build.0 = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|x64.ActiveCfg = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|x64.Build.0 = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|x86.ActiveCfg = Release|Any CPU - {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release_Package|x86.Build.0 = Release|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release|Any CPU.ActiveCfg = Release|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release|Any CPU.Build.0 = Release|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -68,14 +44,22 @@ Global {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release|x64.Build.0 = Release|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release|x86.ActiveCfg = Release|Any CPU {E63D6151-9CB1-4E3F-B74F-F006FDF9AC38}.Release|x86.Build.0 = Release|Any CPU - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|Any CPU.ActiveCfg = Debug|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|Any CPU.Build.0 = Debug|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|ARM64.ActiveCfg = Debug|ARM64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|ARM64.Build.0 = Debug|ARM64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|x64.ActiveCfg = Debug|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|x64.Build.0 = Debug|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|x86.ActiveCfg = Debug|Win32 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug_Package|x86.Build.0 = Debug|Win32 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|Any CPU.ActiveCfg = Debug|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|Any CPU.Build.0 = Debug|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|ARM64.Build.0 = Debug|ARM64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|x64.ActiveCfg = Debug|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|x64.Build.0 = Debug|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|x86.ActiveCfg = Debug|x86 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Debug|x86.Build.0 = Debug|x86 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|Any CPU.ActiveCfg = Release|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|Any CPU.Build.0 = Release|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|ARM64.ActiveCfg = Release|ARM64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|ARM64.Build.0 = Release|ARM64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|x64.ActiveCfg = Release|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|x64.Build.0 = Release|x64 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|x86.ActiveCfg = Release|x86 + {CD1EC7A8-4DA1-4998-9B84-F948AA98CDE3}.Release|x86.Build.0 = Release|x86 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug|Any CPU.ActiveCfg = Debug|x64 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug|Any CPU.Build.0 = Debug|x64 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug|ARM64.ActiveCfg = Debug|ARM64 @@ -84,14 +68,6 @@ Global {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug|x64.Build.0 = Debug|x64 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug|x86.ActiveCfg = Debug|Win32 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Debug|x86.Build.0 = Debug|Win32 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|Any CPU.ActiveCfg = Release|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|Any CPU.Build.0 = Release|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|ARM64.ActiveCfg = Release|ARM64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|ARM64.Build.0 = Release|ARM64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|x64.ActiveCfg = Release|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|x64.Build.0 = Release|x64 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|x86.ActiveCfg = Release|Win32 - {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release_Package|x86.Build.0 = Release|Win32 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release|Any CPU.ActiveCfg = Release|x64 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release|Any CPU.Build.0 = Release|x64 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release|ARM64.ActiveCfg = Release|ARM64 @@ -100,14 +76,6 @@ Global {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release|x64.Build.0 = Release|x64 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release|x86.ActiveCfg = Release|Win32 {BC2FB0E5-F79E-4EA0-8380-73F96ECB6F2E}.Release|x86.Build.0 = Release|Win32 - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|Any CPU.ActiveCfg = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|Any CPU.Build.0 = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|ARM64.ActiveCfg = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|ARM64.Build.0 = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|x64.ActiveCfg = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|x64.Build.0 = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|x86.ActiveCfg = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug_Package|x86.Build.0 = Debug|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -116,14 +84,6 @@ Global {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug|x64.Build.0 = Debug|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug|x86.ActiveCfg = Debug|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Debug|x86.Build.0 = Debug|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|Any CPU.ActiveCfg = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|Any CPU.Build.0 = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|ARM64.ActiveCfg = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|ARM64.Build.0 = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|x64.ActiveCfg = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|x64.Build.0 = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|x86.ActiveCfg = Release|Any CPU - {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release_Package|x86.Build.0 = Release|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release|Any CPU.Build.0 = Release|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release|ARM64.ActiveCfg = Release|Any CPU @@ -132,54 +92,6 @@ Global {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release|x64.Build.0 = Release|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release|x86.ActiveCfg = Release|Any CPU {5FC2380B-F424-4EAE-BDEE-C0D4D4B1C7CF}.Release|x86.Build.0 = Release|Any CPU - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|Any CPU.ActiveCfg = Debug_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|Any CPU.Build.0 = Debug_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|Any CPU.Deploy.0 = Debug_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|ARM64.ActiveCfg = Debug_Package|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|ARM64.Build.0 = Debug_Package|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|ARM64.Deploy.0 = Debug_Package|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|x64.ActiveCfg = Debug_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|x64.Build.0 = Debug_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|x64.Deploy.0 = Debug_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|x86.ActiveCfg = Debug_Package|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|x86.Build.0 = Debug_Package|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug_Package|x86.Deploy.0 = Debug_Package|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|Any CPU.ActiveCfg = Debug|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|Any CPU.Build.0 = Debug|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|Any CPU.Deploy.0 = Debug|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|ARM64.Build.0 = Debug|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|x64.ActiveCfg = Debug|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|x64.Build.0 = Debug|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|x64.Deploy.0 = Debug|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|x86.ActiveCfg = Debug|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|x86.Build.0 = Debug|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Debug|x86.Deploy.0 = Debug|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|Any CPU.ActiveCfg = Release_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|Any CPU.Build.0 = Release_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|Any CPU.Deploy.0 = Release_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|ARM64.ActiveCfg = Release_Package|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|ARM64.Build.0 = Release_Package|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|ARM64.Deploy.0 = Release_Package|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|x64.ActiveCfg = Release_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|x64.Build.0 = Release_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|x64.Deploy.0 = Release_Package|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|x86.ActiveCfg = Release_Package|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|x86.Build.0 = Release_Package|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Release_Package|x86.Deploy.0 = Release_Package|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|Any CPU.ActiveCfg = Release|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|Any CPU.Build.0 = Release|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|Any CPU.Deploy.0 = Release|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|ARM64.ActiveCfg = Release|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|ARM64.Build.0 = Release|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|ARM64.Deploy.0 = Release|ARM64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|x64.ActiveCfg = Release|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|x64.Build.0 = Release|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|x64.Deploy.0 = Release|x64 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|x86.ActiveCfg = Release|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|x86.Build.0 = Release|x86 - {220135C7-EED3-4847-9927-55E809797EF8}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Starward/App.xaml.cs b/src/Starward/App.xaml.cs index 7fb078026..97c141063 100644 --- a/src/Starward/App.xaml.cs +++ b/src/Starward/App.xaml.cs @@ -9,7 +9,6 @@ using System.Globalization; using System.IO; using Vanara.PInvoke; -using Windows.Storage; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -36,15 +35,7 @@ public App() private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) { - string folder; - if (AppConfig.MsixPackaged) - { - folder = Path.Combine(ApplicationData.Current.LocalFolder.Path, "crash"); - } - else - { - folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Starward", "crash"); - } + var folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Starward", "crash"); Directory.CreateDirectory(folder); var file = Path.Combine(folder, $"crash_{DateTime.Now:yyyyMMdd_HHmmss}.txt"); File.WriteAllText(file, e.Exception.ToString()); diff --git a/src/Starward/AppConfig.cs b/src/Starward/AppConfig.cs index eddca8e30..cff80183d 100644 --- a/src/Starward/AppConfig.cs +++ b/src/Starward/AppConfig.cs @@ -24,8 +24,6 @@ using System.Runtime.CompilerServices; using System.Text.Encodings.Web; using System.Text.Json; -using Windows.ApplicationModel; -using Windows.Storage; namespace Starward; @@ -40,8 +38,6 @@ internal static class AppConfig #endif - public static bool MsixPackaged { get; private set; } - public static string? AppVersion { get; private set; } @@ -60,19 +56,8 @@ internal static class AppConfig private static bool reg; - private static readonly ApplicationDataContainer _container; - - - static AppConfig() { - try - { - _ = Package.Current.Id; - MsixPackaged = true; - _container = ApplicationData.Current.LocalSettings; - } - catch { } LoadConfiguration(); } @@ -144,175 +129,88 @@ public static string UserDataFolder private static void LoadConfiguration() { - if (MsixPackaged) + try { - try + AppVersion = typeof(AppConfig).Assembly.GetCustomAttribute()?.InformationalVersion; + var webviewFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Starward\webview"); + Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", webviewFolder, EnvironmentVariableTarget.Process); + + string? baseDir = Path.GetDirectoryName(AppContext.BaseDirectory.TrimEnd('\\')); + string exe = Path.Join(baseDir, "Starward.exe"); + var builder = new ConfigurationBuilder(); + if (File.Exists(exe)) { - var v = Package.Current.Id.Version; - AppVersion = $"{v.Major}.{v.Minor}.{v.Build}"; - Configuration = new ConfigurationBuilder().AddCommandLine(Environment.GetCommandLineArgs()).Build(); - enableConsole = LocalSettingGetValue(nameof(EnableConsole)); - windowSizeMode = LocalSettingGetValue(nameof(WindowSizeMode)); - language = LocalSettingGetValue(nameof(Language)); - string? dir = LocalSettingGetValue(nameof(UserDataFolder)); - if (!string.IsNullOrWhiteSpace(dir)) + string ini = Path.Join(baseDir, "config.ini"); + if (File.Exists(ini)) { - if (Path.IsPathFullyQualified(dir) && Directory.Exists(dir)) - { - userDataFolder = dir; - } + builder.AddIniFile(ini); } - } - catch { } - } - else - { - try - { - AppVersion = typeof(AppConfig).Assembly.GetCustomAttribute()?.InformationalVersion; - var webviewFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Starward\webview"); - Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", webviewFolder, EnvironmentVariableTarget.Process); - - string? baseDir = Path.GetDirectoryName(AppContext.BaseDirectory.TrimEnd('\\')); - string exe = Path.Join(baseDir, "Starward.exe"); - var builder = new ConfigurationBuilder(); - if (File.Exists(exe)) + Configuration = builder.AddCommandLine(Environment.GetCommandLineArgs()).Build(); + enableConsole = Configuration.GetValue(nameof(EnableConsole)); + windowSizeMode = Configuration.GetValue(nameof(WindowSizeMode)); + language = Configuration.GetValue(nameof(Language)); + string? dir = Configuration.GetValue(nameof(UserDataFolder)); + if (!string.IsNullOrWhiteSpace(dir)) { - string ini = Path.Join(baseDir, "config.ini"); - if (File.Exists(ini)) + string folder; + if (Path.IsPathFullyQualified(dir)) { - builder.AddIniFile(ini); + folder = dir; } - Configuration = builder.AddCommandLine(Environment.GetCommandLineArgs()).Build(); - enableConsole = Configuration.GetValue(nameof(EnableConsole)); - windowSizeMode = Configuration.GetValue(nameof(WindowSizeMode)); - language = Configuration.GetValue(nameof(Language)); - string? dir = Configuration.GetValue(nameof(UserDataFolder)); - if (!string.IsNullOrWhiteSpace(dir)) + else { - string folder; - if (Path.IsPathFullyQualified(dir)) - { - folder = dir; - } - else - { - folder = Path.Join(baseDir, dir); - } - if (Directory.Exists(folder)) - { - userDataFolder = Path.GetFullPath(folder); - } + folder = Path.Join(baseDir, dir); } - } - else - { - reg = true; - Configuration = builder.AddCommandLine(Environment.GetCommandLineArgs()).Build(); - enableConsole = Registry.GetValue(REG_KEY_NAME, nameof(EnableConsole), null) is 1; - string? dir = Registry.GetValue(REG_KEY_NAME, nameof(UserDataFolder), null) as string; - if (Directory.Exists(dir)) + if (Directory.Exists(folder)) { - userDataFolder = Path.GetFullPath(dir); + userDataFolder = Path.GetFullPath(folder); } } } - catch - { - Configuration ??= new ConfigurationBuilder().AddCommandLine(Environment.GetCommandLineArgs()).Build(); - } - } - } - - - - private static void SaveConfiguration() - { - if (MsixPackaged) - { - try - { - LocalSettingSetValue(nameof(EnableConsole), EnableConsole); - LocalSettingSetValue(nameof(WindowSizeMode), WindowSizeMode); - LocalSettingSetValue(nameof(Language), Language); - LocalSettingSetValue(nameof(UserDataFolder), UserDataFolder); - } - catch { } - } - else - { - try + else { - if (reg) + reg = true; + Configuration = builder.AddCommandLine(Environment.GetCommandLineArgs()).Build(); + enableConsole = Registry.GetValue(REG_KEY_NAME, nameof(EnableConsole), null) is 1; + string? dir = Registry.GetValue(REG_KEY_NAME, nameof(UserDataFolder), null) as string; + if (Directory.Exists(dir)) { - Registry.SetValue(REG_KEY_NAME, nameof(EnableConsole), EnableConsole ? 1 : 0); - Registry.SetValue(REG_KEY_NAME, nameof(UserDataFolder), UserDataFolder); - } - else - { - string dataFolder = UserDataFolder; - string baseDir = Path.GetDirectoryName(AppContext.BaseDirectory.TrimEnd('\\'))!; - if (dataFolder?.StartsWith(baseDir) ?? false) - { - dataFolder = Path.GetRelativePath(baseDir, dataFolder); - } - File.WriteAllText(Path.Combine(baseDir, "config.ini"), $""" - {nameof(EnableConsole)}={EnableConsole} - {nameof(WindowSizeMode)}={WindowSizeMode} - {nameof(Language)}={Language} - {nameof(UserDataFolder)}={dataFolder} - """); + userDataFolder = Path.GetFullPath(dir); } } - catch { } + } + catch + { + Configuration ??= new ConfigurationBuilder().AddCommandLine(Environment.GetCommandLineArgs()).Build(); } } - - - public static T? LocalSettingGetValue(string key, T? defaultValue = default) + private static void SaveConfiguration() { try { - if (string.IsNullOrWhiteSpace(key)) - { - return defaultValue; - } - var value = _container.Values[key]; - if (value is T t) + if (reg) { - return t; + Registry.SetValue(REG_KEY_NAME, nameof(EnableConsole), EnableConsole ? 1 : 0); + Registry.SetValue(REG_KEY_NAME, nameof(UserDataFolder), UserDataFolder); } - else if (value is string s) + else { - var converter = TypeDescriptor.GetConverter(typeof(T)); - if (converter == null) + string dataFolder = UserDataFolder; + string baseDir = Path.GetDirectoryName(AppContext.BaseDirectory.TrimEnd('\\'))!; + if (dataFolder?.StartsWith(baseDir) ?? false) { - return defaultValue; + dataFolder = Path.GetRelativePath(baseDir, dataFolder); } - return (T?)converter.ConvertFromString(s); + File.WriteAllText(Path.Combine(baseDir, "config.ini"), $""" + {nameof(EnableConsole)}={EnableConsole} + {nameof(WindowSizeMode)}={WindowSizeMode} + {nameof(Language)}={Language} + {nameof(UserDataFolder)}={dataFolder} + """); } - return defaultValue; - } - catch - { - return defaultValue; - } - - } - - - public static void LocalSettingSetValue(string key, T? value) - { - try - { - if (string.IsNullOrWhiteSpace(key)) - { - return; - } - _container.Values[key] = value; } catch { } } @@ -320,7 +218,6 @@ public static void LocalSettingSetValue(string key, T? value) - #endregion @@ -341,15 +238,7 @@ private static void BuildServiceProvider() { if (_serviceProvider == null) { - string logFolder; - if (MsixPackaged) - { - logFolder = Path.Combine(ApplicationData.Current.LocalFolder.Path, "log"); - } - else - { - logFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Starward\log"); - } + var logFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Starward\log"); Directory.CreateDirectory(logFolder); LogFile = Path.Combine(logFolder, $"Starward_{DateTime.Now:yyMMdd_HHmmss}.log"); Log.Logger = new LoggerConfiguration().WriteTo.File(path: LogFile, outputTemplate: "[{Timestamp:HH:mm:ss.fff}] [{Level:u4}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}") diff --git a/src/Starward/Helpers/ProcessHelper.cs b/src/Starward/Helpers/ProcessHelper.cs deleted file mode 100644 index 1254fe1f7..000000000 --- a/src/Starward/Helpers/ProcessHelper.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Security.Principal; -using Windows.ApplicationModel; - -namespace Starward.Helpers; - -internal static class ProcessHelper -{ - - - private static bool? IsAdmin; - - - private static void EnsureIsAdmin() - { - if (IsAdmin is null) - { - using (WindowsIdentity identity = WindowsIdentity.GetCurrent()) - { - WindowsPrincipal principal = new WindowsPrincipal(identity); - IsAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator); - } - } - } - - - - - public static void StartAsAdmin(string? exe = null, string? argument = null) - { - EnsureIsAdmin(); - if (AppConfig.MsixPackaged && !IsAdmin!.Value) - { - if (string.IsNullOrWhiteSpace(exe)) - { - exe = $@"shell:AppsFolder\{Package.Current.Id.FamilyName}!App"; - } - else - { - exe = $@"shell:AppsFolder\{Package.Current.Id.FamilyName}!{exe}"; - } - } - else - { - if (string.IsNullOrWhiteSpace(exe)) - { - exe = Path.Combine(AppContext.BaseDirectory, "Starward.exe"); - } - else - { - exe = Path.Combine(AppContext.BaseDirectory, exe); - } - } - Process.Start(new ProcessStartInfo - { - FileName = exe, - UseShellExecute = true, - Arguments = argument, - Verb = "runas", - }); - } - - - -} diff --git a/src/Starward/Helpers/RegistryHelper.cs b/src/Starward/Helpers/RegistryHelper.cs deleted file mode 100644 index 2d9a29916..000000000 --- a/src/Starward/Helpers/RegistryHelper.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Microsoft.Win32; -using System; -using System.Diagnostics; -using System.Text; - -namespace Starward.Helpers; - -internal static class RegistryHelper -{ - - - - public static void SetValue(params (string keyName, string? valueName, object value, RegistryValueKind valueKind)[] items) - { - if (AppConfig.MsixPackaged) - { - var sb = new StringBuilder(); - foreach ((string keyName, string? valueName, object value, RegistryValueKind valueKind) in items) - { - if (valueKind is RegistryValueKind.Binary && value is byte[] bytes) - { - string base64 = Convert.ToBase64String(bytes); - sb.AppendLine($"[byte[]] $array = [System.Convert]::FromBase64String('{base64}');"); - sb.AppendLine($"Set-ItemProperty -Path '{keyName.Replace("HKEY_CURRENT_USER", "HKCU:")}' -Name '{valueName}' -Value $array;"); - } - if (valueKind is RegistryValueKind.DWord) - { - sb.AppendLine($"Set-ItemProperty -Path '{keyName.Replace("HKEY_CURRENT_USER", "HKCU:")}' -Name '{valueName}' -Value {value};"); - } - if (valueKind is RegistryValueKind.String) - { - sb.AppendLine($"Set-ItemProperty -Path '{keyName.Replace("HKEY_CURRENT_USER", "HKCU:")}' -Name '{valueName}' -Value '{value}';"); - } - } - Process.Start(new ProcessStartInfo - { - FileName = "PowerShell", - CreateNoWindow = true, - WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), - Arguments = sb.ToString(), - })?.WaitForExit(1000); - } - else - { - foreach ((string keyName, string? valueName, object value, RegistryValueKind valueKind) in items) - { - Registry.SetValue(keyName, valueName, value, valueKind); - } - } - } - - - - - - -} diff --git a/src/Starward/Package.appxmanifest b/src/Starward/Package.appxmanifest deleted file mode 100644 index cd1044390..000000000 --- a/src/Starward/Package.appxmanifest +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - Starward - Scighost - Assets\Logo\StoreLogo.png - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Starward/Pages/LauncherPage.xaml.cs b/src/Starward/Pages/LauncherPage.xaml.cs index 6e695e9b5..a69715ec3 100644 --- a/src/Starward/Pages/LauncherPage.xaml.cs +++ b/src/Starward/Pages/LauncherPage.xaml.cs @@ -1174,8 +1174,18 @@ private async Task DownloadGameAsync() if (await dialog.ShowAsync() is ContentDialogResult.Primary) { lang = content.LanguageType; - string argu = $"""{(content.EnableRepairMode ? "repair" : "download")} --biz {gameBiz} --loc "{InstallPath}" --lang {(int)lang} """; - ProcessHelper.StartAsAdmin(null, argu); + var exe = Process.GetCurrentProcess().MainModule?.FileName; + if (!File.Exists(exe)) + { + exe = Path.Combine(AppContext.BaseDirectory, "Starward.exe"); + } + Process.Start(new ProcessStartInfo + { + FileName = exe, + UseShellExecute = true, + Arguments = $"""{(content.EnableRepairMode ? "repair" : "download")} --biz {gameBiz} --loc "{InstallPath}" --lang {(int)lang} """, + Verb = "runas", + }); } } catch (Exception ex) @@ -1213,8 +1223,18 @@ private async Task PreDownloadGameAsync() if (await dialog.ShowAsync() is ContentDialogResult.Primary) { var lang = await _downloadGameService.GetVoiceLanguageAsync(gameBiz, InstallPath); - string argu = $"""download --biz {gameBiz} --loc "{InstallPath}" --lang {(int)lang} """; - ProcessHelper.StartAsAdmin(null, argu); + var exe = Process.GetCurrentProcess().MainModule?.FileName; + if (!File.Exists(exe)) + { + exe = Path.Combine(AppContext.BaseDirectory, "Starward.exe"); + } + Process.Start(new ProcessStartInfo + { + FileName = exe, + UseShellExecute = true, + Arguments = $"""download --biz {gameBiz} --loc "{InstallPath}" --lang {(int)lang} """, + Verb = "runas", + }); } } else @@ -1237,6 +1257,11 @@ private async Task RepairGameAsync() try { var lang = await _downloadGameService.GetVoiceLanguageAsync(gameBiz, InstallPath); + var exe = Process.GetCurrentProcess().MainModule?.FileName; + if (!File.Exists(exe)) + { + exe = Path.Combine(AppContext.BaseDirectory, "Starward.exe"); + } if (gameBiz.ToGame() is GameBiz.GenshinImpact) { var control = new DownloadGameDialog @@ -1261,8 +1286,13 @@ private async Task RepairGameAsync() } lang = control.LanguageType; } - string argu = $"""repair --biz {gameBiz} --loc "{InstallPath}" --lang {(int)lang} """; - ProcessHelper.StartAsAdmin(null, argu); + Process.Start(new ProcessStartInfo + { + FileName = exe, + UseShellExecute = true, + Arguments = $"""repair --biz {gameBiz} --loc "{InstallPath}" --lang {(int)lang} """, + Verb = "runas", + }); } catch (Exception ex) { diff --git a/src/Starward/Pages/MainPage.xaml.cs b/src/Starward/Pages/MainPage.xaml.cs index 0d872ea08..8d36ffadf 100644 --- a/src/Starward/Pages/MainPage.xaml.cs +++ b/src/Starward/Pages/MainPage.xaml.cs @@ -733,7 +733,6 @@ private void UpdateNavigationViewItems() if (CurrentGameBiz.ToGame() is GameBiz.None) { NavigationViewItem_Launcher.Visibility = Visibility.Collapsed; - NavigationViewItem_GameAnnounce.Visibility = Visibility.Collapsed; NavigationViewItem_GameSetting.Visibility = Visibility.Collapsed; NavigationViewItem_Screenshot.Visibility = Visibility.Collapsed; NavigationViewItem_GachaLog.Visibility = Visibility.Collapsed; @@ -743,7 +742,6 @@ private void UpdateNavigationViewItems() else if (CurrentGameBiz.ToGame() is GameBiz.Honkai3rd) { NavigationViewItem_Launcher.Visibility = Visibility.Visible; - NavigationViewItem_GameAnnounce.Visibility = Visibility.Visible; NavigationViewItem_GameSetting.Visibility = Visibility.Visible; NavigationViewItem_Screenshot.Visibility = Visibility.Visible; NavigationViewItem_GachaLog.Visibility = Visibility.Collapsed; @@ -753,7 +751,6 @@ private void UpdateNavigationViewItems() else { NavigationViewItem_Launcher.Visibility = Visibility.Visible; - NavigationViewItem_GameAnnounce.Visibility = Visibility.Visible; NavigationViewItem_GameSetting.Visibility = Visibility.Visible; NavigationViewItem_Screenshot.Visibility = Visibility.Visible; NavigationViewItem_GachaLog.Visibility = Visibility.Visible; diff --git a/src/Starward/Pages/SettingPage.xaml b/src/Starward/Pages/SettingPage.xaml index 25891ad21..4189f89f2 100644 --- a/src/Starward/Pages/SettingPage.xaml +++ b/src/Starward/Pages/SettingPage.xaml @@ -406,15 +406,14 @@ Source="ms-appx:///Assets/logo.png" /> - + + Spacing="4"> - + OnContent="{x:Bind lang:Lang.SettingPage_JoinPreviewReleaseChannel}" /> + diff --git a/src/Starward/Pages/Welcome/SelectDirectoryPage.xaml.cs b/src/Starward/Pages/Welcome/SelectDirectoryPage.xaml.cs index 79c2f841e..e743e1ddd 100644 --- a/src/Starward/Pages/Welcome/SelectDirectoryPage.xaml.cs +++ b/src/Starward/Pages/Welcome/SelectDirectoryPage.xaml.cs @@ -61,7 +61,7 @@ private async Task SelectDirectoryAsync() var exe = Path.Join(parentFolder, "Starward.exe"); string? selectFolder = null; - if (!AppConfig.MsixPackaged && File.Exists(exe)) + if (File.Exists(exe)) { var dialog = new ContentDialog { diff --git a/src/Starward/Properties/PublishProfiles/win10-arm64.pubxml b/src/Starward/Properties/PublishProfiles/win10-arm64.pubxml index fc8abc42b..a7fdd16b6 100644 --- a/src/Starward/Properties/PublishProfiles/win10-arm64.pubxml +++ b/src/Starward/Properties/PublishProfiles/win10-arm64.pubxml @@ -10,11 +10,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121. bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ true False - False - False - True - True + False + True + \ No newline at end of file diff --git a/src/Starward/Properties/PublishProfiles/win10-x64.pubxml b/src/Starward/Properties/PublishProfiles/win10-x64.pubxml index 6f50f2695..26ea7e55c 100644 --- a/src/Starward/Properties/PublishProfiles/win10-x64.pubxml +++ b/src/Starward/Properties/PublishProfiles/win10-x64.pubxml @@ -11,10 +11,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121. true False False - False - True - True - True - partial + True + \ No newline at end of file diff --git a/src/Starward/Properties/PublishProfiles/win10-x86.pubxml b/src/Starward/Properties/PublishProfiles/win10-x86.pubxml index ba99a85a8..34d14d4d4 100644 --- a/src/Starward/Properties/PublishProfiles/win10-x86.pubxml +++ b/src/Starward/Properties/PublishProfiles/win10-x86.pubxml @@ -10,11 +10,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121. bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ true False - False - False - True - True - True - partial + False + True + \ No newline at end of file diff --git a/src/Starward/Properties/launchSettings.json b/src/Starward/Properties/launchSettings.json index 6574d9e3b..707093390 100644 --- a/src/Starward/Properties/launchSettings.json +++ b/src/Starward/Properties/launchSettings.json @@ -1,10 +1,7 @@ -{ +{ "profiles": { - "Starward (Unpackaged)": { + "Starward": { "commandName": "Project" - }, - "Starward (Package)": { - "commandName": "MsixPackage" } } } \ No newline at end of file diff --git a/src/Starward/Services/Cache/CacheBase.cs b/src/Starward/Services/Cache/CacheBase.cs index 68940e93c..fe5c4a6b4 100644 --- a/src/Starward/Services/Cache/CacheBase.cs +++ b/src/Starward/Services/Cache/CacheBase.cs @@ -573,16 +573,9 @@ private async Task ForceInitialiseAsync() if (_baseFolder == null) { - if (AppConfig.MsixPackaged) - { - _baseFolder = ApplicationData.Current.LocalFolder; - } - else - { - var folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Starward"); - Directory.CreateDirectory(folder); - _baseFolder = await StorageFolder.GetFolderFromPathAsync(folder); - } + var folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Starward"); + Directory.CreateDirectory(folder); + _baseFolder = await StorageFolder.GetFolderFromPathAsync(folder); } if (string.IsNullOrWhiteSpace(_cacheFolderName)) diff --git a/src/Starward/Services/DownloadGameService.cs b/src/Starward/Services/DownloadGameService.cs index 9cfd4e943..fa7e698c8 100644 --- a/src/Starward/Services/DownloadGameService.cs +++ b/src/Starward/Services/DownloadGameService.cs @@ -2,7 +2,6 @@ using Microsoft.Win32; using Starward.Core; using Starward.Core.Launcher; -using Starward.Helpers; using Starward.Models; using Starward.Services.Cache; using Starward.SevenZip; @@ -263,7 +262,7 @@ public async Task SetVoiceLanguageAsync(GameBiz biz, string installPath, VoiceLa } if (id != null) { - RegistryHelper.SetValue((key, GameRegistry.GENERAL_DATA_h2389025596, Encoding.UTF8.GetBytes($"{{\"deviceVoiceLanguageType\":{id}}}\0"), RegistryValueKind.Binary)); + Registry.SetValue(key, GameRegistry.GENERAL_DATA_h2389025596, Encoding.UTF8.GetBytes($"{{\"deviceVoiceLanguageType\":{id}}}\0")); } } } diff --git a/src/Starward/Services/GameService.cs b/src/Starward/Services/GameService.cs index 3b762ae8b..3b2c97915 100644 --- a/src/Starward/Services/GameService.cs +++ b/src/Starward/Services/GameService.cs @@ -3,7 +3,6 @@ using Microsoft.Win32; using Starward.Core; using Starward.Core.Gacha; -using Starward.Helpers; using Starward.Models; using System; using System.Collections.Generic; @@ -211,17 +210,14 @@ public void ChangeGameAccount(GameAccount account) 12 or 22 or (>= 32 and <= 36) => GameRegistry.MIHOYOSDK_ADL_PROD_OVERSEA_h1158948810, _ => throw new ArgumentOutOfRangeException($"Unknown region {account.GameBiz}"), }; + Registry.SetValue(key, keyName, account.Value); if (account.GameBiz.ToGame() is GameBiz.StarRail) { - RegistryHelper.SetValue((key, keyName, account.Value, RegistryValueKind.Binary), (key, GameRegistry.App_LastUserID_h2841727341, account.Uid, RegistryValueKind.DWord)); + Registry.SetValue(key, GameRegistry.App_LastUserID_h2841727341, account.Uid); } - else if (account.GameBiz.ToGame() is GameBiz.Honkai3rd) + if (account.GameBiz.ToGame() is GameBiz.Honkai3rd) { - RegistryHelper.SetValue((key, keyName, account.Value, RegistryValueKind.Binary), (key, GameRegistry.GENERAL_DATA_V2_LastLoginUserId_h47158221, account.Uid, RegistryValueKind.DWord)); - } - else - { - RegistryHelper.SetValue((key, keyName, account.Value, RegistryValueKind.Binary)); + Registry.SetValue(key, GameRegistry.GENERAL_DATA_V2_LastLoginUserId_h47158221, account.Uid); } _logger.LogInformation("Change account {name} ({biz}) successfully!", account.Name, account.GameBiz); } @@ -347,7 +343,7 @@ public void SetStarRailFPS(GameBiz biz, int fps) { node["FPS"] = fps; bytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(node)); - RegistryHelper.SetValue((key, GameRegistry.GraphicsSettings_Model_h2986158309, bytes, RegistryValueKind.Binary)); + Registry.SetValue(key, GameRegistry.GraphicsSettings_Model_h2986158309, bytes); } } } @@ -410,21 +406,12 @@ public int UninstallGame(GameBiz gameBiz, string? loc, UninstallStep steps) if (steps.HasFlag(UninstallStep.CleanRegistry)) { _logger.LogInformation("Start to clean registry."); - if (AppConfig.MsixPackaged) - { - string key = gameBiz.GetGameRegistryKey().Replace(@"HKEY_CURRENT_USER", "HKCU:"); - Process.Start(new ProcessStartInfo - { - FileName = "PowerShell", - CreateNoWindow = true, - WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), - Arguments = $"Remove-Item -Path '{key}' -Recurse -Force;", - })?.WaitForExit(); - } - else + string key = gameBiz.GetGameRegistryKey().Replace(@"HKEY_CURRENT_USER\", ""); + Registry.CurrentUser.DeleteSubKeyTree(key, false); + var parent = Registry.CurrentUser.OpenSubKey(Path.GetDirectoryName(key)!); + if (parent != null && parent.SubKeyCount == 0 && parent.ValueCount == 0) { - string key = gameBiz.GetGameRegistryKey().Replace(@"HKEY_CURRENT_USER\", ""); - Registry.CurrentUser.DeleteSubKeyTree(key, false); + Registry.CurrentUser.DeleteSubKey(Path.GetDirectoryName(key)!, false); } _logger.LogInformation("Finished clean registry."); } @@ -436,9 +423,9 @@ public int UninstallGame(GameBiz gameBiz, string? loc, UninstallStep steps) string temp = Path.Join(Path.GetTempPath(), relativePath); string local = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), relativePath); string locallow = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low", relativePath); - DeleteFolder(temp); - DeleteFolder(local); - DeleteFolder(locallow); + DeleteFolderAndParent(temp); + DeleteFolderAndParent(local); + DeleteFolderAndParent(locallow); _logger.LogInformation("Finished deleting temp files."); } @@ -475,26 +462,18 @@ public int UninstallGame(GameBiz gameBiz, string? loc, UninstallStep steps) - void DeleteFolder(string folder) + void DeleteFolderAndParent(string folder) { - if (AppConfig.MsixPackaged) - { - Process.Start(new ProcessStartInfo - { - FileName = "PowerShell", - CreateNoWindow = true, - WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), - Arguments = $"Remove-Item -Path '{folder}' -Recurse -Force;", - })?.WaitForExit(); - } - else + if (Directory.Exists(folder)) { - if (Directory.Exists(folder)) + Directory.Delete(folder, true); + string? parent = Path.GetDirectoryName(folder); + if (Directory.Exists(parent) && Directory.GetDirectories(parent).Length == 0 && Directory.GetFiles(parent).Length == 0) { - Directory.Delete(folder, true); + Directory.Delete(parent, true); } + _logger.LogInformation("Deleted folder {folder}", folder); } - _logger.LogInformation("Deleted folder {folder}", folder); } diff --git a/src/Starward/Services/GameSettingService.cs b/src/Starward/Services/GameSettingService.cs index 742b4ffbd..05e4f5e6a 100644 --- a/src/Starward/Services/GameSettingService.cs +++ b/src/Starward/Services/GameSettingService.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Win32; using Starward.Core; -using Starward.Helpers; using Starward.Models.GameSetting; using System.Text; using System.Text.Json; @@ -89,24 +88,24 @@ public void SetGameResolutionSetting(GameBiz biz, GraphicsSettings_PCResolution_ if (biz.ToGame() is GameBiz.Honkai3rd) { var str = JsonSerializer.Serialize(model) + "\0"; - RegistryHelper.SetValue((keyPath, GENERAL_DATA_V2_ScreenSettingData_h1916288658, Encoding.UTF8.GetBytes(str), RegistryValueKind.Binary), - (keyPath, Screenmanager_Is_Fullscreen_mode_h3981298716, model.IsFullScreen ? 1 : 0, RegistryValueKind.DWord), - (keyPath, Screenmanager_Resolution_Width_h182942802, model.Width, RegistryValueKind.DWord), - (keyPath, Screenmanager_Resolution_Height_h2627697771, model.Height, RegistryValueKind.DWord)); + Registry.SetValue(keyPath, GENERAL_DATA_V2_ScreenSettingData_h1916288658, Encoding.UTF8.GetBytes(str)); + Registry.SetValue(keyPath, Screenmanager_Is_Fullscreen_mode_h3981298716, model.IsFullScreen ? 1 : 0); + Registry.SetValue(keyPath, Screenmanager_Resolution_Width_h182942802, model.Width); + Registry.SetValue(keyPath, Screenmanager_Resolution_Height_h2627697771, model.Height); } if (biz.ToGame() is GameBiz.StarRail) { var str = JsonSerializer.Serialize(model) + "\0"; - RegistryHelper.SetValue((keyPath, GraphicsSettings_PCResolution_h431323223, Encoding.UTF8.GetBytes(str), RegistryValueKind.Binary), - (keyPath, Screenmanager_Fullscreen_mode_h3630240806, model.IsFullScreen ? 1 : 3, RegistryValueKind.DWord), - (keyPath, Screenmanager_Resolution_Width_h182942802, model.Width, RegistryValueKind.DWord), - (keyPath, Screenmanager_Resolution_Height_h2627697771, model.Height, RegistryValueKind.DWord)); + Registry.SetValue(keyPath, GraphicsSettings_PCResolution_h431323223, Encoding.UTF8.GetBytes(str)); + Registry.SetValue(keyPath, Screenmanager_Fullscreen_mode_h3630240806, model.IsFullScreen ? 1 : 3); + Registry.SetValue(keyPath, Screenmanager_Resolution_Width_h182942802, model.Width); + Registry.SetValue(keyPath, Screenmanager_Resolution_Height_h2627697771, model.Height); } if (biz.ToGame() is GameBiz.GenshinImpact) { - RegistryHelper.SetValue((keyPath, Screenmanager_Is_Fullscreen_mode_h3981298716, model.IsFullScreen ? 1 : 0, RegistryValueKind.DWord), - (keyPath, Screenmanager_Resolution_Width_h182942802, model.Width, RegistryValueKind.DWord), - (keyPath, Screenmanager_Resolution_Height_h2627697771, model.Height, RegistryValueKind.DWord)); + Registry.SetValue(keyPath, Screenmanager_Is_Fullscreen_mode_h3981298716, model.IsFullScreen ? 1 : 0); + Registry.SetValue(keyPath, Screenmanager_Resolution_Width_h182942802, model.Width); + Registry.SetValue(keyPath, Screenmanager_Resolution_Height_h2627697771, model.Height); } } @@ -167,11 +166,11 @@ public void SetGameVoiceLanguageSetting(GameBiz biz, int lang) if (node != null) { var str = node.ToJsonString() + "\0"; - RegistryHelper.SetValue((keyPath, GENERAL_DATA_h2389025596, Encoding.UTF8.GetBytes(str), RegistryValueKind.Binary)); + Registry.SetValue(keyPath, GENERAL_DATA_h2389025596, Encoding.UTF8.GetBytes(str)); } else { - RegistryHelper.SetValue((keyPath, GENERAL_DATA_h2389025596, Encoding.UTF8.GetBytes($"{{\"deviceVoiceLanguageType\": {lang}}}\0"), RegistryValueKind.Binary)); + Registry.SetValue(keyPath, GENERAL_DATA_h2389025596, Encoding.UTF8.GetBytes($"{{\"deviceVoiceLanguageType\": {lang}}}\0")); } } if (biz.ToGame() is GameBiz.StarRail) @@ -186,7 +185,7 @@ public void SetGameVoiceLanguageSetting(GameBiz biz, int lang) }; if (!string.IsNullOrWhiteSpace(str)) { - RegistryHelper.SetValue((keyPath, LanguageSettings_LocalAudioLanguage_h882585060, Encoding.UTF8.GetBytes(str), RegistryValueKind.Binary)); + Registry.SetValue(keyPath, LanguageSettings_LocalAudioLanguage_h882585060, Encoding.UTF8.GetBytes(str)); } } } @@ -212,7 +211,7 @@ public void SetGraphicsQualitySetting(GameBiz biz, int value) if (biz.ToGame() is GameBiz.StarRail) { var keyPath = biz.GetGameRegistryKey(); - RegistryHelper.SetValue((keyPath, GraphicsSettings_GraphicsQuality_h523255858, value, RegistryValueKind.DWord)); + Registry.SetValue(keyPath, GraphicsSettings_GraphicsQuality_h523255858, value); } } @@ -242,7 +241,7 @@ public void SetGraphicsSettingModel(GameBiz biz, GraphicsSettings_Model_h2986158 { var keyPath = biz.GetGameRegistryKey(); var str = JsonSerializer.Serialize(model) + "\0"; - RegistryHelper.SetValue((keyPath, GraphicsSettings_Model_h2986158309, Encoding.UTF8.GetBytes(str), RegistryValueKind.Binary)); + Registry.SetValue(keyPath, GraphicsSettings_Model_h2986158309, Encoding.UTF8.GetBytes(str)); } } diff --git a/src/Starward/Services/UpdateService.cs b/src/Starward/Services/UpdateService.cs index 059a494ea..09dc57c73 100644 --- a/src/Starward/Services/UpdateService.cs +++ b/src/Starward/Services/UpdateService.cs @@ -36,11 +36,6 @@ public UpdateService(ILogger logger, HttpClient httpClient, Metad public async Task CheckUpdateAsync(bool disableIgnore = false) { - if (AppConfig.MsixPackaged) - { - _logger.LogInformation("Skip check update for msix packaged."); - return null; - } _logger.LogInformation("Start to check update (Preview: {preview}, Arch: {arch})", AppConfig.EnablePreviewRelease, RuntimeInformation.OSArchitecture); NuGetVersion.TryParse(AppConfig.AppVersion, out var currentVersion); NuGetVersion.TryParse(AppConfig.IgnoreVersion, out var ignoreVersion); diff --git a/src/Starward/Starward.csproj b/src/Starward/Starward.csproj index 52b00ec01..ad10d53b8 100644 --- a/src/Starward/Starward.csproj +++ b/src/Starward/Starward.csproj @@ -2,7 +2,7 @@ WinExe net7.0-windows10.0.22621.0 - 10.0.19043.0 + 10.0.17763.0 Starward enable true @@ -12,37 +12,16 @@ win10-$(Platform).pubxml true true + None + true DISABLE_XAML_GENERATED_MAIN true true true true logo.ico - Debug;Release;Debug_Package;Release_Package - - None - true - - - - embedded - $(DefineConstants);MSIX_PACKAGED - False - True - 54F8A017A9BDFB1646EAD635B02F3F213791C97E - SHA256 - False - True - True - Always - x64|arm64 - 0 - True - - - @@ -82,13 +61,4 @@ - - - - - - - true - -