38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using HarmonyLib;
|
|
using Sandbox.Game.Gui;
|
|
using Sandbox.Graphics.GUI;
|
|
using VRage;
|
|
using VRage.Input;
|
|
|
|
namespace PluginLoader.Patch;
|
|
|
|
[HarmonyPatch(typeof(MyGuiScreenGamePlay), "ShowLoadMessageBox")]
|
|
public static class Patch_IngameRestart
|
|
{
|
|
public static bool Prefix()
|
|
{
|
|
if (Main.Instance.HasLocal && MyInput.Static.IsAnyAltKeyPressed() && MyInput.Static.IsAnyCtrlKeyPressed())
|
|
{
|
|
ShowRestartMenu();
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public static void ShowRestartMenu()
|
|
{
|
|
var box = MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO,
|
|
new("Plugin Loader: Are you sure you want to restart the game?"),
|
|
MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm),
|
|
callback: OnMessageClosed);
|
|
box.SkipTransition = true;
|
|
box.CloseBeforeCallback = true;
|
|
MyGuiSandbox.AddScreen(box);
|
|
}
|
|
|
|
private static void OnMessageClosed(MyGuiScreenMessageBox.ResultEnum result)
|
|
{
|
|
if (result == MyGuiScreenMessageBox.ResultEnum.YES) LoaderTools.UnloadAndRestart();
|
|
}
|
|
} |