From 9ed45530a05ad4c0ba86fe3291d75a4214a9910e Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 24 Nov 2023 15:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E6=B8=85=E7=90=86?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Windows/MainWindow.cs | 62 ++++++++++++++--------- VPet-Simulator.Windows/MainWindow.xaml.cs | 1 + 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 7cc8ac3..2053fd3 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -113,17 +113,17 @@ namespace VPet_Simulator.Windows switch (Core.Save.Mode) { case GameSave.ModeType.PoorCondition: - mt = ClickText.ModeType.PoorCondition; + mt = ICheckText.ModeType.PoorCondition; break; default: case GameSave.ModeType.Nomal: - mt = ClickText.ModeType.Nomal; + mt = ICheckText.ModeType.Nomal; break; case GameSave.ModeType.Happy: - mt = ClickText.ModeType.Happy; + mt = ICheckText.ModeType.Happy; break; case GameSave.ModeType.Ill: - mt = ClickText.ModeType.Ill; + mt = ICheckText.ModeType.Ill; break; } var list = ClickTexts.FindAll(x => x.DaiTime.HasFlag(dt) && x.Mode.HasFlag(mt) && x.CheckState(Main)); @@ -333,7 +333,7 @@ namespace VPet_Simulator.Windows { try { - System.Windows.Forms.SendKeys.SendWait(content); + SendKeys.SendWait(content); } catch (Exception e) { @@ -605,7 +605,7 @@ namespace VPet_Simulator.Windows { if (name.StartsWith("stat_")) { - Steamworks.SteamUserStats.SetStat(name, (int)value); + SteamUserStats.SetStat(name, (int)value); } } /// @@ -623,7 +623,7 @@ namespace VPet_Simulator.Windows switch (Main.State) { case Main.WorkingState.Work: - if (Main.nowWork.Type == GraphHelper.Work.WorkType.Work) + if (Main.nowWork.Type == Work.WorkType.Work) stat[(gi64)"stat_work_time"] += (int)Set.LogicInterval; else stat[(gi64)"stat_study_time"] += (int)Set.LogicInterval; @@ -662,7 +662,7 @@ namespace VPet_Simulator.Windows if (IsSteamUser) { - Task.Run(Steamworks.SteamUserStats.StoreStats); + Task.Run(SteamUserStats.StoreStats); } } /// @@ -975,7 +975,7 @@ namespace VPet_Simulator.Windows //参数 StringBuilder sb = new StringBuilder(); sb.Append("action=data"); - sb.Append($"&steamid={Steamworks.SteamClient.SteamId.Value}"); + sb.Append($"&steamid={SteamClient.SteamId.Value}"); sb.Append($"&ver={version}"); sb.Append("&save="); sb.AppendLine(HttpUtility.UrlEncode(Core.Save.ToLine().ToString() + Set.ToString())); @@ -1093,9 +1093,9 @@ namespace VPet_Simulator.Windows Set = new Setting("Setting#VPET:|\n"); var visualTree = new FrameworkElementFactory(typeof(Border)); - visualTree.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(Window.BackgroundProperty)); + visualTree.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(BackgroundProperty)); var childVisualTree = new FrameworkElementFactory(typeof(ContentPresenter)); - childVisualTree.SetValue(UIElement.ClipToBoundsProperty, true); + childVisualTree.SetValue(ClipToBoundsProperty, true); visualTree.AppendChild(childVisualTree); Template = new ControlTemplate @@ -1217,6 +1217,18 @@ namespace VPet_Simulator.Windows CoreMOD.NowLoading = null; + //判断是否需要清空缓存 + if (App.MainWindows.Count == 1 && Set.LastCacheDate < CoreMODs.Max(x => x.CacheDate)) + {//需要清理缓存 + Set.LastCacheDate = DateTime.Now; + if (Directory.Exists(GraphCore.CachePath)) + { + Directory.Delete(GraphCore.CachePath, true); + Directory.CreateDirectory(GraphCore.CachePath); + } + } + + await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏MOD".Translate())); //当前桌宠动画 @@ -1405,7 +1417,7 @@ namespace VPet_Simulator.Windows { work.MoneyLevel = 0.5; work.MoneyBase = 8; - if (work.Type == GraphHelper.Work.WorkType.Work) + if (work.Type == Work.WorkType.Work) { work.StrengthDrink = 2.5; work.StrengthFood = 3.5; @@ -1530,9 +1542,9 @@ namespace VPet_Simulator.Windows await Dispatcher.InvokeAsync(() => LoadingText.Visibility = Visibility.Collapsed); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "退出桌宠".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; Close(); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "开发控制台".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winConsole(this).Show(); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "操作教程".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "退出桌宠".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; Close(); }); + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "开发控制台".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winConsole(this).Show(); }); + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "操作教程".Translate(), () => { if (LocalizeCore.CurrentCulture == "zh-Hans") ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html"); @@ -1541,8 +1553,8 @@ namespace VPet_Simulator.Windows else ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html"); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "反馈中心".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winReport(this).Show(); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "设置面板".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "反馈中心".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winReport(this).Show(); }); + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "设置面板".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; winSetting.Show(); @@ -1558,23 +1570,23 @@ namespace VPet_Simulator.Windows // eat.Run(b, new BitmapImage(new Uri("pack://application:,,,/Res/汉堡.png")), Main.DisplayToNomal); // } //); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "吃饭".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "吃饭".Translate(), () => { winBetterBuy.Show(Food.FoodType.Meal); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "喝水".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "喝水".Translate(), () => { winBetterBuy.Show(Food.FoodType.Drink); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "收藏".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "收藏".Translate(), () => { winBetterBuy.Show(Food.FoodType.Star); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "药品".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "药品".Translate(), () => { winBetterBuy.Show(Food.FoodType.Drug); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "礼品".Translate(), () => + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "礼品".Translate(), () => { winBetterBuy.Show(Food.FoodType.Gift); }); @@ -1683,7 +1695,7 @@ namespace VPet_Simulator.Windows SetTransparentHitThrough(); } - if (File.Exists(ExtensionValue.BaseDirectory + @"\Tutorial.html") && Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 6, 20)) + if (File.Exists(ExtensionValue.BaseDirectory + @"\Tutorial.html") && Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 10, 20)) { Set["SingleTips"].SetDateTime("tutorial", DateTime.Now); if (LocalizeCore.CurrentCulture == "zh-Hans") @@ -1700,7 +1712,7 @@ namespace VPet_Simulator.Windows Thread.Sleep(2000); Set["SingleTips"].SetBool("helloworld", true); NoticeBox.Show("欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠".Translate(), - "你好".Translate() + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName)); + "你好".Translate() + (IsSteamUser ? SteamClient.Name : Environment.UserName)); //Thread.Sleep(2000); //Main.SayRnd("欢迎使用虚拟桌宠模拟器\n这是个中期的测试版,若有bug请多多包涵\n欢迎加群虚拟主播模拟器430081239或在菜单栏-管理-反馈中提交bug或建议".Translate()); }); @@ -1759,7 +1771,7 @@ namespace VPet_Simulator.Windows return false; } Main.CountNomal = 0; - + if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < 100) { Core.Save.StrengthChange(-2); diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 99444de..afc6244 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -174,6 +174,7 @@ namespace VPet_Simulator.Windows } } + Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading Translate")).Wait(); //加载语言 LocalizeCore.StoreTranslation = true;