From 4c4b2e8510115576641f5db59113761968c5cd76 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Sat, 14 Jun 2025 16:26:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=BF=81=E7=A7=BB=E7=90=86?= =?UTF-8?q?=E6=99=BA,=20=E6=88=98=E6=96=97=E6=AC=A1=E6=95=B0,=20=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=80=8D=E7=8E=87,=20=E5=85=B3=E5=8D=A1=E7=90=86?= =?UTF-8?q?=E6=99=BA=E7=BC=93=E5=AD=98=20(#12986)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rft: 迁移理智, 战斗次数, 代理倍率, 关卡理智缓存 --- src/MaaWpfGui/Helper/Instances.cs | 8 +--- src/MaaWpfGui/Main/AsstProxy.cs | 41 ++++++++++--------- .../FightSettingsUserControlModel.cs | 4 ++ 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/MaaWpfGui/Helper/Instances.cs b/src/MaaWpfGui/Helper/Instances.cs index 63446ff49b..37623ffdb9 100644 --- a/src/MaaWpfGui/Helper/Instances.cs +++ b/src/MaaWpfGui/Helper/Instances.cs @@ -11,7 +11,7 @@ // but WITHOUT ANY WARRANTY // -#pragma warning disable SA1401, CS8632 +#pragma warning disable SA1401 using GlobalHotKey; using MaaWpfGui.Main; @@ -33,10 +33,6 @@ namespace MaaWpfGui.Helper { public static class Data { - public static FightSettingsUserControlModel.FightTimes? FightTimes { get; set; } - - public static FightSettingsUserControlModel.SanityInfo? SanityReport { get; set; } - public static int MedicineUsedTimes { get; set; } public static int ExpiringMedicineUsedTimes { get; set; } @@ -47,7 +43,7 @@ namespace MaaWpfGui.Helper public static void ClearCache() { - SanityReport = null; + FightSettingsUserControlModel.SanityReport = null; MedicineUsedTimes = 0; ExpiringMedicineUsedTimes = 0; StoneUsedTimes = 0; diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 5a01e9c284..6a3b8072d2 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -45,6 +45,7 @@ using static MaaWpfGui.Helper.Instances.Data; using AsstHandle = nint; using AsstInstanceOptionKey = System.Int32; using AsstTaskId = System.Int32; +using FightTask = MaaWpfGui.ViewModels.UserControl.TaskQueue.FightSettingsUserControlModel; using ToastNotification = MaaWpfGui.Helper.ToastNotification; namespace MaaWpfGui.Main @@ -688,10 +689,10 @@ namespace MaaWpfGui.Main private void OnToastNotificationTimerTick(object? sender, EventArgs e) { - if (SanityReport is not null) + if (FightTask.SanityReport is not null) { var sanityReport = LocalizationHelper.GetString("SanityReport"); - var recoveryTime = SanityReport.ReportTime.AddMinutes(SanityReport.SanityCurrent < SanityReport.SanityMax ? (SanityReport.SanityMax - SanityReport.SanityCurrent) * 6 : 0); + var recoveryTime = FightTask.SanityReport.ReportTime.AddMinutes(FightTask.SanityReport.SanityCurrent < FightTask.SanityReport.SanityMax ? (FightTask.SanityReport.SanityMax - FightTask.SanityReport.SanityCurrent) * 6 : 0); sanityReport = sanityReport.Replace("{DateTime}", recoveryTime.ToString("yyyy-MM-dd HH:mm")).Replace("{TimeDiff}", (recoveryTime - DateTimeOffset.Now).ToString(@"h\h\ m\m")); ToastNotification.ShowDirect(sanityReport); } @@ -820,9 +821,9 @@ namespace MaaWpfGui.Main break; } - if (taskChain == "Fight" && SanityReport is not null) + if (taskChain == "Fight" && FightTask.SanityReport is not null) { - var sanityLog = "\n" + string.Format(LocalizationHelper.GetString("CurrentSanity"), SanityReport.SanityCurrent, SanityReport.SanityMax); + var sanityLog = "\n" + string.Format(LocalizationHelper.GetString("CurrentSanity"), FightTask.SanityReport.SanityCurrent, FightTask.SanityReport.SanityMax); Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CompleteTask") + taskChain + sanityLog); } else @@ -898,9 +899,9 @@ namespace MaaWpfGui.Main var allTaskCompleteLog = string.Format(LocalizationHelper.GetString("AllTasksComplete"), diffTaskTime); - if (SanityReport is not null) + if (FightTask.SanityReport is not null) { - var recoveryTime = SanityReport.ReportTime.AddMinutes(SanityReport.SanityCurrent < SanityReport.SanityMax ? (SanityReport.SanityMax - SanityReport.SanityCurrent) * 6 : 0); + var recoveryTime = FightTask.SanityReport.ReportTime.AddMinutes(FightTask.SanityReport.SanityCurrent < FightTask.SanityReport.SanityMax ? (FightTask.SanityReport.SanityMax - FightTask.SanityReport.SanityCurrent) * 6 : 0); sanityReport = sanityReport.Replace("{DateTime}", recoveryTime.ToString("yyyy-MM-dd HH:mm")).Replace("{TimeDiff}", (recoveryTime - DateTimeOffset.Now).ToString(@"h\h\ m\m")); allTaskCompleteLog = allTaskCompleteLog + Environment.NewLine + sanityReport; @@ -949,7 +950,7 @@ namespace MaaWpfGui.Main using (var toast = new ToastNotification(allTaskCompleteTitle)) { - if (SanityReport is not null) + if (FightTask.SanityReport is not null) { toast.AppendContentText(sanityReport); } @@ -1162,19 +1163,19 @@ namespace MaaWpfGui.Main case "StartButton2": case "AnnihilationConfirm": StringBuilder missionStartLogBuilder = new(); - if (FightTimes is null) + if (FightTask.FightReport is null) { missionStartLogBuilder.AppendLine(string.Format(LocalizationHelper.GetString("MissionStart.FightTask"), "???", "???")); } else { - var times = FightTimes.Series == 1 ? $"{FightTimes.TimesFinished + 1}" : $"{FightTimes.TimesFinished + 1}~{FightTimes.TimesFinished + FightTimes.Series}"; - missionStartLogBuilder.AppendLine(string.Format(LocalizationHelper.GetString("MissionStart.FightTask"), times, FightTimes.SanityCost)); + var times = FightTask.FightReport.Series == 1 ? $"{FightTask.FightReport.TimesFinished + 1}" : $"{FightTask.FightReport.TimesFinished + 1}~{FightTask.FightReport.TimesFinished + FightTask.FightReport.Series}"; + missionStartLogBuilder.AppendLine(string.Format(LocalizationHelper.GetString("MissionStart.FightTask"), times, FightTask.FightReport.SanityCost)); } - if (SanityReport is not null) + if (FightTask.SanityReport is not null) { - missionStartLogBuilder.AppendFormat(LocalizationHelper.GetString("CurrentSanity"), SanityReport.SanityCurrent, SanityReport.SanityMax); + missionStartLogBuilder.AppendFormat(LocalizationHelper.GetString("CurrentSanity"), FightTask.SanityReport.SanityCurrent, FightTask.SanityReport.SanityMax); } if (ExpiringMedicineUsedTimes > 0) @@ -1722,10 +1723,10 @@ namespace MaaWpfGui.Main case "SanityBeforeStage": { - SanityReport = null; + FightTask.SanityReport = null; if (subTaskDetails?.ToObject() is { SanityMax: > 0 } report) { - SanityReport = report; + FightTask.SanityReport = report; } break; @@ -1733,18 +1734,18 @@ namespace MaaWpfGui.Main case "FightTimes": { - FightTimes = null; + FightTask.FightReport = null; if ((subTaskDetails?.Children())?.Any() is true) { - FightTimes = subTaskDetails.ToObject()!; - if (FightTimes.TimesFinished > 0) + FightTask.FightReport = subTaskDetails.ToObject()!; + if (FightTask.FightReport.TimesFinished > 0) { - AchievementTrackerHelper.Instance.SetProgress(AchievementIds.OverLimitAgent, FightTimes.TimesFinished); + AchievementTrackerHelper.Instance.SetProgress(AchievementIds.OverLimitAgent, FightTask.FightReport.TimesFinished); } - if (Instances.TaskQueueViewModel.FightTaskRunning && FightSettingsUserControlModel.Instance.HasTimesLimited && FightTimes.TimesFinished + FightTimes.Series > FightSettingsUserControlModel.Instance.MaxTimes) + if (Instances.TaskQueueViewModel.FightTaskRunning && FightTask.Instance.HasTimesLimited && FightTask.FightReport.TimesFinished + FightTask.FightReport.Series > FightTask.Instance.MaxTimes) { - Instances.TaskQueueViewModel.AddLog(string.Format(LocalizationHelper.GetString("FightTimesUnused"), FightTimes.TimesFinished, FightTimes.Series, FightTimes.TimesFinished + FightTimes.Series, FightSettingsUserControlModel.Instance.MaxTimes), UiLogColor.Error); + Instances.TaskQueueViewModel.AddLog(string.Format(LocalizationHelper.GetString("FightTimesUnused"), FightTask.FightReport.TimesFinished, FightTask.FightReport.Series, FightTask.FightReport.TimesFinished + FightTask.FightReport.Series, FightTask.Instance.MaxTimes), UiLogColor.Error); } } diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs index f311aa5a30..50360dd4dd 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs @@ -33,6 +33,10 @@ namespace MaaWpfGui.ViewModels.UserControl.TaskQueue; /// public class FightSettingsUserControlModel : TaskViewModel { + public static FightTimes? FightReport { get; set; } + + public static SanityInfo? SanityReport { get; set; } + static FightSettingsUserControlModel() { Instance = new();