From 0f6da39c5995bc957bb225fb6a020bbf4243ed2f Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 20 May 2022 00:07:29 +0800 Subject: [PATCH] =?UTF-8?q?feat.=E7=AE=80=E5=8D=95=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E4=B8=8B=E6=8A=84=E4=BD=9C=E4=B8=9A=E7=9A=84?= =?UTF-8?q?=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistant/BattleFormationTask.cpp | 13 ++++++++ src/MeoAssistant/BattleProcessTask.cpp | 27 ++++++++++++++++ src/MeoAsstGui/Bootstrapper.cs | 1 + src/MeoAsstGui/Helper/AsstProxy.cs | 13 ++++++++ src/MeoAsstGui/ViewModels/CopilotViewModel.cs | 21 +++++++++++- src/MeoAsstGui/Views/CopilotView.xaml | 32 ++++++++++++------- 6 files changed, 95 insertions(+), 12 deletions(-) diff --git a/src/MeoAssistant/BattleFormationTask.cpp b/src/MeoAssistant/BattleFormationTask.cpp index fe0fbe7eb4..686e210904 100644 --- a/src/MeoAssistant/BattleFormationTask.cpp +++ b/src/MeoAssistant/BattleFormationTask.cpp @@ -26,6 +26,14 @@ bool asst::BattleFormationTask::_run() return false; } + json::value info = basic_info_with_what("BattleFormation"); + auto& details = info["details"]; + auto& formation = details["formation"]; + for (const auto& [name, oper_vec] : m_groups) { + formation.array_emplace(name); + } + callback(AsstMsg::SubTaskExtraInfo, info); + // TODO: 需要加一个滑到头了的检测 while (!need_exit()) { select_opers_in_cur_page(); @@ -89,6 +97,11 @@ bool asst::BattleFormationTask::select_opers_in_cur_page() m_ctrler->click(SkillRectArray.at(skill - 1)); } m_groups.erase(iter); + + json::value info = basic_info_with_what("BattleFormationSelected"); + auto& details = info["details"]; + details["selected"] = name; + callback(AsstMsg::SubTaskExtraInfo, info); } return true; diff --git a/src/MeoAssistant/BattleProcessTask.cpp b/src/MeoAssistant/BattleProcessTask.cpp index 19530a124d..9278ffb46f 100644 --- a/src/MeoAssistant/BattleProcessTask.cpp +++ b/src/MeoAssistant/BattleProcessTask.cpp @@ -65,6 +65,13 @@ bool asst::BattleProcessTask::get_stage_info() bool asst::BattleProcessTask::analyze_opers_preview() { + { + json::value info = basic_info_with_what("BattleAction"); + auto& details = info["details"]; + details["description"] = "识别干员"; + callback(AsstMsg::SubTaskExtraInfo, info); + } + BattleImageAnalyzer oper_analyzer; oper_analyzer.set_target(BattleImageAnalyzer::Target::Oper); @@ -243,6 +250,26 @@ bool asst::BattleProcessTask::update_opers_info(const cv::Mat& image) bool asst::BattleProcessTask::do_action(const BattleAction& action) { + json::value info = basic_info_with_what("BattleAction"); + auto& details = info["details"]; + std::string desc; + switch (action.type) { + case BattleActionType::Deploy: + desc = action.group_name + " 部署"; + break; + case BattleActionType::Retreat: + desc = action.group_name + " 撤退"; + break; + case BattleActionType::UseSkill: + desc = action.group_name + " 技能"; + break; + case BattleActionType::SwitchSpeed: + desc = "切换二倍速"; + break; + } + details["description"] = desc; + callback(AsstMsg::SubTaskExtraInfo, info); + if (!wait_condition(action)) { return false; } diff --git a/src/MeoAsstGui/Bootstrapper.cs b/src/MeoAsstGui/Bootstrapper.cs index e15906abc8..3261909eb4 100644 --- a/src/MeoAsstGui/Bootstrapper.cs +++ b/src/MeoAsstGui/Bootstrapper.cs @@ -29,6 +29,7 @@ namespace MeoAsstGui builder.Bind().ToSelf().InSingletonScope(); builder.Bind().ToSelf().InSingletonScope(); builder.Bind().ToSelf().InSingletonScope(); + builder.Bind().ToSelf().InSingletonScope(); builder.Bind().ToSelf().InSingletonScope(); } diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 7953a724c6..4236cdaf8e 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -371,6 +371,7 @@ namespace MeoAsstGui var subTaskDetails = details["details"]; var mainModel = _container.Get(); + var copilotModel = _container.Get(); switch (what) { case "StageDrops": @@ -489,6 +490,18 @@ namespace MeoAsstGui } } break; + + case "BattleFormation": + copilotModel.AddLog("开始编队\n" + JsonConvert.SerializeObject(subTaskDetails["formation"])); + break; + + case "BattleFormationSelected": + copilotModel.AddLog("选择干员:" + subTaskDetails["selected"].ToString()); + break; + + case "BattleAction": + copilotModel.AddLog("当然步骤:" + subTaskDetails["description"].ToString()); + break; } } diff --git a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs index 3a72e029db..442a38ef8e 100644 --- a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs +++ b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs @@ -29,12 +29,25 @@ namespace MeoAsstGui { private readonly IWindowManager _windowManager; private readonly IContainer _container; + public ObservableCollection LogItemViewModels { get; set; } public CopilotViewModel(IContainer container, IWindowManager windowManager) { _container = container; _windowManager = windowManager; - DisplayName = "自动战斗"; + DisplayName = "自动战斗 Beta"; + LogItemViewModels = new ObservableCollection(); + } + + public void AddLog(string content, string color = "Gray", string weight = "Regular") + { + LogItemViewModels.Add(new LogItemViewModel(content, color, weight)); + //LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight)); + } + + public void ClearLog() + { + LogItemViewModels.Clear(); } private string _filename; @@ -69,6 +82,8 @@ namespace MeoAsstGui public async void Start() { + AddLog("正在连接模拟器……"); + var asstProxy = _container.Get(); if (!_catched) { @@ -80,10 +95,12 @@ namespace MeoAsstGui } if (!_catched) { + AddLog("连接模拟器失败\n请检查连接设置", "darkred"); return; } if (Filename.Length == 0 || !File.Exists(Filename)) { + AddLog("作业文件不存在", "darkred"); return; } @@ -98,10 +115,12 @@ namespace MeoAsstGui } catch (Exception) { + AddLog("作业文件读取出错", "darkred"); return; } asstProxy.AsstStartCopilot(data["stage_name"].ToString(), Filename, Form); + AddLog("Star Burst Stream!"); } public void Stop() diff --git a/src/MeoAsstGui/Views/CopilotView.xaml b/src/MeoAsstGui/Views/CopilotView.xaml index 08cf4918f2..9be5c04f32 100644 --- a/src/MeoAsstGui/Views/CopilotView.xaml +++ b/src/MeoAsstGui/Views/CopilotView.xaml @@ -9,23 +9,33 @@ mc:Ignorable="d" d:DesignHeight="495" d:DesignWidth="800"> - - - - - - + + + + + + Width="300" Height="30" InputMethod.IsInputMethodEnabled="False" />