From a81dcd59b376cc94fe004d09e53eee0f7292e517 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Mon, 24 Jul 2023 08:57:06 +1000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTimer=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/Main.xaml.cs | 28 +++++++++++++++++++----- VPet-Simulator.Core/Display/MainLogic.cs | 9 +++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index dd96b72..7f6e71c 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -1,4 +1,5 @@ using LinePutScript; +using LinePutScript.Localization.WPF; using Panuon.WPF.UI; using System; using System.Linq; @@ -180,20 +181,37 @@ namespace VPet_Simulator.Core PlayingVoice = false; VoicePlayer.Clock = null; } - + public bool MoveTimerSmartMove = false; private void SmartMoveTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - MoveTimer.AutoReset = false; + MoveTimerSmartMove = false; } private void MoveTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - if (MoveTimer.Enabled == false || DisplayType.Type != GraphType.Move) + if (DisplayType.Type != GraphType.Move || !MoveTimerSmartMove) { - MoveTimer.Enabled = false; return; } Core.Controller.MoveWindows(MoveTimerPoint.X, MoveTimerPoint.Y); + + //if (Core.Controller.GetWindowsDistanceLeft() < -500) + //{ + // MessageBox.Show("当前动画移动设计错误: 已到达边界 左侧\n动画名称: {0}\n距离: {1}".Translate(DisplayType.Name, Core.Controller.GetWindowsDistanceLeft()), "MOD移动设计错误".Translate()); + //} + //else if (Core.Controller.GetWindowsDistanceRight() < -500) + //{ + // MessageBox.Show("当前动画移动设计错误: 已到达边界 右侧\n动画名称: {0}\n距离: {1}".Translate(DisplayType.Name, Core.Controller.GetWindowsDistanceRight()), "MOD移动设计错误".Translate()); + //} + //else if (Core.Controller.GetWindowsDistanceUp() < -500) + //{ + // MessageBox.Show("当前动画移动设计错误: 已到达边界 上侧\n动画名称: {0}\n距离: {1}".Translate(DisplayType.Name, Core.Controller.GetWindowsDistanceUp()), "MOD移动设计错误".Translate()); + //} + //else if (Core.Controller.GetWindowsDistanceDown() < -500) + //{ + // MessageBox.Show("当前动画移动设计错误: 已到达边界 下侧\n动画名称: {0}\n距离: {1}".Translate(DisplayType.Name, Core.Controller.GetWindowsDistanceDown()), "MOD移动设计错误".Translate()); + //} + MoveTimer.Start(); } public Action DefaultClickAction; bool isPress = false; @@ -256,7 +274,7 @@ namespace VPet_Simulator.Core //} if (SmartMove) { - MoveTimer.AutoReset = true; + MoveTimerSmartMove = true; SmartMoveTimer.Enabled = false; SmartMoveTimer.Start(); } diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index 7ce363f..ef97586 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -349,10 +349,7 @@ namespace VPet_Simulator.Core /// /// 定点移动定时器 /// - public Timer MoveTimer = new Timer(125) - { - AutoReset = true, - }; + public Timer MoveTimer = new Timer(); /// /// 设置计算间隔 /// @@ -380,7 +377,7 @@ namespace VPet_Simulator.Core MoveTimer.Enabled = false; if (AllowMove) { - MoveTimer.AutoReset = true; + MoveTimerSmartMove = true; if (smartMove) { SmartMoveTimer.Interval = SmartMoveInterval; @@ -395,7 +392,7 @@ namespace VPet_Simulator.Core } else { - MoveTimer.AutoReset = false; + MoveTimerSmartMove = false; } } ///