Merge pull request #300 from peppy/more-beatmap-info

Beatmap details
This commit is contained in:
Dean Herbert 2017-01-30 16:23:30 +09:00 committed by GitHub
commit 578b33dc64
16 changed files with 316 additions and 103 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 System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
@ -18,6 +19,8 @@ namespace osu.Game.Modes.Catch
protected override PlayMode PlayMode => PlayMode.Catch; protected override PlayMode PlayMode => PlayMode.Catch;
public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o;
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

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 System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu; using osu.Game.Modes.Osu;
@ -19,6 +20,8 @@ namespace osu.Game.Modes.Mania
protected override PlayMode PlayMode => PlayMode.Mania; protected override PlayMode PlayMode => PlayMode.Mania;
public override FontAwesome Icon => FontAwesome.fa_osu_mania_o;
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

View File

@ -2,6 +2,9 @@
//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 System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Osu.UI;
@ -15,6 +18,24 @@ namespace osu.Game.Modes.Osu
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new OsuHitRenderer { Objects = objects }; public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new OsuHitRenderer { Objects = objects };
public override IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new[]
{
new BeatmapStatistic
{
Name = @"Circle count",
Content = beatmap.Beatmap.HitObjects.Count(h => h is HitCircle).ToString(),
Icon = FontAwesome.fa_dot_circle_o
},
new BeatmapStatistic
{
Name = @"Slider count",
Content = beatmap.Beatmap.HitObjects.Count(h => h is Slider).ToString(),
Icon = FontAwesome.fa_circle_o
}
};
public override FontAwesome Icon => FontAwesome.fa_osu_osu_o;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => new OsuScoreProcessor(hitObjectCount); public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => new OsuScoreProcessor(hitObjectCount);

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Osu.UI;
@ -19,6 +20,8 @@ namespace osu.Game.Modes.Taiko
protected override PlayMode PlayMode => PlayMode.Taiko; protected override PlayMode PlayMode => PlayMode.Taiko;
public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o;
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

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 System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Database; using osu.Game.Database;
@ -16,6 +17,14 @@ namespace osu.Game.Beatmaps
public List<HitObject> HitObjects { get; set; } public List<HitObject> HitObjects { get; set; }
public List<ControlPoint> ControlPoints { get; set; } public List<ControlPoint> ControlPoints { get; set; }
public List<Color4> ComboColors { get; set; } public List<Color4> ComboColors { get; set; }
public double BPMMaximum => 60000 / ControlPoints.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).First().BeatLength;
public double BPMMinimum => 60000 / ControlPoints.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).First().BeatLength;
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
public double BPMAt(double time)
{
return 60000 / BeatLengthAt(time);
}
public double BeatLengthAt(double time, bool applyMultipliers = false) public double BeatLengthAt(double time, bool applyMultipliers = false)
{ {

View File

@ -1,42 +1,42 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//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 System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework; using osu.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Transformations;
using osu.Game.Database; using osu.Game.Database;
namespace osu.Game.Beatmaps.Drawables namespace osu.Game.Beatmaps.Drawables
{ {
class BeatmapGroup : IStateful<BeatmapGroupState> class BeatmapGroup : IStateful<BeatmapGroupState>
{ {
public BeatmapPanel SelectedPanel; public BeatmapPanel SelectedPanel;
/// <summary> /// <summary>
/// Fires when one of our difficulties was selected. Will fire on first expand. /// Fires when one of our difficulties was selected. Will fire on first expand.
/// </summary> /// </summary>
public Action<BeatmapGroup, BeatmapInfo> SelectionChanged; public Action<BeatmapGroup, BeatmapInfo> SelectionChanged;
/// <summary> /// <summary>
/// Fires when one of our difficulties is clicked when already selected. Should start playing the map. /// Fires when one of our difficulties is clicked when already selected. Should start playing the map.
/// </summary> /// </summary>
public Action<BeatmapInfo> StartRequested; public Action<BeatmapInfo> StartRequested;
public BeatmapSetHeader Header; public BeatmapSetHeader Header;
private BeatmapGroupState state; private BeatmapGroupState state;
public List<BeatmapPanel> BeatmapPanels; public List<BeatmapPanel> BeatmapPanels;
public BeatmapGroupState State public BeatmapGroupState State
{ {
get { return state; } get { return state; }
set set
{ {
state = value; state = value;
switch (state) switch (state)
{ {
case BeatmapGroupState.Expanded: case BeatmapGroupState.Expanded:
@ -56,28 +56,30 @@ namespace osu.Game.Beatmaps.Drawables
panel.FadeOut(300, EasingTypes.OutQuint); panel.FadeOut(300, EasingTypes.OutQuint);
break; break;
} }
} }
} }
public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null) public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null)
{ {
Header = new BeatmapSetHeader(beatmap) Header = new BeatmapSetHeader(beatmap)
{ {
GainedSelection = headerGainedSelection, GainedSelection = headerGainedSelection,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}; };
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b) BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
{ {
Alpha = 0, Alpha = 0,
GainedSelection = panelGainedSelection, GainedSelection = panelGainedSelection,
StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, StartRequested = p => { StartRequested?.Invoke(p.Beatmap); },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}).ToList(); }).ToList();
Header.AddDifficultyIcons(BeatmapPanels);
} }
private void headerGainedSelection(BeatmapSetHeader panel) private void headerGainedSelection(BeatmapSetHeader panel)
{ {
State = BeatmapGroupState.Expanded; State = BeatmapGroupState.Expanded;
//we want to make sure one of our children is selected in the case none have been selected yet. //we want to make sure one of our children is selected in the case none have been selected yet.
@ -85,10 +87,10 @@ namespace osu.Game.Beatmaps.Drawables
BeatmapPanels.First().State = PanelSelectedState.Selected; BeatmapPanels.First().State = PanelSelectedState.Selected;
else else
SelectionChanged?.Invoke(this, SelectedPanel.Beatmap); SelectionChanged?.Invoke(this, SelectedPanel.Beatmap);
} }
private void panelGainedSelection(BeatmapPanel panel) private void panelGainedSelection(BeatmapPanel panel)
{ {
try try
{ {
if (SelectedPanel == panel) return; if (SelectedPanel == panel) return;
@ -96,18 +98,18 @@ namespace osu.Game.Beatmaps.Drawables
if (SelectedPanel != null) if (SelectedPanel != null)
SelectedPanel.State = PanelSelectedState.NotSelected; SelectedPanel.State = PanelSelectedState.NotSelected;
SelectedPanel = panel; SelectedPanel = panel;
} }
finally finally
{ {
State = BeatmapGroupState.Expanded; State = BeatmapGroupState.Expanded;
SelectionChanged?.Invoke(this, panel.Beatmap); SelectionChanged?.Invoke(this, panel.Beatmap);
} }
} }
} }
public enum BeatmapGroupState public enum BeatmapGroupState
{ {
Collapsed, Collapsed,
Expanded, Expanded,
} }
} }

