diff --git a/VPet-Simulator.Core/Display/Main.xaml b/VPet-Simulator.Core/Display/Main.xaml index 956276b..4a16c28 100644 --- a/VPet-Simulator.Core/Display/Main.xaml +++ b/VPet-Simulator.Core/Display/Main.xaml @@ -1,17 +1,22 @@  - - + + + diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index 338747e..c45ec73 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -64,7 +64,7 @@ namespace VPet_Simulator.Core MsgBar = new MessageBar(this); MsgBar.Visibility = Visibility.Collapsed; UIGrid.Children.Add(MsgBar); - + labeldisplaytimer.Elapsed += Labledisplaytimer_Elapsed; if (loadtouchevent) { @@ -97,6 +97,28 @@ namespace VPet_Simulator.Core MoveTimer.Elapsed += MoveTimer_Elapsed; SmartMoveTimer.Elapsed += SmartMoveTimer_Elapsed; } + + private void Labledisplaytimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + if (--labeldisplaycount <= 0) + { + labeldisplaytimer.Enabled = false; + labeldisplaychangenum1 = 0; + labeldisplaychangenum2 = 0; + Dispatcher.Invoke(() => + { + LabelDisplay.Visibility = Visibility.Collapsed; + }); + } + else if (labeldisplaycount < 50) + { + Dispatcher.Invoke(() => + { + LabelDisplay.Opacity = labeldisplaycount / 50; + }); + } + } + /// /// 自动加载触摸事件 /// diff --git a/VPet-Simulator.Core/Display/MainDisplay.cs b/VPet-Simulator.Core/Display/MainDisplay.cs index a6ad075..4dfb1f7 100644 --- a/VPet-Simulator.Core/Display/MainDisplay.cs +++ b/VPet-Simulator.Core/Display/MainDisplay.cs @@ -1,9 +1,10 @@ using System; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Threading; using static VPet_Simulator.Core.GraphCore; - +using Panuon.WPF.UI; namespace VPet_Simulator.Core { public partial class Main @@ -120,6 +121,7 @@ namespace VPet_Simulator.Core { Core.Save.StrengthChange(-2); Core.Save.FeelingChange(1); + LabelDisplayShowChangeNumber("体力-{1} 心情+{2}", 2, 1, tostr1: "f0", tostr2: "f0"); } if (DisplayType == GraphType.Touch_Head_A_Start) return; @@ -149,6 +151,7 @@ namespace VPet_Simulator.Core { Core.Save.StrengthChange(-2); Core.Save.FeelingChange(1); + LabelDisplayShowChangeNumber("体力-{1} 心情+{2}",2,1,tostr1:"f0", tostr2: "f0"); } if (DisplayType == GraphType.Touch_Body_A_Start) return; diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index d2d77e8..16f4cbf 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -58,7 +58,62 @@ namespace VPet_Simulator.Core } }); } - + int labeldisplaycount = 100; + int labeldisplayhash = 0; + Timer labeldisplaytimer = new Timer(10) + { + AutoReset = true, + }; + double labeldisplaychangenum1 = 0; + double labeldisplaychangenum2 = 0; + /// + /// 显示消息弹窗Label + /// + /// 文本 + /// 持续时间 + public void LabelDisplayShow(string text, int time = 2000) + { + labeldisplayhash = text.GetHashCode(); + Dispatcher.Invoke(() => + { + LabelDisplay.Content = text; + LabelDisplay.Opacity = 1; + LabelDisplay.Visibility = Visibility.Visible; + labeldisplaycount = time / 10; + labeldisplaytimer.Start(); + }); + } + /// + /// 显示消息弹窗Lable,自动统计数值变化 + /// + /// 文本 + /// 变化值1 + /// 变化值2 + /// 持续时间 + /// 转换方法1 + /// 转换方法2 + public void LabelDisplayShowChangeNumber(string text, double changenum1, double changenum2 = 0, int time = 2000, string tostr1 = "f2", string tostr2 = "f2") + { + if (labeldisplayhash == text.GetHashCode()) + { + labeldisplaychangenum1 += changenum1; + labeldisplaychangenum2 += changenum2; + } + else + { + labeldisplaychangenum1 = changenum1; + labeldisplaychangenum2 = changenum2; + labeldisplayhash = text.GetHashCode(); + } + Dispatcher.Invoke(() => + { + LabelDisplay.Content = text.Replace("{1}", labeldisplaychangenum1.ToString(tostr1)).Replace("{2}", labeldisplaychangenum2.ToString(tostr2)); + LabelDisplay.Opacity = 1; + LabelDisplay.Visibility = Visibility.Visible; + labeldisplaycount = time / 10; + labeldisplaytimer.Start(); + }); + } public void Saying(GraphCore.Helper.SayType type) { Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.B_Loop), () => Saying(type)); diff --git a/VPet-Simulator.Core/Display/basestyle.xaml b/VPet-Simulator.Core/Display/basestyle.xaml index 7fd3499..a41cbee 100644 --- a/VPet-Simulator.Core/Display/basestyle.xaml +++ b/VPet-Simulator.Core/Display/basestyle.xaml @@ -5,7 +5,7 @@ - + diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj index 9e4c973..2f4d401 100644 --- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj +++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj @@ -76,8 +76,8 @@ ..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll - - ..\packages\Panuon.WPF.UI.1.1.11.11\lib\net462\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.12.1\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Core/packages.config b/VPet-Simulator.Core/packages.config index ea43eed..0ddc626 100644 --- a/VPet-Simulator.Core/packages.config +++ b/VPet-Simulator.Core/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj index e48163f..fd90ea3 100644 --- a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj +++ b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj @@ -94,8 +94,8 @@ ..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll - - ..\packages\Panuon.WPF.UI.1.1.11.11\lib\net462\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.12.1\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Windows.Interface/packages.config b/VPet-Simulator.Windows.Interface/packages.config index ea43eed..0ddc626 100644 --- a/VPet-Simulator.Windows.Interface/packages.config +++ b/VPet-Simulator.Windows.Interface/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj index 6ba6cbe..4b8567e 100644 --- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj +++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj @@ -87,8 +87,8 @@ ..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll - - ..\packages\Panuon.WPF.UI.1.1.11.11\lib\net48\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.12.1\lib\net48\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Windows/packages.config b/VPet-Simulator.Windows/packages.config index d77ae3d..17060e2 100644 --- a/VPet-Simulator.Windows/packages.config +++ b/VPet-Simulator.Windows/packages.config @@ -6,5 +6,5 @@ - + \ No newline at end of file