2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
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;
|
2019-12-12 23:41:46 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select.Details
|
|
|
|
|
{
|
|
|
|
|
public class AdvancedStats : Container
|
|
|
|
|
{
|
2019-12-12 23:41:46 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty;
|
|
|
|
|
|
|
|
|
|
private BeatmapInfo beatmap;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public BeatmapInfo Beatmap
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => beatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmap) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
beatmap = value;
|
|
|
|
|
|
2019-12-12 23:41:46 +08:00
|
|
|
|
updateStatistics();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AdvancedStats()
|
|
|
|
|
{
|
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Spacing = new Vector2(4f),
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
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" },
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-12-13 09:39:54 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
starDifficulty.AccentColour = colours.Yellow;
|
2019-12-12 23:41:46 +08:00
|
|
|
|
mods.ValueChanged += _ => updateStatistics();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateStatistics()
|
|
|
|
|
{
|
2019-12-18 16:00:35 +08:00
|
|
|
|
var baseDifficulty = Beatmap?.BaseDifficulty;
|
|
|
|
|
var adjustedDifficulty = baseDifficulty;
|
2019-12-12 23:41:46 +08:00
|
|
|
|
|
2019-12-18 16:00:35 +08:00
|
|
|
|
if (baseDifficulty != null && mods.Value.Any(m => m is IApplicableToDifficulty))
|
2019-12-12 23:41:46 +08:00
|
|
|
|
{
|
2019-12-18 16:00:35 +08:00
|
|
|
|
adjustedDifficulty = adjustedDifficulty?.Clone();
|
2019-12-12 23:41:46 +08:00
|
|
|
|
|
|
|
|
|
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
|
2019-12-18 16:00:35 +08:00
|
|
|
|
mod.ApplyToDifficulty(adjustedDifficulty);
|
2019-12-12 23:41:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mania specific
|
2019-12-18 16:00:35 +08:00
|
|
|
|
if ((Beatmap?.Ruleset?.ID ?? 0) == 3)
|
2019-12-12 23:41:46 +08:00
|
|
|
|
{
|
|
|
|
|
firstValue.Title = "Key Amount";
|
2019-12-13 09:39:54 +08:00
|
|
|
|
firstValue.BaseValue = (int)MathF.Round(baseDifficulty?.CircleSize ?? 0);
|
2019-12-18 16:00:35 +08:00
|
|
|
|
firstValue.ModdedValue = (int)MathF.Round(adjustedDifficulty?.CircleSize ?? 0);
|
2019-12-12 23:41:46 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
firstValue.Title = "Circle Size";
|
2019-12-13 09:39:54 +08:00
|
|
|
|
firstValue.BaseValue = baseDifficulty?.CircleSize ?? 0;
|
2019-12-18 16:00:35 +08:00
|
|
|
|
firstValue.ModdedValue = adjustedDifficulty?.CircleSize ?? 0;
|
2019-12-12 23:41:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-13 09:39:54 +08:00
|
|
|
|
hpDrain.BaseValue = baseDifficulty?.DrainRate ?? 0;
|
|
|
|
|
accuracy.BaseValue = baseDifficulty?.OverallDifficulty ?? 0;
|
|
|
|
|
approachRate.BaseValue = baseDifficulty?.ApproachRate ?? 0;
|
2019-12-18 16:00:35 +08:00
|
|
|
|
starDifficulty.BaseValue = (float)(Beatmap?.StarDifficulty ?? 0);
|
2019-12-13 09:39:54 +08:00
|
|
|
|
|
2019-12-18 16:00:35 +08:00
|
|
|
|
hpDrain.ModdedValue = adjustedDifficulty?.DrainRate ?? 0;
|
|
|
|
|
accuracy.ModdedValue = adjustedDifficulty?.OverallDifficulty ?? 0;
|
|
|
|
|
approachRate.ModdedValue = adjustedDifficulty?.ApproachRate ?? 0;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class StatisticRow : Container, IHasAccentColour
|
|
|
|
|
{
|
|
|
|
|
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;
|
2019-12-13 09:39:54 +08:00
|
|
|
|
private readonly Bar bar, modBar;
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => name.Text;
|
|
|
|
|
set => name.Text = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-13 09:39:54 +08:00
|
|
|
|
private float baseValue;
|
|
|
|
|
|
|
|
|
|
private float moddedValue;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2019-12-13 09:39:54 +08:00
|
|
|
|
public float BaseValue
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-12-13 09:39:54 +08:00
|
|
|
|
get => baseValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2019-12-13 09:39:54 +08:00
|
|
|
|
baseValue = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
bar.Length = value / maxValue;
|
|
|
|
|
this.value.Text = value.ToString(forceDecimalPlaces ? "0.00" : "0.##");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-13 09:39:54 +08:00
|
|
|
|
public float ModdedValue
|
|
|
|
|
{
|
|
|
|
|
get => moddedValue;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
moddedValue = value;
|
|
|
|
|
modBar.Length = value / maxValue;
|
|
|
|
|
this.value.Text = value.ToString(forceDecimalPlaces ? "0.00" : "0.##");
|
|
|
|
|
|
|
|
|
|
if (moddedValue > baseValue)
|
|
|
|
|
modBar.AccentColour = this.value.Colour = colours.Red;
|
|
|
|
|
else if (moddedValue < baseValue)
|
|
|
|
|
modBar.AccentColour = this.value.Colour = colours.BlueDark;
|
|
|
|
|
else
|
|
|
|
|
modBar.AccentColour = this.value.Colour = Color4.White;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => bar.AccentColour;
|
|
|
|
|
set => bar.AccentColour = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StatisticRow(float maxValue = 10, bool forceDecimalPlaces = false)
|
|
|
|
|
{
|
|
|
|
|
this.maxValue = maxValue;
|
|
|
|
|
this.forceDecimalPlaces = forceDecimalPlaces;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Width = name_width,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Child = name = new OsuSpriteText
|
|
|
|
|
{
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 13)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
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 },
|
|
|
|
|
},
|
2019-12-13 09:39:54 +08:00
|
|
|
|
modBar = new Bar
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Alpha = 0.5f,
|
|
|
|
|
Height = 5,
|
|
|
|
|
Padding = new MarginPadding { Left = name_width + 10, Right = value_width + 10 },
|
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Width = value_width,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Child = value = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 13)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|