Files
MaaAssistantArknights/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/StartUpSettingsUserControlModel.cs
Status102 008673d9eb rft: Wpf一键长草任务配置重构 (#15385)
* rft: 已重构部分

* rft: 差stageList

* rft: 补上界园常乐

* rft: 备选关卡

* i18n: 添加关卡 & 备选

* fix: 任务添加出错时中断

* fix: 当前上次关卡转换错误

* fix: 当前上次关卡转换错误

* rft: 刷理智任务序列化

* perf: 糊点

* fix: 漏了一个

* rft: 迁移标记

* fix: 加上剿灭

* fix: index漏了

* fix: 重构后的基建计划

* chore: customTask弃用多任务

* perf: 周几选择框动画

* fix: 移除备选CheckBox

* perf: 刷理智-剿灭不上传企鹅

* rft: rename

* feat: 刷理智 周几 设置

* chore: sync

* revert: debug

* revert: 使用备选关卡

* feat: 下拉框

# Conflicts:
#	src/MaaWpfGui/Views/UserControl/TaskQueue/FightSettingsUserControl.xaml

* rft: rename

* fix: config

* feat: stageList刷新, 差移除过期关卡

* perf: StageListSource 当日未开放

* fix: bingding

* perf: UI 上下布局

* Revert "perf: UI 上下布局"

This reverts commit df39cb2f09.

* feat: 增加默认隐藏的删除和拖动区域

* chore: 优化触发事件绑定

* perf: 优化全反选按钮布局

* feat: 添加任务列表的删除和重命名

* perf: idle 或 inited 为 false 时禁用删除和重命名

* chore: 确保 StagePlan 有一个元素

* fix: ComboBox无法滚动

* Revert "perf: idle 或 inited 为 false 时禁用删除和重命名"

This reverts commit e0b71b53b6.

* perf: 非 idle 期间禁止重命名或删除任务

* feat: 添加启用周计划勾选框

* perf: 不启用周计划时不重置

* perf: 优化滚动

* fix: 一键长草任务添加或跳过时提示修复

* i18n: TaskQueue 添加任务失败 / 跳过

* feat: config 保存

* perf: 删除任务Dialog增加任务类型文本

* rft: 任务可见rename

* rft: 删除任务 & 任务切换

* perf: 合并备选 & 非备选的关卡选择

* fix: index

* rft: 任务设置界面刷新

* fix: 任务设置界面

* fix: 移除最后一个任务后不会自动选中上一个

* fix: stageList刷新

* perf: 当StageList仅存在一个关卡时隐藏删除按钮

* fix: 刷理智-手动输入关卡代码自动补全

* i18n: 添加关卡

* fix: CreditFightOnceADay set

* fix: ExpectedCollapsalParadigms set

* perf: 移除无用注释 & 变量

* feat: 迁移前加个备份

* fix: 刷理智迁移时重复添加关卡

* fix: 移除信用任务中设置基建任务的UI

* fix: TaskId

* fix: 任务后状态重置

* fix: 基建任务检查

* Revert "fix: 移除信用任务中设置基建任务的UI"

This reverts commit 1f51b5fe00.

* fix: 收取信用任务的基建设置说明

* fix: TaskQueue & 基建房间 拖动容器限制

* fix: CanShowAutoReload

* fix: CustomTask适配

* fix: 任务设置改名删除Context绑定

* perf: 移除 StagePlanItem 的 Index

* rft: TaskId 迁移

* feat: TaskStatus 显示任务颜色

* perf: UI状态颜色 for Light

* perf: config迁移

* fix: base

* perf: 调整界面布局

* perf: 调整运行时任务的颜色,调整圆角

* fix: 拖动标签后无法修改配置

* fix: 部分元素在运行中时未被正确禁用

* fix: 是 move 不是 swap

* docs: 移除文档中关于 `剩余理智` & `备选关卡`中剿灭任务相关的特殊逻辑

* i18n: update introduction\combat for zh-tw

* i18n: KR

* i18n: update zh-tw.xaml

---------

Co-authored-by: uye <99072975+ABA2396@users.noreply.github.com>
Co-authored-by: momomochi987 <as99us301@gmail.com>
Co-authored-by: HX3N <scarlet7518@gmail.com>
2026-01-18 21:47:11 +08:00

116 lines
3.6 KiB
C#

// <copyright file="StartUpSettingsUserControlModel.cs" company="MaaAssistantArknights">
// Part of the MaaWpfGui project, maintained by the MaaAssistantArknights team (Maa Team)
// Copyright (C) 2021-2025 MaaAssistantArknights 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;
using JetBrains.Annotations;
using MaaWpfGui.Configuration.Single.MaaTask;
using MaaWpfGui.Constants;
using MaaWpfGui.Constants.Enums;
using MaaWpfGui.Helper;
using MaaWpfGui.Main;
using MaaWpfGui.Models.AsstTasks;
using MaaWpfGui.Services;
using MaaWpfGui.ViewModels.UI;
using Newtonsoft.Json.Linq;
using static MaaWpfGui.Main.AsstProxy;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
public class StartUpSettingsUserControlModel : TaskSettingsViewModel
{
static StartUpSettingsUserControlModel()
{
Instance = new();
}
public static StartUpSettingsUserControlModel Instance { get; }
public string AccountName
{
get => GetTaskConfig<StartUpTask>().AccountName;
set {
value = value.Trim();
SetTaskConfig<StartUpTask>(t => t.AccountName == value, t => t.AccountName = value);
}
}
// UI 绑定的方法
[UsedImplicitly]
public void AccountSwitchManualRun()
{
_ = Instances.TaskQueueViewModel.QuickSwitchAccount();
}
public override void ProcSubTaskMsg(AsstMsg msg, JObject details)
{
if (msg == AsstMsg.SubTaskExtraInfo && details["what"]?.ToString() == "AccountSwitch")
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AccountSwitch") + $" -->> {details["details"]!["account_name"]}", UiLogColor.Info); // subTaskDetails!["current_account"]
}
}
public override void RefreshUI(BaseTask baseTask)
{
if (baseTask is StartUpTask)
{
Refresh();
}
}
[Obsolete("使用SerializeTask作为代替")]
public override (AsstTaskType Type, JObject Params) Serialize()
{
var clientType = SettingsViewModel.GameSettings.ClientType;
var startGame = SettingsViewModel.GameSettings.StartGame;
var accountName = clientType switch {
ClientType.Official or ClientType.Bilibili => AccountName,
_ => string.Empty,
};
var task = new AsstStartUpTask() {
ClientType = clientType,
StartGame = startGame,
AccountName = accountName,
};
return task.Serialize();
}
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
{
if (baseTask is not StartUpTask startUp)
{
return null;
}
var clientType = SettingsViewModel.GameSettings.ClientType;
var accountName = clientType switch {
ClientType.Official or ClientType.Bilibili => startUp.AccountName,
_ => string.Empty,
};
var task = new AsstStartUpTask() {
ClientType = clientType,
StartGame = !string.IsNullOrEmpty(clientType),
AccountName = accountName,
};
return taskId switch {
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.StartUp, task),
_ => null,
};
}
}