1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 16:12:53 +08:00

Add InitialPosition field

This commit is contained in:
iiSaLMaN 2019-08-04 18:26:01 +03:00
parent 5e4e150330
commit 9325c024bb

View File

@ -61,19 +61,18 @@ namespace osu.Game.Screens.Play
/// Adds a score item based off a <see cref="ScoreInfo"/> with an initial position. /// Adds a score item based off a <see cref="ScoreInfo"/> with an initial position.
/// </summary> /// </summary>
/// <param name="score">The score info to use for this item.</param> /// <param name="score">The score info to use for this item.</param>
/// <param name="position">The initial position of this item.</param> /// <param name="initialPosition">The initial position of this item.</param>
/// <returns>Returns the drawable score item of that player.</returns> /// <returns>Returns the drawable score item of that player.</returns>
public InGameScoreItem AddScore(ScoreInfo score, int? position = null) => score != null ? addScore(score.TotalScore, score.User, position) : null; public InGameScoreItem AddScore(ScoreInfo score, int? initialPosition = null) => score != null ? addScore(score.TotalScore, score.User, initialPosition) : null;
private int maxPosition => this.Where(i => i.ScorePosition.HasValue).Max(i => i.ScorePosition) ?? 0; private int maxPosition => this.Where(i => i.ScorePosition.HasValue).Max(i => i.ScorePosition) ?? 0;
private InGameScoreItem addScore(double totalScore, User user = null, int? position = null) private InGameScoreItem addScore(double totalScore, User user = null, int? position = null)
{ {
var scoreItem = new InGameScoreItem var scoreItem = new InGameScoreItem(position)
{ {
User = user, User = user,
TotalScore = totalScore, TotalScore = totalScore,
ScorePosition = position,
OnScoreChange = updateScores, OnScoreChange = updateScores,
}; };
@ -117,6 +116,7 @@ namespace osu.Game.Screens.Play
public Action OnScoreChange; public Action OnScoreChange;
private int? scorePosition; private int? scorePosition;
public int? InitialPosition;
public int? ScorePosition public int? ScorePosition
{ {
@ -159,7 +159,7 @@ namespace osu.Game.Screens.Play
} }
} }
public InGameScoreItem() public InGameScoreItem(int? initialPosition)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
@ -219,6 +219,8 @@ namespace osu.Game.Screens.Play
}, },
}, },
}; };
InitialPosition = ScorePosition = initialPosition;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]