更新备份目录

This commit is contained in:
ZouJin 2023-08-12 19:58:57 +10:00
parent d6e2ae050b
commit a283216ab4
6 changed files with 47 additions and 32 deletions

View File

@ -1,4 +1,5 @@
using System.Windows; using LinePutScript.Localization.WPF;
using System.Windows;
namespace VPet_Simulator.Windows namespace VPet_Simulator.Windows
{ {
@ -18,7 +19,10 @@ namespace VPet_Simulator.Windows
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{ {
e.Handled = true; e.Handled = true;
string errstr = "游戏发生错误,可能是" + (string.IsNullOrWhiteSpace(CoreMOD.NowLoading) ? "游戏或者MOD" : $"MOD({CoreMOD.NowLoading})") + "导致的\n如有可能请发送 错误信息截图和引发错误之前的操作 给开发者:service@exlb.net\n感谢您对游戏开发的支持\n" + e.Exception.ToString(); string errstr = "游戏发生错误,可能是".Translate() + (string.IsNullOrWhiteSpace(CoreMOD.NowLoading) ?
"游戏或者MOD".Translate() : $"MOD({CoreMOD.NowLoading})") +
"导致的\n如有可能请发送 错误信息截图和引发错误之前的操作 给开发者:service@exlb.net\n感谢您对游戏开发的支持\n".Translate()
+ e.Exception.ToString();
if (MainWindow == null) if (MainWindow == null)
{ {
MessageBox.Show(errstr, "游戏致命性错误"); MessageBox.Show(errstr, "游戏致命性错误");

View File

@ -231,9 +231,11 @@ namespace VPet_Simulator.Windows
} }
} }
} }
catch catch (Exception Exception)
{ {
SuccessLoad = false; SuccessLoad = false;
string errstr = "MOD加载错误,是MOD({0})导致的\n如有可能请发送 错误信息截图和引发错误之前的操作 给开发者:service@exlb.net\n感谢您对游戏开发的支持\n".Translate() + Exception.ToString();
new winReport(mw, errstr).Show();
} }
} }
break; break;

View File