View File

@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Modes;
namespace osu.Game.Beatmaps.Drawables namespace osu.Game.Beatmaps.Drawables
{ {
@ -83,7 +84,7 @@ namespace osu.Game.Beatmaps.Drawables
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Children = new Drawable[] Children = new Drawable[]
{ {
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)) new DifficultyIcon(beatmap)
{ {
Scale = new Vector2(1.8f), Scale = new Vector2(1.8f),
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
@ -130,7 +131,7 @@ namespace osu.Game.Beatmaps.Drawables
}, },
} }
}, },
new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 } new StarCounter { Count = beatmap.StarDifficulty, StarSize = 8 }
} }
} }
} }

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 System; using System;
using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -23,6 +24,7 @@ namespace osu.Game.Beatmaps.Drawables
private OsuConfigManager config; private OsuConfigManager config;
private Bindable<bool> preferUnicode; private Bindable<bool> preferUnicode;
private WorkingBeatmap beatmap; private WorkingBeatmap beatmap;
private FlowContainer difficultyIcons;
public BeatmapSetHeader(WorkingBeatmap beatmap) public BeatmapSetHeader(WorkingBeatmap beatmap)
{ {
@ -56,15 +58,10 @@ namespace osu.Game.Beatmaps.Drawables
TextSize = 17, TextSize = 17,
Shadow = true, Shadow = true,
}, },
new FlowContainer difficultyIcons = new FlowContainer
{ {
Margin = new MarginPadding { Top = 5 }, Margin = new MarginPadding { Top = 5 },
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new[]
{
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)),
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(246, 101, 166, 255)),
}
} }
} }
} }
@ -177,5 +174,11 @@ namespace osu.Game.Beatmaps.Drawables
}); });
} }
} }
public void AddDifficultyIcons(IEnumerable<BeatmapPanel> panels)
{
foreach (var p in panels)
difficultyIcons.Add(new DifficultyIcon(p.Beatmap));
}
} }
} }

