1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:12:57 +08:00

Bind break overlay to accuracy

This commit is contained in:
EVAST9919 2017-09-23 16:42:18 +03:00
parent 2290c3d5d5
commit 2da3ea00b6
5 changed files with 109 additions and 48 deletions

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Scoring;
using System.Collections.Generic;
namespace osu.Game.Screens.Play.BreaksOverlay
@ -119,5 +120,10 @@ namespace osu.Game.Screens.Play.BreaksOverlay
info.FadeOut(fade_duration);
arrowsOverlay.Hide(fade_duration);
}
public void BindProcessor(ScoreProcessor processor)
{
info.AccuracyDisplay.Current.BindTo(processor.Accuracy);
}
}
}

View File

@ -2,16 +2,18 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Play.BreaksOverlay
{
public class InfoContainer : FillFlowContainer
{
public PercentageInfoLine AccuracyDisplay;
public InfoLine<int> RankDisplay;
public InfoLine<Grade> GradeDisplay;
public InfoContainer()
{
AutoSizeAxes = Axes.Both;
@ -28,60 +30,20 @@ namespace osu.Game.Screens.Play.BreaksOverlay
TextSize = 15,
Font = "Exo2.0-Black",
},
new FillFlowContainer<InfoLine>
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Direction = FillDirection.Vertical,
Children = new []
Children = new Drawable[]
{
new InfoLine(@"Accuracy", @"-"),
new InfoLine(@"Rank", @"-"),
new InfoLine(@"Grade", @"-"),
AccuracyDisplay = new PercentageInfoLine(@"Accuracy"),
RankDisplay = new InfoLine<int>(@"Rank", @"#"),
GradeDisplay = new InfoLine<Grade>(@"Grade"),
},
}
};
}
private class InfoLine : Container
{
private const int margin = 2;
private readonly OsuSpriteText text;
private readonly OsuSpriteText valueText;
public InfoLine(string name, string value)
{
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Text = name,
TextSize = 17,
Margin = new MarginPadding { Right = margin }
},
valueText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Text = value,
TextSize = 17,
Font = "Exo2.0-Bold",
Margin = new MarginPadding { Left = margin }
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
text.Colour = colours.Yellow;
valueText.Colour = colours.YellowLight;
}
}
}
}

View File

@ -0,0 +1,89 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Play.BreaksOverlay
{
public class InfoLine<T> : Container
where T : struct
{
private const int margin = 2;
public Bindable<T> Current = new Bindable<T>();
private readonly OsuSpriteText text;
private readonly OsuSpriteText valueText;
private readonly string prefix;
public InfoLine(string name, string prefix = @"")
{
this.prefix = prefix;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Text = name,
TextSize = 17,
Margin = new MarginPadding { Right = margin }
},
valueText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
Text = prefix + @"-",
TextSize = 17,
Font = "Exo2.0-Bold",
Margin = new MarginPadding { Left = margin }
}
};
Current.ValueChanged += currentValueChanged;
}
private void currentValueChanged(T newValue)
{
valueText.Text = prefix + Format(newValue);
}
protected virtual string Format(T count) => count.ToString();
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
text.Colour = colours.Yellow;
valueText.Colour = colours.YellowLight;
}
}
public class PercentageInfoLine : InfoLine<double>
{
public PercentageInfoLine(string name, string prefix = "") : base(name, prefix)
{
}
protected override string Format(double count) => $@"{count:P2}";
}
public enum Grade
{
SSplus,
SS,
Splus,
S,
A,
B,
C,
F
}
}

View File

@ -67,6 +67,7 @@ namespace osu.Game.Screens.Play
#endregion
private BreakOverlay breakOverlay;
private HUDOverlay hudOverlay;
private FailOverlay failOverlay;
@ -173,7 +174,7 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks)
breakOverlay = new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -211,6 +212,8 @@ namespace osu.Game.Screens.Play
hudOverlay.ModDisplay.Current.BindTo(working.Mods);
breakOverlay.BindProcessor(scoreProcessor);
// Bind ScoreProcessor to ourselves
scoreProcessor.AllJudged += onCompletion;
scoreProcessor.Failed += onFail;

View File

@ -280,6 +280,7 @@
<Compile Include="Screens\Play\BreaksOverlay\BreakOverlay.cs" />
<Compile Include="Screens\Play\BreaksOverlay\GlowIcon.cs" />
<Compile Include="Screens\Play\BreaksOverlay\InfoContainer.cs" />
<Compile Include="Screens\Play\BreaksOverlay\InfoLine.cs" />
<Compile Include="Screens\Play\BreaksOverlay\LetterboxOverlay.cs" />
<Compile Include="Screens\Play\BreaksOverlay\RemainingTimeCounter.cs" />
<Compile Include="Beatmaps\IO\OszArchiveReader.cs" />