mirror of https://github.com/ppy/osu
Move colours to HitErrorMeter class
This commit is contained in:
parent
5af1260094
commit
b61aa660c6
|
@ -163,30 +163,9 @@ private void createColourBars(OsuColour colours)
|
|||
centre.Width = 2.5f;
|
||||
colourBars.Add(centre);
|
||||
|
||||
Color4 getColour(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Meh:
|
||||
return colours.Yellow;
|
||||
|
||||
case HitResult.Ok:
|
||||
return colours.Green;
|
||||
|
||||
case HitResult.Good:
|
||||
return colours.GreenLight;
|
||||
|
||||
case HitResult.Great:
|
||||
return colours.Blue;
|
||||
|
||||
default:
|
||||
return colours.BlueLight;
|
||||
}
|
||||
}
|
||||
|
||||
Drawable createColourBar(HitResult result, float height, bool first = false)
|
||||
{
|
||||
var colour = getColour(result);
|
||||
var colour = GetColourForHitResult(result);
|
||||
|
||||
if (first)
|
||||
{
|
||||
|
@ -201,7 +180,7 @@ Drawable createColourBar(HitResult result, float height, bool first = false)
|
|||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = getColour(result),
|
||||
Colour = colour,
|
||||
Height = height * gradient_start
|
||||
},
|
||||
new Box
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
|
@ -34,56 +33,21 @@ public ColourHitErrorMeter(HitWindows hitWindows)
|
|||
|
||||
public override void OnNewJudgement(JudgementResult judgement)
|
||||
{
|
||||
judgementsFlow.Add(new DrawableJudgement(HitWindows.ResultFor(judgement.TimeOffset)));
|
||||
judgementsFlow.Add(new DrawableJudgement(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset))));
|
||||
}
|
||||
|
||||
private class DrawableJudgement : CircularContainer
|
||||
{
|
||||
private readonly Box background;
|
||||
private readonly HitResult result;
|
||||
|
||||
public DrawableJudgement(HitResult result)
|
||||
public DrawableJudgement(Color4 colour)
|
||||
{
|
||||
this.result = result;
|
||||
|
||||
Masking = true;
|
||||
Size = new Vector2(8);
|
||||
Child = background = new Box
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colour
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
background.Colour = colours.Red;
|
||||
break;
|
||||
|
||||
case HitResult.Meh:
|
||||
background.Colour = colours.Yellow;
|
||||
break;
|
||||
|
||||
case HitResult.Ok:
|
||||
background.Colour = colours.Green;
|
||||
break;
|
||||
|
||||
case HitResult.Good:
|
||||
background.Colour = colours.GreenLight;
|
||||
break;
|
||||
|
||||
case HitResult.Great:
|
||||
background.Colour = colours.Blue;
|
||||
break;
|
||||
|
||||
default:
|
||||
background.Colour = colours.BlueLight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
// 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.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
|
@ -11,11 +14,38 @@ public abstract class HitErrorMeter : CompositeDrawable
|
|||
{
|
||||
protected readonly HitWindows HitWindows;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
protected HitErrorMeter(HitWindows hitWindows)
|
||||
{
|
||||
HitWindows = hitWindows;
|
||||
}
|
||||
|
||||
public abstract void OnNewJudgement(JudgementResult judgement);
|
||||
|
||||
protected Color4 GetColourForHitResult(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
return colours.Red;
|
||||
|
||||
case HitResult.Meh:
|
||||
return colours.Yellow;
|
||||
|
||||
case HitResult.Ok:
|
||||
return colours.Green;
|
||||
|
||||
case HitResult.Good:
|
||||
return colours.GreenLight;
|
||||
|
||||
case HitResult.Great:
|
||||
return colours.Blue;
|
||||
|
||||
default:
|
||||
return colours.BlueLight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue