Skip to content

Commit

Permalink
👌 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKrahforst committed Mar 1, 2024
1 parent 052e6f1 commit e2bf089
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 5 deletions.
1 change: 1 addition & 0 deletions BetterBeatSaber/BetterBeatSaber.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
<Compile Include="Enums\HitScoreMode.cs" />
<Compile Include="Extensions\DiContainerExtensions.cs" />
<Compile Include="Extensions\TextMeshProExtensions.cs" />
<Compile Include="Interops\HitScoreVisualizer.cs" />
<Compile Include="Interops\SongCore.cs" />
<Compile Include="Interops\Tweaks55.cs" />
<Compile Include="Interop\Interop.cs" />
Expand Down
3 changes: 2 additions & 1 deletion BetterBeatSaber/Installer/AppInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ internal sealed class AppInstaller : Zenject.Installer {
public override void InstallBindings() {
Container.BindInstance(BetterBeatSaber.Instance).AsSingle();
Container.BindInterfacesAndSelfTo<Manager.ColorManager>().AsSingle();
Container.BindInterop<HitScoreVisualizer>();
Container.BindInterop<SongCore>();
Container.BindInterop<Tweaks55>();
Container.BindInterop<Interops.SongCore>();
}

}
12 changes: 11 additions & 1 deletion BetterBeatSaber/Installer/MenuInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@

using BetterBeatSaber.Colorizer;

using IPA.Loader;

using UnityEngine;

namespace BetterBeatSaber.Installer;

internal sealed class MenuInstaller : Zenject.Installer, IDisposable {

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 Down Expand Up @@ -36,8 +44,10 @@ private static void HideMenuEnvironmentOnOnValueChanged(bool 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)
if(gameObject != null && IsAdaptableNotesInstalled && !AdaptableNotesIgnoredGameObjects.Contains(gameObjectName))
MenuGameObjects.Add(gameObject);
}
}
Expand Down
7 changes: 6 additions & 1 deletion BetterBeatSaber/Interop/Interop.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using IPA.Loader;
using IPA.Logging;

using Zenject;

Expand All @@ -8,10 +9,14 @@ public abstract class Interop<T> : IInitializable where T : Interop<T> {

public static T? Instance { get; private set; }

protected Logger Logger { get; }

protected abstract string Plugin { get; }

protected Interop() =>
protected Interop() {
Instance = (T) this;
Logger = BetterBeatSaber.Instance.Logger.GetChildLogger($"{GetType().Name} Interop");
}

public void Initialize() {
if (!RunIf())
Expand Down
29 changes: 29 additions & 0 deletions BetterBeatSaber/Interops/HitScoreVisualizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using BetterBeatSaber.Interop;
using BetterBeatSaber.Mixin.Attributes;
using BetterBeatSaber.Mixin.Enums;

using IPA.Loader;

namespace BetterBeatSaber.Interops;

internal sealed class HitScoreVisualizer : Interop<HitScoreVisualizer> {

protected override string Plugin => "HitScoreVisualizer";

protected override void Init(PluginMetadata pluginMetadata) =>
Logger.Warn("HitScoreVisualizer has been unpatched, it won't run until HitScore is disabled in Extras and after the game has been restarted");

// ReSharper disable UnusedType.Global
// ReSharper disable UnusedMember.Local
// ReSharper disable InconsistentNaming

[Mixin("HitScoreVisualizer", "HitScoreVisualizer.Installers.HsvMenuInstaller")]
[Mixin("HitScoreVisualizer", "HitScoreVisualizer.Installers.HsvAppInstaller")]
internal static class HitScoreVisualizerMixin {

[MixinMethod(nameof(InstallBindings), MixinAt.Pre)]
private static bool InstallBindings() => !BetterBeatSaberConfig.Instance.HitScoreEnable.CurrentValue;

}

}
8 changes: 6 additions & 2 deletions BetterBeatSaber/Interops/SongCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ protected override void Init(PluginMetadata pluginMetadata) {
BetterBeatSaberConfig.Instance.FakeChroma.OnValueChanged += SetChroma;
}

protected override bool RunIf() =>
PluginManager.GetPluginFromId("Chroma") == null;
protected override bool RunIf() {
var installed = PluginManager.GetPluginFromId("Chroma") != null;
if(installed)
Logger.Info("Fake Chroma won't be enabled because Chroma is installed");
return !installed;
}

private void SetChroma(bool state) {
foreach (var chromaCapability in ChromaCapabilities)
Expand Down
7 changes: 7 additions & 0 deletions BetterBeatSaber/Models/HitScoreFlyingScoreEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

namespace BetterBeatSaber.Models;

/**
* Support for 1.31+
*
* https://github.com/daniel-chambers/HitScoreVisualizer/blob/update-1.32.0/HitScoreVisualizer/HarmonyPatches/FlyingScoreEffectPatch.cs
* https://github.com/daniel-chambers/HitScoreVisualizer/blob/update-1.32.0/HitScoreVisualizer/HarmonyPatches/EffectPoolsManualInstallerPatch.cs
*/

internal sealed class HitScoreFlyingScoreEffect : FlyingScoreEffect {

private static readonly Color Color112 = new(.3f, 0f, 1f);
Expand Down

0 comments on commit e2bf089

Please sign in to comment.