mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
加载存档失败时载入自动保存
This commit is contained in:
parent
74d611a4c6
commit
0cf20b7b45
@ -27,6 +27,8 @@ using LinePutScript.Localization.WPF;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using static VPet_Simulator.Windows.PerformanceDesktopTransparentWindow;
|
using static VPet_Simulator.Windows.PerformanceDesktopTransparentWindow;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Line = LinePutScript.Line;
|
||||||
|
|
||||||
namespace VPet_Simulator.Windows
|
namespace VPet_Simulator.Windows
|
||||||
{
|
{
|
||||||
@ -157,6 +159,21 @@ namespace VPet_Simulator.Windows
|
|||||||
|
|
||||||
private List<Tuple<string, Helper.SayType>> rndtext;
|
private List<Tuple<string, Helper.SayType>> rndtext;
|
||||||
public long lastclicktime { get; set; }
|
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()
|
public void GameLoad()
|
||||||
{
|
{
|
||||||
//加载所有MOD
|
//加载所有MOD
|
||||||
@ -221,8 +238,8 @@ namespace VPet_Simulator.Windows
|
|||||||
Core.Controller = new MWController(this);
|
Core.Controller = new MWController(this);
|
||||||
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps"))
|
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps"))
|
||||||
Core.Save = GameSave.Load(new LpsDocument(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")).First());
|
Core.Save = GameSave.Load(new LpsDocument(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")).First());
|
||||||
else
|
else//如果加载存档失败了,试试加载备份,如果没备份,就新建一个
|
||||||
Core.Save = new GameSave("萝莉斯".Translate());
|
LoadLatestSave();
|
||||||
|
|
||||||
AutoSaveTimer.Elapsed += AutoSaveTimer_Elapsed;
|
AutoSaveTimer.Elapsed += AutoSaveTimer_Elapsed;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user