From 5b5ba74a2db4abd40c0f4eaa659f5d2cae1d7fe7 Mon Sep 17 00:00:00 2001
From: status102 <102887808+status102@users.noreply.github.com>
Date: Mon, 17 Feb 2025 21:02:51 +0800
Subject: [PATCH] =?UTF-8?q?rft:=20Wpf=E9=87=8D=E6=9E=84=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E5=85=AC=E6=8B=9B=E4=BB=BB=E5=8A=A1=E5=BA=8F=E5=88=97=E5=8C=96?=
=?UTF-8?q?=20(#11951)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MaaWpfGui/Main/AsstProxy.cs | 76 -----------
src/MaaWpfGui/ViewModels/TaskViewModel.cs | 11 ++
.../ViewModels/UI/TaskQueueViewModel.cs | 47 +------
.../ReclamationSettingsUserControlModel.cs | 8 +-
.../RecruitSettingsUserControlModel.cs | 124 ++++++++++++++----
5 files changed, 113 insertions(+), 153 deletions(-)
diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs
index e084b0105f..74ea4ee589 100644
--- a/src/MaaWpfGui/Main/AsstProxy.cs
+++ b/src/MaaWpfGui/Main/AsstProxy.cs
@@ -2231,82 +2231,6 @@ namespace MaaWpfGui.Main
return id != 0;
}
- ///
- /// 公开招募。
- ///
- /// 加急次数,仅在 为 时有效。
- /// 首选 Tags,仅在 Tag 等级为 3 时有效。
- /// 会去点击标签的 Tag 等级。
- /// 会去点击确认的 Tag 等级。若仅公招计算,可设置为空数组。
- /// 是否刷新三星 Tags。
- /// 无招募许可时是否继续尝试刷新 Tags。
- /// 是否使用加急许可。
- ///
- /// 公招选择额外tag的模式。可用值包括:
- ///
- /// -
- /// 0
- /// 默认不选择额外tag。
- ///
- /// -
- /// 1
- /// 选满至3个tag。
- ///
- /// -
- /// 2
- /// 尽可能多选且只选四星以上的tag。
- ///
- ///
- ///
- /// 是否在识别到小车词条时跳过。
- /// 3 星招募时间
- /// 4 星招募时间
- /// 5 星招募时间
- /// 是否成功。
- public bool AsstAppendRecruit(
- int maxTimes,
- string[] firstTags,
- int[] selectLevel,
- int[] confirmLevel,
- bool needRefresh,
- bool needForceRefresh,
- bool useExpedited,
- int selectExtraTagsMode,
- bool skipRobot,
- int chooseLevel3Time,
- int chooseLevel4Time,
- int chooseLevel5Time)
- {
- var taskParams = new JObject
- {
- ["refresh"] = needRefresh,
- ["force_refresh"] = needForceRefresh,
- ["select"] = new JArray(selectLevel),
- ["confirm"] = new JArray(confirmLevel),
- ["times"] = maxTimes,
- ["set_time"] = true,
- ["expedite"] = useExpedited,
- ["extra_tags_mode"] = selectExtraTagsMode,
- ["expedite_times"] = maxTimes,
- ["skip_robot"] = skipRobot,
- ["first_tags"] = new JArray(firstTags),
- ["recruitment_time"] = new JObject
- {
- ["3"] = chooseLevel3Time,
- ["4"] = chooseLevel4Time,
- ["5"] = chooseLevel5Time,
- },
- ["report_to_penguin"] = SettingsViewModel.GameSettings.EnablePenguin,
- ["report_to_yituliu"] = SettingsViewModel.GameSettings.EnableYituliu,
- ["penguin_id"] = SettingsViewModel.GameSettings.PenguinId,
- ["server"] = Instances.SettingsViewModel.ServerType,
- };
-
- AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.Recruit, taskParams);
- _taskStatus.Add(id, TaskType.Recruit);
- return id != 0;
- }
-
private static JObject SerializeInfrastTaskParams(
IEnumerable order,
string usesOfDrones,
diff --git a/src/MaaWpfGui/ViewModels/TaskViewModel.cs b/src/MaaWpfGui/ViewModels/TaskViewModel.cs
index b68e167223..dba5cece66 100644
--- a/src/MaaWpfGui/ViewModels/TaskViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/TaskViewModel.cs
@@ -11,7 +11,9 @@
// but WITHOUT ANY WARRANTY
//
#nullable enable
+using System;
using MaaWpfGui.Main;
+using MaaWpfGui.Services;
using Newtonsoft.Json.Linq;
using Stylet;
@@ -22,4 +24,13 @@ public class TaskViewModel : PropertyChangedBase
public virtual void ProcSubTaskMsg(AsstMsg msg, JObject details)
{
}
+
+ ///
+ /// 序列化MAA任务
+ ///
+ /// 返回(Asst任务类型, 参数)
+ public virtual (AsstTaskType Type, JObject Params) Serialize()
+ {
+ throw new NotImplementedException();
+ }
}
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index 69c004ce07..f0e5df17bf 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -1778,50 +1778,9 @@ namespace MaaWpfGui.ViewModels.UI
private static bool AppendRecruit()
{
- // for debug
- if (!int.TryParse(RecruitTask.RecruitMaxTimes, out var maxTimes))
- {
- maxTimes = 0;
- }
-
- var firstList = RecruitTask.AutoRecruitFirstList;
-
- var reqList = new List();
- var cfmList = new List();
-
- if (RecruitTask.ChooseLevel3)
- {
- cfmList.Add(3);
- }
-
- if (RecruitTask.ChooseLevel4)
- {
- reqList.Add(4);
- cfmList.Add(4);
- }
-
- // ReSharper disable once InvertIf
- if (RecruitTask.ChooseLevel5)
- {
- reqList.Add(5);
- cfmList.Add(5);
- }
-
- _ = int.TryParse(RecruitTask.SelectExtraTags, out var selectExtra);
-
- return Instances.AsstProxy.AsstAppendRecruit(
- maxTimes,
- firstList.Cast().Select(i => i.Value).ToArray(),
- [.. reqList],
- [.. cfmList],
- RecruitTask.RefreshLevel3,
- RecruitTask.ForceRefresh,
- RecruitTask.UseExpedited,
- selectExtra,
- RecruitTask.NotChooseLevel1,
- RecruitTask.ChooseLevel3Time,
- RecruitTask.ChooseLevel4Time,
- RecruitTask.ChooseLevel5Time);
+ // 被RemoteControlService反射调用,暂不移除
+ var (type, param) = RecruitTask.Serialize();
+ return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Recruit, type, param);
}
private static bool AppendRoguelike()
diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/ReclamationSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/ReclamationSettingsUserControlModel.cs
index 538ae3c9f7..2d1c66e3f1 100644
--- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/ReclamationSettingsUserControlModel.cs
+++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/ReclamationSettingsUserControlModel.cs
@@ -138,7 +138,6 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
///
/// 自动生息演算。
///
- /// 要组装的支援道具。
/// 生息演算主题["Tales"]
///
/// 策略。可用值包括:
@@ -153,10 +152,11 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
///
///
///
- /// 点击类型:0 连点;1 长按
- /// 单次最大制造轮数
+ /// 点击类型:0 连点;1 长按
+ /// 单次最大制造轮数
+ /// 要组装的支援道具。
/// 返回(Asst任务类型, 参数)
- public (AsstTaskType Type, JObject Params) Serialize()
+ public override (AsstTaskType Type, JObject Params) Serialize()
{
var data = new JObject
{
diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/RecruitSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/RecruitSettingsUserControlModel.cs
index e9d599867e..6b05a017a1 100644
--- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/RecruitSettingsUserControlModel.cs
+++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/RecruitSettingsUserControlModel.cs
@@ -16,10 +16,16 @@ using System.Collections.Generic;
using System.Linq;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
+using MaaWpfGui.Services;
using MaaWpfGui.Utilities.ValueType;
+using MaaWpfGui.ViewModels.UI;
+using Newtonsoft.Json.Linq;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
+///
+/// 自动公招model
+///
public class RecruitSettingsUserControlModel : TaskViewModel
{
static RecruitSettingsUserControlModel()
@@ -72,18 +78,18 @@ public class RecruitSettingsUserControlModel : TaskViewModel
}
}
- private string _recruitMaxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.RecruitMaxTimes, "4");
+ private int _recruitMaxTimes = int.TryParse(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitMaxTimes, "4"), out var outMaxTimes) ? outMaxTimes : 4;
///
/// Gets or sets the maximum times of recruit.
///
- public string RecruitMaxTimes
+ public int RecruitMaxTimes
{
get => _recruitMaxTimes;
set
{
SetAndNotify(ref _recruitMaxTimes, value);
- ConfigurationHelper.SetValue(ConfigurationKeys.RecruitMaxTimes, value);
+ ConfigurationHelper.SetValue(ConfigurationKeys.RecruitMaxTimes, value.ToString());
}
}
@@ -128,40 +134,18 @@ public class RecruitSettingsUserControlModel : TaskViewModel
set => SetAndNotify(ref _useExpedited, value);
}
- private string _selectExtraTags = ConfigurationHelper.GetValue(ConfigurationKeys.SelectExtraTags, "0");
+ private int _selectExtraTags = int.TryParse(ConfigurationHelper.GetValue(ConfigurationKeys.SelectExtraTags, "0"), out var outTags) ? outTags : 0;
///
/// Gets or sets a value indicating three tags are always selected or select only rare tags as many as possible .
///
- public string SelectExtraTags
+ public int SelectExtraTags
{
- get
- {
- if (int.TryParse(_selectExtraTags, out _))
- {
- return _selectExtraTags;
- }
-
- ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, "0");
- return "0";
-
- // v4.28.0迁移,不再支持bool类型
- /*
- var value = "0";
- if (bool.TryParse(_selectExtraTags, out bool boolValue))
- {
- value = boolValue ? "1" : "0";
- }
-
- SetAndNotify(ref _selectExtraTags, value);
- ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value);
- return value;*/
- }
-
+ get => _selectExtraTags;
set
{
SetAndNotify(ref _selectExtraTags, value);
- ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value);
+ ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value.ToString());
}
}
@@ -383,4 +367,86 @@ public class RecruitSettingsUserControlModel : TaskViewModel
SetAndNotify(ref _chooseLevel5Min, value % 60, nameof(ChooseLevel5Min));
}
}
+
+ ///
+ /// 公开招募。
+ ///
+ /// 加急次数,仅在 为 时有效。
+ /// 首选 Tags,仅在 Tag 等级为 3 时有效。
+ /// 会去点击标签的 Tag 等级。
+ /// 会去点击确认的 Tag 等级。若仅公招计算,可设置为空数组。
+ /// 是否刷新三星 Tags。
+ /// 无招募许可时是否继续尝试刷新 Tags。
+ /// 是否使用加急许可。
+ ///
+ /// 公招选择额外tag的模式。可用值包括:
+ ///
+ /// -
+ /// 0
+ /// 默认不选择额外tag。
+ ///
+ /// -
+ /// 1
+ /// 选满至3个tag。
+ ///
+ /// -
+ /// 2
+ /// 尽可能多选且只选四星以上的tag。
+ ///
+ ///
+ ///
+ /// 是否在识别到小车词条时跳过。
+ /// 3 星招募时间
+ /// 4 星招募时间
+ /// 5 星招募时间
+ /// 返回(Asst任务类型, 参数)
+ public override (AsstTaskType Type, JObject Params) Serialize()
+ {
+ var reqList = new List();
+ var cfmList = new List();
+
+ if (ChooseLevel3)
+ {
+ cfmList.Add(3);
+ }
+
+ if (ChooseLevel4)
+ {
+ reqList.Add(4);
+ cfmList.Add(4);
+ }
+
+ // ReSharper disable once InvertIf
+ if (ChooseLevel5)
+ {
+ reqList.Add(5);
+ cfmList.Add(5);
+ }
+
+ var param = new JObject
+ {
+ ["refresh"] = RefreshLevel3,
+ ["force_refresh"] = ForceRefresh,
+ ["select"] = new JArray(reqList.ToArray()),
+ ["confirm"] = new JArray(cfmList.ToArray()),
+ ["times"] = RecruitMaxTimes,
+ ["set_time"] = true,
+ ["expedite"] = UseExpedited,
+ ["extra_tags_mode"] = SelectExtraTags,
+ ["expedite_times"] = RecruitMaxTimes,
+ ["skip_robot"] = NotChooseLevel1,
+ ["first_tags"] = new JArray(AutoRecruitFirstList.Cast().Select(i => i.Value).ToArray()),
+ ["recruitment_time"] = new JObject
+ {
+ ["3"] = ChooseLevel3Time,
+ ["4"] = ChooseLevel4Time,
+ ["5"] = ChooseLevel5Time,
+ },
+ ["report_to_penguin"] = SettingsViewModel.GameSettings.EnablePenguin,
+ ["report_to_yituliu"] = SettingsViewModel.GameSettings.EnableYituliu,
+ ["penguin_id"] = SettingsViewModel.GameSettings.PenguinId,
+ ["server"] = Instances.SettingsViewModel.ServerType,
+ };
+ return (AsstTaskType.Recruit, param);
+ }
}