2018-12-21 17:22:13 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Microsoft.EntityFrameworkCore.Internal;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Lists;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
2018-12-22 14:45:16 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-12-27 14:30:02 +08:00
|
|
|
using osu.Game.Online.Leaderboards;
|
2018-12-21 17:22:13 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
using osu.Game.Screens.Multi.Match.Components;
|
2018-12-22 15:26:27 +08:00
|
|
|
using osu.Game.Screens.Ranking;
|
2018-12-21 17:22:13 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi.Ranking.Pages
|
|
|
|
{
|
2018-12-27 14:30:02 +08:00
|
|
|
public class RoomLeaderboardPage : ResultsPage
|
2018-12-21 17:22:13 +08:00
|
|
|
{
|
|
|
|
private readonly Room room;
|
|
|
|
|
|
|
|
private OsuColour colours;
|
|
|
|
|
|
|
|
private TextFlowContainer rankText;
|
|
|
|
|
2018-12-27 14:30:02 +08:00
|
|
|
public RoomLeaderboardPage(ScoreInfo score, WorkingBeatmap beatmap, Room room)
|
2018-12-21 17:22:13 +08:00
|
|
|
: base(score, beatmap)
|
|
|
|
{
|
|
|
|
this.room = room;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
this.colours = colours;
|
|
|
|
|
2018-12-21 17:37:33 +08:00
|
|
|
MatchLeaderboard leaderboard;
|
|
|
|
|
2018-12-21 17:22:13 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
2018-12-27 14:30:02 +08:00
|
|
|
Colour = colours.Gray6,
|
2018-12-21 17:22:13 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new BufferedContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-12-27 14:30:02 +08:00
|
|
|
BackgroundColour = colours.Gray6,
|
2018-12-21 17:37:33 +08:00
|
|
|
Child = leaderboard = CreateLeaderboard(room)
|
2018-12-21 17:22:13 +08:00
|
|
|
},
|
|
|
|
rankText = new TextFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 0.5f,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-12-27 14:30:02 +08:00
|
|
|
Y = 50,
|
2018-12-21 17:22:13 +08:00
|
|
|
TextAnchor = Anchor.TopCentre
|
|
|
|
},
|
|
|
|
};
|
2018-12-21 17:37:33 +08:00
|
|
|
|
|
|
|
leaderboard.Origin = Anchor.Centre;
|
|
|
|
leaderboard.Anchor = Anchor.Centre;
|
|
|
|
leaderboard.RelativeSizeAxes = Axes.Both;
|
|
|
|
leaderboard.Height = 0.8f;
|
2018-12-27 14:30:02 +08:00
|
|
|
leaderboard.Y = 55;
|
2018-12-21 17:37:33 +08:00
|
|
|
leaderboard.ScoresLoaded = scoresLoaded;
|
2018-12-21 17:22:13 +08:00
|
|
|
}
|
|
|
|
|
2018-12-22 14:45:16 +08:00
|
|
|
private void scoresLoaded(IEnumerable<APIRoomScoreInfo> scores)
|
2018-12-21 17:22:13 +08:00
|
|
|
{
|
2018-12-27 14:30:02 +08:00
|
|
|
Action<SpriteText> gray = s => s.Colour = colours.GrayC;
|
|
|
|
Action<SpriteText> white = s =>
|
|
|
|
{
|
|
|
|
s.TextSize *= 1.4f;
|
|
|
|
s.Colour = colours.GrayF;
|
|
|
|
};
|
2018-12-21 17:22:13 +08:00
|
|
|
|
2018-12-27 14:30:02 +08:00
|
|
|
rankText.AddText(room.Name + "\n", white);
|
2018-12-21 17:22:13 +08:00
|
|
|
rankText.AddText("You are placed ", gray);
|
|
|
|
|
2018-12-22 14:45:16 +08:00
|
|
|
int index = scores.IndexOf(new APIRoomScoreInfo { User = Score.User }, new FuncEqualityComparer<APIRoomScoreInfo>((s1, s2) => s1.User.Id.Equals(s2.User.Id)));
|
2018-12-21 17:22:13 +08:00
|
|
|
|
|
|
|
rankText.AddText($"#{index + 1} ", s =>
|
|
|
|
{
|
|
|
|
s.Font = "Exo2.0-Bold";
|
|
|
|
s.Colour = colours.YellowDark;
|
|
|
|
});
|
|
|
|
|
|
|
|
rankText.AddText("in the room!", gray);
|
|
|
|
}
|
2018-12-21 17:37:33 +08:00
|
|
|
|
2018-12-27 14:30:02 +08:00
|
|
|
protected virtual MatchLeaderboard CreateLeaderboard(Room room) => new ResultsMatchLeaderboard(room);
|
|
|
|
|
|
|
|
public class ResultsMatchLeaderboard : MatchLeaderboard
|
|
|
|
{
|
|
|
|
public ResultsMatchLeaderboard(Room room)
|
|
|
|
: base(room)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override LeaderboardScore CreateDrawableScore(APIRoomScoreInfo model, int index)
|
|
|
|
=> new ResultsMatchLeaderboardScore(model, index);
|
|
|
|
|
|
|
|
protected override FillFlowContainer<LeaderboardScore> CreateScoreFlow()
|
|
|
|
{
|
|
|
|
var flow = base.CreateScoreFlow();
|
|
|
|
flow.Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Top = LeaderboardScore.HEIGHT * 2,
|
|
|
|
Bottom = LeaderboardScore.HEIGHT * 3,
|
|
|
|
};
|
|
|
|
return flow;
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ResultsMatchLeaderboardScore : MatchLeaderboardScore
|
|
|
|
{
|
|
|
|
public ResultsMatchLeaderboardScore(APIRoomScoreInfo score, int rank)
|
|
|
|
: base(score, rank)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-21 17:22:13 +08:00
|
|
|
}
|
|
|
|
}
|