diff --git a/BetterBeatSaber/BetterBeatSaber.csproj b/BetterBeatSaber/BetterBeatSaber.csproj index 3b76055..ff95caf 100644 --- a/BetterBeatSaber/BetterBeatSaber.csproj +++ b/BetterBeatSaber/BetterBeatSaber.csproj @@ -158,6 +158,7 @@ + diff --git a/BetterBeatSaber/Bindings/MenuEnvironmentHider.cs b/BetterBeatSaber/Bindings/MenuEnvironmentHider.cs new file mode 100644 index 0000000..219e208 --- /dev/null +++ b/BetterBeatSaber/Bindings/MenuEnvironmentHider.cs @@ -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 MenuGameObjects = []; + + private static bool IsAdaptableNotesInstalled => PluginManager.GetPluginFromId("AdaptableNotes") != null; + private static readonly List 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); + } + +} \ No newline at end of file diff --git a/BetterBeatSaber/Extensions/TextMeshProExtensions.cs b/BetterBeatSaber/Extensions/TextMeshProExtensions.cs index ff5d1f0..d6dcb19 100644 --- a/BetterBeatSaber/Extensions/TextMeshProExtensions.cs +++ b/BetterBeatSaber/Extensions/TextMeshProExtensions.cs @@ -10,7 +10,7 @@ public static void ApplyGradient(this TMP_Text text, Color start, Color end, int text.ForceMeshUpdate(); - until = until == -1 ? text.textInfo.characterCount : until; + until = until == -1 || until > text.textInfo.characterCount ? text.textInfo.characterCount : until; var steps = start.Steps(end, until); var gradients = new VertexGradient[until]; diff --git a/BetterBeatSaber/Installer/MenuInstaller.cs b/BetterBeatSaber/Installer/MenuInstaller.cs index fa214c8..29ed71b 100644 --- a/BetterBeatSaber/Installer/MenuInstaller.cs +++ b/BetterBeatSaber/Installer/MenuInstaller.cs @@ -1,22 +1,10 @@ -using System; -using System.Collections.Generic; - +using BetterBeatSaber.Bindings; using BetterBeatSaber.Colorizer; -using IPA.Loader; - -using UnityEngine; - namespace BetterBeatSaber.Installer; -internal sealed class MenuInstaller : Zenject.Installer, IDisposable { +internal sealed class MenuInstaller : Zenject.Installer { - private static bool IsAdaptableNotesInstalled => PluginManager.GetPluginFromId("AdaptableNotes") != null; - private static readonly List AdaptableNotesIgnoredGameObjects = [ - "Notes", - "PileOfNotes" - ]; - public override void InstallBindings() { Container.BindInterfacesAndSelfTo().AsSingle(); @@ -25,36 +13,8 @@ public override void InstallBindings() { if(BetterBeatSaberConfig.Instance.ColorizeMenuSign) Container.BindInterfacesAndSelfTo().AsSingle(); - LoadMenuGameObjects(); - - SetMenuEnvironment(!BetterBeatSaberConfig.Instance.HideMenuEnvironment.CurrentValue); - - BetterBeatSaberConfig.Instance.HideMenuEnvironment.OnValueChanged += HideMenuEnvironmentOnOnValueChanged; - - } - - public void Dispose() => - BetterBeatSaberConfig.Instance.HideMenuEnvironment.OnValueChanged -= HideMenuEnvironmentOnOnValueChanged; - - private static readonly List MenuGameObjects = []; - - private static void HideMenuEnvironmentOnOnValueChanged(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 && IsAdaptableNotesInstalled && !AdaptableNotesIgnoredGameObjects.Contains(gameObjectName)) - MenuGameObjects.Add(gameObject); - } - } + Container.BindInterfacesAndSelfTo().AsSingle(); - private static void SetMenuEnvironment(bool value) { - foreach (var gameObject in MenuGameObjects) - gameObject.SetActive(value); } } \ No newline at end of file diff --git a/BetterBeatSaber/Models/HitScoreFlyingScoreEffect.cs b/BetterBeatSaber/Models/HitScoreFlyingScoreEffect.cs index f7b7718..ca352bf 100644 --- a/BetterBeatSaber/Models/HitScoreFlyingScoreEffect.cs +++ b/BetterBeatSaber/Models/HitScoreFlyingScoreEffect.cs @@ -106,11 +106,10 @@ private void Judge(IReadonlyCutScoreBuffer cutScoreBuffer, int? assumedAfterCutS ConfigureText(); var (color, size) = GetColorAndSize(cutScoreBuffer.cutScore, cutScoreBuffer.maxPossibleCutScore); - size = (int) (size * BetterBeatSaberConfig.Instance.HitScoreScale); _colorize = color == null; - var text = $""; + var text = $""; if(color != null) text += $""; @@ -131,9 +130,9 @@ private void Judge(IReadonlyCutScoreBuffer cutScoreBuffer, int? assumedAfterCutS if (BetterBeatSaberConfig.Instance.HitScoreMode.HasFlag(HitScoreMode.TimeDependency)) { if (_colorize) - _colorizationLength = text.Length; - var timeDependency = (int) Mathf.Abs(cutScoreBuffer.noteCutInfo.cutNormal.z) * 100; - text += $"\n{timeDependency}"; + _colorizationLength = text.Length - 1; + var timeDependency = Mathf.Abs(cutScoreBuffer.noteCutInfo.cutNormal.z) * 100; + text += $"\n{timeDependency:N0}"; } else _colorizationLength = -1; _text.text = text; @@ -145,26 +144,26 @@ private static (Color?, int) GetColorAndSize(int score, int maxScore) => 115 => score switch { 115 => (null, 250), 114 => (null, 225), - >= 112 => (Color112: Purple, 200), - >= 110 => (Color110: Cyan, 175), - >= 107 => (Color107: Green, 162), - >= 105 => (Color105: Orange, 150), - _ => (Color0: Red, 125) + >= 112 => (Purple, 200), + >= 110 => (Cyan, 175), + >= 107 => (Green, 162), + >= 105 => (Orange, 150), + _ => (Red, 125) }, 85 => score switch { 85 => (null, 225), 83 => (null, 200), - >= 80 => (Color112: Purple, 175), - >= 70 => (Color110: Cyan, 162), - >= 60 => (Color107: Green, 150), - >= 50 => (Color105: Orange, 125), - _ => (Color0: Red, 125) + >= 80 => (Purple, 175), + >= 70 => (Cyan, 162), + >= 60 => (Green, 150), + >= 50 => (Orange, 125), + _ => (Red, 125) }, - 20 => score == 20 ? (null, 225) : (Color0: Red, 200), + 20 => score == 20 ? (null, 225) : (Red, 200), _ => (null, 0) }; - private static Color GetTimeDependencyColor(int score) => + private static Color GetTimeDependencyColor(float score) => score switch { >= 21 => Red, >= 11 => Orange,