diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 994821e599..e224d09da3 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -608,7 +608,7 @@ namespace MaaWpfGui.Main var screencapCostAvg = details["details"]?["avg"]?.ToString() ?? "???"; var screencapCostMax = details["details"]?["max"]?.ToString() ?? "???"; var currentTime = DateTimeOffset.Now.ToString("HH:mm:ss"); - Instances.SettingsViewModel.ScreencapCost = string.Format(LocalizationHelper.GetString("ScreencapCost"), screencapCostMin, screencapCostAvg, screencapCostMax, currentTime); + SettingsViewModel.PerformanceSettings.ScreencapCost = string.Format(LocalizationHelper.GetString("ScreencapCost"), screencapCostMin, screencapCostAvg, screencapCostMax, currentTime); if (!HasPrintedScreencapWarning && int.TryParse(screencapCostAvg, out var screencapCostAvgInt)) { static void AddLog(string message, string color) diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index d81c17627d..c8780abc0c 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -149,6 +149,11 @@ namespace MaaWpfGui.ViewModels.UI /// public static ExternalNotificationSettingsUserControlModel ExternalNotificationSettings { get; } = new(); + /// + /// Gets 性能设置model + /// + public static PerformanceUserControlModel PerformanceSettings { get; } = new(); + #endregion 设置界面Model /// @@ -375,40 +380,6 @@ namespace MaaWpfGui.ViewModels.UI #endregion EasterEggs - #region Performance - - public List GpuOptions => GpuOption.GetGpuOptions(); - - public GpuOption ActiveGpuOption - { - get => GpuOption.GetCurrent(); - set - { - GpuOption.SetCurrent(value); - AskRestartToApplySettings(); - } - } - - public bool AllowDeprecatedGpu - { - get => GpuOption.AllowDeprecatedGpu; - set - { - GpuOption.AllowDeprecatedGpu = value; - NotifyOfPropertyChange(); - } - } - - private string _screencapCost = string.Format(LocalizationHelper.GetString("ScreencapCost"), "---", "---", "---", "---"); - - public string ScreencapCost - { - get => _screencapCost; - set => SetAndNotify(ref _screencapCost, value); - } - - #endregion Performance - #region 开始唤醒 private string _accountName = ConfigurationHelper.GetValue(ConfigurationKeys.AccountName, string.Empty); diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/PerformanceUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/PerformanceUserControlModel.cs new file mode 100644 index 0000000000..3396976eed --- /dev/null +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/PerformanceUserControlModel.cs @@ -0,0 +1,56 @@ +// +// MaaWpfGui - A part of the MaaCoreArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License v3.0 only as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY +// + +#nullable enable +using System.Collections.Generic; +using MaaWpfGui.Helper; +using MaaWpfGui.ViewModels.UI; +using Stylet; + +namespace MaaWpfGui.ViewModels.UserControl.TaskQueue; + +/// +/// 性能设置 +/// +public class PerformanceUserControlModel : PropertyChangedBase +{ + public List GpuOptions => GpuOption.GetGpuOptions(); + + public GpuOption ActiveGpuOption + { + get => GpuOption.GetCurrent(); + set + { + GpuOption.SetCurrent(value); + SettingsViewModel.AskRestartToApplySettings(); + } + } + + public bool AllowDeprecatedGpu + { + get => GpuOption.AllowDeprecatedGpu; + set + { + GpuOption.AllowDeprecatedGpu = value; + NotifyOfPropertyChange(); + } + } + + private string _screencapCost = string.Format(LocalizationHelper.GetString("ScreencapCost"), "---", "---", "---", "---"); + + public string ScreencapCost + { + get => _screencapCost; + set => SetAndNotify(ref _screencapCost, value); + } +} diff --git a/src/MaaWpfGui/Views/UI/SettingsView.xaml b/src/MaaWpfGui/Views/UI/SettingsView.xaml index 061b6728ab..8060ad9d25 100644 --- a/src/MaaWpfGui/Views/UI/SettingsView.xaml +++ b/src/MaaWpfGui/Views/UI/SettingsView.xaml @@ -55,10 +55,11 @@ DataContext="{Binding TimerSettings}" /> - + DataContext="{Binding PerformanceSettings}" + IsEnabled="{Binding DataContext.Idle, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> - + - - - + + + - - + + - + + Grid.Column="1" + Width="240" + Margin="10,5" + HorizontalAlignment="Center" + VerticalAlignment="Center" + ItemsSource="{Binding GpuOptions}" + SelectedValue="{Binding ActiveGpuOption}"> - - + + HorizontalAlignment="Center" + Text="{c:Binding ScreencapCost}" /> diff --git a/src/MaaWpfGui/Views/UserControl/PerformanceUserControl.xaml.cs b/src/MaaWpfGui/Views/UserControl/Settings/PerformanceUserControl.xaml.cs similarity index 95% rename from src/MaaWpfGui/Views/UserControl/PerformanceUserControl.xaml.cs rename to src/MaaWpfGui/Views/UserControl/Settings/PerformanceUserControl.xaml.cs index a78a6a58b9..8d2d41bdfc 100644 --- a/src/MaaWpfGui/Views/UserControl/PerformanceUserControl.xaml.cs +++ b/src/MaaWpfGui/Views/UserControl/Settings/PerformanceUserControl.xaml.cs @@ -11,7 +11,7 @@ // but WITHOUT ANY WARRANTY // -namespace MaaWpfGui.Views.UserControl +namespace MaaWpfGui.Views.UserControl.Settings { /// /// GameSettingsUserControl.xaml 的交互逻辑