1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 09:22:54 +08:00

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
using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Catch.UI;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
@ -18,6 +19,8 @@ namespace osu.Game.Modes.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 HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Mania.UI;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu;
@ -19,6 +20,8 @@ namespace osu.Game.Modes.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 HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

View File

@ -2,6 +2,9 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
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 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 ScoreProcessor CreateScoreProcessor(int hitObjectCount) => new OsuScoreProcessor(hitObjectCount);

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI;
@ -19,6 +20,8 @@ namespace osu.Game.Modes.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 HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using OpenTK.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
@ -16,6 +17,14 @@ namespace osu.Game.Beatmaps
public List<HitObject> HitObjects { get; set; }
public List<ControlPoint> ControlPoints { 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)
{

View File

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

View File

@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Input;
using osu.Game.Modes;
namespace osu.Game.Beatmaps.Drawables
{
@ -83,7 +84,7 @@ namespace osu.Game.Beatmaps.Drawables
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255))
new DifficultyIcon(beatmap)
{
Scale = new Vector2(1.8f),
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
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
@ -23,6 +24,7 @@ namespace osu.Game.Beatmaps.Drawables
private OsuConfigManager config;
private Bindable<bool> preferUnicode;
private WorkingBeatmap beatmap;
private FlowContainer difficultyIcons;
public BeatmapSetHeader(WorkingBeatmap beatmap)
{
@ -56,15 +58,10 @@ namespace osu.Game.Beatmaps.Drawables
TextSize = 17,
Shadow = true,
},
new FlowContainer
difficultyIcons = new FlowContainer
{
Margin = new MarginPadding { Top = 5 },
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>.
//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.Colour;
using osu.Framework.Graphics.Containers;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Modes;
using OpenTK;
using OpenTK.Graphics;
@ -11,20 +16,76 @@ namespace osu.Game.Beatmaps.Drawables
{
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;
Size = new Vector2(size);
Children = new[]
}
[BackgroundDependencyLoader]
private void load(OsuColour palette)
{
this.palette = palette;
Children = new[]
{
new TextAwesome
{
Anchor = Anchor.Centre,
TextSize = size,
Colour = color,
Icon = icon
TextSize = Size.X,
Colour = getColour(beatmap),
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
public string Version { get; set; }
public float StarDifficulty => BaseDifficulty?.OverallDifficulty ?? 5; //todo: implement properly
public bool Equals(BeatmapInfo other)
{
return ID == other?.ID;

View File

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using OpenTK.Graphics;
using osu.Framework.Graphics.Colour;
@ -17,11 +18,23 @@ namespace osu.Game.Graphics
private static Color4 FromHex(string hex)
{
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);
switch (hex.Length)
{
default:
throw new Exception(@"Invalid hex string length!");
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
@ -56,6 +69,23 @@ namespace osu.Game.Graphics
public Color4 GreenDark = FromHex(@"668800");
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");
}
}

View File

@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface
private const double transform_time = 600;
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_RETRACTED = new Vector2(100, 50);

View File

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

View File

@ -3,7 +3,6 @@
using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Modes;
using OpenTK.Graphics;
@ -20,7 +19,7 @@ namespace osu.Game.Overlays.Toolbar
mode = value;
TooltipMain = 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()
{
base.LoadComplete();

View File

@ -2,6 +2,7 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework;
using osu.Framework.Allocation;
using OpenTK;
@ -14,7 +15,12 @@ using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Framework.Graphics.Colour;
using osu.Game.Beatmaps.Drawables;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Modes;
namespace osu.Game.Screens.Select
{
@ -24,7 +30,7 @@ namespace osu.Game.Screens.Select
private Container beatmapInfoContainer;
private BaseGame game;
private OsuGameBase game;
public BeatmapInfoWedge()
{
@ -42,7 +48,7 @@ namespace osu.Game.Screens.Select
}
[BackgroundDependencyLoader]
private void load(BaseGame game)
private void load(OsuGameBase game)
{
this.game = game;
}
@ -59,6 +65,28 @@ namespace osu.Game.Screens.Select
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
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
{
Depth = newDepth,
@ -99,9 +127,9 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
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,
Children = new[]
Children = new Drawable[]
{
new SpriteText
{
@ -139,11 +167,18 @@ namespace osu.Game.Screens.Select
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);
@ -153,5 +188,47 @@ namespace osu.Game.Screens.Select
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;
});
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);