mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
修复备份读取顺序问题 Fix #192
This commit is contained in:
parent
1c8420d139
commit
5549edf8b1
@ -121,9 +121,18 @@ namespace VPet_Simulator.Windows
|
|||||||
var name = lps.First().Info;
|
var name = lps.First().Info;
|
||||||
var p = mw.Pets.FirstOrDefault(x => x.Name == name);
|
var p = mw.Pets.FirstOrDefault(x => x.Name == name);
|
||||||
if (p == null)
|
if (p == null)
|
||||||
mw.Pets.Add(new PetLoader(lps, di));
|
{
|
||||||
|
p = new PetLoader(lps, di);
|
||||||
|
if (p.Config.Works.Count > 0)
|
||||||
|
Tag.Add("work");
|
||||||
|
mw.Pets.Add(p);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (lps.FindAllLine("work").Length >= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
p.path.Add(di.FullName + "\\" + lps.First()["path"].Info);
|
p.path.Add(di.FullName + "\\" + lps.First()["path"].Info);
|
||||||
p.Config.Set(lps);
|
p.Config.Set(lps);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -180,7 +181,12 @@ namespace VPet_Simulator.Windows
|
|||||||
|
|
||||||
if (Core != null && Core.Save != null)
|
if (Core != null && Core.Save != null)
|
||||||
{
|
{
|
||||||
var ds = new List<string>(Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"));
|
var ds = new List<string>(Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
||||||
|
{
|
||||||
|
if (int.TryParse(x.Split('_')[1], out int i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}).ToList();
|
||||||
while (ds.Count > Set.BackupSaveMaxNum)
|
while (ds.Count > Set.BackupSaveMaxNum)
|
||||||
{
|
{
|
||||||
File.Delete(ds[0]);
|
File.Delete(ds[0]);
|
||||||
|
@ -235,13 +235,18 @@ namespace VPet_Simulator.Windows
|
|||||||
{
|
{
|
||||||
if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"))
|
if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"))
|
||||||
{
|
{
|
||||||
var latestsave = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP")
|
var ds = new List<string>(Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
||||||
.GetFiles("*.lps").OrderByDescending(x => x.LastWriteTime).FirstOrDefault();
|
{
|
||||||
|
if (int.TryParse(x.Split('_')[1], out int i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}).ToList();
|
||||||
|
var latestsave = ds.LastOrDefault();
|
||||||
if (latestsave != null)
|
if (latestsave != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (GameLoad(new Line(File.ReadAllText(latestsave.FullName))))
|
if (GameLoad(new Line(File.ReadAllText(latestsave))))
|
||||||
return;
|
return;
|
||||||
MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate());
|
MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate());
|
||||||
}
|
}
|
||||||
|
1
VPet-Simulator.Windows/mod/0001_ModMaker
Symbolic link
1
VPet-Simulator.Windows/mod/0001_ModMaker
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
D:/Documents/Visual Studio 2022/Projects/VPet.ModMaker/0001_ModMaker
|
Loading…
Reference in New Issue
Block a user