From 4874746525615cb5aaffbe6195d8038b7766543b Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Tue, 30 Jul 2019 12:32:12 +0300 Subject: [PATCH] Add OnScoreChange event For use in scrolling system on a later PR --- osu.Game/Screens/Play/InGameScoreContainer.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/InGameScoreContainer.cs b/osu.Game/Screens/Play/InGameScoreContainer.cs index eb4a0a2f38..985e867510 100644 --- a/osu.Game/Screens/Play/InGameScoreContainer.cs +++ b/osu.Game/Screens/Play/InGameScoreContainer.cs @@ -18,6 +18,12 @@ namespace osu.Game.Screens.Play { public class InGameScoreContainer : FillFlowContainer { + /// + /// Called once an item's score has changed. + /// Useful for doing calculations on what score to show or hide next. (scrolling system) + /// + public event Action OnScoreChange; + /// /// Whether to declare a new position for un-positioned players. /// Must be disabled for online leaderboards with top 50 scores only. @@ -64,12 +70,12 @@ namespace osu.Game.Screens.Play Add(scoreItem); SetLayoutPosition(scoreItem, position ?? maxPosition + 1); - updateScores(); + reorderPositions(); return scoreItem; } - private void updateScores() + private void reorderPositions() { var orderedByScore = this.OrderByDescending(i => i.TotalScore).ToList(); var orderedPositions = this.OrderByDescending(i => i.ScorePosition.HasValue).ThenBy(i => i.ScorePosition).Select(i => i.ScorePosition).ToList(); @@ -82,6 +88,13 @@ namespace osu.Game.Screens.Play orderedByScore[i].ScorePosition = DeclareNewPosition ? newPosition : orderedPositions[i]; } } + + private void updateScores() + { + reorderPositions(); + + OnScoreChange?.Invoke(); + } } public class InGameScoreItem : CompositeDrawable