1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 14:07:25 +08:00

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(@"Add score(rank 999)", () => topScoreContainer.TopScore.Value = scores[0]);
AddStep(@"Add score(rank 110000)", () => topScoreContainer.TopScore.Value = scores[1]);
AddStep(@"Add score(rank 22333)", () => topScoreContainer.TopScore.Value = scores[2]);
AddStep(@"Add null score", () => topScoreContainer.TopScore.Value = null);
AddStep(@"Add score(rank 999)", () => topScoreContainer.Score.Value = scores[0]);
AddStep(@"Add score(rank 110000)", () => topScoreContainer.Score.Value = scores[1]);
AddStep(@"Add score(rank 22333)", () => topScoreContainer.Score.Value = scores[2]);
AddStep(@"Add null score", () => topScoreContainer.Score.Value = null);
scores = new APILegacyUserTopScoreInfo[]
{

View File

@ -1,10 +1,10 @@
// 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 System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Screens.Select.Details;
using osu.Game.Screens.Select.Leaderboards;
@ -28,6 +28,7 @@ namespace osu.Game.Screens.Select
beatmap = value;
Leaderboard.Beatmap = beatmap?.BeatmapInfo;
Details.Beatmap = beatmap?.BeatmapInfo;
TopScore.Hide();
}
}
@ -57,43 +58,50 @@ namespace osu.Game.Screens.Select
}
},
},
new GridContainer
new Container
{
Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT, Bottom = padding },
RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT },
RowDimensions = new Dimension[]
Child = new GridContainer
{
new Dimension(GridSizeMode.Distributed),
new Dimension(GridSizeMode.AutoSize),
},
Content = new[]
{
new Drawable[]
RelativeSizeAxes = Axes.Both,
RowDimensions = new Dimension[]
{
new Container
new Dimension(GridSizeMode.Distributed),
new Dimension(GridSizeMode.AutoSize),
},
Content = new[]
{
new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
new Container
{
Details = new BeatmapDetails
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Padding = new MarginPadding { Vertical = padding },
},
Leaderboard = new BeatmapLeaderboard
{
RelativeSizeAxes = Axes.Both,
Details = new BeatmapDetails
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Padding = new MarginPadding { Top = padding },
},
Leaderboard = new BeatmapLeaderboard
{
RelativeSizeAxes = Axes.Both,
}
}
}
},
new Drawable[]
{
TopScore = new UserTopScoreContainer
{
Score = { BindTarget = Leaderboard.TopScore }
}
}
},
new Drawable[]
{
TopScore = new UserTopScoreContainer(),
}
},
},
}
};
}
}

View File

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

View File

@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
@ -18,6 +19,8 @@ namespace osu.Game.Screens.Select.Leaderboards
{
public class BeatmapLeaderboard : Leaderboard<BeatmapLeaderboardScope, ScoreInfo>
{
public Bindable<APILegacyUserTopScoreInfo> TopScore = new Bindable<APILegacyUserTopScoreInfo>();
public Action<ScoreInfo> ScoreSelected;
private BeatmapInfo beatmap;
@ -133,7 +136,11 @@ namespace osu.Game.Screens.Select.Leaderboards
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;
}