From 4dced9db9d463e7a32737b192bb2d422af8a1b1a Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 30 Nov 2021 23:32:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor.=E5=AE=8C=E6=88=90=E4=B8=BB=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 3 +++ src/MeoAsstGui/Helper/AsstProxy.cs | 16 +++++++----- src/MeoAsstGui/Helper/LogItemViewModel.cs | 14 ++++++++++ src/MeoAsstGui/MeoAsstGui.csproj | 3 +++ .../UserControl/FightSettingsUserControl.xaml | 26 ++++++++++--------- .../InfrastSettingsUserControl.xaml | 2 +- .../UserControl/MallSettingsUserControl.xaml | 2 +- .../ViewModels/SettingsViewModel.cs | 4 ++- .../ViewModels/TaskQueueViewModel.cs | 24 ++++++++++++++--- src/MeoAsstGui/Views/RecruitView.xaml | 4 +-- src/MeoAsstGui/Views/SettingsView.xaml | 8 +++--- src/MeoAsstGui/Views/TaskQueueView.xaml | 20 ++++++++------ 12 files changed, 88 insertions(+), 38 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 295ddb8d33..c52d0787a2 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -193,6 +193,7 @@ }, "MedicineConfirm": { "action": "clickSelf", + "cache": false, "maxTimes": 0, "roi": [ 1000, @@ -225,6 +226,7 @@ "StoneConfirm": { "template": "MedicineConfirm.png", "action": "clickSelf", + "cache": false, "maxTimes": 0, "roi": [ 1000, @@ -364,6 +366,7 @@ ], "next": [ "LastBattle", + "Terminal", "CloseAnno", "TodaysSupplies" ] diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index db80154ab7..8ce85bb5c4 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -87,6 +87,7 @@ namespace MeoAsstGui tvm.AddLog("当前任务:" + taskChain); } break; + case AsstMsg.TaskCompleted: { string taskName = detail["name"].ToString(); @@ -115,6 +116,7 @@ namespace MeoAsstGui case AsstMsg.AllTasksCompleted: { tvm.AddLog("任务队列已全部完成"); + tvm.Idle = true; } break; @@ -126,19 +128,21 @@ namespace MeoAsstGui { string itemName = item["itemName"].ToString(); int count = (int)item["quantity"]; - cur_drops += itemName + " : " + count + " \n"; - } - tvm.AddLog("当次掉落:" + cur_drops); + cur_drops += $"{itemName} : {count}\n"; + } + cur_drops = cur_drops.EndsWith("\n") ? cur_drops.TrimEnd('\n') : "无"; + tvm.AddLog("当次掉落:\n" + cur_drops); + string all_drops = ""; JArray statistics = (JArray)detail["statistics"]; foreach (var item in statistics) { string itemName = item["itemName"].ToString(); int count = (int)item["count"]; - all_drops += itemName + " : " + count + " \n"; + all_drops += $"{itemName} : {count}\n"; } - tvm.AddLog("掉落统计:" + all_drops); - + all_drops = all_drops.EndsWith("\n") ? all_drops.TrimEnd('\n') : "无"; + tvm.AddLog("掉落统计:\n" + all_drops); } break; diff --git a/src/MeoAsstGui/Helper/LogItemViewModel.cs b/src/MeoAsstGui/Helper/LogItemViewModel.cs index 5fc2134a3f..5537839d57 100644 --- a/src/MeoAsstGui/Helper/LogItemViewModel.cs +++ b/src/MeoAsstGui/Helper/LogItemViewModel.cs @@ -9,6 +9,7 @@ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading.Tasks; @@ -21,11 +22,23 @@ namespace MeoAsstGui { public LogItemViewModel(string content, string color = "Black", string weight = "Regular") { + Time = DateTime.Now.ToString("MM'-'dd' 'HH':'mm':'ss") + " "; this.Content = content; this.Color = color; this.Weight = weight; } + private string _time; + + public string Time + { + get { return _time; } + set + { + SetAndNotify(ref _time, value); + } + } + private string _content; public string Content @@ -38,6 +51,7 @@ namespace MeoAsstGui } private string _color; + public string Color { get { return _color; } diff --git a/src/MeoAsstGui/MeoAsstGui.csproj b/src/MeoAsstGui/MeoAsstGui.csproj index 98d434b460..848573f827 100644 --- a/src/MeoAsstGui/MeoAsstGui.csproj +++ b/src/MeoAsstGui/MeoAsstGui.csproj @@ -218,6 +218,9 @@ + + 2.5.2 + 5.7.0 runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml index c40c01a54f..f7f3363148 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml @@ -4,7 +4,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding" mc:Ignorable="d" + xmlns:local="clr-namespace:MeoAsstGui" d:DesignHeight="150" d:DesignWidth="300"> @@ -13,27 +15,27 @@ - - - + + - + - - - + + - + - - - + + - + \ No newline at end of file diff --git a/src/MeoAsstGui/UserControl/InfrastSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/InfrastSettingsUserControl.xaml index c48df7fc2f..7525a1a3cf 100644 --- a/src/MeoAsstGui/UserControl/InfrastSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/InfrastSettingsUserControl.xaml @@ -7,7 +7,7 @@ xmlns:dd="urn:gong-wpf-dragdrop" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="550"> - + diff --git a/src/MeoAsstGui/UserControl/MallSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/MallSettingsUserControl.xaml index 9889d9caf1..1bd5b5e96a 100644 --- a/src/MeoAsstGui/UserControl/MallSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/MallSettingsUserControl.xaml @@ -7,7 +7,7 @@ xmlns:dd="urn:gong-wpf-dragdrop" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="550"> - + diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index 41652fdd0e..a6cbf7f2e0 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -198,9 +198,10 @@ namespace MeoAsstGui SetAndNotify(ref _infrastWorkMode, value); } } + /* 信用商店设置 */ - private bool _creditShopping = false; + private bool _creditShopping = System.Convert.ToBoolean(ViewStatusStorage.Get("Mall.CreditShopping", bool.FalseString)); public bool CreditShopping { @@ -208,6 +209,7 @@ namespace MeoAsstGui set { SetAndNotify(ref _creditShopping, value); + ViewStatusStorage.Set("Mall.CreditShopping", value.ToString()); } } } diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index 65c0f0adbe..ba68cf241d 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -38,14 +38,19 @@ namespace MeoAsstGui public void AddLog(string content, string color = "Black", string weight = "Regular") { - string time = DateTime.Now.ToString("MM'-'dd' 'HH':'mm':'ss") + " "; - LogItemViewModels.Add(new LogItemViewModel(time + content, color, weight)); + LogItemViewModels.Add(new LogItemViewModel(content, color, weight)); //LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight)); } + public void ClearLog() + { + LogItemViewModels.Clear(); + } public async void LinkStart() { + ClearLog(); + AddLog("正在捕获模拟器窗口……"); var asstProxy = _container.Get(); @@ -98,6 +103,7 @@ namespace MeoAsstGui { AddLog("出现未知错误"); } + Idle = !ret; } public void Stop() @@ -105,6 +111,7 @@ namespace MeoAsstGui var asstProxy = _container.Get(); asstProxy.AsstStop(); AddLog("已停止"); + Idle = true; } private bool appendFight() @@ -155,7 +162,18 @@ namespace MeoAsstGui return asstProxy.AsstAppendMall(settings.CreditShopping); } - private bool _shutdown; + private bool _idle = true; + + public bool Idle + { + get { return _idle; } + set + { + SetAndNotify(ref _idle, value); + } + } + + private bool _shutdown = false; public bool Shutdown { diff --git a/src/MeoAsstGui/Views/RecruitView.xaml b/src/MeoAsstGui/Views/RecruitView.xaml index 81a9b1a0e5..b8addde8d6 100644 --- a/src/MeoAsstGui/Views/RecruitView.xaml +++ b/src/MeoAsstGui/Views/RecruitView.xaml @@ -6,7 +6,7 @@ xmlns:s="https://github.com/canton7/Stylet" mc:Ignorable="d" d:DesignHeight="495" d:DesignWidth="800"> - + @@ -29,7 +29,7 @@ - +