1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:02:55 +08:00

Show room leaderboard instead in the lounge

This commit is contained in:
smoogipoo 2019-01-08 19:24:55 +09:00
parent 2ecbb23b63
commit 122fc2de58
6 changed files with 25 additions and 31 deletions

View File

@ -17,12 +17,13 @@ namespace osu.Game.Tests.Visual
{ {
public TestCaseMatchLeaderboard() public TestCaseMatchLeaderboard()
{ {
Add(new MatchLeaderboard(new Room { RoomID = { Value = 3 } }) Add(new MatchLeaderboard
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Size = new Vector2(550f, 450f), Size = new Vector2(550f, 450f),
Scope = MatchLeaderboardScope.Overall, Scope = MatchLeaderboardScope.Overall,
Room = new Room { RoomID = { Value = 3 } }
}); });
} }

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq; using System.Threading;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -13,10 +13,10 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -37,11 +37,11 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private Box statusStrip; private Box statusStrip;
private UpdateableBeatmapBackgroundSprite background; private UpdateableBeatmapBackgroundSprite background;
private ParticipantCountDisplay participantCount; private ParticipantCountDisplay participantCount;
private FillFlowContainer topFlow, participantsFlow; private FillFlowContainer topFlow;
private OsuSpriteText name, status; private OsuSpriteText name, status;
private BeatmapTypeInfo beatmapTypeInfo; private BeatmapTypeInfo beatmapTypeInfo;
private ScrollContainer participantsScroll;
private ParticipantInfo participantInfo; private ParticipantInfo participantInfo;
private MatchLeaderboard leaderboard;
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; }
@ -147,23 +147,13 @@ namespace osu.Game.Screens.Multi.Lounge.Components
}, },
}, },
}, },
participantsScroll = new OsuScrollContainer leaderboard = new MatchLeaderboard
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Top = contentPadding.Top, Left = 38, Right = 37 }, Padding = new MarginPadding { Top = contentPadding.Top, Left = 38, Right = 37 },
Children = new[] }
{
participantsFlow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
LayoutDuration = transition_duration,
Spacing = new Vector2(5f),
},
},
},
}; };
participantInfo.Host.BindTo(bindings.Host); participantInfo.Host.BindTo(bindings.Host);
@ -180,7 +170,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
background.Beatmap.BindTo(bindings.CurrentBeatmap); background.Beatmap.BindTo(bindings.CurrentBeatmap);
bindings.Status.BindValueChanged(displayStatus); bindings.Status.BindValueChanged(displayStatus);
bindings.Participants.BindValueChanged(p => participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)));
bindings.Name.BindValueChanged(n => name.Text = n); bindings.Name.BindValueChanged(n => name.Text = n);
Room.BindValueChanged(updateRoom, true); Room.BindValueChanged(updateRoom, true);
@ -189,10 +178,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private void updateRoom(Room room) private void updateRoom(Room room)
{ {
bindings.Room = room; bindings.Room = room;
leaderboard.Room = room;
if (room != null) if (room != null)
{ {
participantsFlow.FadeIn(transition_duration);
participantCount.FadeIn(transition_duration); participantCount.FadeIn(transition_duration);
beatmapTypeInfo.FadeIn(transition_duration); beatmapTypeInfo.FadeIn(transition_duration);
name.FadeIn(transition_duration); name.FadeIn(transition_duration);
@ -200,7 +189,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
} }
else else
{ {
participantsFlow.FadeOut(transition_duration);
participantCount.FadeOut(transition_duration); participantCount.FadeOut(transition_duration);
beatmapTypeInfo.FadeOut(transition_duration); beatmapTypeInfo.FadeOut(transition_duration);
name.FadeOut(transition_duration); name.FadeOut(transition_duration);
@ -214,7 +202,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
participantsScroll.Height = DrawHeight - topFlow.DrawHeight; leaderboard.Height = DrawHeight - topFlow.DrawHeight;
} }
private void displayStatus(RoomStatus s) private void displayStatus(RoomStatus s)

View File

@ -16,17 +16,18 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
public Action<IEnumerable<APIRoomScoreInfo>> ScoresLoaded; public Action<IEnumerable<APIRoomScoreInfo>> ScoresLoaded;
private readonly Room room; public Room Room
public MatchLeaderboard(Room room)
{ {
this.room = room; get => bindings.Room;
set => bindings.Room = value;
} }
private readonly RoomBindings bindings = new RoomBindings();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
room.RoomID.BindValueChanged(id => bindings.RoomID.BindValueChanged(id =>
{ {
if (id == null) if (id == null)
return; return;
@ -38,10 +39,10 @@ namespace osu.Game.Screens.Multi.Match.Components
protected override APIRequest FetchScores(Action<IEnumerable<APIRoomScoreInfo>> scoresCallback) protected override APIRequest FetchScores(Action<IEnumerable<APIRoomScoreInfo>> scoresCallback)
{ {
if (room.RoomID == null) if (bindings.RoomID.Value == null)
return null; return null;
var req = new GetRoomScoresRequest(room.RoomID.Value ?? 0); var req = new GetRoomScoresRequest(bindings.RoomID.Value ?? 0);
req.Success += r => req.Success += r =>
{ {

View File

@ -71,10 +71,11 @@ namespace osu.Game.Screens.Multi.Match
{ {
new Drawable[] new Drawable[]
{ {
leaderboard = new MatchLeaderboard(room) leaderboard = new MatchLeaderboard
{ {
Padding = new MarginPadding(10), Padding = new MarginPadding(10),
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both,
Room = room
}, },
new Container new Container
{ {

View File

@ -103,8 +103,8 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
public class ResultsMatchLeaderboard : MatchLeaderboard public class ResultsMatchLeaderboard : MatchLeaderboard
{ {
public ResultsMatchLeaderboard(Room room) public ResultsMatchLeaderboard(Room room)
: base(room)
{ {
Room = room;
} }
protected override bool FadeTop => true; protected override bool FadeTop => true;

View File

@ -39,6 +39,7 @@ namespace osu.Game.Screens.Multi
if (room != null) if (room != null)
{ {
RoomID.UnbindFrom(room.RoomID);
Name.UnbindFrom(room.Name); Name.UnbindFrom(room.Name);
Host.UnbindFrom(room.Host); Host.UnbindFrom(room.Host);
Status.UnbindFrom(room.Status); Status.UnbindFrom(room.Status);
@ -56,6 +57,7 @@ namespace osu.Game.Screens.Multi
if (room != null) if (room != null)
{ {
RoomID.BindTo(room.RoomID);
Name.BindTo(room.Name); Name.BindTo(room.Name);
Host.BindTo(room.Host); Host.BindTo(room.Host);
Status.BindTo(room.Status); Status.BindTo(room.Status);
@ -82,6 +84,7 @@ namespace osu.Game.Screens.Multi
currentRuleset.Value = playlistItem?.Ruleset; currentRuleset.Value = playlistItem?.Ruleset;
} }
public readonly Bindable<int?> RoomID = new Bindable<int?>();
public readonly Bindable<string> Name = new Bindable<string>(); public readonly Bindable<string> Name = new Bindable<string>();
public readonly Bindable<User> Host = new Bindable<User>(); public readonly Bindable<User> Host = new Bindable<User>();
public readonly Bindable<RoomStatus> Status = new Bindable<RoomStatus>(); public readonly Bindable<RoomStatus> Status = new Bindable<RoomStatus>();