From 2fe0b0e089a2f8c8a6b8bcb84acd5ee6eee61a2a Mon Sep 17 00:00:00 2001 From: ZouJin Date: Mon, 15 May 2023 20:44:30 +1000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=AF=BC=E8=87=B4=E7=9A=84GDI=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/Main.xaml.cs | 5 ++ VPet-Simulator.Core/Display/MainLogic.cs | 3 +- VPet-Simulator.Core/Graph/GraphCore.cs | 1 + VPet-Simulator.Core/Graph/PNGAnimation.cs | 7 ++- VPet-Simulator.Core/Handle/PetLoader.cs | 7 ++- .../VPet-Simulator.Core.csproj | 6 +- VPet-Simulator.Core/packages.config | 2 +- .../VPet-Simulator.Windows.Interface.csproj | 4 +- .../packages.config | 2 +- VPet-Simulator.Windows/MainWindow.xaml.cs | 63 ++++++++++--------- .../VPet-Simulator.Windows.csproj | 4 +- VPet-Simulator.Windows/packages.config | 2 +- 12 files changed, 62 insertions(+), 44 deletions(-) diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index c95799a..6504d47 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -43,6 +43,10 @@ namespace VPet_Simulator.Core /// 刷新时间时会调用该方法,在所有任务处理完之后 /// public event Action
TimeUIHandle; + /// + /// 是否开始运行 + /// + public bool IsWorking { get; private set; } = false; public Main(GameCore core, bool loadtouchevent = true) { Console.WriteLine(DateTime.Now.ToString("T:fff")); @@ -67,6 +71,7 @@ namespace VPet_Simulator.Core ig.WaitForReadyRun(PetGrid, () => { + IsWorking = true; Dispatcher.Invoke(() => { PetGrid.Tag = ig; diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index 3c2e60e..5db7ebf 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -102,8 +102,7 @@ namespace VPet_Simulator.Core var newmod = Core.Save.CalMode(); if (Core.Save.Mode != newmod) { - //TODO:切换逻辑 - + //TODO:切换显示动画 Core.Save.Mode = newmod; } } diff --git a/VPet-Simulator.Core/Graph/GraphCore.cs b/VPet-Simulator.Core/Graph/GraphCore.cs index 6fc95e6..356f07b 100644 --- a/VPet-Simulator.Core/Graph/GraphCore.cs +++ b/VPet-Simulator.Core/Graph/GraphCore.cs @@ -18,6 +18,7 @@ namespace VPet_Simulator.Core { if (!Directory.Exists(CachePath)) Directory.CreateDirectory(CachePath); + CommConfig["Cache"] = new List(); } public static string CachePath = AppDomain.CurrentDomain.BaseDirectory + @"\cache"; diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.cs b/VPet-Simulator.Core/Graph/PNGAnimation.cs index fe0a709..f6cf011 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.cs @@ -88,7 +88,6 @@ namespace VPet_Simulator.Core GraphCore.CommUIElements["Image1.PNGAnimation"] = new System.Windows.Controls.Image() { Height = 500 }; GraphCore.CommUIElements["Image2.PNGAnimation"] = new System.Windows.Controls.Image() { Height = 500 }; GraphCore.CommUIElements["Image3.PNGAnimation"] = new System.Windows.Controls.Image() { Height = 500 }; - } Task.Run(() => startup(path, paths)); //if (storemem) @@ -164,7 +163,7 @@ namespace VPet_Simulator.Core //生成大文件加载非常慢,先看看有没有缓存能用 Path = GraphCore.CachePath + $"\\{Sub.GetHashCode(path)}_{paths.Length}.png"; Width = 500 * (paths.Length + 1); - if (File.Exists(Path)) + if (File.Exists(Path) || ((List)GraphCore.CommConfig["Cache"]).Contains(path)) { for (int i = 0; i < paths.Length; i++) { @@ -175,6 +174,7 @@ namespace VPet_Simulator.Core } else { + ((List)GraphCore.CommConfig["Cache"]).Add(path); List imgs = new List(); foreach (var file in paths) imgs.Add(System.Drawing.Image.FromFile(file.FullName)); @@ -189,7 +189,8 @@ namespace VPet_Simulator.Core graph.DrawImage(imgs[i], w * i, 0, w, h); Animations.Add(new Animation(this, time, -500 * i)); } - joinedBitmap.Save(Path); + if (!File.Exists(Path)) + joinedBitmap.Save(Path); graph.Dispose(); joinedBitmap.Dispose(); imgs.ForEach(x => x.Dispose()); diff --git a/VPet-Simulator.Core/Handle/PetLoader.cs b/VPet-Simulator.Core/Handle/PetLoader.cs index 55f21f0..c928308 100644 --- a/VPet-Simulator.Core/Handle/PetLoader.cs +++ b/VPet-Simulator.Core/Handle/PetLoader.cs @@ -58,23 +58,28 @@ namespace VPet_Simulator.Core { if (path_name.StartsWith(GraphTypeValue[i])) { + bool isused = false; if (path_name.Contains("happy")) { graph.AddGraph(di.FullName, GameSave.ModeType.Happy, (GraphType)i); + isused = true; } if (path_name.Contains("nomal")) { graph.AddGraph(di.FullName, GameSave.ModeType.Nomal, (GraphType)i); + isused = true; } if (path_name.Contains("poorcondition")) { graph.AddGraph(di.FullName, GameSave.ModeType.PoorCondition, (GraphType)i); + isused = true; } if (path_name.Contains("ill")) { graph.AddGraph(di.FullName, GameSave.ModeType.Ill, (GraphType)i); + isused = true; } - else + if (!isused) { graph.AddGraph(di.FullName, GameSave.ModeType.Nomal, (GraphType)i); } diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj index cb2d910..5a97a9e 100644 --- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj +++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj @@ -74,13 +74,13 @@ - ..\..\VUP-Simulator\packages\LinePutScript.1.8.0\lib\net462\LinePutScript.dll + ..\packages\LinePutScript.1.8.0\lib\net462\LinePutScript.dll ..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll - - ..\packages\Panuon.WPF.UI.1.1.10\lib\net462\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Core/packages.config b/VPet-Simulator.Core/packages.config index 5991b27..868da7a 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 90e9cc5..316dc66 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.10\lib\net462\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Windows.Interface/packages.config b/VPet-Simulator.Windows.Interface/packages.config index 5991b27..868da7a 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/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 1afc047..fb080b1 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -246,18 +246,25 @@ namespace VPet_Simulator.Windows } }; DisplayGrid.Child = Main; + Task.Run(() => + { + while (Main.IsWorking) + { + Thread.Sleep(100); + } + Dispatcher.Invoke(() => LoadingText.Visibility = Visibility.Collapsed); + }); Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "退出桌宠", () => { Close(); }); Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "开发控制台", () => { new winConsole(this).Show(); }); Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "反馈中心", () => { new winReport(this).Show(); }); Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "设置面板", () => - { - Topmost = false; - winSetting.Show(); - }); + { + Topmost = false; + winSetting.Show(); + }); Main.SetMoveMode(Set.AllowMove, Set.SmartMove, Set.SmartMoveInterval * 1000); Main.SetLogicInterval((int)(Set.LogicInterval * 1000)); - LoadingText.Visibility = Visibility.Collapsed; //加载图标 notifyIcon = new NotifyIcon(); notifyIcon.Text = "虚拟桌宠模拟器"; @@ -266,20 +273,20 @@ namespace VPet_Simulator.Windows m_menu = new ContextMenu(); m_menu.MenuItems.Add(new MenuItem("操作教程", (x, y) => { Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\Tutorial.html"); })); m_menu.MenuItems.Add(new MenuItem("重置状态", (x, y) => - { - Main.CleanState(); - Main.DisplayNomal(); - Left = (SystemParameters.PrimaryScreenWidth - Width) / 2; - Top = (SystemParameters.PrimaryScreenHeight - Height) / 2; - })); + { + Main.CleanState(); + Main.DisplayNomal(); + Left = (SystemParameters.PrimaryScreenWidth - Width) / 2; + Top = (SystemParameters.PrimaryScreenHeight - Height) / 2; + })); m_menu.MenuItems.Add(new MenuItem("反馈中心", (x, y) => { new winReport(this).Show(); })); m_menu.MenuItems.Add(new MenuItem("开发控制台", (x, y) => { new winConsole(this).Show(); })); m_menu.MenuItems.Add(new MenuItem("设置面板", (x, y) => - { - Topmost = false; - winSetting.Show(); - })); + { + Topmost = false; + winSetting.Show(); + })); m_menu.MenuItems.Add(new MenuItem("退出桌宠", (x, y) => Close())); LoadDIY(); @@ -290,12 +297,12 @@ namespace VPet_Simulator.Windows notifyIcon.Visible = true; notifyIcon.BalloonTipClicked += (a, b) => - { - Topmost = false; - winSetting.Show(); - }; + { + Topmost = false; + winSetting.Show(); + }; - if (Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 2, 23)) + if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Tutorial.html") && Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 2, 23)) { Set["SingleTips"].SetDateTime("tutorial", DateTime.Now); Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\Tutorial.html"); @@ -303,14 +310,14 @@ namespace VPet_Simulator.Windows if (!Set["SingleTips"].GetBool("helloworld")) { Task.Run(() => - { - Thread.Sleep(2000); - Set["SingleTips"].SetBool("helloworld", true); - notifyIcon.ShowBalloonTip(10, "你好" + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName), - "欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠", ToolTipIcon.Info); - Thread.Sleep(2000); - Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining); - }); + { + Thread.Sleep(2000); + Set["SingleTips"].SetBool("helloworld", true); + notifyIcon.ShowBalloonTip(10, "你好" + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName), + "欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠", ToolTipIcon.Info); + Thread.Sleep(2000); + Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining); + }); } else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 27)) { diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj index b39e785..b93c477 100644 --- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj +++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj @@ -90,8 +90,8 @@ ..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll - - ..\packages\Panuon.WPF.UI.1.1.10\lib\net48\Panuon.WPF.UI.dll + + ..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net48\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Windows/packages.config b/VPet-Simulator.Windows/packages.config index e776a4e..368da8f 100644 --- a/VPet-Simulator.Windows/packages.config +++ b/VPet-Simulator.Windows/packages.config @@ -6,5 +6,5 @@ - + \ No newline at end of file