修复快速点击误触发长按的问题

This commit is contained in:
ZouJin 2023-01-20 20:40:42 +08:00
parent 3210cc7c2b
commit ee8bb69942
3 changed files with 24 additions and 13 deletions

View File

@ -28,8 +28,6 @@
![ss4](README.assets/ss4.gif)![ss4](README.assets/ss8.gif) ![ss4](README.assets/ss4.gif)![ss4](README.assets/ss8.gif)
##### 爬墙 ##### 爬墙
![ss7](README.assets/ss7.gif) ![ss7](README.assets/ss7.gif)

View File

@ -72,9 +72,11 @@ namespace VPet_Simulator.Core
} }
public Action DefaultClickAction; public Action DefaultClickAction;
bool isPress = false; bool isPress = false;
long presstime;
private void MainGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) private void MainGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ {
isPress = true; isPress = true;
CountNomal = 0;
if (DisplayType != GraphCore.GraphType.Default) if (DisplayType != GraphCore.GraphType.Default)
{//不是nomal! 可能会卡timer,所有全部timer清空下 {//不是nomal! 可能会卡timer,所有全部timer清空下
MoveTimer.Stop(); MoveTimer.Stop();
@ -84,14 +86,16 @@ namespace VPet_Simulator.Core
} }
Task.Run(() => Task.Run(() =>
{ {
var pth = DateTime.Now.Ticks;
presstime = pth;
Thread.Sleep(Core.Controller.PressLength); Thread.Sleep(Core.Controller.PressLength);
Point mp = default; Point mp = default;
Dispatcher.BeginInvoke(new Action(() => mp = Mouse.GetPosition(MainGrid))).Wait(); Dispatcher.BeginInvoke(new Action(() => mp = Mouse.GetPosition(MainGrid))).Wait();
if (isPress) if (isPress && presstime == pth)
{//历遍长按事件 {//历遍长按事件
var act = Core.TouchEvent.FirstOrDefault(x => x.IsPress == true && x.Touch(mp)); var act = Core.TouchEvent.FirstOrDefault(x => x.IsPress == true && x.Touch(mp));
if (act != null) if (act != null)
Dispatcher.BeginInvoke(act.DoAction); Dispatcher.Invoke(act.DoAction);
} }
else else
{//历遍点击事件 {//历遍点击事件
@ -107,7 +111,7 @@ namespace VPet_Simulator.Core
private void MainGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) private void MainGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{ {
isPress = false; isPress = false;
if (rasetype != int.MinValue) if (DisplayType.ToString().StartsWith("Raised"))
{ {
MainGrid.MouseMove -= MainGrid_MouseMove; MainGrid.MouseMove -= MainGrid_MouseMove;
rasetype = -1; rasetype = -1;

View File

@ -55,6 +55,10 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
public void DisplayTouchHead() public void DisplayTouchHead()
{ {
if (Core.Save.Strength <= 50)
return;
Core.Save.StrengthChange(-1);
Core.Save.FeelingChange(1);
if (DisplayType == GraphCore.GraphType.Touch_Head_B_Loop) if (DisplayType == GraphCore.GraphType.Touch_Head_B_Loop)
if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop)
{ {
@ -78,6 +82,7 @@ namespace VPet_Simulator.Core
public void DisplayBoring() public void DisplayBoring()
{ {
looptimes = 0; looptimes = 0;
CountNomal = 0;
Display(Core.Graph.FindGraph(GraphCore.GraphType.Boring_A_Start, Core.Save.Mode), DisplayBoringing); Display(Core.Graph.FindGraph(GraphCore.GraphType.Boring_A_Start, Core.Save.Mode), DisplayBoringing);
} }
/// <summary> /// <summary>
@ -97,6 +102,7 @@ namespace VPet_Simulator.Core
public void DisplaySquat() public void DisplaySquat()
{ {
looptimes = 0; looptimes = 0;
CountNomal = 0;
Display(Core.Graph.FindGraph(GraphCore.GraphType.Squat_A_Start, Core.Save.Mode), DisplaySquating); Display(Core.Graph.FindGraph(GraphCore.GraphType.Squat_A_Start, Core.Save.Mode), DisplaySquating);
} }
/// <summary> /// <summary>
@ -181,6 +187,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () => Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () =>
{ {
MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedWalk, 0); MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedWalk, 0);
@ -239,7 +246,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () => Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () =>
{ {
MoveTimerPoint = new Point(Core.Graph.GraphConfig.SpeedWalk, 0); MoveTimerPoint = new Point(Core.Graph.GraphConfig.SpeedWalk, 0);
@ -356,6 +363,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceLeft() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 300 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceLeft() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 300 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio - 145, 0);//TODO:锚定设置 Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio - 145, 0);//TODO:锚定设置
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () => Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () =>
{ {
@ -408,7 +416,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceLeft() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceLeft() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio - 145, 0);//TODO:锚定设置 Core.Controller.MoveWindows(-Core.Controller.GetWindowsDistanceLeft() / Core.Controller.ZoomRatio - 145, 0);//TODO:锚定设置
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () => Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () =>
@ -452,7 +460,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Core.Controller.MoveWindows(Core.Controller.GetWindowsDistanceRight() / Core.Controller.ZoomRatio + 185, 0);//TODO:锚定设置 Core.Controller.MoveWindows(Core.Controller.GetWindowsDistanceRight() / Core.Controller.ZoomRatio + 185, 0);//TODO:锚定设置
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () => Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () =>
@ -506,7 +514,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Core.Controller.MoveWindows(Core.Controller.GetWindowsDistanceRight() / Core.Controller.ZoomRatio + 185, 0);//TODO:锚定设置 Core.Controller.MoveWindows(Core.Controller.GetWindowsDistanceRight() / Core.Controller.ZoomRatio + 185, 0);//TODO:锚定设置
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () => Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () =>
@ -550,6 +558,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceUp() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceUp() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置 Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置
MoveTimerPoint = new Point(Core.Graph.GraphConfig.SpeedClimbTop, 0); MoveTimerPoint = new Point(Core.Graph.GraphConfig.SpeedClimbTop, 0);
@ -600,7 +609,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.GetWindowsDistanceUp() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio) if (Core.Controller.GetWindowsDistanceUp() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio)
{ {
walklength = 0; walklength = 0;
CountNomal = 0;
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置 Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置
MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedClimbTop, 0); MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedClimbTop, 0);