mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 22:27:25 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into accuracy-bar
This commit is contained in:
commit
f70a7abea3
@ -129,6 +129,23 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public List<ScoreInfo> Scores { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DifficultyRating DifficultyRating
|
||||
{
|
||||
get
|
||||
{
|
||||
var rating = StarDifficulty;
|
||||
|
||||
if (rating < 2.0) return DifficultyRating.Easy;
|
||||
if (rating < 2.7) return DifficultyRating.Normal;
|
||||
if (rating < 4.0) return DifficultyRating.Hard;
|
||||
if (rating < 5.3) return DifficultyRating.Insane;
|
||||
if (rating < 6.5) return DifficultyRating.Expert;
|
||||
|
||||
return DifficultyRating.ExpertPlus;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => $"{Metadata} [{Version}]".Trim();
|
||||
|
||||
public bool Equals(BeatmapInfo other)
|
||||
|
15
osu.Game/Beatmaps/DifficultyRating.cs
Normal file
15
osu.Game/Beatmaps/DifficultyRating.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public enum DifficultyRating
|
||||
{
|
||||
Easy,
|
||||
Normal,
|
||||
Hard,
|
||||
Insane,
|
||||
Expert,
|
||||
ExpertPlus
|
||||
}
|
||||
}
|
@ -1,85 +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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
public abstract class DifficultyColouredContainer : Container, IHasAccentColour
|
||||
{
|
||||
public Color4 AccentColour { get; set; }
|
||||
|
||||
private readonly BeatmapInfo beatmap;
|
||||
private OsuColour palette;
|
||||
|
||||
protected DifficultyColouredContainer(BeatmapInfo beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour palette)
|
||||
{
|
||||
if (palette == null)
|
||||
throw new ArgumentNullException(nameof(palette));
|
||||
|
||||
this.palette = palette;
|
||||
AccentColour = getColour(beatmap);
|
||||
}
|
||||
|
||||
private enum DifficultyRating
|
||||
{
|
||||
Easy,
|
||||
Normal,
|
||||
Hard,
|
||||
Insane,
|
||||
Expert,
|
||||
ExpertPlus
|
||||
}
|
||||
|
||||
private DifficultyRating getDifficultyRating(BeatmapInfo beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
var rating = beatmap.StarDifficulty;
|
||||
|
||||
if (rating < 2.0) return DifficultyRating.Easy;
|
||||
if (rating < 2.7) return DifficultyRating.Normal;
|
||||
if (rating < 4.0) return DifficultyRating.Hard;
|
||||
if (rating < 5.3) return DifficultyRating.Insane;
|
||||
if (rating < 6.5) return DifficultyRating.Expert;
|
||||
|
||||
return DifficultyRating.ExpertPlus;
|
||||
}
|
||||
|
||||
private Color4 getColour(BeatmapInfo beatmap)
|
||||
{
|
||||
switch (getDifficultyRating(beatmap))
|
||||
{
|
||||
case DifficultyRating.Easy:
|
||||
return palette.Green;
|
||||
|
||||
default:
|
||||
case DifficultyRating.Normal:
|
||||
return palette.Blue;
|
||||
|
||||
case DifficultyRating.Hard:
|
||||
return palette.Yellow;
|
||||
|
||||
case DifficultyRating.Insane:
|
||||
return palette.Pink;
|
||||
|
||||
case DifficultyRating.Expert:
|
||||
return palette.Purple;
|
||||
|
||||
case DifficultyRating.ExpertPlus:
|
||||
return palette.Gray0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
@ -6,33 +6,46 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
public class DifficultyIcon : DifficultyColouredContainer
|
||||
public class DifficultyIcon : Container, IHasCustomTooltip
|
||||
{
|
||||
private readonly BeatmapInfo beatmap;
|
||||
private readonly RulesetInfo ruleset;
|
||||
|
||||
public DifficultyIcon(BeatmapInfo beatmap, RulesetInfo ruleset = null)
|
||||
: base(beatmap)
|
||||
public DifficultyIcon(BeatmapInfo beatmap, RulesetInfo ruleset = null, bool shouldShowTooltip = true)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
this.beatmap = beatmap;
|
||||
|
||||
this.ruleset = ruleset ?? beatmap.Ruleset;
|
||||
if (shouldShowTooltip)
|
||||
TooltipContent = beatmap;
|
||||
|
||||
Size = new Vector2(20);
|
||||
}
|
||||
|
||||
public string TooltipText { get; set; }
|
||||
|
||||
public ITooltip GetCustomTooltip() => new DifficultyIconTooltip();
|
||||
|
||||
public object TooltipContent { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -52,7 +65,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = AccentColour,
|
||||
Colour = colours.ForDifficultyRating(beatmap.DifficultyRating),
|
||||
},
|
||||
},
|
||||
new ConstrainedIconContainer
|
||||
@ -65,5 +78,105 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class DifficultyIconTooltip : VisibilityContainer, ITooltip
|
||||
{
|
||||
private readonly OsuSpriteText difficultyName, starRating;
|
||||
private readonly Box background;
|
||||
|
||||
private readonly FillFlowContainer difficultyFlow;
|
||||
|
||||
public string TooltipText
|
||||
{
|
||||
set { }
|
||||
}
|
||||
|
||||
public DifficultyIconTooltip()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
AutoSizeDuration = 200,
|
||||
AutoSizeEasing = Easing.OutQuint,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
difficultyName = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold),
|
||||
},
|
||||
difficultyFlow = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
starRating = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Left = 4 },
|
||||
Icon = FontAwesome.Solid.Star,
|
||||
Size = new Vector2(12),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private OsuColour colours;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
this.colours = colours;
|
||||
background.Colour = colours.Gray3;
|
||||
}
|
||||
|
||||
public bool SetContent(object content)
|
||||
{
|
||||
if (!(content is BeatmapInfo beatmap))
|
||||
return false;
|
||||
|
||||
difficultyName.Text = beatmap.Version;
|
||||
starRating.Text = $"{beatmap.StarDifficulty:0.##}";
|
||||
difficultyFlow.Colour = colours.ForDifficultyRating(beatmap.DifficultyRating);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
}
|
||||
|
||||
public void Move(Vector2 pos) => Position = pos;
|
||||
|
||||
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
||||
|
||||
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,22 +30,24 @@ namespace osu.Game.Graphics.Cursor
|
||||
private readonly OsuSpriteText text;
|
||||
private bool instantMovement = true;
|
||||
|
||||
public override string TooltipText
|
||||
public override bool SetContent(object content)
|
||||
{
|
||||
set
|
||||
if (!(content is string contentString))
|
||||
return false;
|
||||
|
||||
if (contentString == text.Text) return true;
|
||||
|
||||
text.Text = contentString;
|
||||
|
||||
if (IsPresent)
|
||||
{
|
||||
if (value == text.Text) return;
|
||||
|
||||
text.Text = value;
|
||||
|
||||
if (IsPresent)
|
||||
{
|
||||
AutoSizeDuration = 250;
|
||||
background.FlashColour(OsuColour.Gray(0.4f), 1000, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
AutoSizeDuration = 0;
|
||||
AutoSizeDuration = 250;
|
||||
background.FlashColour(OsuColour.Gray(0.4f), 1000, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
AutoSizeDuration = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public OsuTooltip()
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Game.Beatmaps;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics
|
||||
@ -37,6 +38,31 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
public Color4 ForDifficultyRating(DifficultyRating difficulty)
|
||||
{
|
||||
switch (difficulty)
|
||||
{
|
||||
case DifficultyRating.Easy:
|
||||
return Green;
|
||||
|
||||
default:
|
||||
case DifficultyRating.Normal:
|
||||
return Blue;
|
||||
|
||||
case DifficultyRating.Hard:
|
||||
return Yellow;
|
||||
|
||||
case DifficultyRating.Insane:
|
||||
return Pink;
|
||||
|
||||
case DifficultyRating.Expert:
|
||||
return Purple;
|
||||
|
||||
case DifficultyRating.ExpertPlus:
|
||||
return Gray0;
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
|
||||
public readonly Color4 PurpleLighter = FromHex(@"eeeeff");
|
||||
public readonly Color4 PurpleLight = FromHex(@"aa88ff");
|
||||
|
@ -122,6 +122,7 @@ namespace osu.Game.Online.Chat
|
||||
return new LinkDetails(LinkAction.OpenBeatmapSet, args[3]);
|
||||
|
||||
case "u":
|
||||
case "users":
|
||||
return new LinkDetails(LinkAction.OpenUserProfile, args[3]);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Colour = Color4.Black.Opacity(0.5f),
|
||||
},
|
||||
},
|
||||
icon = new DifficultyIcon(beatmap)
|
||||
icon = new DifficultyIcon(beatmap, shouldShowTooltip: false)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -92,6 +92,15 @@ namespace osu.Game.Overlays
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start playing the current track (if not already playing).
|
||||
/// </summary>
|
||||
public void Play()
|
||||
{
|
||||
if (!IsPlaying)
|
||||
TogglePause();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle pause / play.
|
||||
/// </summary>
|
||||
|
@ -46,8 +46,11 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
if (!s.OnlineBeatmapSetID.HasValue)
|
||||
continue;
|
||||
|
||||
var panel = new DirectGridPanel(s.ToBeatmapSet(Rulesets));
|
||||
ItemsContainer.Add(panel);
|
||||
ItemsContainer.Add(new DirectGridPanel(s.ToBeatmapSet(Rulesets))
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -402,31 +402,35 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private class DifficultyColourBar : DifficultyColouredContainer
|
||||
private class DifficultyColourBar : Container
|
||||
{
|
||||
private readonly BeatmapInfo beatmap;
|
||||
|
||||
public DifficultyColourBar(BeatmapInfo beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
const float full_opacity_ratio = 0.7f;
|
||||
|
||||
var difficultyColour = colours.ForDifficultyRating(beatmap.DifficultyRating);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = AccentColour,
|
||||
Colour = difficultyColour,
|
||||
Width = full_opacity_ratio,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Colour = AccentColour,
|
||||
Colour = difficultyColour,
|
||||
Alpha = 0.5f,
|
||||
X = full_opacity_ratio,
|
||||
Width = 1 - full_opacity_ratio,
|
||||
|
@ -82,7 +82,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
Origin = Anchor.CentreLeft,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DifficultyIcon(beatmap)
|
||||
new DifficultyIcon(beatmap, shouldShowTooltip: false)
|
||||
{
|
||||
Scale = new Vector2(1.8f),
|
||||
},
|
||||
|
@ -359,6 +359,7 @@ namespace osu.Game.Screens.Select
|
||||
return;
|
||||
|
||||
beatmapNoDebounce = beatmap;
|
||||
|
||||
performUpdateSelected();
|
||||
}
|
||||
|
||||
@ -586,10 +587,18 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
Track track = Beatmap.Value.Track;
|
||||
|
||||
if ((!track.IsRunning || restart) && music?.IsUserPaused != true)
|
||||
if (!track.IsRunning || restart)
|
||||
{
|
||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
track.Restart();
|
||||
|
||||
if (music != null)
|
||||
{
|
||||
// use the global music controller (when available) to cancel a potential local user paused state.
|
||||
music.SeekTo(track.RestartPoint);
|
||||
music.Play();
|
||||
}
|
||||
else
|
||||
track.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user