mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
rft: Wpf唤醒任务序列化
This commit is contained in:
@@ -2186,26 +2186,6 @@ namespace MaaWpfGui.Main
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始唤醒。
|
||||
/// </summary>
|
||||
/// <param name="clientType">客户端版本。</param>
|
||||
/// <param name="enable">是否自动启动客户端。</param>
|
||||
/// <param name="accountName">需要切换到的登录名,留空以禁用</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
public bool AsstAppendStartUp(string clientType, bool enable, string accountName)
|
||||
{
|
||||
var taskParams = new JObject
|
||||
{
|
||||
["client_type"] = clientType,
|
||||
["start_game_enabled"] = enable,
|
||||
["account_name"] = accountName,
|
||||
};
|
||||
AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.StartUp, taskParams);
|
||||
_taskStatus.Add(id, TaskType.StartUp);
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
public bool AsstAppendCloseDown(string clientType)
|
||||
{
|
||||
if (!AsstStop())
|
||||
|
||||
53
src/MaaWpfGui/Models/AsstTasks/AsstStartUpTask.cs
Normal file
53
src/MaaWpfGui/Models/AsstTasks/AsstStartUpTask.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
// <copyright file="AsstStartUpTask.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.ComponentModel;
|
||||
using MaaWpfGui.Services;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MaaWpfGui.Models.AsstTasks;
|
||||
|
||||
public class AsstStartUpTask : AsstBaseTask
|
||||
{
|
||||
public override AsstTaskType TaskType => AsstTaskType.StartUp;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 客户端版本
|
||||
/// </summary>
|
||||
[JsonProperty("client_type")]
|
||||
public string ClientType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether gets or sets 是否自动启动客户端
|
||||
/// </summary>
|
||||
[JsonProperty("start_game_enabled")]
|
||||
public bool StartGame { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 需要切换到的登录名,留空以禁用
|
||||
/// </summary>
|
||||
[JsonProperty("account_name", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[DefaultValue("")]
|
||||
public string AccountName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 开始唤醒。
|
||||
/// </summary>
|
||||
/// <param name="clientType">客户端版本。</param>
|
||||
/// <param name="enable">是否自动启动客户端。</param>
|
||||
/// <param name="accountName">需要切换到的登录名,留空以禁用</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
public override (AsstTaskType TaskType, JObject Params) Serialize() => (AsstTaskType.StartUp, JObject.FromObject(this));
|
||||
}
|
||||
@@ -27,6 +27,7 @@ using MaaWpfGui.Extensions;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Main;
|
||||
using MaaWpfGui.Models;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.States;
|
||||
using MaaWpfGui.Utilities;
|
||||
@@ -1539,11 +1540,14 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
private static bool AppendStart()
|
||||
{
|
||||
var mode = SettingsViewModel.GameSettings.ClientType;
|
||||
var enable = mode.Length != 0;
|
||||
StartUpTask.AccountName = StartUpTask.AccountName.Trim();
|
||||
var accountName = StartUpTask.AccountName;
|
||||
return Instances.AsstProxy.AsstAppendStartUp(mode, enable, accountName);
|
||||
var clientType = SettingsViewModel.GameSettings.ClientType;
|
||||
var (type, param) = new AsstStartUpTask()
|
||||
{
|
||||
ClientType = clientType,
|
||||
StartGame = !string.IsNullOrEmpty(clientType),
|
||||
AccountName = StartUpTask.AccountName,
|
||||
}.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.StartUp, type, param);
|
||||
}
|
||||
|
||||
private bool AppendFight()
|
||||
|
||||
@@ -27,13 +27,14 @@ public class StartUpSettingsUserControlModel : TaskViewModel
|
||||
|
||||
public static StartUpSettingsUserControlModel Instance { get; }
|
||||
|
||||
private string _accountName = ConfigurationHelper.GetValue(ConfigurationKeys.AccountName, string.Empty);
|
||||
private string _accountName = ConfigurationHelper.GetValue(ConfigurationKeys.AccountName, string.Empty).Trim();
|
||||
|
||||
public string AccountName
|
||||
{
|
||||
get => _accountName;
|
||||
set
|
||||
{
|
||||
value = value.Trim();
|
||||
SetAndNotify(ref _accountName, value);
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.AccountName, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user