feat: 添加自定义任务,仅在 debug 模式下可见入口

fix #7407
This commit is contained in:
uye
2025-04-06 18:49:42 +08:00
parent 53b0d56209
commit 977cd6c9b6
7 changed files with 117 additions and 0 deletions

View File

@@ -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";// 已迁移

View File

@@ -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;

View File

@@ -114,6 +114,11 @@ namespace MaaWpfGui.ViewModels.UI
/// </summary>
public static ReclamationSettingsUserControlModel ReclamationTask => ReclamationSettingsUserControlModel.Instance;
/// <summary>
/// Gets 生稀盐酸任务Model
/// </summary>
public static CustomSettingsUserControlModel CustomTask => CustomSettingsUserControlModel.Instance;
#endregion Model
private static readonly IEnumerable<TaskViewModel> 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<DragItemViewModel>(new DragItemViewModel[taskList.Count]);
var nonOrderList = new List<DragItemViewModel>();
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);
}
/// <summary>
/// Gets a value indicating whether it is initialized.
/// </summary>

View File

@@ -0,0 +1,35 @@
// <copyright file="ReclamationSettingsUserControlModel.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 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);
}
}

View File

@@ -311,6 +311,7 @@
<taskQueue:RoguelikeSettingsUserControl DataContext="{Binding RoguelikeTask}" Visibility="{c:Binding DataContext.TaskSettingVisibilities.AutoRoguelike, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
<taskQueue:ReclamationSettingsUserControl DataContext="{Binding ReclamationTask}" Visibility="{c:Binding DataContext.TaskSettingVisibilities.Reclamation, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
<taskQueue:PostActionUserControl DataContext="{Binding PostActionSetting}" Visibility="{c:Binding DataContext.TaskSettingVisibilities.AfterAction, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
<taskQueue:CustomUserControl DataContext="{Binding CustomTask}" Visibility="{c:Binding DataContext.TaskSettingVisibilities.Custom, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
</hc:SimpleStackPanel>
</hc:ScrollViewer>
<hc:ButtonGroup

View File

@@ -0,0 +1,19 @@
<UserControl
x:Class="MaaWpfGui.Views.UserControl.TaskQueue.CustomUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:taskQueue="clr-namespace:MaaWpfGui.ViewModels.UserControl.TaskQueue"
MaxWidth="220"
d:Background="White"
d:DataContext="{d:DesignInstance {x:Type taskQueue:CustomSettingsUserControlModel}}"
d:DesignWidth="220"
s:View.ActionTarget="{Binding}"
mc:Ignorable="d">
<StackPanel>
<TextBox hc:TitleElement.Title="Task Name" Text="{Binding TaskName}" />
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,28 @@
// <copyright file="CustomUserControl.xaml.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>
namespace MaaWpfGui.Views.UserControl.TaskQueue;
/// <summary>
/// CustomUserControl.xaml 的交互逻辑
/// </summary>
public partial class CustomUserControl : System.Windows.Controls.UserControl
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomUserControl"/> class.
/// </summary>
public CustomUserControl()
{
InitializeComponent();
}
}