diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index aa27e21d4b..aa92fe6f61 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1844,6 +1844,7 @@ namespace MaaWpfGui.Main Gacha, ReclamationAlgorithm, ReclamationAlgorithm2, + Custom, } private readonly Dictionary _latestTaskId = []; @@ -2480,6 +2481,20 @@ namespace MaaWpfGui.Main return id != 0 && AsstStart(); } + public bool AsstStartTestLink() + { + var taskParams = new JObject + { + ["task_names"] = new JArray + { + "Stop", + }, + }; + AsstTaskId id = AsstAppendTaskWithEncoding("Custom", taskParams); + _latestTaskId[TaskType.Custom] = id; + return id != 0 && AsstStart(); + } + /// /// 自动抄作业。 /// diff --git a/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs b/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs index e4e9a68a1b..ab51a3f6b0 100644 --- a/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/RecognizerViewModel.cs @@ -820,7 +820,7 @@ namespace MaaWpfGui.ViewModels.UI private BitmapImage? _gachaImage; - public BitmapImage GachaImage + public BitmapImage? GachaImage { get => _gachaImage; set => SetAndNotify(ref _gachaImage, value); diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index fcaad2549b..bcb998cb5b 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -28,6 +28,7 @@ using System.Runtime.InteropServices.ComTypes; using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media.Imaging; using HandyControl.Controls; using HandyControl.Data; using MaaWpfGui.Configuration; @@ -1620,6 +1621,7 @@ namespace MaaWpfGui.ViewModels.UI Instances.TaskQueueViewModel.CustomInfrastPlanIndex--; Instances.TaskQueueViewModel.CustomInfrastPlanIndex++; } + Instances.TaskQueueViewModel.NeedAddCustomInfrastPlanInfo = true; } } @@ -1943,7 +1945,7 @@ namespace MaaWpfGui.ViewModels.UI private ObservableCollection _roguelikeModeList = new(); /// - /// Gets the list of roguelike modes. + /// Gets or sets the list of roguelike modes. /// public ObservableCollection RoguelikeModeList { @@ -1975,7 +1977,6 @@ namespace MaaWpfGui.ViewModels.UI ]; // public List RoguelikeCoreCharList { get; set; } - private string _roguelikeTheme = ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeTheme, "Sarkaz"); /// @@ -2145,7 +2146,6 @@ namespace MaaWpfGui.ViewModels.UI /// public bool RoguelikeOnlyStartWithEliteTwo => _roguelikeOnlyStartWithEliteTwo && RoguelikeStartWithEliteTwo; - private bool _roguelike3FirstFloorFoldartal = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.Roguelike3FirstFloorFoldartal, bool.FalseString)); /// @@ -2198,7 +2198,6 @@ namespace MaaWpfGui.ViewModels.UI /// public bool Roguelike3NewSquad2StartingFoldartal => _roguelike3NewSquad2StartingFoldartal && RoguelikeSquadIsFoldartal; - private string _roguelike3NewSquad2StartingFoldartals = ConfigurationHelper.GetValue(ConfigurationKeys.Roguelike3NewSquad2StartingFoldartals, string.Empty); public string Roguelike3NewSquad2StartingFoldartals @@ -3371,7 +3370,6 @@ namespace MaaWpfGui.ViewModels.UI get => AllVersionTypeList.Where(v => AllowNightlyUpdates || v.Value != UpdateVersionType.Nightly).ToList(); } - public bool AllowNightlyUpdates { get; set; } = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.AllowNightlyUpdates, bool.FalseString)); private bool _hasAcknowledgedNightlyWarning = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.HasAcknowledgedNightlyWarning, bool.FalseString)); @@ -4079,6 +4077,59 @@ namespace MaaWpfGui.ViewModels.UI } } + /// + /// Test Link And Get Image. + /// + // UI 绑定的方法 + // ReSharper disable once UnusedMember.Global + public async void TestLinkAndGetImage() + { + _runningState.SetIdle(false); + + string errMsg = string.Empty; + TestLinkInfo = LocalizationHelper.GetString("ConnectingToEmulator"); + bool caught = await Task.Run(() => Instances.AsstProxy.AsstConnect(ref errMsg)); + if (!caught) + { + TestLinkInfo = errMsg; + _runningState.SetIdle(true); + return; + } + + if (!Instances.AsstProxy.AsstStartTestLink()) + { + return; + } + + var image = Instances.AsstProxy.AsstGetImage(); + TestLinkImage = image; + TestLinkInfo = "Finish"; + } + + private bool _showTestLinkImage = false; + + public bool ShowTestLinkImage + { + get => _showTestLinkImage; + set => SetAndNotify(ref _showTestLinkImage, value); + } + + private BitmapImage? _testLinkImage; + + public BitmapImage? TestLinkImage + { + get => _testLinkImage; + set => SetAndNotify(ref _testLinkImage, value); + } + + private string _testLinkInfo = string.Empty; + + public string TestLinkInfo + { + get => _testLinkInfo; + set => SetAndNotify(ref _testLinkInfo, value); + } + /// /// 标题栏显示模拟器名称和IP端口。 /// diff --git a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml index 68a90207e4..e30bab88bf 100644 --- a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml @@ -162,7 +162,26 @@ hc:TitleElement.TitlePlacement="Left" Text="{Binding MuMuEmulator12Extras.Display}" Visibility="{c:Binding 'ConnectConfig=="MuMuEmulator12"'}" /> +