View File

@ -1,9 +1,14 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//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 System;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -11,20 +16,76 @@ namespace osu.Game.Beatmaps.Drawables
{ {
class DifficultyIcon : Container class DifficultyIcon : Container
{ {
public DifficultyIcon(FontAwesome icon, Color4 color) private readonly BeatmapInfo beatmap;
private OsuColour palette;
public DifficultyIcon(BeatmapInfo beatmap)
{ {
this.beatmap = beatmap;
const float size = 20; const float size = 20;
Size = new Vector2(size); Size = new Vector2(size);
Children = new[] }
[BackgroundDependencyLoader]
private void load(OsuColour palette)
{
this.palette = palette;
Children = new[]
{ {
new TextAwesome new TextAwesome
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
TextSize = size, TextSize = Size.X,
Colour = color, Colour = getColour(beatmap),
Icon = icon Icon = FontAwesome.fa_circle
},
new TextAwesome
{
Anchor = Anchor.Centre,
TextSize = Size.X,
Colour = Color4.White,
Icon = Ruleset.GetRuleset(beatmap.Mode).Icon
} }
}; };
}
enum DifficultyRating
{
Easy,
Normal,
Hard,
Insane,
Expert
}
private DifficultyRating getDifficultyRating(BeatmapInfo beatmap)
{
var rating = beatmap.StarDifficulty;
if (rating < 1.5) return DifficultyRating.Easy;
if (rating < 2.25) return DifficultyRating.Normal;
if (rating < 3.75) return DifficultyRating.Hard;
if (rating < 5.25) return DifficultyRating.Insane;
return DifficultyRating.Expert;
}
private Color4 getColour(BeatmapInfo beatmap)
{
switch (getDifficultyRating(beatmap))
{
case DifficultyRating.Easy:
return palette.Green;
default:
case DifficultyRating.Normal:
return palette.Yellow;
case DifficultyRating.Hard:
return palette.Pink;
case DifficultyRating.Insane:
return palette.Purple;
case DifficultyRating.Expert:
return palette.Gray0;
}
} }
} }
} }

View File

