From 43d330fcc769d059bbedc93df7bc91d291f155bf Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Sun, 19 Sep 2021 10:24:20 +0800 Subject: [PATCH] Settings_General_UseOpenGL --- README.en.md | 4 +- README.md | 4 +- src/AboutAppInfoPopup.cs | 10 +- .../Pages/Settings/Settings_General.axaml | 15 +- .../ST.Client.Desktop.Linux.csproj | 5 +- .../LinuxDesktopPlatformServiceImpl.cs | 75 ++----- .../Internals/UnixHelpers.cs | 75 +++++++ .../MacDesktopPlatformServiceImpl.cs | 64 +----- .../Models/Settings/ASFSettings.cs | 33 ---- .../Models/Settings/GameLibrarySettings.cs | 184 ------------------ .../Models/Settings/GeneralSettings.cs | 87 --------- .../Models/Settings/ProxySettings.cs | 77 -------- .../Models/Settings/SettingsHost.cs | 92 --------- .../Models/Settings/SteamAccountSettings.cs | 24 --- .../Models/Settings/SteamSettings.cs | 75 ------- .../Models/Settings/UISettings.cs | 92 --------- .../UI/Resx/AppResources.Designer.cs | 9 + .../UI/Resx/AppResources.resx | 3 + src/ST.Client/Services/IPlatformService.cs | 1 + 19 files changed, 134 insertions(+), 795 deletions(-) create mode 100644 src/ST.Client.Desktop.Mac/Internals/UnixHelpers.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/ASFSettings.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/GameLibrarySettings.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/GeneralSettings.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/ProxySettings.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/SettingsHost.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/SteamAccountSettings.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/SteamSettings.cs delete mode 100644 src/ST.Client.Desktop/Models/Settings/UISettings.cs diff --git a/README.en.md b/README.en.md index 50752cfc1..c25204796 100644 --- a/README.en.md +++ b/README.en.md @@ -126,7 +126,7 @@ OS | Version | Architectures | [Android]: https://support.google.com/android -### iOS / iPadOS +### ~~iOS / iPadOS~~ OS | Version | Architectures | ------------------------------|-------------------------|-------------------| @@ -146,7 +146,7 @@ OS | Version | Architectures | Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/milestones), and feel free to ask questions. ## ⌨️ Development Environment -[Visual Studio 2019 Version 16.11 Or Higher](https://visualstudio.microsoft.com/vs/) Or [JetBrains Rider](https://www.jetbrains.com/rider/) Or ~~[Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/)~~ Or ~~[Visual Studio Code](https://code.visualstudio.com/)~~ +[Visual Studio 2022 Version 17.0 Or Higher](https://visualstudio.microsoft.com/vs/preview/) Or ~~[Visual Studio 2019 Version 16.11 Or Higher](https://visualstudio.microsoft.com/vs/)~~ Or [JetBrains Rider](https://www.jetbrains.com/rider/) Or ~~[Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/)~~ Or ~~[Visual Studio Code](https://code.visualstudio.com/)~~ - Supported Operating Systems - [Windows 10 Version 2004 Or Higher: Home, Professional, Education, and Enterprise (LTSC and S are not supported)](https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements) - [macOS 10.14 Mojave Or Higher](https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2019-system-requirements-mac) diff --git a/README.md b/README.md index 68bc69b1c..279f9c480 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ OS | Version | Architectures | [Android]: https://support.google.com/android -### iOS / iPadOS +### ~~iOS / iPadOS~~ OS | Version | Architectures | ------------------------------|-------------------------|-------------------| @@ -155,7 +155,7 @@ OS | Version | Architectures | 查看这个 [milestones](https://github.com/SteamTools-Team/SteamTools/milestones) 来了解我们下一步的开发计划,并随时提出问题。 ## ⌨️ 开发环境 -[Visual Studio 2019 版本 16.11 或更高版本](https://visualstudio.microsoft.com/zh-hans/vs/) 或 [JetBrains Rider](https://www.jetbrains.com/rider/) 或 ~~[Visual Studio for Mac](https://visualstudio.microsoft.com/zh-hans/vs/mac/)~~ 或 ~~[Visual Studio Code](https://code.visualstudio.com/)~~ +[Visual Studio 2022 版本 17.0 或更高版本](https://visualstudio.microsoft.com/zh-hans/vs/preview/) 或 ~~[Visual Studio 2019 版本 16.11 或更高版本](https://visualstudio.microsoft.com/zh-hans/vs/)~~ 或 [JetBrains Rider](https://www.jetbrains.com/rider/) 或 ~~[Visual Studio for Mac](https://visualstudio.microsoft.com/zh-hans/vs/mac/)~~ 或 ~~[Visual Studio Code](https://code.visualstudio.com/)~~ - 系统要求 - [Windows 10 版本 2004 或更高版本:家庭版、专业版、教育版和企业版(不支持 LTSC 和 Windows 10 S,在较早的操作系统上可能不受支持)](https://docs.microsoft.com/zh-cn/visualstudio/releases/2019/system-requirements) - [macOS 10.14 Mojave 或更高版本](https://docs.microsoft.com/zh-cn/visualstudio/productinfo/vs2019-system-requirements-mac) diff --git a/src/AboutAppInfoPopup.cs b/src/AboutAppInfoPopup.cs index 9cc46759c..02ecf2e14 100644 --- a/src/AboutAppInfoPopup.cs +++ b/src/AboutAppInfoPopup.cs @@ -57,6 +57,7 @@ namespace System.Application.UI if (OperatingSystem2.IsWindows) { var dps = IDesktopPlatformService.Instance; +#pragma warning disable CA1416 // 验证平台兼容性 var productName = dps.WindowsProductName; var major = Environment.OSVersion.Version.Major; var minor = Environment.OSVersion.Version.Minor; @@ -66,10 +67,11 @@ namespace System.Application.UI var servicePack = Environment.OSVersion.ServicePack; if (!string.IsNullOrEmpty(servicePack)) { - b.Append(" "); + b.Append(' '); b.Append(servicePack); } var releaseId = dps.WindowsReleaseIdOrDisplayVersion; +#pragma warning restore CA1416 // 验证平台兼容性 if (!string.IsNullOrWhiteSpace(releaseId)) { b.Append(" ("); @@ -79,7 +81,7 @@ namespace System.Application.UI } else { - b.AppendFormat("{0} {1}", Environment.OSVersion.Version); + b.AppendFormat("{0} {1}", DeviceInfo2.OSName, Environment.OSVersion.Version); } #endif b.AppendLine(); @@ -118,14 +120,14 @@ namespace System.Application.UI b.Append("[clr.ver] "); string? clrVersion; try - { + { clrVersion = typeof(object).Assembly.GetRequiredCustomAttribute().InformationalVersion.Split('+', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); } catch { clrVersion = null; } - b.Append(string.IsNullOrEmpty(clrVersion) ? Environment.Version : (object)clrVersion); + b.Append(string.IsNullOrEmpty(clrVersion) ? Environment.Version : clrVersion); b.AppendLine(); #if __ANDROID__ diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_General.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_General.axaml index cd10a8a5e..e984cdd16 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_General.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_General.axaml @@ -3,6 +3,7 @@ xmlns:vm="clr-namespace:System.Application.UI.ViewModels;assembly=System.Application.SteamTools.Client.Desktop" xmlns:resx="clr-namespace:System.Application.UI.Resx;assembly=System.Application.SteamTools.Client.Desktop" xmlns:ms="clr-namespace:System.Application.Models.Settings;assembly=System.Application.SteamTools.Client.Desktop" + xmlns:sys_os2="clr-namespace:System;assembly=System.OperatingSystem2" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" @@ -69,7 +70,7 @@ - + - + + + + + + + + + + diff --git a/src/ST.Client.Desktop.Linux/ST.Client.Desktop.Linux.csproj b/src/ST.Client.Desktop.Linux/ST.Client.Desktop.Linux.csproj index ab4afa567..b1a9f5309 100644 --- a/src/ST.Client.Desktop.Linux/ST.Client.Desktop.Linux.csproj +++ b/src/ST.Client.Desktop.Linux/ST.Client.Desktop.Linux.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -24,6 +24,9 @@ Properties\InternalsVisibleTo.cs + + Internals + diff --git a/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs b/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs index 81e298591..98d2494b2 100644 --- a/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs +++ b/src/ST.Client.Desktop.Linux/Services/Implementation/LinuxDesktopPlatformServiceImpl.cs @@ -1,6 +1,4 @@ using System.Application.Models; -using System.Application.UI.Resx; -using System.Application.UI.ViewModels; using System.Diagnostics; using System.IO; using System.Net; @@ -12,68 +10,21 @@ namespace System.Application.Services.Implementation { internal sealed partial class LinuxDesktopPlatformServiceImpl : IDesktopPlatformService { + public const string xdg = "xdg-open"; + public const string vi = "vi"; + public const string VSC = "code"; + public void SetResizeMode(IntPtr hWnd, ResizeModeCompat value) { } - async ValueTask IPlatformService.AdminShellAsync(string shell, bool admin) - { - var file = new FileInfo(Path.Combine(IOPath.AppDataDirectory, $@"{(admin ? "sudo" : "")}shell.sh")); - if (file.Exists) - file.Delete(); - var scriptContent = new StringBuilder(); - if (admin) - { - TextBoxWindowViewModel vm = new() - { - Title = AppResources.MacSudoPasswordTips, - InputType = TextBoxWindowViewModel.TextBoxInputType.Password, - Description = $"sudo {shell}", - }; - await TextBoxWindowViewModel.ShowDialogAsync(vm); - if (string.IsNullOrWhiteSpace(vm.Value)) - return; - scriptContent.AppendLine($"echo \"{vm.Value}\" | sudo -S {shell}"); - } - else - { - scriptContent.AppendLine(shell); - } - using (var stream = file.CreateText()) - { - stream.Write(scriptContent); - stream.Flush(); - stream.Close(); - } - using (var p = new Process()) - { - p.StartInfo.FileName = "/bin/bash"; - p.StartInfo.Arguments = $"\"{file.FullName}\""; - p.StartInfo.UseShellExecute = false; - p.StartInfo.RedirectStandardOutput = true; - p.Exited += (object? _, EventArgs _) => - { - if (file.Exists) - file.Delete(); - if (p.ExitCode != 0) - { - ((IPlatformService)this).AdminShell(shell); - } - }; - p.Start(); - var ret = p.StandardOutput.ReadToEnd(); - p.Kill(); - if (file.Exists) - file.Delete(); - } - } + ValueTask IPlatformService.AdminShellAsync(string shell, bool admin) => UnixHelpers.AdminShellAsync(shell, admin); + public string GetCommandLineArgs(Process process) { return string.Empty; } - public const string xdg = "xdg-open"; - public void OpenFolderByDirectoryPath(DirectoryInfo info) { Process2.StartPath(xdg, info.FullName); @@ -85,9 +36,6 @@ namespace System.Application.Services.Implementation Process2.StartPath(xdg, info.DirectoryName); } - public const string vi = "vi"; - const string VSC = "code"; - public string? GetFileName(TextReaderProvider provider) => provider switch { TextReaderProvider.VSCode => VSC, @@ -110,12 +58,12 @@ namespace System.Application.Services.Implementation return Path.Combine(rootPath, "Steam"); } - public string? GetSteamProgramPath() - { - return "/usr/bin/steam"; - } + static readonly Lazy _SteamProgramPath = new(() => string.Format("{0}usr{0}bin{0}steam", Path.DirectorySeparatorChar)); + + public string? GetSteamProgramPath() => _SteamProgramPath.Value; public string GetLastSteamLoginUserName() => string.Empty; + public string? GetRegistryVdfPath() { var value = string.Format( @@ -124,6 +72,7 @@ namespace System.Application.Services.Implementation Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); return value; } + public void SetCurrentUser(string userName) { try @@ -153,7 +102,7 @@ namespace System.Application.Services.Implementation static string GetMachineSecretKey() { - var filePath = "/etc/machine-id"; + var filePath = string.Format("{0}etc{0}machine-id", Path.DirectorySeparatorChar); return File.ReadAllText(filePath); } diff --git a/src/ST.Client.Desktop.Mac/Internals/UnixHelpers.cs b/src/ST.Client.Desktop.Mac/Internals/UnixHelpers.cs new file mode 100644 index 000000000..dbbcafb9e --- /dev/null +++ b/src/ST.Client.Desktop.Mac/Internals/UnixHelpers.cs @@ -0,0 +1,75 @@ +using System.Application.UI.Resx; +using System.Application.UI.ViewModels; +using System.Diagnostics; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +// ReSharper disable once CheckNamespace +namespace System.Application +{ + static class UnixHelpers + { + static readonly Lazy _bin_bash = new(() => string.Format("{0}bin{0}bash", Path.DirectorySeparatorChar)); + + /// + /// /bin/bash + /// + public static string BinBash => _bin_bash.Value; + + public static ValueTask AdminShellAsync(string shell, bool admin) + => AdminShellAsync(shell, admin, 3); + + static async ValueTask AdminShellAsync(string shell, bool admin, sbyte retry_count) + { + if (retry_count <= 0) return; + + var file = new FileInfo(Path.Combine(IOPath.AppDataDirectory, $@"{(admin ? "sudo" : "")}shell.sh")); + + if (file.Exists) + file.Delete(); + var scriptContent = new StringBuilder(); + if (admin) + { + TextBoxWindowViewModel vm = new() + { + Title = AppResources.MacSudoPasswordTips, + InputType = TextBoxWindowViewModel.TextBoxInputType.Password, + Description = $"sudo {shell}", + }; + await TextBoxWindowViewModel.ShowDialogAsync(vm); + if (string.IsNullOrWhiteSpace(vm.Value)) + return; + scriptContent.AppendLine($"echo \"{vm.Value}\" | sudo -S {shell}"); + } + else + { + scriptContent.AppendLine(shell); + } + using (var stream = file.CreateText()) + { + stream.Write(scriptContent); + stream.Flush(); + } + using var p = new Process(); + p.StartInfo.FileName = BinBash; + p.StartInfo.Arguments = $"\"{file.FullName}\""; + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.Exited += async (_, _) => + { + if (file.Exists) + file.Delete(); + if (p.ExitCode != 0) + { + await AdminShellAsync(shell, admin, --retry_count); + } + }; + p.Start(); + var ret = p.StandardOutput.ReadToEnd(); + p.Kill(); + if (file.Exists) + file.Delete(); + } + } +} \ No newline at end of file diff --git a/src/ST.Client.Desktop.Mac/Services/Implementation/MacDesktopPlatformServiceImpl.cs b/src/ST.Client.Desktop.Mac/Services/Implementation/MacDesktopPlatformServiceImpl.cs index 58576d1cd..4473827f7 100644 --- a/src/ST.Client.Desktop.Mac/Services/Implementation/MacDesktopPlatformServiceImpl.cs +++ b/src/ST.Client.Desktop.Mac/Services/Implementation/MacDesktopPlatformServiceImpl.cs @@ -6,8 +6,6 @@ using AppKit; using Foundation; #endif using System.Application.Models; -using System.Application.UI.Resx; -using System.Application.UI.ViewModels; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; @@ -19,6 +17,9 @@ namespace System.Application.Services.Implementation { internal sealed partial class MacDesktopPlatformServiceImpl : IDesktopPlatformService { + public const string TextEdit = "TextEdit"; + public const string VSC = "Visual Studio Code"; + public void SetResizeMode(IntPtr hWnd, ResizeModeCompat value) { } @@ -41,56 +42,7 @@ namespace System.Application.Services.Implementation return ret.Split("\n"); } - async ValueTask IPlatformService.AdminShellAsync(string shell, bool admin) - { - var file = new FileInfo(Path.Combine(IOPath.AppDataDirectory, $@"{(admin ? "sudo" : "")}shell.sh")); - - if (file.Exists) - file.Delete(); - var scriptContent = new StringBuilder(); - if (admin) - { - TextBoxWindowViewModel vm = new() - { - Title = AppResources.MacSudoPasswordTips, - InputType = TextBoxWindowViewModel.TextBoxInputType.Password, - Description = $"sudo {shell}", - }; - await TextBoxWindowViewModel.ShowDialogAsync(vm); - if (string.IsNullOrWhiteSpace(vm.Value)) - return; - scriptContent.AppendLine($"echo \"{vm.Value}\" | sudo -S {shell}"); - } - else - { - scriptContent.AppendLine(shell); - } - using (var stream = file.CreateText()) - { - stream.Write(scriptContent); - stream.Flush(); - stream.Close(); - } - using var p = new Process(); - p.StartInfo.FileName = "/bin/bash"; - p.StartInfo.Arguments = $"\"{file.FullName}\""; - p.StartInfo.UseShellExecute = false; - p.StartInfo.RedirectStandardOutput = true; - p.Exited += (object? _, EventArgs _) => - { - if (file.Exists) - file.Delete(); - if (p.ExitCode != 0) - { - ((IPlatformService)this).AdminShell(shell); - } - }; - p.Start(); - var ret = p.StandardOutput.ReadToEnd(); - p.Kill(); - if (file.Exists) - file.Delete(); - } + ValueTask IPlatformService.AdminShellAsync(string shell, bool admin) => UnixHelpers.AdminShellAsync(shell, admin); public static void OpenFile(string appName, string filePath) => NSWorkspace.SharedWorkspace.OpenFile(filePath, appName); @@ -109,9 +61,6 @@ namespace System.Application.Services.Implementation NSWorkspace.SharedWorkspace.ActivateFileViewer(new[] { new NSUrl(info.FullName, isDir: false) }); } - const string TextEdit = "TextEdit"; - const string VSC = "Visual Studio Code"; - public string? GetFileName(TextReaderProvider provider) => provider switch { TextReaderProvider.VSCode => VSC, @@ -207,7 +156,7 @@ namespace System.Application.Services.Implementation { value = NSString.FromHandle(valueIntPtr) ?? value; } - IOObjectRelease(platformExpert); + _ = IOObjectRelease(platformExpert); } return value; @@ -290,7 +239,8 @@ namespace System.Application.Services.Implementation shellContent.AppendLine($"networksetup -setsecurewebproxy '{item}' '{ip}' {port}"); shellContent.AppendLine($"networksetup -setsecurewebproxystate '{item}' on"); } - else { + else + { shellContent.AppendLine($"networksetup -setwebproxystate '{item}' off"); shellContent.AppendLine($"networksetup -setsecurewebproxystate '{item}' off"); } diff --git a/src/ST.Client.Desktop/Models/Settings/ASFSettings.cs b/src/ST.Client.Desktop/Models/Settings/ASFSettings.cs deleted file mode 100644 index 8210ea3ec..000000000 --- a/src/ST.Client.Desktop/Models/Settings/ASFSettings.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System.Application.Models.Settings -{ - public static class ASFSettings - { - static ASFSettings() - { - } - - /// - /// ASF路径 - /// - public static SerializableProperty ArchiSteamFarmExePath { get; } - = new SerializableProperty(GetKey(), Providers.Local, string.Empty) { AutoSave = true }; - - /// - /// 程序启动时自动运行ASF - /// - public static SerializableProperty AutoRunArchiSteamFarm { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(ASFSettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/GameLibrarySettings.cs b/src/ST.Client.Desktop/Models/Settings/GameLibrarySettings.cs deleted file mode 100644 index 7cb57e1d6..000000000 --- a/src/ST.Client.Desktop/Models/Settings/GameLibrarySettings.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System.Application.Models.Settings -{ - public static class GameLibrarySettings - { - public static readonly Lazy> DefaultIgnoreList = new(new ReadOnlyCollection(new List - { - 5, - 7, - 8, - 90, - 92, - 205, - 211, - 215, - 218, - 310, - 364, - 459, - 480, - 513, - 563, - 564, - 575, - 629, - 635, - 640, - 644, - 740, - 745, - 753, - 760, - 761, - 764, - 765, - 766, - 767, - 1007, - 1213, - 1255, - 1260, - 1273, - 2145, - 2403, - 4270, - 4940, - 8680, - 8710, - 8730, - 8770, - 12250, - 12750, - 13180, - 13260, - 16830, - 16864, - 16865, - 16871, - 16872, - 16879, - 17505, - 17515, - 17525, - 17535, - 17555, - 17575, - 17585, - 17705, - 43110, - 61800, - 61810, - 61820, - 61830, - 104700, - 201700, - 224220, - 232610, - 375350, - 245550, - 254000, - 254020, - 254040, - 259280, - 285050, - 312710, - 314700, - 321040, - 329950, - 331710, - 344750, - 354850, - 368900, - 373110, - 383030, - 385200, - 388870, - 392050, - 392870, - 395980, - 397620, - 399580, - 407730, - 407740, - 407750, - 410590, - 410700, - 416270, - 428430, - 431270, - 432150, - 447880, - 449630, - 457930, - 457940, - 460660, - 461570, - 462370, - 463620, - 473580, - 473620, - 473630, - 473640, - 473650, - 486340, - 488200, - 491250, - 492240, - 496600, - 501690, - 505440, - 509840, - 516230, - 516700, - 524440, - 526790, - 528210, - 533710, - 545950, - 546450, - 559500, - 559940, - 562020, - 576080, - 576440, - 581620, - 592490, - 603770, - 603780, - 605470, - 654310, - 700580 - })); - - /// - /// 隐藏的游戏列表 - /// - public static SerializableProperty> HideGameList { get; } - = new SerializableProperty>(GetKey(), Providers.Local, new Dictionary()) { AutoSave = true }; - - /// - /// 挂时长游戏列表 - /// - public static SerializableProperty> AFKAppList { get; } - = new SerializableProperty>(GetKey(), Providers.Local, new Dictionary()) { AutoSave = true }; - - /// - /// 启用自动挂机 - /// - public static SerializableProperty IsAutoAFKApps { get; } - = new SerializableProperty(GetKey(), Providers.Local, true) { AutoSave = true }; - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(GameLibrarySettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/GeneralSettings.cs b/src/ST.Client.Desktop/Models/Settings/GeneralSettings.cs deleted file mode 100644 index 0ff4709cb..000000000 --- a/src/ST.Client.Desktop/Models/Settings/GeneralSettings.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Application.Services; -using System.Collections.Generic; -using System.Linq; -using System.Properties; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System.Application.Models.Settings -{ - public static class GeneralSettings - { - static GeneralSettings() - { -#if !__MOBILE__ - WindowsStartupAutoRun.ValueChanged += WindowsStartupAutoRun_ValueChanged; - //CreateDesktopShortcut.ValueChanged += CreateDesktopShortcut_ValueChanged; -#endif - } - -#if !__MOBILE__ - private static void WindowsStartupAutoRun_ValueChanged(object? sender, ValueChangedEventArgs e) - { - DI.Get().SetBootAutoStart(e.NewValue, ThisAssembly.AssemblyTrademark); - } - - public static void InitWindowsStartupAutoRun() - { - WindowsStartupAutoRun_ValueChanged(null, new(default, WindowsStartupAutoRun.Value)); - } - - /// - /// 程序是否开机自启动 - /// - public static SerializableProperty WindowsStartupAutoRun { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - ///// - ///// 创建桌面快捷方式 - ///// - //public static SerializableProperty CreateDesktopShortcut { get; } - // = new SerializableProperty(GetKey(), Providers.Roaming, false) { AutoSave = true }; - - /// - /// 程序启动时最小化 - /// - public static SerializableProperty IsStartupAppMinimized { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 是否显示起始页 - /// - public static SerializableProperty IsShowStartPage { get; } - = new SerializableProperty(GetKey(), Providers.Local, true) { AutoSave = true }; - - /// - /// 启用游戏列表本地缓存 - /// - public static SerializableProperty IsSteamAppListLocalCache { get; } - = new SerializableProperty(GetKey(), Providers.Local, true) { AutoSave = true }; -#endif - - /// - /// 自动检查更新 - /// - public static SerializableProperty IsAutoCheckUpdate { get; } - = new SerializableProperty(GetKey(), Providers.Local, true) { AutoSave = true }; - - /// - /// 启用错误日志记录 - /// - public static SerializableProperty IsEnableLogRecord { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 用户设置的文本阅读器提供商,根据平台值不同,值格式为 枚举字符串 或 程序路径 - /// - public static SerializableProperty> TextReaderProvider { get; } - = new SerializableProperty>(GetKey(), Providers.Local, null) { AutoSave = true }; - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(GeneralSettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/ProxySettings.cs b/src/ST.Client.Desktop/Models/Settings/ProxySettings.cs deleted file mode 100644 index 953777f75..000000000 --- a/src/ST.Client.Desktop/Models/Settings/ProxySettings.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Application.Serialization; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net; -using System.Runtime.CompilerServices; - -namespace System.Application.Models.Settings -{ - public static class ProxySettings - { - /// - /// 启用脚本自动检查更新 - /// - public static SerializableProperty IsAutoCheckScriptUpdate { get; } - = new SerializableProperty(GetKey(), Providers.Local, true) { AutoSave = true }; - /// - /// 启用GOG插件代理 - /// - public static SerializableProperty IsProxyGOG { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 启用windows系统代理模式 - /// - public static SerializableProperty EnableWindowsProxy { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 启用代理脚本 - /// - public static SerializableProperty IsEnableScript { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 程序启动时自动启动代理 - /// - public static SerializableProperty ProgramStartupRunProxy { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 是否只针对Steam内置浏览器启用脚本 - /// - public static SerializableProperty IsOnlyWorkSteamBrowser { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// 代理服务启用状态 - /// - public static SerializableProperty> SupportProxyServicesStatus { get; } - = new SerializableProperty>(GetKey(), Providers.Local, new List()); - - /// - /// 系统代理模式端口 - /// - public static SerializableProperty SystemProxyPortId { get; } - = new SerializableProperty(GetKey(), Providers.Local, 26501); - - /// - /// 系统代理模式IP - /// - public static SerializableProperty SystemProxyIp { get; } - = new SerializableProperty(GetKey(), Providers.Local, IPAddress.Loopback.ToString()); - - /// - /// 脚本启用状态 - /// - public static SerializableProperty> ScriptsStatus { get; } - = new SerializableProperty>(GetKey(), Providers.Local, new List()) { AutoSave = true }; - - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(ProxySettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/SettingsHost.cs b/src/ST.Client.Desktop/Models/Settings/SettingsHost.cs deleted file mode 100644 index 81b4d4be1..000000000 --- a/src/ST.Client.Desktop/Models/Settings/SettingsHost.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Application.Services; -using System.Collections.Generic; -using System.IO; -using System.Runtime.CompilerServices; -using System.Text; - -namespace System.Application.Models.Settings -{ - public abstract class SettingsHost - { - private static readonly Dictionary instances = new(); - private readonly Dictionary cachedProperties = new(); - - protected virtual string CategoryName => GetType().Name; - - public const string ConfigName = "Config.mpo"; - - protected SettingsHost() - { - instances[GetType()] = this; - } - - /// - /// 请参阅 缓存在当前实例中获取 - /// 如果没有缓存,根据创建它 - /// - /// - protected SerializableProperty Cache(Func> create, [CallerMemberName] string propertyName = "") where T : notnull - { - var key = CategoryName + "." + propertyName; - - if (cachedProperties.TryGetValue(key, out var obj) && obj is SerializableProperty property1) - return property1; - - var property = create(key); - cachedProperties[key] = property; - - return property; - } - - #region Load / Save - - public static void Load() - { - try - { - Providers.Local.Load(); - } - catch (Exception ex) - { - Log.Error(nameof(SettingsHost), "Config Load", ex); - - File.Delete(Providers.LocalFilePath); - Providers.Local.Load(); - } - - } - - public static void Save() - { - try - { - Providers.Local.Save(); - } - catch (Exception ex) - { - Log.Error(nameof(SettingsHost), "Config Save", ex); - throw; - } - - } - - #endregion - - /// - /// 获取类型的配置对象的唯一实例。 - /// - public static T Instance() where T : SettingsHost, new() - { - return instances.TryGetValue(typeof(T), out var host) ? (T)host : new T(); - } - } - - public static class Providers - { - public static string LocalFilePath => Path.Combine(IOPath.AppDataDirectory, SettingsHost.ConfigName); - - public static ISerializationProvider Local { get; } = new FileSettingsProvider(LocalFilePath); - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/SteamAccountSettings.cs b/src/ST.Client.Desktop/Models/Settings/SteamAccountSettings.cs deleted file mode 100644 index 67b9ed926..000000000 --- a/src/ST.Client.Desktop/Models/Settings/SteamAccountSettings.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System.Application.Models.Settings -{ - public static class SteamAccountSettings - { - /// - /// Steam账号备注字典 - /// - public static SerializableProperty?> AccountRemarks { get; } - = new SerializableProperty?>(GetKey(), Providers.Local, null); - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(GameLibrarySettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/SteamSettings.cs b/src/ST.Client.Desktop/Models/Settings/SteamSettings.cs deleted file mode 100644 index 3b66b3a9e..000000000 --- a/src/ST.Client.Desktop/Models/Settings/SteamSettings.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System.Application.Models.Settings -{ - public static class SteamSettings - { - static SteamSettings() - { - IsRunSteamMinimized.ValueChanged += IsRunSteamMinimized_ValueChanged; - IsRunSteamNoCheckUpdate.ValueChanged += IsRunSteamNoCheckUpdate_ValueChanged; - } - - private static void IsRunSteamNoCheckUpdate_ValueChanged(object sender, ValueChangedEventArgs e) - { - if (e.NewValue) - SteamStratParameter.Value += " -noverifyfiles"; - else - SteamStratParameter.Value = SteamStratParameter.Value.Replace("-noverifyfiles", "").Trim(); - } - - private static void IsRunSteamMinimized_ValueChanged(object sender, ValueChangedEventArgs e) - { - if (e.NewValue) - SteamStratParameter.Value += " -silent"; - else - SteamStratParameter.Value = SteamStratParameter.Value.Replace("-silent", "").Trim(); - } - - /// - /// SteamÆô¶¯²ÎÊý - /// - public static SerializableProperty SteamStratParameter { get; } - = new SerializableProperty(GetKey(), Providers.Local, string.Empty) { AutoSave = true }; - - /// - /// SteamƤ·ô - /// - public static SerializableProperty SteamSkin { get; } - = new SerializableProperty(GetKey(), Providers.Local, string.Empty) { AutoSave = true }; - - /// - /// ×Զ¯ÔËÐÐSteam - /// - public static SerializableProperty IsAutoRunSteam { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// SteamÆô¶¯ʱ×îС»¯µ½ÍÐÅÌ - /// - public static SerializableProperty IsRunSteamMinimized { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// SteamÆô¶¯ʱ²»¼ì²é¸üР- /// - public static SerializableProperty IsRunSteamNoCheckUpdate { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - /// - /// ¼ì²⵽SteamÆô¶¯ʱµ¯³öÏûϢ֪ͨ - /// - public static SerializableProperty IsEnableSteamLaunchNotification { get; } - = new SerializableProperty(GetKey(), Providers.Local, false) { AutoSave = true }; - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(SteamSettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/Models/Settings/UISettings.cs b/src/ST.Client.Desktop/Models/Settings/UISettings.cs deleted file mode 100644 index ef2b4f490..000000000 --- a/src/ST.Client.Desktop/Models/Settings/UISettings.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Application.Serialization; -using System.Application.UI; -using System.Application.UI.ViewModels; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System.Application.Models.Settings -{ - public static class UISettings - { - static UISettings() - { - //Theme.ValueChanged += Theme_ValueChanged; - } - - //private static void Theme_ValueChanged(object sender, ValueChangedEventArgs e) - //{ - // if (e.NewValue != e.OldValue) - // { - // var value = (AppTheme)e.NewValue; - // if (value.IsDefined()) - // { - // AppHelper.Current.Theme = value; - // } - // } - //} - - /// - /// 主题 - /// - public static SerializableProperty Theme { get; } - = new SerializableProperty(GetKey(), Providers.Local, 0) { AutoSave = true }; - - /// - /// 语言 - /// - public static SerializableProperty Language { get; } - = new SerializableProperty(GetKey(), Providers.Local, "") { AutoSave = true }; - -#if !__MOBILE__ - /// - /// 字体 - /// - public static SerializableProperty FontName { get; } - = new SerializableProperty(GetKey(), Providers.Local, "Default") { AutoSave = true }; - - /// - /// 背景图片路径 - /// - public static SerializableProperty BackgroundImagePath { get; } - = new SerializableProperty(GetKey(), Providers.Local, "") { AutoSave = true }; - - /// - /// 主题选择 - /// - public static SerializableProperty ThemeAccent { get; } - = new SerializableProperty(GetKey(), Providers.Local, 0) { AutoSave = true }; - - /// - /// 窗口毛玻璃背景透明度 - /// - public static SerializableProperty AcrylicOpacity { get; } - = new SerializableProperty(GetKey(), Providers.Local, 0.80) { AutoSave = true }; - - /// - /// 库存游戏封面大小 - /// - public static SerializableProperty AppGridSize { get; } - = new SerializableProperty(GetKey(), Providers.Local, 150) { AutoSave = true }; - - /// - /// 所有窗口位置记忆集合 - /// - public static SerializableProperty> WindowSizePositions { get; } - = new SerializableProperty>(GetKey(), Providers.Local, new Dictionary()) { AutoSave = false }; -#endif - - /// - /// 记住不再提示的窗口 - /// - public static SerializableProperty> MessageBoxRememberChooseKeys { get; } - = new SerializableProperty>(GetKey(), Providers.Local, new Dictionary()) { AutoSave = false }; - - private static string GetKey([CallerMemberName] string propertyName = "") - { - return nameof(UISettings) + "." + propertyName; - } - } -} diff --git a/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs b/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs index b51d13500..3774f3afb 100644 --- a/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs +++ b/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs @@ -3303,6 +3303,15 @@ namespace System.Application.UI.Resx { } } + /// + /// 查找类似 使用 OpenGL 渲染 的本地化字符串。 + /// + public static string Settings_General_UseOpenGL { + get { + return ResourceManager.GetString("Settings_General_UseOpenGL", resourceCulture); + } + } + /// /// 查找类似 语言 的本地化字符串。 /// diff --git a/src/ST.Client.Desktop/UI/Resx/AppResources.resx b/src/ST.Client.Desktop/UI/Resx/AppResources.resx index 5a24cbfb5..df3af5dc1 100644 --- a/src/ST.Client.Desktop/UI/Resx/AppResources.resx +++ b/src/ST.Client.Desktop/UI/Resx/AppResources.resx @@ -1601,4 +1601,7 @@ 打分&评价 + + 使用 OpenGL 渲染 + \ No newline at end of file diff --git a/src/ST.Client/Services/IPlatformService.cs b/src/ST.Client/Services/IPlatformService.cs index 09a61a3d8..fcd01f67f 100644 --- a/src/ST.Client/Services/IPlatformService.cs +++ b/src/ST.Client/Services/IPlatformService.cs @@ -11,6 +11,7 @@ namespace System.Application.Services public static IPlatformService Instance => DI.Get(); string[] GetMacNetworksetup() => throw new PlatformNotSupportedException(); + async void AdminShell(string str, bool admin = false) => await AdminShellAsync(str, admin); ValueTask AdminShellAsync(string str, bool admin = false) => throw new PlatformNotSupportedException();