mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Fix results sometimes showing incorrect score position
This commit is contained in:
@ -28,6 +28,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
public class TestScenePlaylistsResultsScreen : ScreenTestScene
|
public class TestScenePlaylistsResultsScreen : ScreenTestScene
|
||||||
{
|
{
|
||||||
private const int scores_per_result = 10;
|
private const int scores_per_result = 10;
|
||||||
|
private const int real_user_position = 200;
|
||||||
|
|
||||||
private TestResultsScreen resultsScreen;
|
private TestResultsScreen resultsScreen;
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
createResults(() => userScore);
|
createResults(() => userScore);
|
||||||
|
|
||||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
|
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).State == PanelState.Expanded);
|
||||||
|
AddAssert($"score panel position is {real_user_position}",
|
||||||
|
() => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineID == userScore.OnlineID).ScorePosition.Value == real_user_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -236,7 +239,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
EndedAt = userScore.Date,
|
EndedAt = userScore.Date,
|
||||||
Passed = userScore.Passed,
|
Passed = userScore.Passed,
|
||||||
Rank = userScore.Rank,
|
Rank = userScore.Rank,
|
||||||
Position = 200,
|
Position = real_user_position,
|
||||||
MaxCombo = userScore.MaxCombo,
|
MaxCombo = userScore.MaxCombo,
|
||||||
TotalScore = userScore.TotalScore,
|
TotalScore = userScore.TotalScore,
|
||||||
User = userScore.User,
|
User = userScore.User,
|
||||||
|
@ -87,6 +87,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
{
|
{
|
||||||
var allScores = new List<MultiplayerScore> { userScore };
|
var allScores = new List<MultiplayerScore> { userScore };
|
||||||
|
|
||||||
|
// Other scores could have arrived between score submission and entering the results screen. Ensure the local player score position is up to date.
|
||||||
|
if (Score != null)
|
||||||
|
{
|
||||||
|
Score.Position = userScore.Position;
|
||||||
|
ScorePanelList.GetPanelForScore(Score).ScorePosition.Value = userScore.Position;
|
||||||
|
}
|
||||||
|
|
||||||
if (userScore.ScoresAround?.Higher != null)
|
if (userScore.ScoresAround?.Higher != null)
|
||||||
{
|
{
|
||||||
allScores.AddRange(userScore.ScoresAround.Higher.Scores);
|
allScores.AddRange(userScore.ScoresAround.Higher.Scores);
|
||||||
|
@ -2,36 +2,42 @@
|
|||||||
// 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.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.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Scoring;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Ranking.Contracted
|
namespace osu.Game.Screens.Ranking.Contracted
|
||||||
{
|
{
|
||||||
public class ContractedPanelTopContent : CompositeDrawable
|
public class ContractedPanelTopContent : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly ScoreInfo score;
|
public readonly Bindable<int?> ScorePosition = new Bindable<int?>();
|
||||||
|
|
||||||
public ContractedPanelTopContent(ScoreInfo score)
|
private OsuSpriteText text;
|
||||||
|
|
||||||
|
public ContractedPanelTopContent()
|
||||||
{
|
{
|
||||||
this.score = score;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChild = new OsuSpriteText
|
InternalChild = text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Y = 6,
|
Y = 6,
|
||||||
Text = score.Position != null ? $"#{score.Position}" : string.Empty,
|
|
||||||
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold)
|
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
ScorePosition.BindValueChanged(pos => text.Text = pos.NewValue != null ? $"#{pos.NewValue}" : string.Empty, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
@ -78,6 +79,11 @@ namespace osu.Game.Screens.Ranking
|
|||||||
|
|
||||||
public event Action<PanelState> StateChanged;
|
public event Action<PanelState> StateChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The position of the score in the rankings.
|
||||||
|
/// </summary>
|
||||||
|
public readonly Bindable<int?> ScorePosition = new Bindable<int?>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An action to be invoked if this <see cref="ScorePanel"/> is clicked while in an expanded state.
|
/// An action to be invoked if this <see cref="ScorePanel"/> is clicked while in an expanded state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -103,6 +109,8 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
Score = score;
|
Score = score;
|
||||||
displayWithFlair = isNewLocalScore;
|
displayWithFlair = isNewLocalScore;
|
||||||
|
|
||||||
|
ScorePosition.Value = score.Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -211,8 +219,8 @@ namespace osu.Game.Screens.Ranking
|
|||||||
topLayerBackground.FadeColour(expanded_top_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
topLayerBackground.FadeColour(expanded_top_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
||||||
middleLayerBackground.FadeColour(expanded_middle_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
middleLayerBackground.FadeColour(expanded_middle_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
||||||
|
|
||||||
topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
|
topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User) { Alpha = 0 });
|
||||||
middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score, displayWithFlair).With(d => d.Alpha = 0));
|
middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score, displayWithFlair) { Alpha = 0 });
|
||||||
|
|
||||||
// only the first expanded display should happen with flair.
|
// only the first expanded display should happen with flair.
|
||||||
displayWithFlair = false;
|
displayWithFlair = false;
|
||||||
@ -224,8 +232,13 @@ namespace osu.Game.Screens.Ranking
|
|||||||
topLayerBackground.FadeColour(contracted_top_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
topLayerBackground.FadeColour(contracted_top_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
||||||
middleLayerBackground.FadeColour(contracted_middle_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
middleLayerBackground.FadeColour(contracted_middle_layer_colour, RESIZE_DURATION, Easing.OutQuint);
|
||||||
|
|
||||||
topLayerContentContainer.Add(topLayerContent = new ContractedPanelTopContent(Score).With(d => d.Alpha = 0));
|
topLayerContentContainer.Add(topLayerContent = new ContractedPanelTopContent
|
||||||
middleLayerContentContainer.Add(middleLayerContent = new ContractedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
{
|
||||||
|
ScorePosition = { BindTarget = ScorePosition },
|
||||||
|
Alpha = 0
|
||||||
|
});
|
||||||
|
|
||||||
|
middleLayerContentContainer.Add(middleLayerContent = new ContractedPanelMiddleContent(Score) { Alpha = 0 });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user