2020-08-03 19:13:02 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-09-11 09:30:14 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2022-10-12 06:22:46 +00:00
|
|
|
using osu.Framework.Graphics;
|
2020-08-03 19:13:02 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2022-10-12 06:11:52 +00:00
|
|
|
using osu.Game.Screens.Play;
|
2020-08-03 19:13:02 +00:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
|
|
|
{
|
2020-08-19 05:39:40 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Represents a component that displays a skinned <see cref="ICatchComboCounter"/> and handles combo judgement results for updating it accordingly.
|
|
|
|
/// </summary>
|
2020-08-03 19:13:02 +00:00
|
|
|
public partial class CatchComboDisplay : SkinnableDrawable
|
|
|
|
{
|
|
|
|
private int currentCombo;
|
|
|
|
|
2022-10-12 06:14:54 +00:00
|
|
|
public ICatchComboCounter? ComboCounter => Drawable as ICatchComboCounter;
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2022-10-12 06:14:33 +00:00
|
|
|
private readonly IBindable<bool> showCombo = new BindableBool(true);
|
2022-09-11 09:30:14 +00:00
|
|
|
|
2020-08-03 19:13:02 +00:00
|
|
|
public CatchComboDisplay()
|
2022-11-09 07:04:56 +00:00
|
|
|
: base(new CatchSkinComponentLookup(CatchSkinComponents.CatchComboCounter), _ => Empty())
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-01-15 14:11:59 +00:00
|
|
|
[Resolved]
|
2022-10-12 06:25:16 +00:00
|
|
|
private Player? player { get; set; }
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
2022-09-11 09:30:14 +00:00
|
|
|
{
|
2022-10-12 06:25:16 +00:00
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-10-12 06:14:33 +00:00
|
|
|
if (player != null)
|
2022-09-11 09:30:14 +00:00
|
|
|
{
|
2022-10-12 06:14:33 +00:00
|
|
|
showCombo.BindTo(player.ShowingOverlayComponents);
|
2022-10-12 06:22:46 +00:00
|
|
|
showCombo.BindValueChanged(s => this.FadeTo(s.NewValue ? 1 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING), true);
|
2022-09-11 09:30:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-27 05:50:42 +00:00
|
|
|
protected override void SkinChanged(ISkinSource skin)
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
2021-05-27 05:50:42 +00:00
|
|
|
base.SkinChanged(skin);
|
2020-09-22 03:35:18 +00:00
|
|
|
ComboCounter?.UpdateCombo(currentCombo);
|
2020-08-03 19:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnNewResult(DrawableCatchHitObject judgedObject, JudgementResult result)
|
|
|
|
{
|
2020-09-29 05:26:36 +00:00
|
|
|
if (!result.Type.AffectsCombo() || !result.HasResult)
|
2020-08-03 19:13:02 +00:00
|
|
|
return;
|
|
|
|
|
2020-10-02 20:57:49 +00:00
|
|
|
if (!result.IsHit)
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
|
|
|
updateCombo(0, null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateCombo(result.ComboAtJudgement + 1, judgedObject.AccentColour.Value);
|
|
|
|
}
|
|
|
|
|
2023-01-19 10:43:23 +00:00
|
|
|
public void OnRevertResult(JudgementResult result)
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
2020-09-29 05:26:36 +00:00
|
|
|
if (!result.Type.AffectsCombo() || !result.HasResult)
|
2020-08-03 19:13:02 +00:00
|
|
|
return;
|
|
|
|
|
2023-01-19 10:43:23 +00:00
|
|
|
updateCombo(result.ComboAtJudgement, null);
|
2020-08-03 19:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateCombo(int newCombo, Color4? hitObjectColour)
|
|
|
|
{
|
|
|
|
currentCombo = newCombo;
|
|
|
|
ComboCounter?.UpdateCombo(newCombo, hitObjectColour);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|