2022-12-12 06:47:17 +08: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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-12-12 22:10:10 +08:00
|
|
|
using osu.Game.Rulesets;
|
2022-12-12 06:47:17 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
|
|
|
{
|
|
|
|
public partial class JudgementCounter : OverlayContainer
|
|
|
|
{
|
|
|
|
public BindableBool ShowName = new BindableBool();
|
|
|
|
public Bindable<FillDirection> Direction = new Bindable<FillDirection>();
|
|
|
|
|
|
|
|
public readonly JudgementCounterInfo Result;
|
|
|
|
|
|
|
|
public JudgementCounter(JudgementCounterInfo result)
|
|
|
|
{
|
|
|
|
Result = result;
|
|
|
|
}
|
|
|
|
|
2022-12-12 06:58:10 +08:00
|
|
|
public OsuSpriteText ResultName = null!;
|
2022-12-12 06:47:17 +08:00
|
|
|
private FillFlowContainer flowContainer = null!;
|
|
|
|
private JudgementRollingCounter counter = null!;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-12-12 22:10:10 +08:00
|
|
|
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset)
|
2022-12-12 06:47:17 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
InternalChild = flowContainer = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
counter = new JudgementRollingCounter
|
|
|
|
{
|
|
|
|
Current = Result.ResultCount
|
|
|
|
},
|
2022-12-12 06:58:10 +08:00
|
|
|
ResultName = new OsuSpriteText
|
2022-12-12 06:47:17 +08:00
|
|
|
{
|
|
|
|
Font = OsuFont.Numeric.With(size: 8),
|
2022-12-12 22:10:10 +08:00
|
|
|
Text = ruleset.Value.CreateInstance().GetDisplayNameForHitResult(Result.Type)
|
2022-12-12 06:47:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-12 22:10:10 +08:00
|
|
|
var result = Result.Type;
|
2022-12-12 06:47:17 +08:00
|
|
|
|
|
|
|
if (result.IsBasic())
|
|
|
|
{
|
2022-12-12 22:10:10 +08:00
|
|
|
Colour = colours.ForHitResult(Result.Type);
|
2022-12-12 06:47:17 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!result.IsBonus())
|
|
|
|
{
|
|
|
|
Colour = colours.PurpleLight;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Colour = colours.PurpleLighter;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
ShowName.BindValueChanged(value =>
|
|
|
|
{
|
|
|
|
if (value.NewValue)
|
|
|
|
{
|
2022-12-12 06:58:10 +08:00
|
|
|
ResultName.Show();
|
2022-12-12 06:47:17 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-12 06:58:10 +08:00
|
|
|
ResultName.Hide();
|
2022-12-12 06:47:17 +08:00
|
|
|
}, true);
|
|
|
|
|
|
|
|
Direction.BindValueChanged(direction =>
|
|
|
|
{
|
|
|
|
flowContainer.Direction = direction.NewValue;
|
|
|
|
|
|
|
|
if (direction.NewValue == FillDirection.Vertical)
|
|
|
|
{
|
|
|
|
changeAnchor(Anchor.TopLeft);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
changeAnchor(Anchor.BottomLeft);
|
|
|
|
|
2022-12-12 06:58:10 +08:00
|
|
|
void changeAnchor(Anchor anchor) => counter.Anchor = ResultName.Anchor = counter.Origin = ResultName.Origin = anchor;
|
2022-12-12 06:47:17 +08:00
|
|
|
}, true);
|
|
|
|
|
|
|
|
base.LoadComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
{
|
2022-12-15 23:12:34 +08:00
|
|
|
this.FadeIn(500, Easing.OutQuint);
|
2022-12-12 06:47:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
{
|
|
|
|
this.FadeOut(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
private sealed partial class JudgementRollingCounter : RollingCounter<int>
|
|
|
|
{
|
|
|
|
protected override OsuSpriteText CreateSpriteText()
|
|
|
|
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(fixedWidth: true, size: 16));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|