@ -73,6 +73,8 @@ namespace osu.Game.Database
// Metadata // Metadata
public string Version { get; set; } public string Version { get; set; }
public float StarDifficulty => BaseDifficulty?.OverallDifficulty ?? 5; //todo: implement properly
public bool Equals(BeatmapInfo other) public bool Equals(BeatmapInfo other)
{ {
return ID == other?.ID; return ID == other?.ID;

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
@ -17,11 +18,23 @@ namespace osu.Game.Graphics
private static Color4 FromHex(string hex) private static Color4 FromHex(string hex)
{ {
return new Color4( switch (hex.Length)
Convert.ToByte(hex.Substring(0, 2), 16), {
Convert.ToByte(hex.Substring(2, 2), 16), default:
Convert.ToByte(hex.Substring(4, 2), 16), throw new Exception(@"Invalid hex string length!");
255); case 3:
return new Color4(
(byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17),
(byte)(Convert.ToByte(hex.Substring(1, 1), 16) * 17),
(byte)(Convert.ToByte(hex.Substring(2, 1), 16) * 17),
255);
case 6:
return new Color4(
Convert.ToByte(hex.Substring(0, 2), 16),
Convert.ToByte(hex.Substring(2, 2), 16),
Convert.ToByte(hex.Substring(4, 2), 16),
255);
}
} }
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
@ -56,6 +69,23 @@ namespace osu.Game.Graphics
public Color4 GreenDark = FromHex(@"668800"); public Color4 GreenDark = FromHex(@"668800");
public Color4 GreenDarker = FromHex(@"445500"); public Color4 GreenDarker = FromHex(@"445500");
public Color4 Gray0 = FromHex(@"000");
public Color4 Gray1 = FromHex(@"111");
public Color4 Gray2 = FromHex(@"222");
public Color4 Gray3 = FromHex(@"333");
public Color4 Gray4 = FromHex(@"444");
public Color4 Gray5 = FromHex(@"555");
public Color4 Gray6 = FromHex(@"666");
public Color4 Gray7 = FromHex(@"777");
public Color4 Gray8 = FromHex(@"888");
public Color4 Gray9 = FromHex(@"999");
public Color4 GrayA = FromHex(@"aaa");
public Color4 GrayB = FromHex(@"bbb");
public Color4 GrayC = FromHex(@"ccc");
public Color4 GrayD = FromHex(@"ddd");
public Color4 GrayE = FromHex(@"eee");
public Color4 GrayF = FromHex(@"fff");
public Color4 Red = FromHex(@"fc4549"); public Color4 Red = FromHex(@"fc4549");
} }
} }

View File

@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface
private const double transform_time = 600; private const double transform_time = 600;
private const int pulse_length = 250; private const int pulse_length = 250;
private const float shear = 0.1f; private const float shear = 0.15f;
public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50); public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50);
public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50); public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50);

View File