@ -91,22 +91,22 @@ namespace VPet_Simulator.Windows
} }
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", Set.ToString()); File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", Set.ToString());
if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\UserData")) if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"))
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\UserData"); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP");
if (Core != null && Core.Save != null) if (Core != null && Core.Save != null)
{ {
var ds = new List<string>(Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + @"\UserData")); var ds = new List<string>(Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"));
while (ds.Count > Set.BackupSaveMaxNum) while (ds.Count > Set.BackupSaveMaxNum)
{ {
File.Delete(ds[0]); File.Delete(ds[0]);
ds.RemoveAt(0); ds.RemoveAt(0);
} }
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + $"\\UserData\\Save_{st}.lps")) if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + $"\\BackUP\\Save_{st}.lps"))
File.Delete(AppDomain.CurrentDomain.BaseDirectory + $"\\UserData\\Save_{st}.lps"); File.Delete(AppDomain.CurrentDomain.BaseDirectory + $"\\BackUP\\Save_{st}.lps");
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")) if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps"))
File.Move(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps", AppDomain.CurrentDomain.BaseDirectory + $"\\UserData\\Save_{st}.lps"); File.Move(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps", AppDomain.CurrentDomain.BaseDirectory + $"\\BackUP\\Save_{st}.lps");
var l = Core.Save.ToLine(); var l = Core.Save.ToLine();
if (HashCheck) if (HashCheck)
{ {

View File

@ -159,9 +159,9 @@ namespace VPet_Simulator.Windows
public void LoadLatestSave(string petname) public void LoadLatestSave(string petname)
{ {
if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\UserData")) if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"))
{ {
var latestsave = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\UserData") var latestsave = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP")
.GetFiles("*.lps").OrderByDescending(x => x.LastWriteTime).FirstOrDefault(); .GetFiles("*.lps").OrderByDescending(x => x.LastWriteTime).FirstOrDefault();
if (latestsave != null) if (latestsave != null)
{ {
@ -229,12 +229,33 @@ namespace VPet_Simulator.Windows
else else
LocalizeCore.LoadCulture(Set.Language); LocalizeCore.LoadCulture(Set.Language);
//旧版本设置兼容
var cgpteb = Set["CGPT"].Find("enable");
if (cgpteb != null)
{
if (Set["CGPT"][(gbol)"enable"])
{
Set["CGPT"][(gstr)"type"] = "API";
}
else
{
Set["CGPT"][(gstr)"type"] = "LB";
}
Set["CGPT"].Remove(cgpteb);
}
if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\UserData") && !Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"))
{
Directory.Move(AppDomain.CurrentDomain.BaseDirectory + @"\UserData", AppDomain.CurrentDomain.BaseDirectory + @"\BackUP");
}
Dispatcher.BeginInvoke(new Action(() => LoadingText.Content = "尝试加载游戏MOD".Translate())); Dispatcher.BeginInvoke(new Action(() => LoadingText.Content = "尝试加载游戏MOD".Translate()));
//当前桌宠动画 //当前桌宠动画
var petloader = Pets.Find(x => x.Name == Set.PetGraph); var petloader = Pets.Find(x => x.Name == Set.PetGraph);
petloader ??= Pets[0]; petloader ??= Pets[0];
//加载游戏内容 //加载存档
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") &&
!GameLoad(new LpsDocument(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")).First())) !GameLoad(new LpsDocument(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")).First()))
@ -274,20 +295,6 @@ namespace VPet_Simulator.Windows
rndtext.Add("关注 {0} 谢谢喵".Translate(Environment.UserName)); rndtext.Add("关注 {0} 谢谢喵".Translate(Environment.UserName));
} }
//旧版本设置兼容
var cgpteb = Set["CGPT"].Find("enable");
if (cgpteb != null)
{
if (Set["CGPT"][(gbol)"enable"])
{
Set["CGPT"][(gstr)"type"] = "API";
}
else
{
Set["CGPT"][(gstr)"type"] = "LB";
}
Set["CGPT"].Remove(cgpteb);
}
//音乐识别timer加载 //音乐识别timer加载
MusicTimer = new System.Timers.Timer(100) MusicTimer = new System.Timers.Timer(100)
{ {

View File

@ -62,7 +62,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath> <OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;X64,DEMO</DefineConstants> <DefineConstants>TRACE;X64;DEMO</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@ -96,7 +96,7 @@
</Reference> </Reference>
<Reference Include="CSCore, Version=1.2.1.2, Culture=neutral, PublicKeyToken=5a08f2b6f4415dea, processorArchitecture=MSIL"> <Reference Include="CSCore, Version=1.2.1.2, Culture=neutral, PublicKeyToken=5a08f2b6f4415dea, processorArchitecture=MSIL">
<HintPath>..\packages\CSCore.1.2.1.2\lib\net35-client\CSCore.dll</HintPath> <HintPath>..\packages\CSCore.1.2.1.2\lib\net35-client\CSCore.dll</HintPath>
</Reference> </Reference>
<Reference Include="LinePutScript, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="LinePutScript, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LinePutScript.1.9.2\lib\net462\LinePutScript.dll</HintPath> <HintPath>..\packages\LinePutScript.1.9.2\lib\net462\LinePutScript.dll</HintPath>
</Reference> </Reference>
@ -312,7 +312,9 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="steam_api64.dll" /> <None Include="steam_api64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -972,9 +972,9 @@ namespace VPet_Simulator.Windows
reloadid = mw.Set.Statistics[(gint)"savetimes"]; reloadid = mw.Set.Statistics[(gint)"savetimes"];
CBSaveReLoad.SelectedItem = null; CBSaveReLoad.SelectedItem = null;
CBSaveReLoad.Items.Clear(); CBSaveReLoad.Items.Clear();
if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\UserData")) if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP"))
{ {
foreach (var file in new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\UserData") foreach (var file in new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\BackUP")
.GetFiles().OrderByDescending(x => x.LastWriteTime)) .GetFiles().OrderByDescending(x => x.LastWriteTime))
{ {
if (file.Extension.ToLower() == ".lps") if (file.Extension.ToLower() == ".lps")
@ -992,7 +992,7 @@ namespace VPet_Simulator.Windows
if (CBSaveReLoad.SelectedItem != null) if (CBSaveReLoad.SelectedItem != null)
{ {
string txt = (string)CBSaveReLoad.SelectedItem; string txt = (string)CBSaveReLoad.SelectedItem;
string path = AppDomain.CurrentDomain.BaseDirectory + @"\UserData\" + txt + ".lps"; string path = AppDomain.CurrentDomain.BaseDirectory + @"\BackUP\" + txt + ".lps";
if (File.Exists(path)) if (File.Exists(path))
{ {
var l = new Line(File.ReadAllText(path)); var l = new Line(File.ReadAllText(path));