2014-12-03 23:15:26 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
using System.IO;
|
2015-09-17 12:02:39 +00:00
|
|
|
|
using System.Management;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2016-04-27 09:13:07 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
2013-08-29 10:05:50 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class ExceptionDialog : Form
|
|
|
|
|
{
|
2023-05-30 09:34:21 +00:00
|
|
|
|
private const string CRASH_DUMP_FILE = "UZBCrash.txt";
|
2020-07-25 16:42:07 +00:00
|
|
|
|
|
2016-03-16 23:26:53 +00:00
|
|
|
|
private readonly bool isterminating;
|
|
|
|
|
private readonly string logpath;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public ExceptionDialog(UnhandledExceptionEventArgs e)
|
|
|
|
|
{
|
2013-08-29 10:05:50 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2020-07-25 16:42:07 +00:00
|
|
|
|
logpath = Path.Combine(General.SettingsPath, CRASH_DUMP_FILE);
|
2013-08-29 10:05:50 +00:00
|
|
|
|
Exception ex = (Exception)e.ExceptionObject;
|
2013-09-09 14:03:02 +00:00
|
|
|
|
errorDescription.Text = "Error in " + ex.Source + ":";
|
2016-02-01 22:04:00 +00:00
|
|
|
|
string sysinfo = GetSystemInfo();
|
2016-03-16 23:26:53 +00:00
|
|
|
|
using(StreamWriter sw = File.CreateText(logpath))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-02-01 22:04:00 +00:00
|
|
|
|
sw.Write(sysinfo + GetExceptionDescription(ex));
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 14:03:02 +00:00
|
|
|
|
errorMessage.Text = ex.Message + Environment.NewLine + ex.StackTrace;
|
2016-03-16 23:26:53 +00:00
|
|
|
|
isterminating = e.IsTerminating; // Recoverable?
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public ExceptionDialog(ThreadExceptionEventArgs e)
|
|
|
|
|
{
|
2013-08-29 10:05:50 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2020-07-25 16:42:07 +00:00
|
|
|
|
logpath = Path.Combine(General.SettingsPath, CRASH_DUMP_FILE);
|
2013-09-09 14:03:02 +00:00
|
|
|
|
errorDescription.Text = "Error in " + e.Exception.Source + ":";
|
2015-09-17 12:02:39 +00:00
|
|
|
|
string sysinfo = GetSystemInfo();
|
2016-03-16 23:26:53 +00:00
|
|
|
|
using(StreamWriter sw = File.CreateText(logpath))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-09-17 12:02:39 +00:00
|
|
|
|
sw.Write(sysinfo + GetExceptionDescription(e.Exception));
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 12:02:39 +00:00
|
|
|
|
errorMessage.Text = sysinfo + "********EXCEPTION DETAILS********" + Environment.NewLine
|
|
|
|
|
+ e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
|
string[] titles =
|
|
|
|
|
{
|
2023-05-26 14:55:19 +00:00
|
|
|
|
"Ultimate Zone Builder was killed by Eggman's nefarious TV magic.",
|
|
|
|
|
"Ultimate Zone Builder was killed by an environmental hazard.",
|
|
|
|
|
"Ultimate Zone Builder drowned.",
|
|
|
|
|
"Ultimate Zone Builder was crushed.",
|
|
|
|
|
"Ultimate Zone Builder fell into a bottomless pit.",
|
|
|
|
|
"Ultimate Zone Builder asphyxiated in space.",
|
|
|
|
|
"Ultimate Zone Builder died.",
|
|
|
|
|
"Ultimate Zone Builder's playtime with heavy objects killed Ultimate Zone Builder.",
|
|
|
|
|
"Resynching...",
|
|
|
|
|
"You have been banned from the server.",
|
|
|
|
|
"SIGSEGV - segment violation",
|
|
|
|
|
"[Eggman laughing]",
|
|
|
|
|
"[Armageddon pow]",
|
|
|
|
|
"[Dying]",
|
|
|
|
|
"I'm outta here...",
|
|
|
|
|
"GAME OVER",
|
|
|
|
|
"SONIC MADE A BAD FUTURE IN Ultimate Zone Builder",
|
|
|
|
|
"Sonic arrived just in time to see what little of the 'ruins' were left.",
|
|
|
|
|
"The natural beauty of the zone had been obliterated.",
|
|
|
|
|
"I'm putting my foot down.",
|
|
|
|
|
"All of this is over. You will be left with ashes.",
|
|
|
|
|
"some doofus gave us an empty string?",
|
|
|
|
|
"unfortunate player falls into spike?!",
|
|
|
|
|
"Ack! Metal Sonic shouldn't die! Cut the tape, end recording!",
|
|
|
|
|
"ALL YOUR RINGS ARE BELONG TO US!",
|
|
|
|
|
"Hohohoho!! *B^D",
|
|
|
|
|
"So that's it. I was so busy playing SRB2 I never noticed... but... everything's gone...",
|
|
|
|
|
"Tails! You made the engines quit!"
|
|
|
|
|
};
|
2016-03-16 23:26:53 +00:00
|
|
|
|
|
2013-08-30 15:00:44 +00:00
|
|
|
|
this.Text = titles[new Random().Next(0, titles.Length - 1)];
|
2016-03-16 23:26:53 +00:00
|
|
|
|
bContinue.Enabled = !isterminating;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 12:02:39 +00:00
|
|
|
|
private static string GetSystemInfo()
|
|
|
|
|
{
|
|
|
|
|
string result = "***********SYSTEM INFO***********" + Environment.NewLine;
|
|
|
|
|
|
|
|
|
|
// Get OS name
|
|
|
|
|
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
|
2016-02-22 08:04:06 +00:00
|
|
|
|
foreach(ManagementBaseObject mo in searcher.Get())
|
2015-09-17 12:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
result += "OS: " + mo["Caption"] + Environment.NewLine;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get GPU name
|
|
|
|
|
searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
|
2016-02-22 08:04:06 +00:00
|
|
|
|
foreach(ManagementBaseObject mo in searcher.Get())
|
2015-09-17 12:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
PropertyData bpp = mo.Properties["CurrentBitsPerPixel"];
|
|
|
|
|
PropertyData description = mo.Properties["Description"];
|
|
|
|
|
if(bpp != null && description != null && bpp.Value != null)
|
|
|
|
|
{
|
|
|
|
|
result += "GPU: " + description.Value + Environment.NewLine;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-30 09:34:21 +00:00
|
|
|
|
// Get UZB version
|
2023-05-30 10:14:57 +00:00
|
|
|
|
result += "UZB: v" + General.ThisAssembly.GetName().Version + Environment.NewLine;
|
2018-04-16 00:22:24 +00:00
|
|
|
|
result += "Platform: " + (Environment.Is64BitProcess ? "x64" : "x86") + Environment.NewLine + Environment.NewLine;
|
2015-09-17 12:02:39 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private static string GetExceptionDescription(Exception ex)
|
|
|
|
|
{
|
2016-01-27 14:08:15 +00:00
|
|
|
|
// Add to error logger
|
|
|
|
|
General.WriteLogLine("***********************************************************");
|
|
|
|
|
General.ErrorLogger.Add(ErrorType.Error, ex.Source + ": " + ex.Message);
|
|
|
|
|
General.WriteLogLine("***********************************************************");
|
2013-12-05 09:24:55 +00:00
|
|
|
|
|
2013-12-02 09:26:09 +00:00
|
|
|
|
string message = "********EXCEPTION DETAILS********"
|
|
|
|
|
+ Environment.NewLine + ex.Source + ": " + ex.Message + Environment.NewLine + ex.StackTrace;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(File.Exists(General.LogFile))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2013-12-02 09:26:09 +00:00
|
|
|
|
string[] lines = File.ReadAllLines(General.LogFile);
|
2014-09-12 12:19:58 +00:00
|
|
|
|
message += Environment.NewLine + Environment.NewLine + "***********ACTIONS LOG***********";
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int i = lines.Length - 1; i > -1; i--)
|
2013-12-02 09:26:09 +00:00
|
|
|
|
message += Environment.NewLine + lines[i];
|
|
|
|
|
} catch(Exception) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-28 12:24:58 +00:00
|
|
|
|
private void reportlink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
|
if(!File.Exists(logpath)) return;
|
2016-12-28 12:24:58 +00:00
|
|
|
|
try { System.Diagnostics.Process.Start("explorer.exe", @"/select, " + logpath); }
|
|
|
|
|
catch { MessageBox.Show("Unable to show the error report location..."); }
|
|
|
|
|
reportlink.LinkVisited = true;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-28 12:24:58 +00:00
|
|
|
|
private void newissue_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2023-05-26 14:55:19 +00:00
|
|
|
|
try { System.Diagnostics.Process.Start("https://git.do.srb2.org/STJr/UltimateZoneBuilder/-/issues"); }
|
2016-12-28 12:24:58 +00:00
|
|
|
|
catch { MessageBox.Show("Unable to open URL..."); }
|
|
|
|
|
newissue.LinkVisited = true;
|
2013-08-29 10:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void bContinue_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-08-29 10:05:50 +00:00
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-25 13:20:53 +00:00
|
|
|
|
private void bQuit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(General.Map != null) General.Map.SaveMapBackup();
|
|
|
|
|
this.DialogResult = DialogResult.Cancel;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void bToClipboard_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-08-29 10:05:50 +00:00
|
|
|
|
errorMessage.SelectAll();
|
|
|
|
|
errorMessage.Copy();
|
|
|
|
|
errorMessage.DeselectAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|