mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
全新存档/备份系统
This commit is contained in:
parent
1a21507ca2
commit
c82155f3d5
@ -188,12 +188,12 @@ namespace VPet_Simulator.Windows
|
||||
Set.StartRecordLastPoint = new Point(Dispatcher.Invoke(() => Left), Dispatcher.Invoke(() => Top));
|
||||
File.WriteAllText(ExtensionValue.BaseDirectory + @"\Setting.lps", Set.ToString());
|
||||
|
||||
if (!Directory.Exists(ExtensionValue.BaseDirectory + @"\BackUP"))
|
||||
Directory.CreateDirectory(ExtensionValue.BaseDirectory + @"\BackUP");
|
||||
if (!Directory.Exists(ExtensionValue.BaseDirectory + @"\Saves"))
|
||||
Directory.CreateDirectory(ExtensionValue.BaseDirectory + @"\Saves");
|
||||
|
||||
if (Core != null && Core.Save != null)
|
||||
{
|
||||
var ds = new List<string>(Directory.GetFiles(ExtensionValue.BaseDirectory + @"\BackUP", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
||||
var ds = new List<string>(Directory.GetFiles(ExtensionValue.BaseDirectory + @"\Saves", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
||||
{
|
||||
if (int.TryParse(x.Split('_')[1].Split('.')[0], out int i))
|
||||
return i;
|
||||
@ -204,13 +204,13 @@ namespace VPet_Simulator.Windows
|
||||
File.Delete(ds[0]);
|
||||
ds.RemoveAt(0);
|
||||
}
|
||||
if (File.Exists(ExtensionValue.BaseDirectory + $"\\BackUP\\Save_{st}.lps"))
|
||||
File.Delete(ExtensionValue.BaseDirectory + $"\\BackUP\\Save_{st}.lps");
|
||||
if (File.Exists(ExtensionValue.BaseDirectory + $"\\Saves\\Save_{st}.lps"))
|
||||
File.Delete(ExtensionValue.BaseDirectory + $"\\Saves\\Save_{st}.lps");
|
||||
|
||||
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.lps"))
|
||||
File.Move(ExtensionValue.BaseDirectory + @"\Save.lps", ExtensionValue.BaseDirectory + $"\\BackUP\\Save_{st}.lps");
|
||||
File.Move(ExtensionValue.BaseDirectory + @"\Save.lps", ExtensionValue.BaseDirectory + @"\Save.bkp");
|
||||
|
||||
File.WriteAllText(ExtensionValue.BaseDirectory + @"\Save.lps", GameSavesData.ToLPS().ToString());
|
||||
File.WriteAllText(ExtensionValue.BaseDirectory + $"\\Saves\\Save_{st}.lps", GameSavesData.ToLPS().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ namespace VPet_Simulator.Windows
|
||||
var point = Set.StartRecordLastPoint;
|
||||
if (point.X != 0 || point.Y != 0)
|
||||
{
|
||||
L= point.X;
|
||||
T = point.Y;
|
||||
L = point.X;
|
||||
T = point.Y;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -155,6 +155,17 @@ namespace VPet_Simulator.Windows
|
||||
}
|
||||
Closed += ForceClose;
|
||||
|
||||
//更新存档系统
|
||||
if (!Directory.Exists(ExtensionValue.BaseDirectory + @"\Saves"))
|
||||
{
|
||||
if (Directory.Exists(ExtensionValue.BaseDirectory + @"\BackUP"))
|
||||
{
|
||||
Directory.Move(ExtensionValue.BaseDirectory + @"\BackUP", ExtensionValue.BaseDirectory + @"\Saves");
|
||||
}
|
||||
else
|
||||
Directory.CreateDirectory(ExtensionValue.BaseDirectory + @"\Saves");
|
||||
}
|
||||
|
||||
Task.Run(GameLoad);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -258,9 +269,9 @@ namespace VPet_Simulator.Windows
|
||||
|
||||
public void LoadLatestSave(string petname)
|
||||
{
|
||||
if (Directory.Exists(ExtensionValue.BaseDirectory + @"\BackUP"))
|
||||
if (Directory.Exists(ExtensionValue.BaseDirectory + @"\Saves"))
|
||||
{
|
||||
var ds = new List<string>(Directory.GetFiles(ExtensionValue.BaseDirectory + @"\BackUP", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
||||
var ds = new List<string>(Directory.GetFiles(ExtensionValue.BaseDirectory + @"\Saves", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
||||
{
|
||||
if (int.TryParse(x.Split('_')[1].Split('.')[0], out int i))
|
||||
return i;
|
||||
@ -383,11 +394,6 @@ namespace VPet_Simulator.Windows
|
||||
else//新玩家,默认设置为
|
||||
Set["CGPT"][(gstr)"type"] = "LB";
|
||||
|
||||
if (Directory.Exists(ExtensionValue.BaseDirectory + @"\UserData") && !Directory.Exists(ExtensionValue.BaseDirectory + @"\BackUP"))
|
||||
{
|
||||
Directory.Move(ExtensionValue.BaseDirectory + @"\UserData", ExtensionValue.BaseDirectory + @"\BackUP");
|
||||
}
|
||||
|
||||
//加载数据合理化:食物
|
||||
if (!Set["gameconfig"].GetBool("noAutoCal"))
|
||||
{
|
||||
@ -410,7 +416,7 @@ namespace VPet_Simulator.Windows
|
||||
|
||||
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏存档".Translate()));
|
||||
//加载存档
|
||||
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.lps"))
|
||||
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.lps")) //有老的旧存档,优先旧存档
|
||||
try
|
||||
{
|
||||
if (!GameLoad(new LpsDocument(File.ReadAllText(ExtensionValue.BaseDirectory + @"\Save.lps"))))
|
||||
|
@ -1103,15 +1103,12 @@ namespace VPet_Simulator.Windows
|
||||
reloadid = mw.Set.SaveTimes;
|
||||
CBSaveReLoad.SelectedItem = null;
|
||||
CBSaveReLoad.Items.Clear();
|
||||
if (Directory.Exists(ExtensionValue.BaseDirectory + @"\BackUP"))
|
||||
if (Directory.Exists(ExtensionValue.BaseDirectory + @"\Saves"))
|
||||
{
|
||||
foreach (var file in new DirectoryInfo(ExtensionValue.BaseDirectory + @"\BackUP")
|
||||
.GetFiles().OrderByDescending(x => x.LastWriteTime))
|
||||
foreach (var file in new DirectoryInfo(ExtensionValue.BaseDirectory + @"\Saves")
|
||||
.GetFiles("Save*.lps").OrderByDescending(x => x.LastWriteTime))
|
||||
{
|
||||
if (file.Extension.ToLower() == ".lps")
|
||||
{
|
||||
CBSaveReLoad.Items.Add(file.Name.Split('.').First());
|
||||
}
|
||||
CBSaveReLoad.Items.Add(file.Name.Split('.').First());
|
||||
}
|
||||
CBSaveReLoad.SelectedIndex = 0;
|
||||
}
|
||||
@ -1123,7 +1120,7 @@ namespace VPet_Simulator.Windows
|
||||
if (CBSaveReLoad.SelectedItem != null)
|
||||
{
|
||||
string txt = (string)CBSaveReLoad.SelectedItem;
|
||||
string path = ExtensionValue.BaseDirectory + @"\BackUP\" + txt + ".lps";
|
||||
string path = ExtensionValue.BaseDirectory + @"\Saves\" + txt + ".lps";
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
|
Loading…
x
Reference in New Issue
Block a user