VPet/VPet-Simulator.Windows/App.xaml.cs

62 lines
2.3 KiB
C#
Raw Normal View History

2023-08-12 09:58:57 +00:00
using LinePutScript.Localization.WPF;
using System.Windows;
2022-12-13 07:10:18 +00:00
namespace VPet_Simulator.Windows
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
2023-01-24 06:56:16 +00:00
public App() : base()
{
2023-01-29 08:27:24 +00:00
#if !DEBUG
2023-01-24 06:56:16 +00:00
base.DispatcherUnhandledException += App_DispatcherUnhandledException;
2023-01-29 08:27:24 +00:00
#endif
2023-01-24 06:56:16 +00:00
//AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
2023-10-10 17:03:23 +00:00
public static string[] Args { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
Args = e.Args;
}
2023-01-24 06:56:16 +00:00
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
2023-08-16 18:21:46 +00:00
var expt = e.Exception.ToString();
if (expt.Contains("value") && expt.Contains("Panuon.WPF.UI.Internal.Utils") && expt.Contains("NaN"))
{
2023-10-10 17:03:23 +00:00
MessageBox.Show("由于修改游戏数据导致数据溢出,存档可能会出错\n开发者提醒您请不要使用过于超模的MOD".Translate());
2023-08-21 18:26:27 +00:00
return;
}
else if (expt.Contains("System.IO.FileNotFoundException") && expt.Contains("cache"))
{
MessageBox.Show("缓存被其他软件删除,游戏无法继续运行\n请重启游戏重新生成缓存".Translate());
return;
2023-10-10 17:03:23 +00:00
}
else if (expt.Contains("0x80070008"))
2023-08-21 18:26:27 +00:00
{
MessageBox.Show("游戏内存不足,请修改设置中渲染分辨率以便降低内存使用".Translate());
2023-08-16 18:21:46 +00:00
}
2023-08-12 09:58:57 +00:00
string errstr = "游戏发生错误,可能是".Translate() + (string.IsNullOrWhiteSpace(CoreMOD.NowLoading) ?
"游戏或者MOD".Translate() : $"MOD({CoreMOD.NowLoading})") +
"导致的\n如有可能请发送 错误信息截图和引发错误之前的操作 给开发者:service@exlb.net\n感谢您对游戏开发的支持\n".Translate()
2023-08-16 18:21:46 +00:00
+ expt;
2023-01-24 06:56:16 +00:00
if (MainWindow == null)
{
2023-08-13 17:29:45 +00:00
MessageBox.Show(errstr, "游戏致命性错误".Translate());
2023-01-24 06:56:16 +00:00
return;
}
2023-01-24 07:55:02 +00:00
else
{
new winReport(((MainWindow)MainWindow), errstr).Show();
return;
}
2023-01-24 06:56:16 +00:00
}
2022-12-13 07:10:18 +00:00
}
}