diff --git a/resource/tasks.json b/resource/tasks.json index 4d0d198855..f4780558a7 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -3973,7 +3973,7 @@ "roi": [ 1120, 20, - 150, + 160, 40 ], "ocrReplace": [ diff --git a/src/MaaCore/Assistant.cpp b/src/MaaCore/Assistant.cpp index 14e749a487..0b7c80cb27 100644 --- a/src/MaaCore/Assistant.cpp +++ b/src/MaaCore/Assistant.cpp @@ -421,6 +421,14 @@ void Assistant::working_proc() if (m_tasks_list.empty()) { callback_json["finished_tasks"] = json::array(finished_tasks); + + const auto& sanity_str = status()->get_str(Status::FightSanityReport); + if (sanity_str) { + auto sanity_array = json::array(json::parse(*sanity_str).value_or(json::value(json::array()))); + // ["100/135", "2023-09-01 09:31:53.527"] + callback_json["sanity"] = sanity_array; + } + append_callback(AsstMsg::AllTasksCompleted, callback_json); finished_tasks.clear(); clear_cache(); diff --git a/src/MaaCore/Status.h b/src/MaaCore/Status.h index 815f3d8b8c..fe87157669 100644 --- a/src/MaaCore/Status.h +++ b/src/MaaCore/Status.h @@ -38,6 +38,7 @@ namespace asst public: static inline const std::string InfrastAvailableOpersForGroup = "InfrastAvailableOpersForGroup"; + static inline const std::string FightSanityReport = "FightSanityReport"; static inline const std::string RoguelikeCharElitePrefix = "RoguelikeElite-"; static inline const std::string RoguelikeCharLevelPrefix = "RoguelikeLevel-"; diff --git a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp index 5d45e25255..f721540a21 100644 --- a/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp +++ b/src/MaaCore/Task/Fight/SanityBeforeStagePlugin.cpp @@ -4,6 +4,7 @@ #include "Config/TaskData.h" #include "Controller/Controller.h" +#include "Status.h" #include "Utils/ImageIo.hpp" #include "Utils/Logger.hpp" #include "Vision/RegionOCRer.h" @@ -19,6 +20,10 @@ bool asst::SanityBeforeStagePlugin::verify(AsstMsg msg, const json::value& detai if (task.ends_with("StartButton1")) { return true; } + else if (task.ends_with("Stop") && details.at("pre_task").as_string().ends_with("StartButton1")) { + // 次数达限 + return true; + } else { return false; } @@ -49,8 +54,8 @@ void asst::SanityBeforeStagePlugin::get_sanity() if (!analyzer.analyze()) { Log.info(__FUNCTION__, "Current Sanity analyze failed"); - cv::rectangle(img, make_rect(Task.get("SanityMatch")->roi), cv::Scalar(0, 0, 255), 2); std::string stem = utils::get_time_filestem(); + cv::rectangle(img, make_rect(Task.get("SanityMatch")->roi), cv::Scalar(0, 0, 255), 2); imwrite(utils::path("debug") / utils::path("sanity") / (stem + "_failed_img.png"), img); return; } @@ -69,4 +74,9 @@ void asst::SanityBeforeStagePlugin::get_sanity() json::value sanity_info = basic_info_with_what("SanityBeforeStage"); sanity_info["details"]["sanity"] = text; callback(AsstMsg::SubTaskExtraInfo, sanity_info); + + json::array value; + value.emplace_back(std::move(text)); + value.emplace_back(utils::get_format_time()); + status()->set_str(Status::FightSanityReport, value.dumps()); } diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 53d9f67919..23fc2491f9 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -589,6 +589,7 @@ namespace MaaWpfGui.Main case AsstMsg.AllTasksCompleted: bool isMainTaskQueueAllCompleted = true; var finished_tasks = details["finished_tasks"] as JArray; + var sanity_report = details["sanity"] as JArray; if (finished_tasks.Count == 1) { var unique_finished_task = (AsstTaskId)finished_tasks[0]; @@ -617,19 +618,49 @@ namespace MaaWpfGui.Main if (isMainTaskQueueAllCompleted) { - Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete")); + bool isSanityForecastSucc = true; + DateTimeOffset? reportTime = null; + TimeSpan timeDiff = TimeSpan.Zero; + if (isSanityForecastSucc &= sanity_report.Count == 2 && ((string)sanity_report[0]).Contains("/")) + { + int[] sanity = ((string)sanity_report[0]).Split('/').Select(i => Convert.ToInt32(i)).ToArray(); + reportTime = DateTimeOffset.Parse((string)sanity_report[1]); + if (isSanityForecastSucc &= sanity.Length == 2 && sanity[1] > 1) + { + timeDiff = new TimeSpan(0, sanity[0] < sanity[1] ? (sanity[1] - sanity[0]) * 6 : 0, 0); + reportTime = reportTime?.AddMinutes(timeDiff.TotalMinutes); + } + } + var allTaskCompleteTitle = LocalizationHelper.GetString("AllTasksComplete"); var allTaskCompleteMessage = LocalizationHelper.GetString("AllTaskCompleteContent"); + var sanityReport = LocalizationHelper.GetString("SanityReport"); - var configurationPreset = ConfigurationHelper.GetValue(ConfigurationKeys.CurrentConfiguration, "Default"); + var configurationPreset = ConfigurationHelper.GetCurrentConfiguration(); allTaskCompleteMessage = allTaskCompleteMessage - .Replace("{Datetime}", DateTime.Now.ToString("U")) + .Replace("{DateTime}", DateTime.Now.ToString("U")) .Replace("{Preset}", configurationPreset); + if (isSanityForecastSucc) + { + sanityReport = sanityReport.Replace("{DateTime}", reportTime?.ToString("T")).Replace("{TimeDiff}", timeDiff.ToString(@"hh\:mm")); + + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete") + Environment.NewLine + sanityReport); + ExternalNotificationService.Send(allTaskCompleteTitle, allTaskCompleteMessage + Environment.NewLine + sanityReport); + } + else + { + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete")); + ExternalNotificationService.Send(allTaskCompleteTitle, allTaskCompleteMessage); + } - ExternalNotificationService.Send(allTaskCompleteTitle, allTaskCompleteMessage); using (var toast = new ToastNotification(allTaskCompleteTitle)) { + if (isSanityForecastSucc) + { + toast.AppendContentText(sanityReport); + } + toast.Show(); } diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 2aad54a6dd..d394a30a29 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -541,7 +541,8 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Start combat: Complete combat All task(s) completed! - MAA has completed all tasks under the {Preset} configuration in {Datetime}. + Sanity will be full on {DateTime} ({TimeDiff} later). + MAA has completed all tasks under the {Preset} configuration in {DateTime}. Tasks started Tasks stopped Failed to open the client. Please check the configuration file diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 2329e90b67..18f1dfaf03 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -541,7 +541,8 @@ Bilibili: ログイン インターフェイスに表示されるアカウント 戦闘開始: 戦闘完了 すべてのタスクが完了しました! - MAA は、{Datetime} の {Preset} 構成の下にあるすべてのプリセット タスクを完了しました。 + 理性は {DateTime} に満杯になります ({TimeDiff} 後)。 + MAA は、{DateTime} の {Preset} 構成の下にあるすべてのプリセット タスクを完了しました。 Tasks started Tasks stopped クライアントを開くのに失敗しました。構成ファイルを確認してください diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index e0209e8ffb..1af088791a 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -541,7 +541,8 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: Zhang San 작전 시작: 작전 완료 모든 작업이 완료되었습니다! - MAA는 {Datetime}의 {Preset} 구성에서 모든 사전 설정 작업을 완료했습니다. + {DateTime}({TimeDiff} 이후)에 정신 상태가 가득 차게 됩니다. + MAA는 {DateTime}의 {Preset} 구성에서 모든 사전 설정 작업을 완료했습니다. 작업 시작됨 작업 중지됨 클라이언트를 시작하지 못했습니다. 설정 파일을 확인하세요 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 47c7babffb..68f113a8ec 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -541,7 +541,8 @@ 开始战斗: 完成战斗 任务已全部完成! - MAA 已在 {Datetime} 完成了 {Preset} 配置下所有预设的任务。 + 理智将在 {DateTime} ({TimeDiff} 后) 回满。 + MAA 已在 {DateTime} 完成了 {Preset} 配置下所有预设的任务。 开始执行任务 任务终止 打开客户端失败,请检查配置文件 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 389a3b867e..5b3b080515 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -541,7 +541,8 @@ 開始戰鬥: 完成戰鬥 任務已全部完成! - MAA 已在 {Datetime} 完成了 {Preset} 配置下所有預設的任務。 + 理智會在 {DateTime} ({TimeDiff} 後) 回滿。 + MAA 已在 {DateTime} 完成了 {Preset} 配置下所有預設的任務。 開始執行任務 任務終止 打開用戶端失敗,請檢查設定檔