// // 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 // #nullable enable using System.Collections.Generic; using System.Linq; using MaaWpfGui.Configuration.Single.MaaTask; using MaaWpfGui.Helper; using MaaWpfGui.Models.AsstTasks; using MaaWpfGui.Utilities; using MaaWpfGui.Utilities.ValueType; using MaaWpfGui.ViewModels.UI; using static MaaWpfGui.Main.AsstProxy; using Mode = MaaWpfGui.Configuration.Single.MaaTask.ReclamationMode; using Stage = MaaWpfGui.Configuration.Single.MaaTask.RelaunchAnchorStage; using Theme = MaaWpfGui.Configuration.Single.MaaTask.ReclamationTheme; namespace MaaWpfGui.ViewModels.UserControl.TaskQueue; public class ReclamationSettingsUserControlModel : TaskSettingsViewModel, ReclamationSettingsUserControlModel.ISerialize { static ReclamationSettingsUserControlModel() { Instance = new(); } public static ReclamationSettingsUserControlModel Instance { get; } /// /// Gets the list of reclamation themes. /// public List> ReclamationThemeList { get; } = [ new() { Display = $"{LocalizationHelper.GetString("ReclamationThemeFire")} ({LocalizationHelper.GetString("ClosedStage")})", Value = Theme.Fire }, new() { Display = LocalizationHelper.GetString("ReclamationThemeTales"), Value = Theme.Tales }, new() { Display = LocalizationHelper.GetString("ReclamationThemeRelaunchAnchor"), Value = Theme.RelaunchAnchor }, ]; /// /// Gets or sets 生息演算主题["Tales"]. /// public Theme ReclamationTheme { get => GetTaskConfig().Theme; set => SetTaskConfig( t => t.Theme == value, t => { t.Theme = value; if (value == Theme.RelaunchAnchor) { t.Mode = Mode.NoArchive; t.ClearStore = false; } }); } /// /// Gets the list of reclamation stages for RelaunchAnchor theme. /// public List> ReclamationStageList { get; } = [ new() { Display = "RA-1", Value = Stage.RA1 }, new() { Display = "RA-15", Value = Stage.RA15 }, ]; /// /// Gets or sets 生息演算关卡选择 /// public Stage ReclamationStage { get => GetTaskConfig().Stage; set => SetTaskConfig(t => t.Stage == value, t => t.Stage = value); } /// /// Gets the list of reclamation modes. /// public List> ReclamationModeList { get; } = [ new() { Display = LocalizationHelper.GetString("ReclamationModeProsperityNoSave"), Value = Mode.NoArchive }, new() { Display = LocalizationHelper.GetString("ReclamationModeProsperityInSave"), Value = Mode.Archive }, ]; /// /// Gets or sets 策略,无存档刷生息点数 / 有存档刷生息点数 /// 可用值包括: /// /// /// 0 /// 无存档时通过进出关卡刷生息点数 /// /// /// 1 /// 有存档时通过合成支援道具刷生息点数 /// /// /// public Mode ReclamationMode { get => GetTaskConfig().Mode; set => SetTaskConfig(t => t.Mode == value, t => t.Mode = value); } /// /// Gets or sets 要组装的支援道具 /// public string ReclamationToolToCraft { get => GetTaskConfig().ToolToCraft; set { value = value.Replace(';', ';').Trim(); SetTaskConfig(t => t.ToolToCraft == value, t => t.ToolToCraft = value); } } /// /// Gets the list of reclamation increment modes. /// public List> ReclamationIncrementModeList { get; } = [ new() { Display = LocalizationHelper.GetString("ReclamationIncrementModeClick"), Value = 0 }, new() { Display = LocalizationHelper.GetString("ReclamationIncrementModeHold"), Value = 1 }, ]; /// /// Gets or sets 点击类型:0 连点;1 长按 /// public int ReclamationIncrementMode { get => GetTaskConfig().IncrementMode; set => SetTaskConfig(t => t.IncrementMode == value, t => t.IncrementMode = value); } /// /// Gets or sets 单次最大制造轮数 /// public int ReclamationMaxCraftCountPerRound { get => GetTaskConfig().MaxCraftCountPerRound; set => SetTaskConfig(t => t.MaxCraftCountPerRound == value, t => t.MaxCraftCountPerRound = value); } /// /// Gets or sets a value indicating whether 刷完点数后是否清空商店 /// public bool ReclamationClearStore { get => GetTaskConfig().ClearStore; set => SetTaskConfig(t => t.ClearStore == value, t => t.ClearStore = value); } /// /// Gets the theme-specific tip text. /// [PropertyDependsOn(nameof(ReclamationTheme), nameof(ReclamationStage))] public string ReclamationTip { get { var theme = ReclamationTheme; if (theme == Theme.RelaunchAnchor) { var stageTipKey = $"ReclamationTipRelaunchAnchorRA{(int)ReclamationStage}"; if (LocalizationHelper.TryGetString(stageTipKey, out var stageTip)) { return stageTip; } return LocalizationHelper.GetString("ReclamationTipRelaunchAnchorRA1"); } else if (theme == Theme.Tales || theme == Theme.Fire) { return LocalizationHelper.GetString("ReclamationTipTales"); } else { return string.Empty; } } } public override void RefreshUI(BaseTask baseTask) { if (baseTask is ReclamationTask) { Refresh(); } } public override (bool? IsSuccess, IEnumerable TaskId) SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize).Serialize(baseTask, taskId); private interface ISerialize : ITaskQueueModelSerialize { (bool? IsSuccess, IEnumerable TaskId) ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId) { if (baseTask is not ReclamationTask reclamation) { return (null, []); } var toolToCraft = !string.IsNullOrEmpty(reclamation.ToolToCraft) ? reclamation.ToolToCraft : LocalizationHelper.GetString("ReclamationToolToCraftPlaceholder", DataHelper.ClientLanguageMapper[SettingsViewModel.GameSettings.ClientType]); var task = new AsstReclamationTask() { Theme = reclamation.Theme, Stage = reclamation.Stage, Mode = reclamation.Mode, IncrementMode = reclamation.IncrementMode, MaxCraftCountPerRound = reclamation.MaxCraftCountPerRound, ToolToCraft = [.. toolToCraft.Split(';').Select(s => s.Trim())], ClearStore = reclamation.ClearStore, }; return taskId switch { int id when id > 0 => (Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task), [id]), null => FromSingle(Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Reclamation, task)), _ => (null, []), }; } } }