Skip to content

Commit

Permalink
BSML optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kinsi55 committed Mar 9, 2022
1 parent 8940722 commit fe7273a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
21 changes: 19 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
/// <summary>
/// Called when the plugin is first loaded by IPA (either when the game starts or when the plugin is enabled if it starts disabled).
Expand All @@ -38,15 +55,15 @@ 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]
public void OnDisable() {
SceneManager.activeSceneChanged -= OnActiveSceneChanged;

harmony.UnpatchSelf();
BSMLSettings.instance.RemoveSettingsMenu(Configuration.PluginConfig.Instance);
BsmlWrapper.DisableUI();
}
#endregion

Expand Down
5 changes: 2 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}

0 comments on commit fe7273a

Please sign in to comment.