Skip to content

Commit

Permalink
👌 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKrahforst committed Mar 2, 2024
1 parent 9770911 commit 62a5c86
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 61 deletions.
1 change: 1 addition & 0 deletions BetterBeatSaber/BetterBeatSaber.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="Bindings\MenuEnvironmentHider.cs" />
<Compile Include="Colorizer\BombColorizer.cs" />
<Compile Include="Colorizer\BurnMarkAreaColorizer.cs" />
<Compile Include="Colorizer\FeetColorizer.cs" />
Expand Down
56 changes: 56 additions & 0 deletions BetterBeatSaber/Bindings/MenuEnvironmentHider.cs
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);
}

}
2 changes: 1 addition & 1 deletion BetterBeatSaber/Extensions/TextMeshProExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
46 changes: 3 additions & 43 deletions BetterBeatSaber/Installer/MenuInstaller.cs
Original file line number Diff line number Diff line change
@@ -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<string> AdaptableNotesIgnoredGameObjects = [
"Notes",
"PileOfNotes"
];

public override void InstallBindings() {

Container.BindInterfacesAndSelfTo<DustColorizer>().AsSingle();
Expand All @@ -25,36 +13,8 @@ public override void InstallBindings() {
if(BetterBeatSaberConfig.Instance.ColorizeMenuSign)
Container.BindInterfacesAndSelfTo<MenuSignColorizer>().AsSingle();

LoadMenuGameObjects();

SetMenuEnvironment(!BetterBeatSaberConfig.Instance.HideMenuEnvironment.CurrentValue);

BetterBeatSaberConfig.Instance.HideMenuEnvironment.OnValueChanged += HideMenuEnvironmentOnOnValueChanged;

}

public void Dispose() =>
BetterBeatSaberConfig.Instance.HideMenuEnvironment.OnValueChanged -= HideMenuEnvironmentOnOnValueChanged;

private static readonly List<GameObject> 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<MenuEnvironmentHider>().AsSingle();

private static void SetMenuEnvironment(bool value) {
foreach (var gameObject in MenuGameObjects)
gameObject.SetActive(value);
}

}
33 changes: 16 additions & 17 deletions BetterBeatSaber/Models/HitScoreFlyingScoreEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $"<size={size}%>";
var text = $"<size={size * BetterBeatSaberConfig.Instance.HitScoreScale:N0}%>";
if(color != null)
text += $"<color=#{color.Value.ToHex()}>";

Expand All @@ -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<size=100%><color=#{GetTimeDependencyColor(timeDependency).ToHex()}>{timeDependency}</color></size>";
_colorizationLength = text.Length - 1;
var timeDependency = Mathf.Abs(cutScoreBuffer.noteCutInfo.cutNormal.z) * 100;
text += $"\n<size={100 * BetterBeatSaberConfig.Instance.HitScoreScale:N0}%><color=#{GetTimeDependencyColor(timeDependency).ToHex()}>{timeDependency:N0}</color></size>";
} else _colorizationLength = -1;

_text.text = text;
Expand All @@ -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,
Expand Down

0 comments on commit 62a5c86

Please sign in to comment.