1
0
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:
Jorolf 2017-03-28 20:18:56 +02:00
parent 305bc9cff6
commit 199c70ff95
3 changed files with 150 additions and 13 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Screens.Testing; using osu.Framework.Screens.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
@ -20,9 +21,11 @@ namespace osu.Desktop.VisualTests.Tests
{ {
base.Reset(); base.Reset();
Add(new Details Details details;
Add(details = new Details
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(150),
Beatmap = new BeatmapInfo Beatmap = new BeatmapInfo
{ {
Version = "VisualTest", Version = "VisualTest",
@ -40,11 +43,11 @@ namespace osu.Desktop.VisualTests.Tests
}, },
StarDifficulty = 5.3f, 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));
} }
} }
} }

View File

@ -13,6 +13,7 @@ using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -33,6 +34,8 @@ namespace osu.Game.Screens.Select
private SpriteText positiveRatings; private SpriteText positiveRatings;
private FillFlowContainer<DetailsBar> ratingsGraph; private FillFlowContainer<DetailsBar> ratingsGraph;
private FillFlowContainer<RetryAndFailBar> retryAndFailGraph;
private BeatmapInfo beatmap; private BeatmapInfo beatmap;
public BeatmapInfo Beatmap public BeatmapInfo Beatmap
{ {
@ -91,7 +94,53 @@ 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() public Details()
{ {
@ -280,7 +329,7 @@ namespace osu.Game.Screens.Select
Text = "Rating Spread", Text = "Rating Spread",
TextSize = 14, TextSize = 14,
Font = @"Exo2.0-Medium", Font = @"Exo2.0-Medium",
Anchor = Anchor.BottomCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
}, },
ratingsGraph = new FillFlowContainer<DetailsBar> ratingsGraph = new FillFlowContainer<DetailsBar>
@ -288,13 +337,40 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Height = 50, 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; source.Colour = colour.GrayB;
tags.Colour = colour.YellowLight; tags.Colour = colour.YellowLight;
stars.BarColour = colour.YellowLight; stars.BarColour = colour.Yellow;
ratingsBar.BackgroundColour = colour.Green; ratingsBar.BackgroundColour = colour.Green;
ratingsBar.BarColour = colour.YellowDark; ratingsBar.BarColour = colour.YellowDark;
ratingsGraph.Colour = colour.BlueDark; ratingsGraph.Colour = colour.BlueDark;
} }
@ -407,5 +482,63 @@ namespace osu.Game.Screens.Select
valueText.Colour = colour.GrayB; 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;
}
}
} }
} }

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using System;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -14,7 +15,7 @@ namespace osu.Game.Screens.Select
private Box background; private Box background;
private Box bar; private Box bar;
private const int resizeDuration = 250; private const int resize_duration = 250;
private float length; private float length;
public float Length public float Length
@ -89,11 +90,11 @@ namespace osu.Game.Screens.Select
{ {
case BarDirection.LeftToRight: case BarDirection.LeftToRight:
case BarDirection.RightToLeft: case BarDirection.RightToLeft:
bar.ResizeTo(new Vector2(length, 1), resizeDuration); bar.ResizeTo(new Vector2(length, 1), resize_duration);
break; break;
case BarDirection.TopToBottom: case BarDirection.TopToBottom:
case BarDirection.BottomToTop: case BarDirection.BottomToTop:
bar.ResizeTo(new Vector2(1, length), resizeDuration); bar.ResizeTo(new Vector2(1, length), resize_duration);
break; break;
} }