diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index 526a215..08a9d62 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -60,8 +60,9 @@ namespace VPet_Simulator.Core var ig = Core.Graph.FindGraph(GraphCore.GraphType.Default, core.Save.Mode); PetGrid.Child = ig.This; - var ig2 = Core.Graph.FindGraph(GraphCore.GraphType.Touch_Head_A_Start, core.Save.Mode); + var ig2 = Core.Graph.FindGraph(GraphCore.GraphType.Touch_Head_A_Start, core.Save.Mode); PetGrid2.Child = ig2.This; //用于缓存 + PetGrid2.Visibility = Visibility.Collapsed; ig.Run(DisplayNomal); diff --git a/VPet-Simulator.Core/Display/MainDisplay.cs b/VPet-Simulator.Core/Display/MainDisplay.cs index 0341f0c..65b72fe 100644 --- a/VPet-Simulator.Core/Display/MainDisplay.cs +++ b/VPet-Simulator.Core/Display/MainDisplay.cs @@ -873,7 +873,7 @@ namespace VPet_Simulator.Core default: Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio); MoveTimer.Enabled = false; - DisplayFalled_Right(); + DisplayFalled_Left(); return; } } @@ -886,7 +886,7 @@ namespace VPet_Simulator.Core {//停下来 Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio); MoveTimer.Enabled = false; - DisplayFalled_Right(); + DisplayFalled_Left(); } } /// diff --git a/VPet-Simulator.Core/Display/MessageBar.xaml.cs b/VPet-Simulator.Core/Display/MessageBar.xaml.cs index 9d8ff68..8f2f966 100644 --- a/VPet-Simulator.Core/Display/MessageBar.xaml.cs +++ b/VPet-Simulator.Core/Display/MessageBar.xaml.cs @@ -59,7 +59,7 @@ namespace VPet_Simulator.Core { Task.Run(() => { - Thread.Sleep(timeleft * 50); + Thread.Sleep(timeleft * 100); if (m.DisplayType == GraphCore.GraphType.Default || m.DisplayType.ToString().Contains("Say")) m.Display(GraphCore.GraphType.Say_C_End, m.DisplayNomal); }); diff --git a/VPet-Simulator.Core/Graph/GraphCore.cs b/VPet-Simulator.Core/Graph/GraphCore.cs index 6e84387..c87bbb5 100644 --- a/VPet-Simulator.Core/Graph/GraphCore.cs +++ b/VPet-Simulator.Core/Graph/GraphCore.cs @@ -11,7 +11,7 @@ namespace VPet_Simulator.Core { public class GraphCore { - + public static string CachePath = AppDomain.CurrentDomain.BaseDirectory + @"\cache"; /// /// 动画类型 /// @@ -298,7 +298,7 @@ namespace VPet_Simulator.Core AddGraph(new Picture(paths[0].FullName, modetype, graphtype, int.Parse(paths[0].Name.Split('.').Reverse().ToArray()[1].Split('_').Last())), graphtype); else - AddGraph(new PNGAnimation(paths, modetype, graphtype), graphtype); + AddGraph(new PNGAnimation(path, paths, modetype, graphtype), graphtype); } /// /// 随机数字典(用于确保随机动画不会错位) diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs b/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs index 3becdd0..79859fa 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs @@ -13,9 +13,11 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows; -using static System.Net.WebRequestMethods; using System.Windows.Threading; using System.Threading; +using System.Drawing; +using LinePutScript; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TreeView; namespace VPet_Simulator.Core { @@ -65,9 +67,10 @@ namespace VPet_Simulator.Core /// /// 新建 PNG 动画 /// - /// 文件夹位置 + /// 文件夹位置 + /// 文件内容列表 /// 是否循环 - public PNGAnimation(FileInfo[] paths, Save.ModeType modetype, GraphCore.GraphType graphtype, bool isLoop = false) + public PNGAnimation(string path, FileInfo[] paths, Save.ModeType modetype, GraphCore.GraphType graphtype, bool isLoop = false) { InitializeComponent(); Animations = new List(); @@ -75,18 +78,71 @@ namespace VPet_Simulator.Core //StoreMemory = storemem; GraphType = graphtype; ModeType = modetype; - //if (storemem) - foreach (var file in paths) + //新方法:加载大图片 + //生成大文件加载非常慢,先看看有没有缓存能用 + string cp = GraphCore.CachePath + $"\\{Sub.GetHashCode(path)}_{paths.Length}.png"; + if (File.Exists(cp)) { - int time = int.Parse(file.Name.Split('.').Reverse().ToArray()[1].Split('_').Last()); - var img = new Image() + var img = new System.Windows.Controls.Image() { - Source = new BitmapImage(new Uri(file.FullName)), - Visibility = Visibility.Hidden + HorizontalAlignment = HorizontalAlignment.Left, + Width = 500 * (paths.Length + 1), + Height = 500 }; MainGrid.Children.Add(img); - Animations.Add(new Animation(this, time, () => img.Visibility = Visibility.Visible, () => img.Visibility = Visibility.Hidden)); + for (int i = 0; i < paths.Length; i++) + { + FileInfo file = paths[i]; + int time = int.Parse(file.Name.Split('.').Reverse().ToArray()[1].Split('_').Last()); + int wxi = -500 * i; + Animations.Add(new Animation(this, time, () => img.Margin = new Thickness(wxi, 0, 0, 0))); + } + img.Source = new BitmapImage(new Uri(cp)); } + else + { + List imgs = new List(); + foreach (var file in paths) + imgs.Add(System.Drawing.Image.FromFile(file.FullName)); + int w = imgs[0].Width; + int h = imgs[0].Height; + Bitmap joinedBitmap = new Bitmap(w * paths.Length, h); + var graph = Graphics.FromImage(joinedBitmap); + var img = new System.Windows.Controls.Image() + { + HorizontalAlignment = HorizontalAlignment.Left, + Width = 500 * (paths.Length + 1), + Height = 500 + }; + MainGrid.Children.Add(img); + for (int i = 0; i < paths.Length; i++) + { + FileInfo file = paths[i]; + int time = int.Parse(file.Name.Split('.').Reverse().ToArray()[1].Split('_').Last()); + graph.DrawImage(imgs[i], w * i, 0, w, h); + int wxi = -500 * i; + Animations.Add(new Animation(this, time, () => img.Margin = new Thickness(wxi, 0, 0, 0))); + } + joinedBitmap.Save(cp); + graph.Dispose(); + joinedBitmap.Dispose(); + imgs.ForEach(x => x.Dispose()); + img.Source = new BitmapImage(new Uri(cp)); + } + + + //if (storemem) + //foreach (var file in paths) + //{ + // int time = int.Parse(file.Name.Split('.').Reverse().ToArray()[1].Split('_').Last()); + // var img = new Image() + // { + // Source = new BitmapImage(new Uri(file.FullName)), + // Visibility = Visibility.Hidden + // }; + // MainGrid.Children.Add(img); + // Animations.Add(new Animation(this, time, () => img.Visibility = Visibility.Visible, () => img.Visibility = Visibility.Hidden)); + //} //else //{ // Image[] imgs = new Image[3]; @@ -149,20 +205,20 @@ namespace VPet_Simulator.Core /// 显示 /// public Action Visible; - /// - /// 隐藏 - /// - public Action Hidden; + ///// + ///// 隐藏 + ///// + //public Action Hidden; /// /// 帧时间 /// public int Time; - public Animation(PNGAnimation parent, int time, Action visible, Action hidden) + public Animation(PNGAnimation parent, int time, Action visible)//, Action hidden) { this.parent = parent; Time = time; Visible = visible; - Hidden = hidden; + //Hidden = hidden; } /// /// 运行该图层 @@ -193,24 +249,24 @@ namespace VPet_Simulator.Core EndAction?.Invoke();//运行结束动画时事件 parent.StopAction?.Invoke(); parent.StopAction = null; - //延时隐藏 - Task.Run(() => - { - Thread.Sleep(25); - parent.Dispatcher.Invoke(Hidden); - }); + ////延时隐藏 + //Task.Run(() => + //{ + // Thread.Sleep(25); + // parent.Dispatcher.Invoke(Hidden); + //}); return; } //要下一步,现在就隐藏图层 //隐藏该图层 - parent.Dispatcher.Invoke(Hidden); + //parent.Dispatcher.Invoke(Hidden); parent.Animations[parent.nowid].Run(EndAction); return; } else { parent.IsContinue = false; - parent.Dispatcher.Invoke(Hidden); + //parent.Dispatcher.Invoke(Hidden); if (parent.DoEndAction) EndAction?.Invoke();//运行结束动画时事件 parent.StopAction?.Invoke(); diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj index 664e9e5..319623a 100644 --- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj +++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj @@ -69,15 +69,13 @@ - ..\packages\LinePutScript.1.6.1\lib\net462\LinePutScript.dll + ..\..\VUPSimulator\packages\LinePutScript.1.6.1\lib\net462\LinePutScript.dll - False - ..\Refer\Panuon.WPF.dll + ..\..\VUPSimulator\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll - - False - ..\Refer\Panuon.WPF.UI.dll + + ..\..\VUPSimulator\packages\Panuon.WPF.UI.1.1.6.7\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Core/packages.config b/VPet-Simulator.Core/packages.config index 07c1614..608dcf0 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/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index a29f3ff..948e540 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -72,6 +72,11 @@ namespace VPet_Simulator.Windows } else Set = new Setting("Setting#VPET:|\n"); + + if (!Directory.Exists(GraphCore.CachePath)) + { + Directory.CreateDirectory(GraphCore.CachePath); + } //this.Width = 400 * ZoomSlider.Value; //this.Height = 450 * ZoomSlider.Value; @@ -156,7 +161,6 @@ namespace VPet_Simulator.Windows Dispatcher.Invoke(new Action(() => { Core.Graph = Pets[0].Graph(); - LoadingText.Visibility = Visibility.Collapsed; winSetting = new winGameSetting(this); Main = new Main(Core) { }; Main.DefaultClickAction = () => @@ -179,6 +183,7 @@ namespace VPet_Simulator.Windows Main.SetMoveMode(Set.AllowMove, Set.SmartMove, Set.SmartMoveInterval * 1000); Main.SetLogicInterval((int)(Set.LogicInterval * 1000)); + LoadingText.Visibility = Visibility.Collapsed; //加载图标 notifyIcon = new NotifyIcon(); notifyIcon.Text = "虚拟桌宠模拟器"; @@ -217,6 +222,12 @@ namespace VPet_Simulator.Windows Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议"); }); } + else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 2, 13)) + { + Set["SingleTips"].SetDateTime("update", DateTime.Now); + notifyIcon.ShowBalloonTip(10, "更新通知 02/13", + "现在使用缓存机制,不仅占用小,而且再也不会有那种闪闪的问题了!", ToolTipIcon.Info); + } })); }