mirror of
https://github.com/ppy/osu.git
synced 2025-01-22 07:23:21 +08:00
Merge branch 'master' into localise-toasts
This commit is contained in:
commit
68078bd5bd
@ -32,12 +32,14 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
private TestResultsScreen resultsScreen;
|
private TestResultsScreen resultsScreen;
|
||||||
private int currentScoreId;
|
private int currentScoreId;
|
||||||
private bool requestComplete;
|
private bool requestComplete;
|
||||||
|
private int totalCount;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
currentScoreId = 0;
|
currentScoreId = 0;
|
||||||
requestComplete = false;
|
requestComplete = false;
|
||||||
|
totalCount = 0;
|
||||||
bindHandler();
|
bindHandler();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,7 +55,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
});
|
});
|
||||||
|
|
||||||
createResults(() => userScore);
|
createResults(() => userScore);
|
||||||
waitForDisplay();
|
|
||||||
|
|
||||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||||
}
|
}
|
||||||
@ -62,7 +63,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
public void TestShowNullUserScore()
|
public void TestShowNullUserScore()
|
||||||
{
|
{
|
||||||
createResults();
|
createResults();
|
||||||
waitForDisplay();
|
|
||||||
|
|
||||||
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
});
|
});
|
||||||
|
|
||||||
createResults(() => userScore);
|
createResults(() => userScore);
|
||||||
waitForDisplay();
|
|
||||||
|
|
||||||
AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1);
|
AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1);
|
||||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||||
@ -91,7 +90,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
AddStep("bind delayed handler", () => bindHandler(true));
|
AddStep("bind delayed handler", () => bindHandler(true));
|
||||||
|
|
||||||
createResults();
|
createResults();
|
||||||
waitForDisplay();
|
|
||||||
|
|
||||||
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
||||||
}
|
}
|
||||||
@ -100,7 +98,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
public void TestFetchWhenScrolledToTheRight()
|
public void TestFetchWhenScrolledToTheRight()
|
||||||
{
|
{
|
||||||
createResults();
|
createResults();
|
||||||
waitForDisplay();
|
|
||||||
|
|
||||||
AddStep("bind delayed handler", () => bindHandler(true));
|
AddStep("bind delayed handler", () => bindHandler(true));
|
||||||
|
|
||||||
@ -131,7 +128,6 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
});
|
});
|
||||||
|
|
||||||
createResults(() => userScore);
|
createResults(() => userScore);
|
||||||
waitForDisplay();
|
|
||||||
|
|
||||||
AddStep("bind delayed handler", () => bindHandler(true));
|
AddStep("bind delayed handler", () => bindHandler(true));
|
||||||
|
|
||||||
@ -161,13 +157,15 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => resultsScreen.ChildrenOfType<ScorePanelList>().FirstOrDefault()?.AllPanelsVisible == true);
|
waitForDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForDisplay()
|
private void waitForDisplay()
|
||||||
{
|
{
|
||||||
AddUntilStep("wait for request to complete", () => requestComplete);
|
AddUntilStep("wait for load to complete", () =>
|
||||||
AddUntilStep("wait for panels to be visible", () => resultsScreen.ChildrenOfType<ScorePanelList>().FirstOrDefault()?.AllPanelsVisible == true);
|
requestComplete
|
||||||
|
&& resultsScreen.ScorePanelList.GetScorePanels().Count() == totalCount
|
||||||
|
&& resultsScreen.ScorePanelList.AllPanelsVisible);
|
||||||
AddWaitStep("wait for display", 5);
|
AddWaitStep("wait for display", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +201,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
triggerFail(s);
|
triggerFail(s);
|
||||||
else
|
else
|
||||||
triggerSuccess(s, createUserResponse(userScore));
|
triggerSuccess(s, createUserResponse(userScore));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IndexPlaylistScoresRequest i:
|
case IndexPlaylistScoresRequest i:
|
||||||
@ -248,6 +247,8 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
totalCount++;
|
||||||
|
|
||||||
for (int i = 1; i <= scores_per_result; i++)
|
for (int i = 1; i <= scores_per_result; i++)
|
||||||
{
|
{
|
||||||
multiplayerUserScore.ScoresAround.Lower.Scores.Add(new MultiplayerScore
|
multiplayerUserScore.ScoresAround.Lower.Scores.Add(new MultiplayerScore
|
||||||
@ -285,6 +286,8 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
},
|
},
|
||||||
Statistics = userScore.Statistics
|
Statistics = userScore.Statistics
|
||||||
});
|
});
|
||||||
|
|
||||||
|
totalCount += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
addCursor(multiplayerUserScore.ScoresAround.Lower);
|
addCursor(multiplayerUserScore.ScoresAround.Lower);
|
||||||
@ -325,6 +328,8 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{ HitResult.Great, 300 }
|
{ HitResult.Great, 300 }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
totalCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
addCursor(result);
|
addCursor(result);
|
||||||
|
@ -163,7 +163,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for fetch", () => leaderboard.Scores != null);
|
AddUntilStep("wait for fetch", () => leaderboard.Scores != null);
|
||||||
|
|
||||||
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scoreBeingDeleted.OnlineScoreID));
|
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scoreBeingDeleted.OnlineScoreID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +170,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestDeleteViaDatabase()
|
public void TestDeleteViaDatabase()
|
||||||
{
|
{
|
||||||
AddStep("delete top score", () => scoreManager.Delete(importedScores[0]));
|
AddStep("delete top score", () => scoreManager.Delete(importedScores[0]));
|
||||||
|
AddUntilStep("wait for fetch", () => leaderboard.Scores != null);
|
||||||
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != importedScores[0].OnlineScoreID));
|
AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != importedScores[0].OnlineScoreID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
|
|||||||
score2Text.X = Math.Max(5 + score2Text.DrawWidth / 2, score2Bar.DrawWidth);
|
score2Text.X = Math.Max(5 + score2Text.DrawWidth / 2, score2Bar.DrawWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MatchScoreCounter : ScoreCounter
|
private class MatchScoreCounter : CommaSeparatedScoreCounter
|
||||||
{
|
{
|
||||||
private OsuSpriteText displayedSpriteText;
|
private OsuSpriteText displayedSpriteText;
|
||||||
|
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
// 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 osu.Framework.Extensions.LocalisationExtensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public abstract class CommaSeparatedScoreCounter : RollingCounter<double>
|
||||||
|
{
|
||||||
|
protected override double RollingDuration => 1000;
|
||||||
|
protected override Easing RollingEasing => Easing.Out;
|
||||||
|
|
||||||
|
protected override double GetProportionalDuration(double currentValue, double newValue) =>
|
||||||
|
currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||||
|
|
||||||
|
protected override LocalisableString FormatCount(double count) => ((long)count).ToLocalisableString(@"N0");
|
||||||
|
|
||||||
|
protected override OsuSpriteText CreateSpriteText()
|
||||||
|
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(fixedWidth: true));
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -13,43 +14,30 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override double RollingDuration => 1000;
|
protected override double RollingDuration => 1000;
|
||||||
protected override Easing RollingEasing => Easing.Out;
|
protected override Easing RollingEasing => Easing.Out;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether comma separators should be displayed.
|
|
||||||
/// </summary>
|
|
||||||
public bool UseCommaSeparator { get; }
|
|
||||||
|
|
||||||
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
||||||
|
|
||||||
|
private string formatString;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Displays score.
|
/// Displays score.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||||
/// <param name="useCommaSeparator">Whether comma separators should be displayed.</param>
|
protected ScoreCounter(int leading = 0)
|
||||||
protected ScoreCounter(int leading = 0, bool useCommaSeparator = false)
|
|
||||||
{
|
{
|
||||||
UseCommaSeparator = useCommaSeparator;
|
|
||||||
|
|
||||||
RequiredDisplayDigits.Value = leading;
|
RequiredDisplayDigits.Value = leading;
|
||||||
RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay());
|
RequiredDisplayDigits.BindValueChanged(displayDigitsChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
private void displayDigitsChanged(ValueChangedEvent<int> _)
|
||||||
{
|
{
|
||||||
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
formatString = new string('0', RequiredDisplayDigits.Value);
|
||||||
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override LocalisableString FormatCount(double count)
|
protected override double GetProportionalDuration(double currentValue, double newValue) =>
|
||||||
{
|
currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||||
string format = new string('0', RequiredDisplayDigits.Value);
|
|
||||||
|
|
||||||
if (UseCommaSeparator)
|
protected override LocalisableString FormatCount(double count) => ((long)count).ToLocalisableString(formatString);
|
||||||
{
|
|
||||||
for (int i = format.Length - 3; i > 0; i -= 3)
|
|
||||||
format = format.Insert(i, @",");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((long)count).ToString(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override OsuSpriteText CreateSpriteText()
|
protected override OsuSpriteText CreateSpriteText()
|
||||||
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(fixedWidth: true));
|
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(fixedWidth: true));
|
||||||
|
@ -72,9 +72,12 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're calling .Result, but this should not be a blocking call due to the above GetDifficultyAsync() calls.
|
var totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false);
|
||||||
return scores.OrderByDescending(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken).Result)
|
|
||||||
.ThenBy(s => s.OnlineScoreID)
|
return scores.Select((score, index) => (score, totalScore: totalScores[index]))
|
||||||
|
.OrderByDescending(g => g.totalScore)
|
||||||
|
.ThenBy(g => g.score.OnlineScoreID)
|
||||||
|
.Select(g => g.score)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public class DefaultScoreCounter : GameplayScoreCounter, ISkinnableDrawable
|
public class DefaultScoreCounter : GameplayScoreCounter, ISkinnableDrawable
|
||||||
{
|
{
|
||||||
public DefaultScoreCounter()
|
public DefaultScoreCounter()
|
||||||
: base(6)
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre;
|
Anchor = Anchor.TopCentre;
|
||||||
Origin = Anchor.TopCentre;
|
Origin = Anchor.TopCentre;
|
||||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
private Bindable<ScoringMode> scoreDisplayMode;
|
private Bindable<ScoringMode> scoreDisplayMode;
|
||||||
|
|
||||||
protected GameplayScoreCounter(int leading = 0, bool useCommaSeparator = false)
|
protected GameplayScoreCounter()
|
||||||
: base(leading, useCommaSeparator)
|
: base(6)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
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;
|
||||||
@ -148,7 +146,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Score2Text.X = Math.Max(5 + Score2Text.DrawWidth / 2, score2Bar.DrawWidth);
|
Score2Text.X = Math.Max(5 + Score2Text.DrawWidth / 2, score2Bar.DrawWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class MatchScoreCounter : ScoreCounter
|
protected class MatchScoreCounter : CommaSeparatedScoreCounter
|
||||||
{
|
{
|
||||||
private OsuSpriteText displayedSpriteText;
|
private OsuSpriteText displayedSpriteText;
|
||||||
|
|
||||||
@ -173,8 +171,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
=> displayedSpriteText.Font = winning
|
=> displayedSpriteText.Font = winning
|
||||||
? OsuFont.Torus.With(weight: FontWeight.Bold, size: font_size, fixedWidth: true)
|
? OsuFont.Torus.With(weight: FontWeight.Bold, size: font_size, fixedWidth: true)
|
||||||
: OsuFont.Torus.With(weight: FontWeight.Regular, size: font_size * 0.8f, fixedWidth: true);
|
: OsuFont.Torus.With(weight: FontWeight.Regular, size: font_size * 0.8f, fixedWidth: true);
|
||||||
|
|
||||||
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(@"N0");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ namespace osu.Game.Skinning
|
|||||||
public bool UsesFixedAnchor { get; set; }
|
public bool UsesFixedAnchor { get; set; }
|
||||||
|
|
||||||
public LegacyScoreCounter()
|
public LegacyScoreCounter()
|
||||||
: base(6)
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight;
|
Anchor = Anchor.TopRight;
|
||||||
Origin = Anchor.TopRight;
|
Origin = Anchor.TopRight;
|
||||||
|
Loading…
Reference in New Issue
Block a user