mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 22:27:25 +08:00
Added fails and retries
This commit is contained in:
parent
305bc9cff6
commit
199c70ff95
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Screens.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Screens.Select;
|
||||
@ -20,9 +21,11 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
Add(new Details
|
||||
Details details;
|
||||
Add(details = new Details
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(150),
|
||||
Beatmap = new BeatmapInfo
|
||||
{
|
||||
Version = "VisualTest",
|
||||
@ -40,11 +43,11 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
},
|
||||
StarDifficulty = 5.3f,
|
||||
},
|
||||
Ratings = new[]
|
||||
{
|
||||
1,2,3,4,5,6,7,8,9,10
|
||||
}
|
||||
});
|
||||
|
||||
details.Ratings = Enumerable.Range(1, 10);
|
||||
details.Fails = Enumerable.Range(1, 100).Select(i => (int)(Math.Cos(i) * 100));
|
||||
details.Retries = Enumerable.Range(1, 100).Select(i => (int)(Math.Sin(i) * 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -33,6 +34,8 @@ namespace osu.Game.Screens.Select
|
||||
private SpriteText positiveRatings;
|
||||
private FillFlowContainer<DetailsBar> ratingsGraph;
|
||||
|
||||
private FillFlowContainer<RetryAndFailBar> retryAndFailGraph;
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
@ -92,6 +95,52 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private List<int> retries = Enumerable.Repeat(0,100).ToList();
|
||||
public IEnumerable<int> Retries
|
||||
{
|
||||
get
|
||||
{
|
||||
return retries;
|
||||
}
|
||||
set
|
||||
{
|
||||
retries = value.ToList();
|
||||
calcRetryAndFailBarLength();
|
||||
}
|
||||
}
|
||||
|
||||
private List<int> fails = Enumerable.Repeat(0,100).ToList();
|
||||
public IEnumerable<int> Fails
|
||||
{
|
||||
get
|
||||
{
|
||||
return fails;
|
||||
}
|
||||
set
|
||||
{
|
||||
fails = value.ToList();
|
||||
calcRetryAndFailBarLength();
|
||||
}
|
||||
}
|
||||
|
||||
private void calcRetryAndFailBarLength()
|
||||
{
|
||||
List<RetryAndFailBar> retryAndFailGraphBars = retryAndFailGraph.Children.ToList();
|
||||
for (int i = 0; i < 100; i++)
|
||||
if (retryAndFailGraphBars.Count > i)
|
||||
{
|
||||
retryAndFailGraphBars[i].FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0));
|
||||
retryAndFailGraphBars[i].RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0));
|
||||
}
|
||||
else
|
||||
retryAndFailGraph.Add(new RetryAndFailBar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.01f,
|
||||
FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)),
|
||||
RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)),
|
||||
});
|
||||
}
|
||||
|
||||
public Details()
|
||||
{
|
||||
@ -280,7 +329,7 @@ namespace osu.Game.Screens.Select
|
||||
Text = "Rating Spread",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Medium",
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
},
|
||||
ratingsGraph = new FillFlowContainer<DetailsBar>
|
||||
@ -288,13 +337,40 @@ namespace osu.Game.Screens.Select
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Height = 50,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding { Left = 10, Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
retryAndFailGraph = new FillFlowContainer<RetryAndFailBar>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Height = 50,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = "Points of Failure",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Medium",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -305,11 +381,10 @@ namespace osu.Game.Screens.Select
|
||||
source.Colour = colour.GrayB;
|
||||
tags.Colour = colour.YellowLight;
|
||||
|
||||
stars.BarColour = colour.YellowLight;
|
||||
stars.BarColour = colour.Yellow;
|
||||
|
||||
ratingsBar.BackgroundColour = colour.Green;
|
||||
ratingsBar.BarColour = colour.YellowDark;
|
||||
|
||||
ratingsGraph.Colour = colour.BlueDark;
|
||||
}
|
||||
|
||||
@ -407,5 +482,63 @@ namespace osu.Game.Screens.Select
|
||||
valueText.Colour = colour.GrayB;
|
||||
}
|
||||
}
|
||||
|
||||
private class RetryAndFailBar : Container<DetailsBar>
|
||||
{
|
||||
private DetailsBar retryBar;
|
||||
private DetailsBar failBar;
|
||||
|
||||
public float RetryLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return retryBar.Length;
|
||||
}
|
||||
set
|
||||
{
|
||||
retryBar.Length = value + FailLength;
|
||||
}
|
||||
}
|
||||
|
||||
public float FailLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return failBar.Length;
|
||||
}
|
||||
set
|
||||
{
|
||||
failBar.Length = value;
|
||||
}
|
||||
}
|
||||
|
||||
public RetryAndFailBar()
|
||||
{
|
||||
Children = new[]
|
||||
{
|
||||
retryBar = new DetailsBar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = BarDirection.BottomToTop,
|
||||
Length = 0,
|
||||
BackgroundColour = new Color4(0,0,0,0),
|
||||
},
|
||||
failBar = new DetailsBar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = BarDirection.BottomToTop,
|
||||
Length = 0,
|
||||
BackgroundColour = new Color4(0,0,0,0),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
retryBar.Colour = colour.Yellow;
|
||||
failBar.Colour = colour.YellowDarker;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -14,7 +15,7 @@ namespace osu.Game.Screens.Select
|
||||
private Box background;
|
||||
private Box bar;
|
||||
|
||||
private const int resizeDuration = 250;
|
||||
private const int resize_duration = 250;
|
||||
|
||||
private float length;
|
||||
public float Length
|
||||
@ -89,11 +90,11 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
case BarDirection.LeftToRight:
|
||||
case BarDirection.RightToLeft:
|
||||
bar.ResizeTo(new Vector2(length, 1), resizeDuration);
|
||||
bar.ResizeTo(new Vector2(length, 1), resize_duration);
|
||||
break;
|
||||
case BarDirection.TopToBottom:
|
||||
case BarDirection.BottomToTop:
|
||||
bar.ResizeTo(new Vector2(1, length), resizeDuration);
|
||||
bar.ResizeTo(new Vector2(1, length), resize_duration);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user