Merge remote-tracking branch 'origin/master' into i-beatmap

This commit is contained in:
smoogipoo
2018-05-07 09:58:53 +09:00
96 changed files with 1002 additions and 428 deletions

View File

@ -16,11 +16,22 @@ namespace osu.Game.Screens.Select.Carousel
protected List<CarouselItem> InternalChildren = new List<CarouselItem>();
/// <summary>
/// Used to assign a monotonically increasing ID to children as they are added. This member is
/// incremented whenever a child is added.
/// </summary>
private ulong currentChildID;
public override List<DrawableCarouselItem> Drawables
{
get
{
var drawables = base.Drawables;
// if we are explicitly not present, don't ever present children.
// without this check, children drawables can potentially be presented without their group header.
if (DrawableRepresentation.Value?.IsPresent == false) return drawables;
foreach (var c in InternalChildren)
drawables.AddRange(c.Drawables);
return drawables;
@ -39,6 +50,7 @@ namespace osu.Game.Screens.Select.Carousel
public virtual void AddChild(CarouselItem i)
{
i.State.ValueChanged += v => ChildItemStateChanged(i, v);
i.ChildID = ++currentChildID;
InternalChildren.Add(i);
}

View File

@ -24,16 +24,18 @@ namespace osu.Game.Screens.Select.Carousel
{
var items = new List<DrawableCarouselItem>();
var self = drawableRepresentation.Value;
var self = DrawableRepresentation.Value;
if (self?.IsPresent == true) items.Add(self);
return items;
}
}
private int creationOrder;
protected CarouselItem()
{
drawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
DrawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
Filtered.ValueChanged += v =>
{
@ -42,15 +44,23 @@ namespace osu.Game.Screens.Select.Carousel
};
}
private readonly Lazy<DrawableCarouselItem> drawableRepresentation;
protected readonly Lazy<DrawableCarouselItem> DrawableRepresentation;
/// <summary>
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
/// </summary>
internal ulong ChildID;
/// <summary>
/// Create a fresh drawable version of this item. If you wish to consume the current representation, use <see cref="DrawableRepresentation"/> instead.
/// </summary>
protected abstract DrawableCarouselItem CreateDrawableRepresentation();
public virtual void Filter(FilterCriteria criteria)
{
}
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => GetHashCode().CompareTo(other.GetHashCode());
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ChildID.CompareTo(other.ChildID);
}
public enum CarouselItemState

View File

@ -17,6 +17,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using OpenTK;
using OpenTK.Graphics;
@ -35,6 +36,8 @@ namespace osu.Game.Screens.Select.Carousel
private Triangles triangles;
private StarCounter starCounter;
private BeatmapSetOverlay beatmapOverlay;
public DrawableCarouselBeatmap(CarouselBeatmap panel) : base(panel)
{
beatmap = panel.Beatmap;
@ -42,8 +45,10 @@ namespace osu.Game.Screens.Select.Carousel
}
[BackgroundDependencyLoader(true)]
private void load(SongSelect songSelect, BeatmapManager manager)
private void load(SongSelect songSelect, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
{
this.beatmapOverlay = beatmapOverlay;
if (songSelect != null)
{
startRequested = songSelect.FinaliseSelection;
@ -171,6 +176,10 @@ namespace osu.Game.Screens.Select.Carousel
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)),
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
new OsuMenuItem("Details", MenuItemType.Standard, () =>
{
if (beatmap.OnlineBeatmapID.HasValue) beatmapOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value);
}),
};
}
}

View File

@ -46,7 +46,7 @@ namespace osu.Game.Screens.Select.Carousel
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
dialogOverlay = overlay;
if (beatmapOverlay != null)
viewDetails = beatmapOverlay.ShowBeatmapSet;
viewDetails = beatmapOverlay.FetchAndShowBeatmapSet;
Children = new Drawable[]
{

View File

@ -40,10 +40,10 @@ namespace osu.Game.Screens.Select.Details
firstValue.Value = Beatmap?.BaseDifficulty?.CircleSize ?? 0;
}
hpDrain.Value = beatmap.BaseDifficulty?.DrainRate ?? 0;
accuracy.Value = beatmap.BaseDifficulty?.OverallDifficulty ?? 0;
approachRate.Value = beatmap.BaseDifficulty?.ApproachRate ?? 0;
starDifficulty.Value = (float)beatmap.StarDifficulty;
hpDrain.Value = Beatmap?.BaseDifficulty?.DrainRate ?? 0;
accuracy.Value = Beatmap?.BaseDifficulty?.OverallDifficulty ?? 0;
approachRate.Value = Beatmap?.BaseDifficulty?.ApproachRate ?? 0;
starDifficulty.Value = (float)(Beatmap?.StarDifficulty ?? 0);
}
}

View File

@ -25,10 +25,10 @@ namespace osu.Game.Screens.Select.Details
if (value == metrics) return;
metrics = value;
var retries = Metrics.Retries;
var fails = Metrics.Fails;
var retries = Metrics?.Retries ?? new int[0];
var fails = Metrics?.Fails ?? new int[0];
float maxValue = fails.Zip(retries, (fail, retry) => fail + retry).Max();
float maxValue = fails.Any() ? fails.Zip(retries, (fail, retry) => fail + retry).Max() : 0;
failGraph.MaxValue = maxValue;
retryGraph.MaxValue = maxValue;

View File

@ -21,6 +21,7 @@ namespace osu.Game.Screens.Select.Details
private readonly BarGraph graph;
private BeatmapMetrics metrics;
public BeatmapMetrics Metrics
{
get { return metrics; }
@ -31,15 +32,25 @@ namespace osu.Game.Screens.Select.Details
const int rating_range = 10;
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
if (metrics == null)
{
negativeRatings.Text = "0";
positiveRatings.Text = "0";
ratingsBar.Length = 0;
graph.Values = new float[rating_range];
}
else
{
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
var negativeCount = ratings.Take(rating_range / 2).Sum();
var totalCount = ratings.Sum();
var negativeCount = ratings.Take(rating_range / 2).Sum();
var totalCount = ratings.Sum();
negativeRatings.Text = negativeCount.ToString();
positiveRatings.Text = (totalCount - negativeCount).ToString();
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
graph.Values = ratings.Take(rating_range).Select(r => (float)r);
negativeRatings.Text = negativeCount.ToString();
positiveRatings.Text = (totalCount - negativeCount).ToString();
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
graph.Values = ratings.Take(rating_range).Select(r => (float)r);
}
}
}