mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Merge pull request #29108 from bdach/daily-challenge/better-breakdown
Improve score breakdown on daily challenge
This commit is contained in:
commit
4fa6a19409
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
||||||
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
||||||
@ -61,6 +62,8 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
|||||||
|
|
||||||
breakdown.AddNewScore(ev);
|
breakdown.AddNewScore(ev);
|
||||||
});
|
});
|
||||||
|
AddStep("set user score", () => breakdown.UserBestScore.Value = new MultiplayerScore { TotalScore = RNG.Next(1_000_000) });
|
||||||
|
AddStep("unset user score", () => breakdown.UserBestScore.Value = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,6 +333,8 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
}
|
}
|
||||||
|
|
||||||
metadataClient.MultiplayerRoomScoreSet += onRoomScoreSet;
|
metadataClient.MultiplayerRoomScoreSet += onRoomScoreSet;
|
||||||
|
|
||||||
|
((IBindable<MultiplayerScore?>)breakdown.UserBestScore).BindTo(leaderboard.UserBestScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void presentScore(long id)
|
private void presentScore(long id)
|
||||||
|
@ -22,6 +22,9 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
{
|
{
|
||||||
public partial class DailyChallengeLeaderboard : CompositeDrawable
|
public partial class DailyChallengeLeaderboard : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
public IBindable<MultiplayerScore?> UserBestScore => userBestScore;
|
||||||
|
private readonly Bindable<MultiplayerScore?> userBestScore = new Bindable<MultiplayerScore?>();
|
||||||
|
|
||||||
public Action<long>? PresentScore { get; init; }
|
public Action<long>? PresentScore { get; init; }
|
||||||
|
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
@ -130,7 +133,9 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
request.Success += req => Schedule(() =>
|
request.Success += req => Schedule(() =>
|
||||||
{
|
{
|
||||||
var best = req.Scores.Select(s => s.CreateScoreInfo(scoreManager, rulesets, playlistItem, beatmap.Value.BeatmapInfo)).ToArray();
|
var best = req.Scores.Select(s => s.CreateScoreInfo(scoreManager, rulesets, playlistItem, beatmap.Value.BeatmapInfo)).ToArray();
|
||||||
var userBest = req.UserScore?.CreateScoreInfo(scoreManager, rulesets, playlistItem, beatmap.Value.BeatmapInfo);
|
|
||||||
|
userBestScore.Value = req.UserScore;
|
||||||
|
var userBest = userBestScore.Value?.CreateScoreInfo(scoreManager, rulesets, playlistItem, beatmap.Value.BeatmapInfo);
|
||||||
|
|
||||||
cancellationTokenSource?.Cancel();
|
cancellationTokenSource?.Cancel();
|
||||||
cancellationTokenSource = null;
|
cancellationTokenSource = null;
|
||||||
|
@ -4,14 +4,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Metadata;
|
using osu.Game.Online.Metadata;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -20,6 +23,8 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
{
|
{
|
||||||
public partial class DailyChallengeScoreBreakdown : CompositeDrawable
|
public partial class DailyChallengeScoreBreakdown : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
public Bindable<MultiplayerScore?> UserBestScore { get; } = new Bindable<MultiplayerScore?>();
|
||||||
|
|
||||||
private FillFlowContainer<Bar> barsContainer = null!;
|
private FillFlowContainer<Bar> barsContainer = null!;
|
||||||
|
|
||||||
private const int bin_count = MultiplayerPlaylistItemStats.TOTAL_SCORE_DISTRIBUTION_BINS;
|
private const int bin_count = MultiplayerPlaylistItemStats.TOTAL_SCORE_DISTRIBUTION_BINS;
|
||||||
@ -44,29 +49,24 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
|
|
||||||
for (int i = 0; i < bin_count; ++i)
|
for (int i = 0; i < bin_count; ++i)
|
||||||
{
|
{
|
||||||
LocalisableString? label = null;
|
barsContainer.Add(new Bar(100_000 * i, 100_000 * (i + 1) - 1)
|
||||||
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
case 4:
|
|
||||||
case 6:
|
|
||||||
case 8:
|
|
||||||
label = @$"{100 * i}k";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
label = @"1M";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
barsContainer.Add(new Bar(label)
|
|
||||||
{
|
{
|
||||||
Width = 1f / bin_count,
|
Width = 1f / bin_count,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
UserBestScore.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
foreach (var bar in barsContainer)
|
||||||
|
bar.ContainsLocalUser.Value = UserBestScore.Value is not null && bar.BinStart <= UserBestScore.Value.TotalScore && UserBestScore.Value.TotalScore <= bar.BinEnd;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void AddNewScore(NewScoreEvent newScoreEvent)
|
public void AddNewScore(NewScoreEvent newScoreEvent)
|
||||||
{
|
{
|
||||||
int targetBin = (int)Math.Clamp(Math.Floor((float)newScoreEvent.TotalScore / 100000), 0, bin_count - 1);
|
int targetBin = (int)Math.Clamp(Math.Floor((float)newScoreEvent.TotalScore / 100000), 0, bin_count - 1);
|
||||||
@ -113,20 +113,34 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
barsContainer[i].UpdateCounts(bins[i], max);
|
barsContainer[i].UpdateCounts(bins[i], max);
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class Bar : CompositeDrawable
|
private partial class Bar : CompositeDrawable, IHasTooltip
|
||||||
{
|
{
|
||||||
private readonly LocalisableString? label;
|
public BindableBool ContainsLocalUser { get; } = new BindableBool();
|
||||||
|
|
||||||
|
public readonly int BinStart;
|
||||||
|
public readonly int BinEnd;
|
||||||
|
|
||||||
private long count;
|
private long count;
|
||||||
private long max;
|
private long max;
|
||||||
|
|
||||||
public Container CircularBar { get; private set; } = null!;
|
public Container CircularBar { get; private set; } = null!;
|
||||||
|
|
||||||
public Bar(LocalisableString? label = null)
|
private Box fill = null!;
|
||||||
|
private Box flashLayer = null!;
|
||||||
|
private OsuSpriteText userIndicator = null!;
|
||||||
|
|
||||||
|
public Bar(int binStart, int binEnd)
|
||||||
{
|
{
|
||||||
this.label = label;
|
BinStart = binStart;
|
||||||
|
BinEnd = binEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
@ -142,35 +156,83 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
},
|
},
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Masking = true,
|
Children = new Drawable[]
|
||||||
Child = CircularBar = new Container
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
CircularBar = new Container
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Height = 0.01f,
|
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 10,
|
|
||||||
Colour = colourProvider.Highlight1,
|
|
||||||
Child = new Box
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Height = 0.01f,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
fill = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
flashLayer = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
userIndicator = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Colour = colours.Orange1,
|
||||||
|
Text = "You",
|
||||||
|
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
||||||
|
Alpha = 0,
|
||||||
|
RelativePositionAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Bottom = 5, },
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
string? label = null;
|
||||||
|
|
||||||
|
switch (BinStart)
|
||||||
|
{
|
||||||
|
case 200_000:
|
||||||
|
case 400_000:
|
||||||
|
case 600_000:
|
||||||
|
case 800_000:
|
||||||
|
label = @$"{BinStart / 1000}k";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1_000_000:
|
||||||
|
label = @"1M";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (label != null)
|
if (label != null)
|
||||||
{
|
{
|
||||||
AddInternal(new OsuSpriteText
|
AddInternal(new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Text = label.Value,
|
Text = label,
|
||||||
Colour = colourProvider.Content2,
|
Colour = colourProvider.Content2,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
ContainsLocalUser.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
fill.FadeColour(ContainsLocalUser.Value ? colours.Orange1 : colourProvider.Highlight1, 300, Easing.OutQuint);
|
||||||
|
userIndicator.FadeTo(ContainsLocalUser.Value ? 1 : 0, 300, Easing.OutQuint);
|
||||||
|
}, true);
|
||||||
|
FinishTransforms(true);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -185,10 +247,14 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
count = newCount;
|
count = newCount;
|
||||||
max = newMax;
|
max = newMax;
|
||||||
|
|
||||||
CircularBar.ResizeHeightTo(0.01f + 0.99f * count / max, 300, Easing.OutQuint);
|
float height = 0.01f + 0.99f * count / max;
|
||||||
|
CircularBar.ResizeHeightTo(height, 300, Easing.OutQuint);
|
||||||
|
userIndicator.MoveToY(-height, 300, Easing.OutQuint);
|
||||||
if (isIncrement)
|
if (isIncrement)
|
||||||
CircularBar.FlashColour(Colour4.White, 600, Easing.OutQuint);
|
flashLayer.FadeOutFromOne(600, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LocalisableString TooltipText => LocalisableString.Format("{0:N0} passes in {1:N0} - {2:N0} range", count, BinStart, BinEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user