2017-09-08 01:53:53 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select.Details
|
|
|
|
|
{
|
|
|
|
|
public class AdvancedStats : Container
|
|
|
|
|
{
|
2017-09-08 02:21:18 +08:00
|
|
|
|
private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty;
|
2017-09-08 01:53:53 +08:00
|
|
|
|
|
|
|
|
|
private BeatmapInfo beatmap;
|
|
|
|
|
public BeatmapInfo Beatmap
|
|
|
|
|
{
|
|
|
|
|
get { return beatmap; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmap) return;
|
|
|
|
|
beatmap = value;
|
|
|
|
|
|
|
|
|
|
//mania specific
|
2017-10-06 05:23:26 +08:00
|
|
|
|
if ((Beatmap?.Ruleset?.Id ?? 0) == 3)
|
2017-09-08 01:53:53 +08:00
|
|
|
|
{
|
|
|
|
|
firstValue.Title = "Key Amount";
|
2017-10-06 05:23:26 +08:00
|
|
|
|
firstValue.Value = (int)Math.Round(Beatmap?.Difficulty?.CircleSize ?? 0);
|
2017-09-08 01:53:53 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
firstValue.Title = "Circle Size";
|
2017-10-06 05:23:26 +08:00
|
|
|
|
firstValue.Value = Beatmap?.Difficulty?.CircleSize ?? 0;
|
2017-09-08 01:53:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 05:23:26 +08:00
|
|
|
|
hpDrain.Value = beatmap.Difficulty?.DrainRate ?? 0;
|
|
|
|
|
accuracy.Value = beatmap.Difficulty?.OverallDifficulty ?? 0;
|
|
|
|
|
approachRate.Value = beatmap.Difficulty?.ApproachRate ?? 0;
|
2017-09-08 01:53:53 +08:00
|
|
|
|
starDifficulty.Value = (float)beatmap.StarDifficulty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AdvancedStats()
|
|
|
|
|
{
|
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Spacing = new Vector2(4f),
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2017-09-08 02:21:18 +08:00
|
|
|
|
firstValue = new StatisticRow(), //circle size/key amount
|
|
|
|
|
hpDrain = new StatisticRow { Title = "HP Drain" },
|
|
|
|
|
accuracy = new StatisticRow { Title = "Accuracy" },
|
|
|
|
|
approachRate = new StatisticRow { Title = "Approach Rate" },
|
|
|
|
|
starDifficulty = new StatisticRow(10, true) { Title = "Star Difficulty" },
|
2017-09-08 01:53:53 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
starDifficulty.AccentColour = colours.Yellow;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 02:21:18 +08:00
|
|
|
|
private class StatisticRow : Container, IHasAccentColour
|
2017-09-08 01:53:53 +08:00
|
|
|
|
{
|
|
|
|
|
private const float value_width = 25;
|
|
|
|
|
private const float name_width = 70;
|
|
|
|
|
|
|
|
|
|
private readonly float maxValue;
|
|
|
|
|
private readonly bool forceDecimalPlaces;
|
|
|
|
|
private readonly OsuSpriteText name, value;
|
|
|
|
|
private readonly Bar bar;
|
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get { return name.Text; }
|
|
|
|
|
set { name.Text = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private float difficultyValue;
|
|
|
|
|
public float Value
|
|
|
|
|
{
|
|
|
|
|
get { return difficultyValue; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
difficultyValue = value;
|
|
|
|
|
bar.Length = value / maxValue;
|
2017-09-08 02:01:31 +08:00
|
|
|
|
this.value.Text = value.ToString(forceDecimalPlaces ? "0.00" : "0.##");
|
2017-09-08 01:53:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get { return bar.AccentColour; }
|
|
|
|
|
set { bar.AccentColour = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 02:21:18 +08:00
|
|
|
|
public StatisticRow(float maxValue = 10, bool forceDecimalPlaces = false)
|
2017-09-08 01:53:53 +08:00
|
|
|
|
{
|
|
|
|
|
this.maxValue = maxValue;
|
|
|
|
|
this.forceDecimalPlaces = forceDecimalPlaces;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Width = name_width,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-09-08 02:38:23 +08:00
|
|
|
|
Child = name = new OsuSpriteText
|
2017-09-08 01:53:53 +08:00
|
|
|
|
{
|
|
|
|
|
TextSize = 13,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
bar = new Bar
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 5,
|
|
|
|
|
BackgroundColour = Color4.White.Opacity(0.5f),
|
|
|
|
|
Padding = new MarginPadding { Left = name_width + 10, Right = value_width + 10 },
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Width = value_width,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Child = value = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
TextSize = 13,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|