Update `CatchComboDisplay` implementation to use newly exposed bindable

This commit is contained in:
Dean Herbert 2022-10-12 15:14:33 +09:00
parent d2d589a156
commit 652bc4ac61
1 changed files with 10 additions and 54 deletions

View File

@ -6,11 +6,9 @@
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
using osuTK.Graphics;
@ -27,14 +25,7 @@ public class CatchComboDisplay : SkinnableDrawable
[CanBeNull]
public ICatchComboCounter ComboCounter => Drawable as ICatchComboCounter;
private Bindable<HUDVisibilityMode> hudVisibilityMode = null!;
private readonly BindableBool replayLoaded = new BindableBool();
private readonly BindableBool showCombo = new BindableBool();
[Resolved]
private OsuConfigManager config { get; set; }
private readonly IBindable<bool> showCombo = new BindableBool(true);
public CatchComboDisplay()
: base(new CatchSkinComponent(CatchSkinComponents.CatchComboCounter), _ => Empty())
@ -42,51 +33,18 @@ public CatchComboDisplay()
}
[BackgroundDependencyLoader(true)]
private void load(DrawableRuleset drawableRuleset, HUDOverlay hud)
private void load(Player player)
{
hudVisibilityMode = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode);
hudVisibilityMode.BindValueChanged(s =>
if (player != null)
{
updateVisibilityState();
});
if (drawableRuleset != null)
replayLoaded.BindTo(drawableRuleset.HasReplayLoaded);
replayLoaded.BindValueChanged(s =>
{
updateVisibilityState();
});
showCombo.BindTo(player.ShowingOverlayComponents);
showCombo.BindValueChanged(s =>
{
if (ComboCounter == null) return;
if (!s.NewValue)
{
ComboCounter.Hide();
}
});
updateVisibilityState();
void updateVisibilityState()
{
switch (hudVisibilityMode.Value)
{
case HUDVisibilityMode.Never:
showCombo.Value = false;
break;
case HUDVisibilityMode.HideDuringGameplay:
showCombo.Value = replayLoaded.Value;
break;
case HUDVisibilityMode.Always:
showCombo.Value = true;
break;
}
ComboCounter?.Hide();
else
ComboCounter?.Show();
}, true);
}
}
@ -120,8 +78,6 @@ public void OnRevertResult(DrawableCatchHitObject judgedObject, JudgementResult
private void updateCombo(int newCombo, Color4? hitObjectColour)
{
if (!showCombo.Value) return;
currentCombo = newCombo;
ComboCounter?.UpdateCombo(newCombo, hitObjectColour);
}