diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 65e461f3a8..cc760b5bfb 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -299,6 +299,8 @@ namespace MaaWpfGui.Constants public const string ShowWindowBeforeForceScheduledStart = "Timer.ShowWindowBeforeForceScheduledStart"; public const string CustomConfig = "Timer.CustomConfig"; + public const string DebugTaskName = "Debug.TaskName"; + // public const string AnnouncementInfo = "Announcement.AnnouncementInfo";// 已迁移 // public const string DoNotRemindThisAnnouncementAgain = "Announcement.DoNotRemindThisAnnouncementAgain";// 已迁移 // public const string DoNotShowAnnouncement = "Announcement.DoNotShowAnnouncement";// 已迁移 diff --git a/src/MaaWpfGui/Models/TaskSettingVisibilityInfo.cs b/src/MaaWpfGui/Models/TaskSettingVisibilityInfo.cs index f25cfdb2e2..8192b5377d 100644 --- a/src/MaaWpfGui/Models/TaskSettingVisibilityInfo.cs +++ b/src/MaaWpfGui/Models/TaskSettingVisibilityInfo.cs @@ -35,6 +35,7 @@ namespace MaaWpfGui.Models private bool _autoRoguelike; private bool _reclamation; private bool _afterAction; + private bool _custom; public bool WakeUp { get => _wakeUp; set => SetAndNotify(ref _wakeUp, value); } @@ -54,6 +55,8 @@ namespace MaaWpfGui.Models public bool AfterAction { get => _afterAction; set => SetAndNotify(ref _afterAction, value); } + public bool Custom { get => _custom; set => SetAndNotify(ref _custom, value); } + public static TaskSettingVisibilityInfo Current { get; } = new(); public void Set(string taskName, bool enable) @@ -93,6 +96,9 @@ namespace MaaWpfGui.Models case "AfterAction": AfterAction = enable; break; + case "Custom": + Custom = enable; + break; } EnableAdvancedSettings = false; diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index d531b2af39..2266b6d855 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -114,6 +114,11 @@ namespace MaaWpfGui.ViewModels.UI /// public static ReclamationSettingsUserControlModel ReclamationTask => ReclamationSettingsUserControlModel.Instance; + /// + /// Gets 生稀盐酸任务Model + /// + public static CustomSettingsUserControlModel CustomTask => CustomSettingsUserControlModel.Instance; + #endregion 长草任务Model private static readonly IEnumerable TaskViewModelTypes = InitTaskViewModelList(); @@ -652,6 +657,11 @@ namespace MaaWpfGui.ViewModels.UI "Reclamation" ]; + if (Instances.VersionUpdateViewModel.IsDebugVersion() || File.Exists("DEBUG") || File.Exists("DEBUG.txt")) + { + taskList.Add("Custom"); + } + var tempOrderList = new List(new DragItemViewModel[taskList.Count]); var nonOrderList = new List(); for (int i = 0; i != taskList.Count; ++i) @@ -1334,6 +1344,10 @@ namespace MaaWpfGui.ViewModels.UI taskRet &= AppendReclamation(); break; + case "Custom": + taskRet &= AppendCustom(); + break; + default: --count; _logger.Error("Unknown task: " + item.OriginalName); @@ -1741,6 +1755,18 @@ namespace MaaWpfGui.ViewModels.UI return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param); } + private static bool AppendCustom() + { + var taskParams = new JObject + { + ["task_names"] = new JArray + { + CustomTask.TaskName, + }, + }; + return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Custom, AsstTaskType.Custom, taskParams); + } + /// /// Gets a value indicating whether it is initialized. /// diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs new file mode 100644 index 0000000000..b792818964 --- /dev/null +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs @@ -0,0 +1,35 @@ +// +// 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 MaaWpfGui.Constants; +using MaaWpfGui.Helper; + +namespace MaaWpfGui.ViewModels.UserControl.TaskQueue; + +public class CustomSettingsUserControlModel : TaskViewModel +{ + static CustomSettingsUserControlModel() + { + Instance = new(); + } + + public static CustomSettingsUserControlModel Instance { get; } + + private string _taskName = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.DebugTaskName, string.Empty); + + public string TaskName + { + get => _taskName; + set => SetAndNotify(ref _taskName, value); + } +} diff --git a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml index 59c83a4b2e..de5c0e9c5a 100644 --- a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml +++ b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml @@ -311,6 +311,7 @@ + + + + + diff --git a/src/MaaWpfGui/Views/UserControl/TaskQueue/CustomUserControl.xaml.cs b/src/MaaWpfGui/Views/UserControl/TaskQueue/CustomUserControl.xaml.cs new file mode 100644 index 0000000000..51b8abce4d --- /dev/null +++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/CustomUserControl.xaml.cs @@ -0,0 +1,28 @@ +// +// 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 +// + +namespace MaaWpfGui.Views.UserControl.TaskQueue; + +/// +/// CustomUserControl.xaml 的交互逻辑 +/// +public partial class CustomUserControl : System.Windows.Controls.UserControl +{ + /// + /// Initializes a new instance of the class. + /// + public CustomUserControl() + { + InitializeComponent(); + } +}