-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9770911
commit 62a5c86
Showing
5 changed files
with
77 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using IPA.Loader; | ||
|
||
using UnityEngine; | ||
|
||
using Zenject; | ||
|
||
namespace BetterBeatSaber.Bindings; | ||
|
||
internal sealed class MenuEnvironmentHider : IInitializable, IDisposable { | ||
|
||
private static readonly List<GameObject> MenuGameObjects = []; | ||
|
||
private static bool IsAdaptableNotesInstalled => PluginManager.GetPluginFromId("AdaptableNotes") != null; | ||
private static readonly List<string> AdaptableNotesIgnoredGameObjects = [ | ||
"Notes", | ||
"PileOfNotes" | ||
]; | ||
|
||
public void Initialize() { | ||
LoadMenuGameObjects(); | ||
SetMenuEnvironment(!BetterBeatSaberConfig.Instance.HideMenuEnvironment.CurrentValue); | ||
BetterBeatSaberConfig.Instance.HideMenuEnvironment.OnValueChanged += OnHideMenuEnvironmentChanged; | ||
} | ||
|
||
public void Dispose() => | ||
BetterBeatSaberConfig.Instance.HideMenuEnvironment.OnValueChanged -= OnHideMenuEnvironmentChanged; | ||
|
||
private static void OnHideMenuEnvironmentChanged(bool state) => | ||
SetMenuEnvironment(!state); | ||
|
||
private static void LoadMenuGameObjects() { | ||
|
||
MenuGameObjects.Clear(); | ||
|
||
foreach (var gameObjectName in BetterBeatSaberConfig.Instance.MenuGameObjects) { | ||
|
||
if (IsAdaptableNotesInstalled && AdaptableNotesIgnoredGameObjects.Contains(gameObjectName)) | ||
continue; | ||
|
||
var gameObject = GameObject.Find(gameObjectName); | ||
if(gameObject != null) | ||
MenuGameObjects.Add(gameObject); | ||
|
||
} | ||
|
||
} | ||
|
||
private static void SetMenuEnvironment(bool value) { | ||
foreach (var gameObject in MenuGameObjects) | ||
gameObject.SetActive(value); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters