1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Add to more places

This commit is contained in:
smoogipoo 2020-08-28 22:51:48 +09:00
parent ec2674e1ea
commit c1838902a6
4 changed files with 45 additions and 11 deletions

View File

@ -9,16 +9,20 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public abstract class RollingCounter<T> : Container public abstract class RollingCounter<T> : Container, IHasCurrentValue<T>
where T : struct, IEquatable<T> where T : struct, IEquatable<T>
{ {
/// <summary> private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
/// The current value.
/// </summary> public Bindable<T> Current
public Bindable<T> Current = new Bindable<T>(); {
get => current.Current;
set => current.Current = value;
}
private SpriteText displayedCountSpriteText; private SpriteText displayedCountSpriteText;

View File

@ -4,6 +4,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -38,6 +39,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly FillFlowContainer<InfoColumn> statisticsColumns; private readonly FillFlowContainer<InfoColumn> statisticsColumns;
private readonly ModsInfoColumn modsColumn; private readonly ModsInfoColumn modsColumn;
[Resolved]
private ScoreManager scoreManager { get; set; }
public TopScoreStatisticsSection() public TopScoreStatisticsSection()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -87,6 +91,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
} }
[BackgroundDependencyLoader]
private void load()
{
if (score != null)
totalScoreColumn.Current = scoreManager.GetTotalScoreString(score);
}
private ScoreInfo score;
/// <summary> /// <summary>
/// Sets the score to be displayed. /// Sets the score to be displayed.
/// </summary> /// </summary>
@ -94,7 +107,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
set set
{ {
totalScoreColumn.Text = $@"{value.TotalScore:N0}"; if (score == value)
return;
score = value;
accuracyColumn.Text = value.DisplayAccuracy; accuracyColumn.Text = value.DisplayAccuracy;
maxComboColumn.Text = $@"{value.MaxCombo:N0}x"; maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0; ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0;
@ -102,6 +119,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
statisticsColumns.ChildrenEnumerable = value.SortedStatistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value)); statisticsColumns.ChildrenEnumerable = value.SortedStatistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value));
modsColumn.Mods = value.Mods; modsColumn.Mods = value.Mods;
if (IsLoaded)
totalScoreColumn.Current = scoreManager.GetTotalScoreString(value);
} }
} }
@ -190,6 +210,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
set => text.Text = value; set => text.Text = value;
} }
public Bindable<string> Current
{
get => text.Current;
set => text.Current = value;
}
} }
private class ModsInfoColumn : InfoColumn private class ModsInfoColumn : InfoColumn

View File

@ -30,6 +30,9 @@ namespace osu.Game.Screens.Ranking.Contracted
{ {
private readonly ScoreInfo score; private readonly ScoreInfo score;
[Resolved]
private ScoreManager scoreManager { get; set; }
/// <summary> /// <summary>
/// Creates a new <see cref="ContractedPanelMiddleContent"/>. /// Creates a new <see cref="ContractedPanelMiddleContent"/>.
/// </summary> /// </summary>
@ -160,7 +163,7 @@ namespace osu.Game.Screens.Ranking.Contracted
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Text = score.TotalScore.ToString("N0"), Current = scoreManager.GetTotalScoreString(score),
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true), Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true),
Spacing = new Vector2(-1, 0) Spacing = new Vector2(-1, 0)
}, },

View File

@ -25,15 +25,16 @@ namespace osu.Game.Screens.Ranking.Expanded
/// </summary> /// </summary>
public class ExpandedPanelMiddleContent : CompositeDrawable public class ExpandedPanelMiddleContent : CompositeDrawable
{ {
private readonly ScoreInfo score; private const float padding = 10;
private readonly ScoreInfo score;
private readonly List<StatisticDisplay> statisticDisplays = new List<StatisticDisplay>(); private readonly List<StatisticDisplay> statisticDisplays = new List<StatisticDisplay>();
private FillFlowContainer starAndModDisplay; private FillFlowContainer starAndModDisplay;
private RollingCounter<long> scoreCounter; private RollingCounter<long> scoreCounter;
private const float padding = 10; [Resolved]
private ScoreManager scoreManager { get; set; }
/// <summary> /// <summary>
/// Creates a new <see cref="ExpandedPanelMiddleContent"/>. /// Creates a new <see cref="ExpandedPanelMiddleContent"/>.
@ -238,7 +239,7 @@ namespace osu.Game.Screens.Ranking.Expanded
using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY, true)) using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY, true))
{ {
scoreCounter.FadeIn(); scoreCounter.FadeIn();
scoreCounter.Current.Value = score.TotalScore; scoreCounter.Current = scoreManager.GetTotalScore(score);
double delay = 0; double delay = 0;