mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
feat: add /xlrestart
This commit is contained in:
parent
b3e20eec18
commit
9e139389ea
3 changed files with 29 additions and 8 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -98,6 +100,19 @@ internal sealed class Dalamud : IServiceType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal DirectoryInfo AssetDirectory => new(Service<DalamudStartInfo>.Get().AssetDirectory!);
|
internal DirectoryInfo AssetDirectory => new(Service<DalamudStartInfo>.Get().AssetDirectory!);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Signal to the crash handler process that we should restart the game.
|
||||||
|
/// </summary>
|
||||||
|
public static void RestartGame()
|
||||||
|
{
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
static extern void RaiseException(uint dwExceptionCode, uint dwExceptionFlags, uint nNumberOfArguments, IntPtr lpArguments);
|
||||||
|
|
||||||
|
RaiseException(0x12345678, 0, 0, IntPtr.Zero);
|
||||||
|
Process.GetCurrentProcess().Kill();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queue an unload of Dalamud when it gets the chance.
|
/// Queue an unload of Dalamud when it gets the chance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,12 @@ internal class DalamudCommands : IServiceType
|
||||||
ShowInHelp = false,
|
ShowInHelp = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commandManager.AddHandler("/xlrestart", new CommandInfo(this.OnRestartCommand)
|
||||||
|
{
|
||||||
|
HelpMessage = "Restart the game.",
|
||||||
|
ShowInHelp = false,
|
||||||
|
});
|
||||||
|
|
||||||
commandManager.AddHandler("/xlhelp", new CommandInfo(this.OnHelpCommand)
|
commandManager.AddHandler("/xlhelp", new CommandInfo(this.OnHelpCommand)
|
||||||
{
|
{
|
||||||
HelpMessage = Loc.Localize("DalamudCmdInfoHelp", "Shows list of commands available. If an argument is provided, shows help for that command."),
|
HelpMessage = Loc.Localize("DalamudCmdInfoHelp", "Shows list of commands available. If an argument is provided, shows help for that command."),
|
||||||
|
|
@ -153,6 +159,11 @@ internal class DalamudCommands : IServiceType
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRestartCommand(string command, string arguments)
|
||||||
|
{
|
||||||
|
Dalamud.RestartGame();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnHelpCommand(string command, string arguments)
|
private void OnHelpCommand(string command, string arguments)
|
||||||
{
|
{
|
||||||
var chatGui = Service<ChatGui>.Get();
|
var chatGui = Service<ChatGui>.Get();
|
||||||
|
|
|
||||||
|
|
@ -717,12 +717,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
||||||
|
|
||||||
if (ImGui.MenuItem("Restart game"))
|
if (ImGui.MenuItem("Restart game"))
|
||||||
{
|
{
|
||||||
[DllImport("kernel32.dll")]
|
Dalamud.RestartGame();
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
static extern void RaiseException(uint dwExceptionCode, uint dwExceptionFlags, uint nNumberOfArguments, IntPtr lpArguments);
|
|
||||||
|
|
||||||
RaiseException(0x12345678, 0, 0, IntPtr.Zero);
|
|
||||||
Process.GetCurrentProcess().Kill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.MenuItem("Kill game"))
|
if (ImGui.MenuItem("Kill game"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue