mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
rft: Wpf基建任务序列化调整 (#12053)
* rft: Wpf基建任务序列化 * rft: 迁移遗漏的CustomInfrastEnabled
This commit is contained in:
@@ -2244,88 +2244,6 @@ namespace MaaWpfGui.Main
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
private static JObject SerializeInfrastTaskParams(
|
||||
IEnumerable<string> order,
|
||||
string usesOfDrones,
|
||||
bool continueTraining,
|
||||
double dormThreshold,
|
||||
bool dormFilterNotStationedEnabled,
|
||||
bool dormDormTrustEnabled,
|
||||
bool originiumShardAutoReplenishment,
|
||||
bool isCustom,
|
||||
string filename,
|
||||
int planIndex)
|
||||
{
|
||||
var taskParams = new JObject
|
||||
{
|
||||
["facility"] = new JArray(order.ToArray<object>()),
|
||||
["drones"] = usesOfDrones,
|
||||
["continue_training"] = continueTraining,
|
||||
["threshold"] = dormThreshold,
|
||||
["dorm_notstationed_enabled"] = dormFilterNotStationedEnabled,
|
||||
["dorm_trust_enabled"] = dormDormTrustEnabled,
|
||||
["replenish"] = originiumShardAutoReplenishment,
|
||||
["mode"] = isCustom ? 10000 : 0,
|
||||
["filename"] = filename,
|
||||
["plan_index"] = planIndex,
|
||||
};
|
||||
|
||||
return taskParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 基建换班。
|
||||
/// </summary>
|
||||
/// <param name="order">要换班的设施(有序)。</param>
|
||||
/// <param name="usesOfDrones">
|
||||
/// 无人机用途。可用值包括:
|
||||
/// <list type="bullet">
|
||||
/// <item><c>_NotUse</c></item>
|
||||
/// <item><c>Money</c></item>
|
||||
/// <item><c>SyntheticJade</c></item>
|
||||
/// <item><c>CombatRecord</c></item>
|
||||
/// <item><c>PureGold</c></item>
|
||||
/// <item><c>OriginStone</c></item>
|
||||
/// <item><c>Chip</c></item>
|
||||
/// </list>
|
||||
/// </param>
|
||||
/// <param name="continueTraining">训练室是否尝试连续专精</param>
|
||||
/// <param name="dormThreshold">宿舍进驻心情阈值。</param>
|
||||
/// <param name="dormFilterNotStationedEnabled">宿舍是否使用未进驻筛选标签</param>
|
||||
/// <param name="dormDormTrustEnabled">宿舍是否使用蹭信赖功能</param>
|
||||
/// <param name="originiumShardAutoReplenishment">制造站搓玉是否补货</param>
|
||||
/// <param name="isCustom">是否开启自定义配置</param>
|
||||
/// <param name="filename">自定义配置文件路径</param>
|
||||
/// <param name="planIndex">自定义配置计划编号</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
public bool AsstAppendInfrast(
|
||||
IEnumerable<string> order,
|
||||
string usesOfDrones,
|
||||
bool continueTraining,
|
||||
double dormThreshold,
|
||||
bool dormFilterNotStationedEnabled,
|
||||
bool dormDormTrustEnabled,
|
||||
bool originiumShardAutoReplenishment,
|
||||
bool isCustom,
|
||||
string filename,
|
||||
int planIndex)
|
||||
{
|
||||
var taskParams = SerializeInfrastTaskParams(
|
||||
order,
|
||||
usesOfDrones,
|
||||
continueTraining,
|
||||
dormThreshold,
|
||||
dormFilterNotStationedEnabled,
|
||||
dormDormTrustEnabled,
|
||||
originiumShardAutoReplenishment,
|
||||
isCustom,
|
||||
filename,
|
||||
planIndex);
|
||||
AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.Infrast, taskParams);
|
||||
_taskStatus.Add(id, TaskType.Infrast);
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
public bool AsstSetInfrastTaskParams(
|
||||
IEnumerable<string> order,
|
||||
string usesOfDrones,
|
||||
@@ -2345,17 +2263,19 @@ namespace MaaWpfGui.Main
|
||||
return false;
|
||||
}
|
||||
|
||||
var taskParams = SerializeInfrastTaskParams(
|
||||
order,
|
||||
usesOfDrones,
|
||||
continueTraining,
|
||||
dormThreshold,
|
||||
dormFilterNotStationedEnabled,
|
||||
dormDormTrustEnabled,
|
||||
originiumShardAutoReplenishment,
|
||||
isCustom,
|
||||
filename,
|
||||
planIndex);
|
||||
var taskParams = new AsstInfrastTask
|
||||
{
|
||||
Facilitys = order.ToList(),
|
||||
UsesOfDrones = usesOfDrones,
|
||||
ContinueTraining = continueTraining,
|
||||
DormThreshold = dormThreshold,
|
||||
DormFilterNotStationedEnabled = dormFilterNotStationedEnabled,
|
||||
DormDormTrustEnabled = dormDormTrustEnabled,
|
||||
OriginiumShardAutoReplenishment = originiumShardAutoReplenishment,
|
||||
IsCustom = isCustom,
|
||||
Filename = filename,
|
||||
PlanIndex = planIndex,
|
||||
}.Serialize().Params;
|
||||
return AsstSetTaskParamsWithEncoding(id, taskParams);
|
||||
}
|
||||
|
||||
|
||||
104
src/MaaWpfGui/Models/AsstTasks/AsstInfrastTask.cs
Normal file
104
src/MaaWpfGui/Models/AsstTasks/AsstInfrastTask.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
// <copyright file="AsstInfrastTask.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.Linq;
|
||||
|
||||
namespace MaaWpfGui.Models.AsstTasks;
|
||||
|
||||
/// <summary>
|
||||
/// 基建任务
|
||||
/// </summary>
|
||||
public class AsstInfrastTask : AsstBaseTask
|
||||
{
|
||||
public override AsstTaskType TaskType => AsstTaskType.Infrast;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 要换班的设施(有序)
|
||||
/// </summary>
|
||||
public List<string> Facilitys { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 无人机用途。可用值包括:
|
||||
/// <list type="bullet">
|
||||
/// <item><c>_NotUse</c></item>
|
||||
/// <item><c>Money</c></item>
|
||||
/// <item><c>SyntheticJade</c></item>
|
||||
/// <item><c>CombatRecord</c></item>
|
||||
/// <item><c>PureGold</c></item>
|
||||
/// <item><c>OriginStone</c></item>
|
||||
/// <item><c>Chip</c></item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public string UsesOfDrones { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 训练室是否尝试连续专精
|
||||
/// </summary>
|
||||
public bool ContinueTraining { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 宿舍进驻心情阈值
|
||||
/// </summary>
|
||||
public double DormThreshold { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 宿舍是否使用未进驻筛选标签
|
||||
/// </summary>
|
||||
public bool DormFilterNotStationedEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 宿舍是否使用蹭信赖功能
|
||||
/// </summary>
|
||||
public bool DormDormTrustEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 制造站搓玉是否补货
|
||||
/// </summary>
|
||||
public bool OriginiumShardAutoReplenishment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 是否开启自定义配置
|
||||
/// </summary>
|
||||
public bool IsCustom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 自定义配置文件路径
|
||||
/// </summary>
|
||||
public string Filename { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 自定义配置计划编号
|
||||
/// </summary>
|
||||
public int PlanIndex { get; set; }
|
||||
|
||||
public override (AsstTaskType TaskType, JObject Params) Serialize()
|
||||
{
|
||||
var taskParams = new JObject
|
||||
{
|
||||
["facility"] = JArray.FromObject(Facilitys),
|
||||
["drones"] = UsesOfDrones,
|
||||
["continue_training"] = ContinueTraining,
|
||||
["threshold"] = DormThreshold,
|
||||
["dorm_notstationed_enabled"] = DormFilterNotStationedEnabled,
|
||||
["dorm_trust_enabled"] = DormDormTrustEnabled,
|
||||
["replenish"] = OriginiumShardAutoReplenishment,
|
||||
["mode"] = IsCustom ? 10000 : 0,
|
||||
["filename"] = Filename,
|
||||
["plan_index"] = PlanIndex,
|
||||
};
|
||||
|
||||
return (TaskType, taskParams);
|
||||
}
|
||||
}
|
||||
@@ -1370,6 +1370,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
{
|
||||
ResetTaskSelection();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1715,24 +1716,28 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
private bool AppendInfrast()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
if (InfrastTask.CustomInfrastEnabled && (!File.Exists(InfrastTask.CustomInfrastFile) || CustomInfrastPlanInfoList.Count == 0))
|
||||
{
|
||||
AddLog(LocalizationHelper.GetString("CustomizeInfrastSelectionEmpty"), UiLogColor.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
var order = InfrastTask.GetInfrastOrderList();
|
||||
return Instances.AsstProxy.AsstAppendInfrast(
|
||||
order,
|
||||
InfrastTask.UsesOfDrones,
|
||||
InfrastTask.ContinueTraining,
|
||||
InfrastTask.DormThreshold / 100.0,
|
||||
InfrastTask.DormFilterNotStationedEnabled,
|
||||
InfrastTask.DormTrustEnabled,
|
||||
InfrastTask.OriginiumShardAutoReplenishment,
|
||||
InfrastTask.CustomInfrastEnabled,
|
||||
InfrastTask.CustomInfrastFile,
|
||||
CustomInfrastPlanIndex);
|
||||
var (type, param) = new AsstInfrastTask
|
||||
{
|
||||
Facilitys = InfrastTask.GetInfrastOrderList(),
|
||||
UsesOfDrones = InfrastTask.UsesOfDrones,
|
||||
ContinueTraining = InfrastTask.ContinueTraining,
|
||||
DormThreshold = InfrastTask.DormThreshold / 100.0,
|
||||
DormFilterNotStationedEnabled = InfrastTask.DormFilterNotStationedEnabled,
|
||||
DormDormTrustEnabled = InfrastTask.DormTrustEnabled,
|
||||
OriginiumShardAutoReplenishment = InfrastTask.OriginiumShardAutoReplenishment,
|
||||
IsCustom = InfrastTask.CustomInfrastEnabled,
|
||||
Filename = InfrastTask.CustomInfrastFile,
|
||||
PlanIndex = CustomInfrastPlanIndex,
|
||||
}.Serialize();
|
||||
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Infrast, type, param);
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, IEnumerable<string>> _blackCharacterListMapping = new()
|
||||
@@ -1962,18 +1967,6 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
}
|
||||
*/
|
||||
|
||||
private bool _customInfrastEnabled = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastEnabled, bool.FalseString));
|
||||
|
||||
public bool CustomInfrastEnabled
|
||||
{
|
||||
get => _customInfrastEnabled;
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _customInfrastEnabled, value);
|
||||
RefreshCustomInfrastPlan();
|
||||
}
|
||||
}
|
||||
|
||||
public bool NeedAddCustomInfrastPlanInfo { get; set; } = true;
|
||||
|
||||
private int _customInfrastPlanIndex = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanIndex, "0"));
|
||||
@@ -2031,7 +2024,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<GenericCombinedData<int>> CustomInfrastPlanList { get; } = new();
|
||||
public ObservableCollection<GenericCombinedData<int>> CustomInfrastPlanList { get; } = [];
|
||||
|
||||
public struct CustomInfrastPlanInfo
|
||||
{
|
||||
@@ -2056,7 +2049,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
private List<CustomInfrastPlanInfo> CustomInfrastPlanInfoList { get; } = new();
|
||||
private List<CustomInfrastPlanInfo> CustomInfrastPlanInfoList { get; } = [];
|
||||
|
||||
private bool _customInfrastPlanHasPeriod;
|
||||
private bool _customInfrastInfoOutput;
|
||||
@@ -2067,7 +2060,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
CustomInfrastPlanList.Clear();
|
||||
_customInfrastPlanHasPeriod = false;
|
||||
|
||||
if (!CustomInfrastEnabled)
|
||||
if (!InfrastTask.CustomInfrastEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2179,7 +2172,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
public void RefreshCustomInfrastPlanIndexByPeriod()
|
||||
{
|
||||
if (!CustomInfrastEnabled || !_customInfrastPlanHasPeriod || InfrastTaskRunning)
|
||||
if (!InfrastTask.CustomInfrastEnabled || !_customInfrastPlanHasPeriod || InfrastTaskRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2206,7 +2199,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
public void IncreaseCustomInfrastPlanIndex()
|
||||
{
|
||||
if (!CustomInfrastEnabled || _customInfrastPlanHasPeriod || CustomInfrastPlanInfoList.Count == 0)
|
||||
if (!InfrastTask.CustomInfrastEnabled || _customInfrastPlanHasPeriod || CustomInfrastPlanInfoList.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,8 +201,6 @@ public class InfrastSettingsUserControlModel : TaskViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public static TaskQueueViewModel CustomInfrastPlanDataContext { get => Instances.TaskQueueViewModel; }
|
||||
|
||||
private string _usesOfDrones = ConfigurationHelper.GetValue(ConfigurationKeys.UsesOfDrones, "Money");
|
||||
|
||||
/// <summary>
|
||||
@@ -329,7 +327,7 @@ public class InfrastSettingsUserControlModel : TaskViewModel
|
||||
{
|
||||
SetAndNotify(ref _customInfrastEnabled, value);
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.CustomInfrastEnabled, value.ToString());
|
||||
Instances.TaskQueueViewModel.CustomInfrastEnabled = value;
|
||||
Instances.TaskQueueViewModel.RefreshCustomInfrastPlan();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:setting="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
xmlns:taskQueue="clr-namespace:MaaWpfGui.ViewModels.UserControl.TaskQueue"
|
||||
xmlns:task="clr-namespace:MaaWpfGui.ViewModels.UserControl.TaskQueue"
|
||||
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
d:Background="White"
|
||||
d:DataContext="{d:DesignInstance {x:Type taskQueue:FightSettingsUserControlModel}}"
|
||||
d:DataContext="{d:DesignInstance {x:Type task:FightSettingsUserControlModel}}"
|
||||
d:DesignWidth="220"
|
||||
s:View.ActionTarget="{Binding}"
|
||||
mc:Ignorable="d">
|
||||
@@ -317,7 +317,7 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4" Visibility="{c:Binding 'CustomInfrastEnabled and TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings', Source={x:Static helper:Instances.TaskQueueViewModel}}">
|
||||
<Grid Grid.Row="4" Visibility="{c:Binding 'CustomInfrastEnabled and TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings', Source={x:Static task:InfrastSettingsUserControlModel.Instance}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="100" />
|
||||
<ColumnDefinition />
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
<!-- 开自定义基建计划时,放在常规设置的部分 -->
|
||||
<StackPanel Visibility="{c:Binding 'CustomInfrastEnabled and !TaskSettingVisibilities.EnableAdvancedSettings'}">
|
||||
<ComboBox
|
||||
<hc:ComboBox
|
||||
Margin="0,4"
|
||||
VerticalContentAlignment="Center"
|
||||
hc:InfoElement.Title="{DynamicResource CustomInfrastPlan}"
|
||||
|
||||
Reference in New Issue
Block a user