From 0cf20b7b450770f30fae542719aa17c8d0f66f83 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Thu, 13 Jul 2023 23:43:09 +1000 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=AD=98=E6=A1=A3=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=E8=BD=BD=E5=85=A5=E8=87=AA=E5=8A=A8=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Windows/MainWindow.xaml.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 9c30e02..c9c53a2 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -27,6 +27,8 @@ using LinePutScript.Localization.WPF; using System.Runtime.InteropServices; using System.Windows.Interop; using static VPet_Simulator.Windows.PerformanceDesktopTransparentWindow; +using System.Windows.Shapes; +using Line = LinePutScript.Line; namespace VPet_Simulator.Windows { @@ -157,6 +159,21 @@ namespace VPet_Simulator.Windows private List> rndtext; public long lastclicktime { get; set; } + + public void LoadLatestSave() + { + if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\UserData")) + { + var latestsave = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\UserData") + .GetFiles("*.lps").OrderByDescending(x => x.LastWriteTime).FirstOrDefault(); + if(latestsave != null) + { + Core.Save = GameSave.Load(new Line(File.ReadAllText(latestsave.FullName))); + return; + } + } + Core.Save = new GameSave("萝莉斯".Translate()); + } public void GameLoad() { //加载所有MOD @@ -221,8 +238,8 @@ namespace VPet_Simulator.Windows Core.Controller = new MWController(this); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")) Core.Save = GameSave.Load(new LpsDocument(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")).First()); - else - Core.Save = new GameSave("萝莉斯".Translate()); + else//如果加载存档失败了,试试加载备份,如果没备份,就新建一个 + LoadLatestSave(); AutoSaveTimer.Elapsed += AutoSaveTimer_Elapsed;