26 lines
867 B
C#
26 lines
867 B
C#
using HarmonyLib;
|
|
using Sandbox;
|
|
using VRage.Input;
|
|
|
|
namespace PluginLoader.Patch;
|
|
|
|
[HarmonyPatch(typeof(MySandboxGame), "LoadData")]
|
|
public static class Patch_DisableConfig
|
|
{
|
|
public static void Postfix()
|
|
{
|
|
// This is the earliest point in which I can use MyInput.Static
|
|
if (Main.Instance == null)
|
|
return;
|
|
|
|
var main = Main.Instance;
|
|
var config = main.Config;
|
|
if (config != null && config.Count > 0 && MyInput.Static is MyVRageInput &&
|
|
MyInput.Static.IsKeyPress(MyKeys.Escape)
|
|
&& LoaderTools.ShowMessageBox("Escape pressed. Start the game with all plugins disabled?",
|
|
"Plugin Loader", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
main.DisablePlugins();
|
|
else
|
|
main.InstantiatePlugins();
|
|
}
|
|
} |