1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

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.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Catch.UI;

View File

@ -4,9 +4,13 @@
#nullable disable
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.Skinning;
using osuTK.Graphics;
@ -22,11 +26,69 @@ namespace osu.Game.Rulesets.Catch.UI
[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; }
public CatchComboDisplay()
: 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)
{
base.SkinChanged(skin);
@ -57,6 +119,8 @@ namespace osu.Game.Rulesets.Catch.UI
private void updateCombo(int newCombo, Color4? hitObjectColour)
{
if (!showCombo.Value) return;
currentCombo = newCombo;
ComboCounter?.UpdateCombo(newCombo, hitObjectColour);
}