mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
rft: Wpf CustomTask序列化 (#12264)
This commit is contained in:
@@ -2208,19 +2208,12 @@ namespace MaaWpfGui.Main
|
||||
|
||||
public bool AsstStartGacha(bool once = true)
|
||||
{
|
||||
var taskParams = new JObject
|
||||
var task = new AsstCustomTask()
|
||||
{
|
||||
["task_names"] = new JArray
|
||||
{
|
||||
once ? "GachaOnce" : "GachaTenTimes",
|
||||
|
||||
// TEST
|
||||
// "Block",
|
||||
},
|
||||
CustomTasks = [once ? "GachaOnce" : "GachaTenTimes"],
|
||||
};
|
||||
AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.Custom, taskParams);
|
||||
_taskStatus.Add(id, TaskType.Gacha);
|
||||
return id != 0 && AsstStart();
|
||||
var (type, param) = task.Serialize();
|
||||
return AsstAppendTaskWithEncoding(TaskType.Gacha, type, param) && AsstStart();
|
||||
}
|
||||
|
||||
public bool AsstStartVideoRec(string filename)
|
||||
|
||||
30
src/MaaWpfGui/Models/AsstTasks/AsstCustomTask.cs
Normal file
30
src/MaaWpfGui/Models/AsstTasks/AsstCustomTask.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
// <copyright file="AsstCustomTask.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.Services;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MaaWpfGui.Models.AsstTasks;
|
||||
|
||||
public class AsstCustomTask : AsstBaseTask
|
||||
{
|
||||
public override AsstTaskType TaskType => AsstTaskType.Custom;
|
||||
|
||||
[JsonProperty("task_names")]
|
||||
public List<string> CustomTasks { get; set; } = [];
|
||||
|
||||
public override (AsstTaskType TaskType, JObject Params) Serialize() => (AsstTaskType.Custom, JObject.FromObject(this));
|
||||
}
|
||||
@@ -1347,8 +1347,11 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
break;
|
||||
|
||||
case "Custom":
|
||||
taskRet &= AppendCustom();
|
||||
break;
|
||||
{
|
||||
var (type, param) = CustomTask.Serialize();
|
||||
taskRet &= Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
--count;
|
||||
@@ -1757,18 +1760,6 @@ 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>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// <copyright file="ReclamationSettingsUserControlModel.cs" company="MaaAssistantArknights">
|
||||
// <copyright file="CustomSettingsUserControlModel.cs" company="MaaAssistantArknights">
|
||||
// MaaWpfGui - A part of the MaaCoreArknights project
|
||||
// Copyright (C) 2021 MistEO and Contributors
|
||||
//
|
||||
@@ -13,6 +13,9 @@
|
||||
#nullable enable
|
||||
using MaaWpfGui.Constants;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
@@ -36,4 +39,13 @@ public class CustomSettingsUserControlModel : TaskViewModel
|
||||
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.DebugTaskName, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override (AsstTaskType Type, JObject Params) Serialize()
|
||||
{
|
||||
var task = new AsstCustomTask()
|
||||
{
|
||||
CustomTasks = { TaskName },
|
||||
};
|
||||
return task.Serialize();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user