mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Compare commits
3 commits
d784fcfb06
...
85ad7766a9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85ad7766a9 | ||
|
|
b35faf13b5 | ||
|
|
caa869d3ac |
8 changed files with 46 additions and 26 deletions
|
|
@ -453,3 +453,9 @@ void veh::raise_external_event(const std::wstring& info)
|
||||||
wcsncpy_s(g_external_event_info, info.c_str(), info_size);
|
wcsncpy_s(g_external_event_info, info.c_str(), info_size);
|
||||||
RaiseException(CUSTOM_EXCEPTION_EXTERNAL_EVENT, 0, 0, nullptr);
|
RaiseException(CUSTOM_EXCEPTION_EXTERNAL_EVENT, 0, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void BootVehRaiseExternalEventW(LPCWSTR info)
|
||||||
|
{
|
||||||
|
const std::wstring info_wstr(info);
|
||||||
|
veh::raise_external_event(info_wstr);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,6 @@ public sealed class EntryPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
var pluginInfo = string.Empty;
|
var pluginInfo = string.Empty;
|
||||||
var supportText = ", please visit us on Discord for more help";
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pm = Service<PluginManager>.GetNullable();
|
var pm = Service<PluginManager>.GetNullable();
|
||||||
|
|
@ -300,9 +299,6 @@ public sealed class EntryPoint
|
||||||
if (plugin != null)
|
if (plugin != null)
|
||||||
{
|
{
|
||||||
pluginInfo = $"Plugin that caused this:\n{plugin.Name}\n\nClick \"Yes\" and remove it.\n\n";
|
pluginInfo = $"Plugin that caused this:\n{plugin.Name}\n\nClick \"Yes\" and remove it.\n\n";
|
||||||
|
|
||||||
if (plugin.IsThirdParty)
|
|
||||||
supportText = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
@ -310,31 +306,18 @@ public sealed class EntryPoint
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
const MESSAGEBOX_STYLE flags = MESSAGEBOX_STYLE.MB_YESNO | MESSAGEBOX_STYLE.MB_ICONERROR | MESSAGEBOX_STYLE.MB_SYSTEMMODAL;
|
|
||||||
var result = Windows.Win32.PInvoke.MessageBox(
|
|
||||||
new HWND(Process.GetCurrentProcess().MainWindowHandle),
|
|
||||||
$"An internal error in a Dalamud plugin occurred.\nThe game must close.\n\n{ex.GetType().Name}\n{info}\n\n{pluginInfo}More information has been recorded separately{supportText}.\n\nDo you want to disable all plugins the next time you start the game?",
|
|
||||||
"Dalamud",
|
|
||||||
flags);
|
|
||||||
|
|
||||||
if (result == MESSAGEBOX_RESULT.IDYES)
|
|
||||||
{
|
|
||||||
Log.Information("User chose to disable plugins on next launch...");
|
|
||||||
var config = Service<DalamudConfiguration>.Get();
|
|
||||||
config.PluginSafeMode = true;
|
|
||||||
config.ForceSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.CloseAndFlush();
|
Log.CloseAndFlush();
|
||||||
Environment.Exit(-1);
|
|
||||||
|
ErrorHandling.CrashWithContext($"{ex}\n\n{info}\n\n{pluginInfo}");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.Fatal("Unhandled SEH object on AppDomain: {Object}", args.ExceptionObject);
|
Log.Fatal("Unhandled SEH object on AppDomain: {Object}", args.ExceptionObject);
|
||||||
|
|
||||||
Log.CloseAndFlush();
|
Log.CloseAndFlush();
|
||||||
Environment.Exit(-1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Environment.Exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnUnhandledExceptionStallDebug(object sender, UnhandledExceptionEventArgs args)
|
private static void OnUnhandledExceptionStallDebug(object sender, UnhandledExceptionEventArgs args)
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,9 @@ public record struct SeStringDrawParams
|
||||||
/// <see cref="ImGui.GetWindowDrawList"/> (the default).</value>
|
/// <see cref="ImGui.GetWindowDrawList"/> (the default).</value>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If this value is set, <see cref="ImGui.Dummy"/> will not be called, and ImGui ID will be ignored.
|
/// If this value is set, <see cref="ImGui.Dummy"/> will not be called, and ImGui ID will be ignored.
|
||||||
/// You <b>must</b> specify a valid draw list and a valid font via <see cref="Font"/> if you set this value,
|
/// You <b>must</b> specify a valid draw list, a valid font via <see cref="Font"/> and <see cref="FontSize"/> if you set this value,
|
||||||
/// since the renderer will not be able to retrieve them from ImGui context.
|
/// since the renderer will not be able to retrieve them from ImGui context.
|
||||||
|
/// Must be set when drawing off the main thread.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public ImDrawListPtr? TargetDrawList { get; set; }
|
public ImDrawListPtr? TargetDrawList { get; set; }
|
||||||
|
|
||||||
|
|
@ -29,11 +30,13 @@ public record struct SeStringDrawParams
|
||||||
|
|
||||||
/// <summary>Gets or sets the font to use.</summary>
|
/// <summary>Gets or sets the font to use.</summary>
|
||||||
/// <value>Font to use, or <c>null</c> to use <see cref="ImGui.GetFont"/> (the default).</value>
|
/// <value>Font to use, or <c>null</c> to use <see cref="ImGui.GetFont"/> (the default).</value>
|
||||||
|
/// <remarks>Must be set when specifying a target draw-list or drawing off the main thread.</remarks>
|
||||||
public ImFontPtr? Font { get; set; }
|
public ImFontPtr? Font { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets the font size.</summary>
|
/// <summary>Gets or sets the font size.</summary>
|
||||||
/// <value>Font size in pixels, or <c>0</c> to use the current ImGui font size <see cref="ImGui.GetFontSize"/>.
|
/// <value>Font size in pixels, or <c>0</c> to use the current ImGui font size <see cref="ImGui.GetFontSize"/>.
|
||||||
/// </value>
|
/// </value>
|
||||||
|
/// <remarks>Must be set when specifying a target draw-list or drawing off the main thread.</remarks>
|
||||||
public float? FontSize { get; set; }
|
public float? FontSize { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets the line height ratio.</summary>
|
/// <summary>Gets or sets the line height ratio.</summary>
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public unsafe ref struct SeStringDrawState
|
||||||
this.drawList = ssdp.TargetDrawList.Value;
|
this.drawList = ssdp.TargetDrawList.Value;
|
||||||
this.ScreenOffset = Vector2.Zero;
|
this.ScreenOffset = Vector2.Zero;
|
||||||
this.FontSize = ssdp.FontSize ?? throw new ArgumentException(
|
this.FontSize = ssdp.FontSize ?? throw new ArgumentException(
|
||||||
$"{nameof(ssdp.FontSize)} must be set to render outside the main thread.");
|
$"{nameof(ssdp.FontSize)} must be set when specifying a target draw list, as it cannot be fetched from the ImGui state.");
|
||||||
this.WrapWidth = ssdp.WrapWidth ?? float.MaxValue;
|
this.WrapWidth = ssdp.WrapWidth ?? float.MaxValue;
|
||||||
this.Color = ssdp.Color ?? uint.MaxValue;
|
this.Color = ssdp.Color ?? uint.MaxValue;
|
||||||
this.LinkHoverBackColor = 0; // Interactivity is unused outside the main thread.
|
this.LinkHoverBackColor = 0; // Interactivity is unused outside the main thread.
|
||||||
|
|
|
||||||
|
|
@ -667,6 +667,8 @@ internal class DalamudInterface : IInternalDisposableService
|
||||||
{
|
{
|
||||||
if (this.isImGuiDrawDevMenu)
|
if (this.isImGuiDrawDevMenu)
|
||||||
{
|
{
|
||||||
|
using var barColor = ImRaii.PushColor(ImGuiCol.WindowBg, new Vector4(0.060f, 0.060f, 0.060f, 0.773f));
|
||||||
|
barColor.Push(ImGuiCol.MenuBarBg, Vector4.Zero);
|
||||||
if (ImGui.BeginMainMenuBar())
|
if (ImGui.BeginMainMenuBar())
|
||||||
{
|
{
|
||||||
var pluginManager = Service<PluginManager>.Get();
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
|
|
@ -839,6 +841,11 @@ internal class DalamudInterface : IInternalDisposableService
|
||||||
ImGui.PopStyleVar();
|
ImGui.PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui.MenuItem("Raise external event through boot"))
|
||||||
|
{
|
||||||
|
ErrorHandling.CrashWithContext("Tést");
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndMenu();
|
ImGui.EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
21
Dalamud/Utility/ErrorHandling.cs
Normal file
21
Dalamud/Utility/ErrorHandling.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Dalamud.Utility;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Utilities for handling errors inside Dalamud.
|
||||||
|
/// </summary>
|
||||||
|
internal static partial class ErrorHandling
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Crash the game at this point, and show the crash handler with the supplied context.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The context to show in the crash handler.</param>
|
||||||
|
public static void CrashWithContext(string context)
|
||||||
|
{
|
||||||
|
BootVehRaiseExternalEvent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
[LibraryImport("Dalamud.Boot.dll", EntryPoint = "BootVehRaiseExternalEventW", StringMarshalling = StringMarshalling.Utf16)]
|
||||||
|
private static partial void BootVehRaiseExternalEvent(string info);
|
||||||
|
}
|
||||||
|
|
@ -1014,8 +1014,8 @@ int main() {
|
||||||
config.pButtons = buttons;
|
config.pButtons = buttons;
|
||||||
config.cButtons = ARRAYSIZE(buttons);
|
config.cButtons = ARRAYSIZE(buttons);
|
||||||
config.nDefaultButton = IdButtonRestart;
|
config.nDefaultButton = IdButtonRestart;
|
||||||
config.pszExpandedControlText = L"Hide stack trace";
|
config.pszExpandedControlText = L"Hide further information";
|
||||||
config.pszCollapsedControlText = L"Stack trace for plugin developers";
|
config.pszCollapsedControlText = L"Further information for developers";
|
||||||
config.pszExpandedInformation = window_log_str.c_str();
|
config.pszExpandedInformation = window_log_str.c_str();
|
||||||
config.pszWindowTitle = L"Dalamud Crash Handler";
|
config.pszWindowTitle = L"Dalamud Crash Handler";
|
||||||
config.pRadioButtons = radios;
|
config.pRadioButtons = radios;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5d01489c34f33a3d645f49085d7fc0065a1ac801
|
Subproject commit 19111a07705e6fa2d5d499662988f7e78d101b12
|
||||||
Loading…
Add table
Add a link
Reference in a new issue