Make it works and some layout adjustments

This commit is contained in:
Andrei Zavatski
2019-07-14 14:03:14 +03:00
parent d1409d4610
commit 963e025bb8
4 changed files with 53 additions and 35 deletions

View File

@ -43,10 +43,10 @@ namespace osu.Game.Tests.Visual.SongSelect
}); });
AddStep(@"Trigger visibility", topScoreContainer.ToggleVisibility); AddStep(@"Trigger visibility", topScoreContainer.ToggleVisibility);
AddStep(@"Add score(rank 999)", () => topScoreContainer.TopScore.Value = scores[0]); AddStep(@"Add score(rank 999)", () => topScoreContainer.Score.Value = scores[0]);
AddStep(@"Add score(rank 110000)", () => topScoreContainer.TopScore.Value = scores[1]); AddStep(@"Add score(rank 110000)", () => topScoreContainer.Score.Value = scores[1]);
AddStep(@"Add score(rank 22333)", () => topScoreContainer.TopScore.Value = scores[2]); AddStep(@"Add score(rank 22333)", () => topScoreContainer.Score.Value = scores[2]);
AddStep(@"Add null score", () => topScoreContainer.TopScore.Value = null); AddStep(@"Add null score", () => topScoreContainer.Score.Value = null);
scores = new APILegacyUserTopScoreInfo[] scores = new APILegacyUserTopScoreInfo[]
{ {

View File

@ -1,10 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Screens.Select.Details; using osu.Game.Screens.Select.Details;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
@ -28,6 +28,7 @@ namespace osu.Game.Screens.Select
beatmap = value; beatmap = value;
Leaderboard.Beatmap = beatmap?.BeatmapInfo; Leaderboard.Beatmap = beatmap?.BeatmapInfo;
Details.Beatmap = beatmap?.BeatmapInfo; Details.Beatmap = beatmap?.BeatmapInfo;
TopScore.Hide();
} }
} }
@ -57,10 +58,13 @@ namespace osu.Game.Screens.Select
} }
}, },
}, },
new GridContainer new Container
{
Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT, Bottom = padding },
RelativeSizeAxes = Axes.Both,
Child = new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT },
RowDimensions = new Dimension[] RowDimensions = new Dimension[]
{ {
new Dimension(GridSizeMode.Distributed), new Dimension(GridSizeMode.Distributed),
@ -79,7 +83,7 @@ namespace osu.Game.Screens.Select
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0, Alpha = 0,
Padding = new MarginPadding { Vertical = padding }, Padding = new MarginPadding { Top = padding },
}, },
Leaderboard = new BeatmapLeaderboard Leaderboard = new BeatmapLeaderboard
{ {
@ -90,10 +94,14 @@ namespace osu.Game.Screens.Select
}, },
new Drawable[] new Drawable[]
{ {
TopScore = new UserTopScoreContainer(), TopScore = new UserTopScoreContainer
{
Score = { BindTarget = Leaderboard.TopScore }
}
} }
}, },
}, },
}
}; };
} }
} }

View File

@ -13,13 +13,13 @@ namespace osu.Game.Screens.Select.Details
{ {
public class UserTopScoreContainer : VisibilityContainer public class UserTopScoreContainer : VisibilityContainer
{ {
private const int height = 110; private const int height = 90;
private const int duration = 300; private const int duration = 300;
private readonly Container contentContainer; private readonly Container contentContainer;
private readonly Container scoreContainer; private readonly Container scoreContainer;
public Bindable<APILegacyUserTopScoreInfo> TopScore = new Bindable<APILegacyUserTopScoreInfo>(); public Bindable<APILegacyUserTopScoreInfo> Score = new Bindable<APILegacyUserTopScoreInfo>();
protected override bool StartHidden => true; protected override bool StartHidden => true;
@ -37,13 +37,13 @@ namespace osu.Game.Screens.Select.Details
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Height = height, Height = height,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Vertical = 10 },
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 5 },
Text = @"your personal best".ToUpper(), Text = @"your personal best".ToUpper(),
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold), Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold),
}, },
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Select.Details
} }
}; };
TopScore.BindValueChanged((score) => onScoreChanged(score.NewValue)); Score.BindValueChanged((score) => onScoreChanged(score.NewValue));
} }
private void onScoreChanged(APILegacyUserTopScoreInfo score) private void onScoreChanged(APILegacyUserTopScoreInfo score)
@ -66,7 +66,10 @@ namespace osu.Game.Screens.Select.Details
scoreContainer.Clear(); scoreContainer.Clear();
if (score != null) if (score != null)
{
scoreContainer.Add(new LeaderboardScore(score.Score, score.Position)); scoreContainer.Add(new LeaderboardScore(score.Score, score.Position));
Show();
}
} }
protected override void PopIn() protected override void PopIn()

View File

@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -18,6 +19,8 @@ namespace osu.Game.Screens.Select.Leaderboards
{ {
public class BeatmapLeaderboard : Leaderboard<BeatmapLeaderboardScope, ScoreInfo> public class BeatmapLeaderboard : Leaderboard<BeatmapLeaderboardScope, ScoreInfo>
{ {
public Bindable<APILegacyUserTopScoreInfo> TopScore = new Bindable<APILegacyUserTopScoreInfo>();
public Action<ScoreInfo> ScoreSelected; public Action<ScoreInfo> ScoreSelected;
private BeatmapInfo beatmap; private BeatmapInfo beatmap;
@ -133,7 +136,11 @@ namespace osu.Game.Screens.Select.Leaderboards
var req = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope, requestMods); var req = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope, requestMods);
req.Success += r => scoresCallback?.Invoke(r.Scores); req.Success += r =>
{
scoresCallback?.Invoke(r.Scores);
TopScore.Value = r.UserScore;
};
return req; return req;
} }