Merge branch 'master' into fix-music-controller-regressed

This commit is contained in:
Dean Herbert 2020-09-04 20:10:43 +09:00 committed by GitHub
commit b8e5acfef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 72 additions and 43 deletions

View File

@ -22,19 +22,19 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
{ {
Name = @"Fruit Count", Name = @"Fruit Count",
Content = fruits.ToString(), Content = fruits.ToString(),
CreateIcon = () => new BeatmapStatisticSprite("circles"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Juice Stream Count", Name = @"Juice Stream Count",
Content = juiceStreams.ToString(), Content = juiceStreams.ToString(),
CreateIcon = () => new BeatmapStatisticSprite("sliders"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Banana Shower Count", Name = @"Banana Shower Count",
Content = bananaShowers.ToString(), Content = bananaShowers.ToString(),
CreateIcon = () => new BeatmapStatisticSprite("spinners"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners),
} }
}; };
} }

View File

@ -40,13 +40,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Note Count", Name = @"Note Count",
CreateIcon = () => new BeatmapStatisticSprite("circles"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
Content = notes.ToString(), Content = notes.ToString(),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Hold Note Count", Name = @"Hold Note Count",
CreateIcon = () => new BeatmapStatisticSprite("sliders"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
Content = holdnotes.ToString(), Content = holdnotes.ToString(),
}, },
}; };

View File

@ -22,19 +22,19 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
{ {
Name = @"Circle Count", Name = @"Circle Count",
Content = circles.ToString(), Content = circles.ToString(),
CreateIcon = () => new BeatmapStatisticSprite("circles"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Slider Count", Name = @"Slider Count",
Content = sliders.ToString(), Content = sliders.ToString(),
CreateIcon = () => new BeatmapStatisticSprite("sliders"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Spinner Count", Name = @"Spinner Count",
Content = spinners.ToString(), Content = spinners.ToString(),
CreateIcon = () => new BeatmapStatisticSprite("spinners"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners),
} }
}; };
} }

View File

@ -21,19 +21,19 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Hit Count", Name = @"Hit Count",
CreateIcon = () => new BeatmapStatisticSprite("circles"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles),
Content = hits.ToString(), Content = hits.ToString(),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Drumroll Count", Name = @"Drumroll Count",
CreateIcon = () => new BeatmapStatisticSprite("sliders"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders),
Content = drumrolls.ToString(), Content = drumrolls.ToString(),
}, },
new BeatmapStatistic new BeatmapStatistic
{ {
Name = @"Swell Count", Name = @"Swell Count",
CreateIcon = () => new BeatmapStatisticSprite("spinners"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners),
Content = swells.ToString(), Content = swells.ToString(),
} }
}; };

View File

@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps
public IconUsage Icon = FontAwesome.Regular.QuestionCircle; public IconUsage Icon = FontAwesome.Regular.QuestionCircle;
/// <summary> /// <summary>
/// A function to create the icon for display purposes. /// A function to create the icon for display purposes. Use default icons available via <see cref="BeatmapStatisticIcon"/> whenever possible for conformity.
/// </summary> /// </summary>
public Func<Drawable> CreateIcon; public Func<Drawable> CreateIcon;

View File

@ -0,0 +1,43 @@
// 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.
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps
{
/// <summary>
/// A default implementation of an icon used to represent beatmap statistics.
/// </summary>
public class BeatmapStatisticIcon : Sprite
{
private readonly BeatmapStatisticsIconType iconType;
public BeatmapStatisticIcon(BeatmapStatisticsIconType iconType)
{
this.iconType = iconType;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get($"Icons/BeatmapDetails/{iconType.ToString().Kebaberize()}");
}
}
public enum BeatmapStatisticsIconType
{
Accuracy,
ApproachRate,
Bpm,
Circles,
HpDrain,
Length,
OverallDifficulty,
Size,
Sliders,
Spinners,
}
}

View File

@ -1,25 +0,0 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps
{
public class BeatmapStatisticSprite : Sprite
{
private readonly string iconName;
public BeatmapStatisticSprite(string iconName)
{
this.iconName = iconName;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get($"Icons/BeatmapDetails/{iconName}");
}
}
}

View File

@ -295,7 +295,8 @@ namespace osu.Game.Overlays
private void changeBeatmap(WorkingBeatmap newWorking) private void changeBeatmap(WorkingBeatmap newWorking)
{ {
// The provided beatmap is same as current, no need to do any changes. // This method can potentially be triggered multiple times as it is eagerly fired in next() / prev() to ensure correct execution order
// (changeBeatmap must be called before consumers receive the bindable changed event, which is not the case when the local beatmap bindable is updated directly).
if (newWorking == current) if (newWorking == current)
return; return;

View File

@ -1,12 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Overlays.Settings.Sections.Gameplay; using osu.Game.Overlays.Settings.Sections.Gameplay;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Logging;
namespace osu.Game.Overlays.Settings.Sections namespace osu.Game.Overlays.Settings.Sections
{ {
@ -34,9 +36,17 @@ namespace osu.Game.Overlays.Settings.Sections
{ {
foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance())) foreach (Ruleset ruleset in rulesets.AvailableRulesets.Select(info => info.CreateInstance()))
{ {
SettingsSubsection section = ruleset.CreateSettings(); try
if (section != null) {
Add(section); SettingsSubsection section = ruleset.CreateSettings();
if (section != null)
Add(section);
}
catch (Exception e)
{
Logger.Error(e, "Failed to load ruleset settings");
}
} }
} }
} }

View File

@ -318,14 +318,14 @@ namespace osu.Game.Screens.Select
labels.Add(new InfoLabel(new BeatmapStatistic labels.Add(new InfoLabel(new BeatmapStatistic
{ {
Name = "Length", Name = "Length",
CreateIcon = () => new BeatmapStatisticSprite("length"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length),
Content = TimeSpan.FromMilliseconds(b.BeatmapInfo.Length).ToString(@"m\:ss"), Content = TimeSpan.FromMilliseconds(b.BeatmapInfo.Length).ToString(@"m\:ss"),
})); }));
labels.Add(new InfoLabel(new BeatmapStatistic labels.Add(new InfoLabel(new BeatmapStatistic
{ {
Name = "BPM", Name = "BPM",
CreateIcon = () => new BeatmapStatisticSprite("bpm"), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Bpm),
Content = getBPMRange(b), Content = getBPMRange(b),
})); }));