hide catchcombo when Hud hide

This commit is contained in:
cdwcgt 2022-09-11 17:30:14 +08:00
parent 7f5fe56c1d
commit 857e943b8d
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
2 changed files with 64 additions and 2 deletions

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;

View File

@ -4,9 +4,13 @@
#nullable disable #nullable disable
using JetBrains.Annotations; 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.Catch.Objects.Drawables;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK.Graphics; using osuTK.Graphics;
@ -22,11 +26,69 @@ public class CatchComboDisplay : SkinnableDrawable
[CanBeNull] [CanBeNull]
public ICatchComboCounter ComboCounter => Drawable as ICatchComboCounter; 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; }
public CatchComboDisplay() public CatchComboDisplay()
: base(new CatchSkinComponent(CatchSkinComponents.CatchComboCounter), _ => Empty()) : base(new CatchSkinComponent(CatchSkinComponents.CatchComboCounter), _ => Empty())
{ {
} }
[BackgroundDependencyLoader(true)]
private void load(DrawableRuleset drawableRuleset)
{
hudVisibilityMode = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode);
hudVisibilityMode.BindValueChanged(s =>
{
updateVisibilityState();
});
if (drawableRuleset != null)
replayLoaded.BindTo(drawableRuleset.HasReplayLoaded);
replayLoaded.BindValueChanged(s =>
{
updateVisibilityState();
});
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;
}
}
}
protected override void SkinChanged(ISkinSource skin) protected override void SkinChanged(ISkinSource skin)
{ {
base.SkinChanged(skin); base.SkinChanged(skin);
@ -57,6 +119,8 @@ public void OnRevertResult(DrawableCatchHitObject judgedObject, JudgementResult
private void updateCombo(int newCombo, Color4? hitObjectColour) private void updateCombo(int newCombo, Color4? hitObjectColour)
{ {
if (!showCombo.Value) return;
currentCombo = newCombo; currentCombo = newCombo;
ComboCounter?.UpdateCombo(newCombo, hitObjectColour); ComboCounter?.UpdateCombo(newCombo, hitObjectColour);
} }