mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
rft: WpfGui重构 拆分设置-性能设置 (#11329)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -149,6 +149,11 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
/// </summary>
|
||||
public static ExternalNotificationSettingsUserControlModel ExternalNotificationSettings { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets 性能设置model
|
||||
/// </summary>
|
||||
public static PerformanceUserControlModel PerformanceSettings { get; } = new();
|
||||
|
||||
#endregion 设置界面Model
|
||||
|
||||
/// <summary>
|
||||
@@ -375,40 +380,6 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
#endregion EasterEggs
|
||||
|
||||
#region Performance
|
||||
|
||||
public List<GpuOption> 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);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// <copyright file="PerformanceUserControlModel.cs" company="MaaAssistantArknights">
|
||||
// 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
|
||||
// </copyright>
|
||||
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.ViewModels.UI;
|
||||
using Stylet;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
/// <summary>
|
||||
/// 性能设置
|
||||
/// </summary>
|
||||
public class PerformanceUserControlModel : PropertyChangedBase
|
||||
{
|
||||
public List<GpuOption> 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);
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,11 @@
|
||||
DataContext="{Binding TimerSettings}" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[2]}" />
|
||||
<userControl:PerformanceUserControl
|
||||
<settingsViews:PerformanceUserControl
|
||||
Margin="0,20"
|
||||
HorizontalAlignment="Center"
|
||||
IsEnabled="{Binding Idle}" />
|
||||
DataContext="{Binding PerformanceSettings}"
|
||||
IsEnabled="{Binding DataContext.Idle, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
|
||||
|
||||
<hc:Divider Content="{Binding ListTitle[3]}" />
|
||||
<settingsViews:GameSettingsUserControl
|
||||
|
||||
@@ -1,69 +1,66 @@
|
||||
<UserControl
|
||||
x:Class="MaaWpfGui.Views.UserControl.PerformanceUserControl"
|
||||
x:Name="performanceUserControl"
|
||||
x:Class="MaaWpfGui.Views.UserControl.Settings.PerformanceUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
|
||||
xmlns:constants="clr-namespace:MaaWpfGui.Constants"
|
||||
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:helper="clr-namespace:MaaWpfGui.Helper"
|
||||
xmlns:local="clr-namespace:MaaWpfGui"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
|
||||
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels"
|
||||
xmlns:vm="clr-namespace:MaaWpfGui"
|
||||
d:DataContext="{d:DesignInstance {x:Type ui:SettingsViewModel}}"
|
||||
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels.UserControl.Settings"
|
||||
d:Background="White"
|
||||
d:DataContext="{d:DesignInstance {x:Type viewModels:PerformanceUserControlModel}}"
|
||||
d:DesignWidth="550"
|
||||
mc:Ignorable="d">
|
||||
<Grid
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextBlock Margin="24, 0, 0, 0"
|
||||
Text="{DynamicResource UseGpuForInference}"/>
|
||||
<controls:TextBlock Margin="24,0,0,0" Text="{DynamicResource UseGpuForInference}" />
|
||||
<hc:ComboBox
|
||||
Grid.Column="1"
|
||||
Width="240"
|
||||
Margin="10, 5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding GpuOptions}"
|
||||
SelectedValue="{Binding ActiveGpuOption}"
|
||||
>
|
||||
Grid.Column="1"
|
||||
Width="240"
|
||||
Margin="10,5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding GpuOptions}"
|
||||
SelectedValue="{Binding ActiveGpuOption}">
|
||||
<hc:ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource ComboBoxItemBaseStyle}">
|
||||
<Style BasedOn="{StaticResource ComboBoxItemBaseStyle}" TargetType="ComboBoxItem">
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger >
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsDeprecated}" Value="True"/>
|
||||
<Condition Binding="{Binding DataContext.AllowDeprecatedGpu, RelativeSource={RelativeSource AncestorType=hc:ComboBox}}" Value="False"/>
|
||||
<Condition Binding="{Binding IsDeprecated}" Value="True" />
|
||||
<Condition Binding="{Binding DataContext.AllowDeprecatedGpu, RelativeSource={RelativeSource AncestorType=hc:ComboBox}}" Value="False" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</hc:ComboBox.ItemContainerStyle>
|
||||
</hc:ComboBox>
|
||||
<CheckBox Grid.Row="1" Grid.Column="1" Margin="10, 5" Content="{DynamicResource GpuAllowDeprecated}" IsChecked="{Binding AllowDeprecatedGpu}"/>
|
||||
<CheckBox
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="10,5"
|
||||
Content="{DynamicResource GpuAllowDeprecated}"
|
||||
IsChecked="{Binding AllowDeprecatedGpu}" />
|
||||
<controls:TextBlock
|
||||
Grid.Row="2"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="10"
|
||||
Text="{c:Binding ScreencapCost}"/>
|
||||
HorizontalAlignment="Center"
|
||||
Text="{c:Binding ScreencapCost}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -11,7 +11,7 @@
|
||||
// but WITHOUT ANY WARRANTY
|
||||
// </copyright>
|
||||
|
||||
namespace MaaWpfGui.Views.UserControl
|
||||
namespace MaaWpfGui.Views.UserControl.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// GameSettingsUserControl.xaml 的交互逻辑
|
||||
Reference in New Issue
Block a user