mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +08:00
Use Bindable for setting score
This commit is contained in:
parent
0584ee9ce5
commit
d30ae24f58
@ -43,8 +43,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
|
||||
AddStep(@"Trigger visibility", topScoreContainer.ToggleVisibility);
|
||||
AddStep(@"Add score", () => topScoreContainer.TopScore = scores[0]);
|
||||
AddStep(@"Add another score", () => topScoreContainer.TopScore = scores[1]);
|
||||
AddStep(@"Add score", () => topScoreContainer.TopScore.Value = scores[0]);
|
||||
AddStep(@"Add another score", () => topScoreContainer.TopScore.Value = scores[1]);
|
||||
AddStep(@"Add null score", () => topScoreContainer.TopScore.Value = null);
|
||||
|
||||
scores = new APILegacyUserTopScoreInfo[]
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
@ -18,14 +19,7 @@ namespace osu.Game.Screens.Select.Details
|
||||
private readonly Container contentContainer;
|
||||
private readonly Container scoreContainer;
|
||||
|
||||
public APILegacyUserTopScoreInfo TopScore
|
||||
{
|
||||
set
|
||||
{
|
||||
scoreContainer.Clear();
|
||||
scoreContainer.Add(new LeaderboardScore(value.Score, value.Position));
|
||||
}
|
||||
}
|
||||
public Bindable<APILegacyUserTopScoreInfo> TopScore = new Bindable<APILegacyUserTopScoreInfo>();
|
||||
|
||||
protected override bool StartHidden => true;
|
||||
|
||||
@ -62,6 +56,16 @@ namespace osu.Game.Screens.Select.Details
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TopScore.BindValueChanged((score) => onScoreChanged(score.NewValue));
|
||||
}
|
||||
|
||||
private void onScoreChanged(APILegacyUserTopScoreInfo score)
|
||||
{
|
||||
scoreContainer.Clear();
|
||||
|
||||
if (score != null)
|
||||
scoreContainer.Add(new LeaderboardScore(score.Score, score.Position));
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
|
Loading…
Reference in New Issue
Block a user