From fe7273acab46255a36769f58fec24b7c6ba1afc6 Mon Sep 17 00:00:00 2001 From: Kinsi Date: Wed, 9 Mar 2022 01:05:29 +0100 Subject: [PATCH] BSML optional --- Plugin.cs | 21 +++++++++++++++++++-- manifest.json | 5 ++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Plugin.cs b/Plugin.cs index 8a7cfdf..53c4f8e 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -17,6 +17,23 @@ public class Plugin { public static Harmony harmony; + static class BsmlWrapper { + static readonly bool hasBsml = IPA.Loader.PluginManager.GetPluginFromId("BeatSaberMarkupLanguage") != null; + + public static void EnableUI() { + void wrap() => BSMLSettings.instance.AddSettingsMenu("Gotta Go Fast", "GottaGoFast.Views.settings.bsml", Configuration.PluginConfig.Instance); + + if(hasBsml) + wrap(); + } + public static void DisableUI() { + void wrap() => BSMLSettings.instance.RemoveSettingsMenu(Configuration.PluginConfig.Instance); + + if(hasBsml) + wrap(); + } + } + [Init] /// /// Called when the plugin is first loaded by IPA (either when the game starts or when the plugin is enabled if it starts disabled). @@ -38,7 +55,7 @@ public void OnEnable() { SceneManager.activeSceneChanged += OnActiveSceneChanged; harmony.PatchAll(Assembly.GetExecutingAssembly()); - BSMLSettings.instance.AddSettingsMenu("Gotta Go Fast", "GottaGoFast.Views.settings.bsml", Configuration.PluginConfig.Instance); + BsmlWrapper.EnableUI(); } [OnDisable] @@ -46,7 +63,7 @@ public void OnDisable() { SceneManager.activeSceneChanged -= OnActiveSceneChanged; harmony.UnpatchSelf(); - BSMLSettings.instance.RemoveSettingsMenu(Configuration.PluginConfig.Instance); + BsmlWrapper.DisableUI(); } #endregion diff --git a/manifest.json b/manifest.json index 9b85458..76a4a28 100644 --- a/manifest.json +++ b/manifest.json @@ -2,12 +2,11 @@ "id": "GottaGoFast", "name": "Gotta Go Fast", "author": "Kinsi55", - "version": "0.1.3", + "version": "0.2.0", "description": "Significantly decreases the time it takes to (re)start songs", "gameVersion": "1.19.0", "dependsOn": { - "BSIPA": "^4.0.5", - "BeatSaberMarkupLanguage": "^1.5.3" + "BSIPA": "^4.0.5" }, "features": [] } \ No newline at end of file