mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
修复快速点击误触发长按的问题
This commit is contained in:
parent
3210cc7c2b
commit
ee8bb69942
@ -28,8 +28,6 @@
|
||||
|
||||
![ss4](README.assets/ss4.gif)![ss4](README.assets/ss8.gif)
|
||||
|
||||
|
||||
|
||||
##### 爬墙
|
||||
|
||||
![ss7](README.assets/ss7.gif)
|
||||
|
@ -57,7 +57,7 @@ namespace VPet_Simulator.Core
|
||||
var ig = Core.Graph.FindGraph(GraphCore.GraphType.Default, Core.Save.Mode);
|
||||
PetGrid.Child = ig.This;
|
||||
ig.Run(DisplayNomal);
|
||||
|
||||
|
||||
|
||||
EventTimer.Elapsed += EventTimer_Elapsed;
|
||||
MoveTimer.Elapsed += MoveTimer_Elapsed;
|
||||
@ -72,9 +72,11 @@ namespace VPet_Simulator.Core
|
||||
}
|
||||
public Action DefaultClickAction;
|
||||
bool isPress = false;
|
||||
long presstime;
|
||||
private void MainGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
isPress = true;
|
||||
CountNomal = 0;
|
||||
if (DisplayType != GraphCore.GraphType.Default)
|
||||
{//不是nomal! 可能会卡timer,所有全部timer清空下
|
||||
MoveTimer.Stop();
|
||||
@ -84,14 +86,16 @@ namespace VPet_Simulator.Core
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(Core.Controller.PressLength);
|
||||
var pth = DateTime.Now.Ticks;
|
||||
presstime = pth;
|
||||
Thread.Sleep(Core.Controller.PressLength);
|
||||
Point mp = default;
|
||||
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));
|
||||
if (act != null)
|
||||
Dispatcher.BeginInvoke(act.DoAction);
|
||||
Dispatcher.Invoke(act.DoAction);
|
||||
}
|
||||
else
|
||||
{//历遍点击事件
|
||||
@ -107,7 +111,7 @@ namespace VPet_Simulator.Core
|
||||
private void MainGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
isPress = false;
|
||||
if (rasetype != int.MinValue)
|
||||
if (DisplayType.ToString().StartsWith("Raised"))
|
||||
{
|
||||
MainGrid.MouseMove -= MainGrid_MouseMove;
|
||||
rasetype = -1;
|
||||
|
@ -55,6 +55,10 @@ namespace VPet_Simulator.Core
|
||||
/// </summary>
|
||||
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 (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop)
|
||||
{
|
||||
@ -78,6 +82,7 @@ namespace VPet_Simulator.Core
|
||||
public void DisplayBoring()
|
||||
{
|
||||
looptimes = 0;
|
||||
CountNomal = 0;
|
||||
Display(Core.Graph.FindGraph(GraphCore.GraphType.Boring_A_Start, Core.Save.Mode), DisplayBoringing);
|
||||
}
|
||||
/// <summary>
|
||||
@ -97,6 +102,7 @@ namespace VPet_Simulator.Core
|
||||
public void DisplaySquat()
|
||||
{
|
||||
looptimes = 0;
|
||||
CountNomal = 0;
|
||||
Display(Core.Graph.FindGraph(GraphCore.GraphType.Squat_A_Start, Core.Save.Mode), DisplaySquating);
|
||||
}
|
||||
/// <summary>
|
||||
@ -181,6 +187,7 @@ namespace VPet_Simulator.Core
|
||||
if (Core.Controller.GetWindowsDistanceLeft() > 400 * Core.Controller.ZoomRatio)
|
||||
{
|
||||
walklength = 0;
|
||||
CountNomal = 0;
|
||||
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Left_A_Start, Core.Save.Mode), () =>
|
||||
{
|
||||
MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedWalk, 0);
|
||||
@ -239,7 +246,7 @@ namespace VPet_Simulator.Core
|
||||
if (Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio)
|
||||
{
|
||||
walklength = 0;
|
||||
|
||||
CountNomal = 0;
|
||||
Display(Core.Graph.FindGraph(GraphCore.GraphType.Walk_Right_A_Start, Core.Save.Mode), () =>
|
||||
{
|
||||
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)
|
||||
{
|
||||
walklength = 0;
|
||||
CountNomal = 0;
|
||||
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), () =>
|
||||
{
|
||||
@ -408,7 +416,7 @@ namespace VPet_Simulator.Core
|
||||
if (Core.Controller.GetWindowsDistanceLeft() < 50 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio)
|
||||
{
|
||||
walklength = 0;
|
||||
|
||||
CountNomal = 0;
|
||||
|
||||
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), () =>
|
||||
@ -452,7 +460,7 @@ namespace VPet_Simulator.Core
|
||||
if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceUp() > 400 * Core.Controller.ZoomRatio)
|
||||
{
|
||||
walklength = 0;
|
||||
|
||||
CountNomal = 0;
|
||||
|
||||
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), () =>
|
||||
@ -506,7 +514,7 @@ namespace VPet_Simulator.Core
|
||||
if (Core.Controller.GetWindowsDistanceRight() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceDown() > 400 * Core.Controller.ZoomRatio)
|
||||
{
|
||||
walklength = 0;
|
||||
|
||||
CountNomal = 0;
|
||||
|
||||
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), () =>
|
||||
@ -550,6 +558,7 @@ namespace VPet_Simulator.Core
|
||||
if (Core.Controller.GetWindowsDistanceUp() < 100 * Core.Controller.ZoomRatio && Core.Controller.GetWindowsDistanceRight() > 400 * Core.Controller.ZoomRatio)
|
||||
{
|
||||
walklength = 0;
|
||||
CountNomal = 0;
|
||||
|
||||
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置
|
||||
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)
|
||||
{
|
||||
walklength = 0;
|
||||
|
||||
CountNomal = 0;
|
||||
|
||||
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio - 150);//TODO:锚定设置
|
||||
MoveTimerPoint = new Point(-Core.Graph.GraphConfig.SpeedClimbTop, 0);
|
||||
@ -657,7 +666,7 @@ namespace VPet_Simulator.Core
|
||||
/// <param name="graph">动画</param>
|
||||
/// <param name="EndAction">结束操作</param>
|
||||
public void Display(IGraph graph, Action EndAction = null)
|
||||
{
|
||||
{
|
||||
//if(graph.GraphType == GraphType.Climb_Up_Left)
|
||||
//{
|
||||
// Dispatcher.Invoke(() => Say(graph.GraphType.ToString()));
|
||||
|
Loading…
Reference in New Issue
Block a user