@ -4,20 +4,28 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using System.Reflection;
using osu.Framework.Extensions;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Linq; using osu.Game.Beatmaps;
using osu.Game.Graphics;
namespace osu.Game.Modes namespace osu.Game.Modes
{ {
public class BeatmapStatistic
{
public FontAwesome Icon;
public string Content;
public string Name;
}
public abstract class Ruleset public abstract class Ruleset
{ {
private static ConcurrentDictionary<PlayMode, Type> availableRulesets = new ConcurrentDictionary<PlayMode, Type>(); private static ConcurrentDictionary<PlayMode, Type> availableRulesets = new ConcurrentDictionary<PlayMode, Type>();
public abstract ScoreOverlay CreateScoreOverlay(); public abstract ScoreOverlay CreateScoreOverlay();
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount); public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount);
public abstract HitRenderer CreateHitRendererWith(List<HitObject> objects); public abstract HitRenderer CreateHitRendererWith(List<HitObject> objects);
@ -28,6 +36,8 @@ namespace osu.Game.Modes
protected abstract PlayMode PlayMode { get; } protected abstract PlayMode PlayMode { get; }
public virtual FontAwesome Icon => FontAwesome.fa_question_circle;
public static Ruleset GetRuleset(PlayMode mode) public static Ruleset GetRuleset(PlayMode mode)
{ {
Type type; Type type;

View File

@ -3,7 +3,6 @@
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Modes; using osu.Game.Modes;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -20,7 +19,7 @@ namespace osu.Game.Overlays.Toolbar
mode = value; mode = value;
TooltipMain = mode.GetDescription(); TooltipMain = mode.GetDescription();
TooltipSub = $"Play some {mode.GetDescription()}"; TooltipSub = $"Play some {mode.GetDescription()}";
Icon = getModeIcon(mode); Icon = Ruleset.GetRuleset(mode).Icon;
} }
} }
@ -48,17 +47,6 @@ namespace osu.Game.Overlays.Toolbar
} }
} }
private FontAwesome getModeIcon(PlayMode mode)
{
switch (mode)
{
default: return FontAwesome.fa_osu_osu_o;
case PlayMode.Taiko: return FontAwesome.fa_osu_taiko_o;
case PlayMode.Catch: return FontAwesome.fa_osu_fruits_o;
case PlayMode.Mania: return FontAwesome.fa_osu_mania_o;
}
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();

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 System; using System;
using System.Collections.Generic;
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using OpenTK; using OpenTK;
@ -14,7 +15,12 @@ using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.MathUtils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Modes;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -24,7 +30,7 @@ namespace osu.Game.Screens.Select
private Container beatmapInfoContainer; private Container beatmapInfoContainer;
private BaseGame game; private OsuGameBase game;
public BeatmapInfoWedge() public BeatmapInfoWedge()
{ {
@ -42,7 +48,7 @@ namespace osu.Game.Screens.Select
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(BaseGame game) private void load(OsuGameBase game)
{ {
this.game = game; this.game = game;
} }
@ -59,6 +65,28 @@ namespace osu.Game.Screens.Select
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo; BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo; BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
List<InfoLabel> labels = new List<InfoLabel>();
if (beatmap.Beatmap != null)
{
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "Length",
Icon = FontAwesome.fa_clock_o,
Content = TimeSpan.FromMilliseconds(beatmap.Beatmap.HitObjects.Last().EndTime - beatmap.Beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
}));
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "BPM",
Icon = FontAwesome.fa_circle,
Content = getBPMRange(beatmap.Beatmap),
}));
//get statistics fromt he current ruleset.
Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).ForEach(s => labels.Add(new InfoLabel(s)));
}
(beatmapInfoContainer = new BufferedContainer (beatmapInfoContainer = new BufferedContainer
{ {
Depth = newDepth, Depth = newDepth,
@ -99,9 +127,9 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Direction = FlowDirection.VerticalOnly, Direction = FlowDirection.VerticalOnly,
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 }, Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 20 },
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new[] Children = new Drawable[]
{ {
new SpriteText new SpriteText
{ {
@ -139,11 +167,18 @@ namespace osu.Game.Screens.Select
Shadow = true, Shadow = true,
}, },
} }
} },
new FlowContainer
{
Margin = new MarginPadding { Top = 20 },
Spacing = new Vector2(40,0),
AutoSizeAxes = Axes.Both,
Children = labels
},
} }
} },
} }
}).Preload(game, delegate(Drawable d) }).Preload(game, delegate (Drawable d)
{ {
FadeIn(250); FadeIn(250);
@ -153,5 +188,47 @@ namespace osu.Game.Screens.Select
Add(d); Add(d);
}); });
} }
private string getBPMRange(Beatmap beatmap)
{
double bpmMax = beatmap.BPMMaximum;
double bpmMin = beatmap.BPMMinimum;
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.BPMMode) + "bpm)";
}
public class InfoLabel : Container
{
public InfoLabel(BeatmapStatistic statistic)
{
AutoSizeAxes = Axes.Both;
Children = new[]
{
new TextAwesome
{
Icon = FontAwesome.fa_square,
Colour = new Color4(68, 17, 136, 255),
Rotation = 45
},
new TextAwesome
{
Icon = statistic.Icon,
Colour = new Color4(255, 221, 85, 255),
Scale = new Vector2(0.8f)
},
new SpriteText
{
Margin = new MarginPadding { Left = 13 },
Font = @"Exo2.0-Bold",
Colour = new Color4(255, 221, 85, 255),
Text = statistic.Content,
TextSize = 17,
Origin = Anchor.CentreLeft
},
};
}
}
} }
} }

View File

@ -310,7 +310,7 @@ namespace osu.Game.Screens.Select
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
}); });
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList(); beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database); var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);