1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 20:05:29 +08:00

Seed the results screen

This commit is contained in:
smoogipoo 2018-12-21 18:37:33 +09:00
parent 4149734f89
commit 7e9cc4e876
3 changed files with 98 additions and 22 deletions

View File

@ -3,13 +3,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Screens.Multi.Ranking; using osu.Game.Screens.Multi.Ranking;
using osu.Game.Screens.Multi.Ranking.Pages; using osu.Game.Screens.Multi.Ranking.Pages;
using osu.Game.Screens.Multi.Ranking.Types; using osu.Game.Screens.Multi.Ranking.Types;
using osu.Game.Screens.Ranking.Pages;
using osu.Game.Screens.Ranking.Types;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -33,15 +38,87 @@ namespace osu.Game.Tests.Visual
if (beatmapInfo != null) if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo); Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
MultiResults res; Child = new TestMultiResults(new ScoreInfo
{
User = new User { Id = 10 },
});
}
Child = res = new MultiResults(new ScoreInfo private class TestMultiResults : MultiResults
{ {
User = new User private readonly Room room;
public TestMultiResults(ScoreInfo score)
: this(score, new Room())
{ {
Id = 9623649 }
},
}, new Room { RoomID = { Value = 46 } }); public TestMultiResults(ScoreInfo score, Room room)
: base(score, room)
{
this.room = room;
}
protected override IEnumerable<IResultType> CreateResultTypes() => new IResultType[]
{
new ScoreResultType(Score, Beatmap),
new RankingResultType(Score, Beatmap),
new TestRoomRankingResultType(Score, Beatmap, room),
};
}
private class TestRoomRankingResultType : RoomRankingResultType
{
private readonly ScoreInfo score;
private readonly WorkingBeatmap beatmap;
private readonly Room room;
public TestRoomRankingResultType(ScoreInfo score, WorkingBeatmap beatmap, Room room)
: base(score, beatmap, room)
{
this.score = score;
this.beatmap = beatmap;
this.room = room;
}
public override ResultsPage CreatePage() => new TestRoomRankingResultsPage(score, beatmap, room);
}
private class TestRoomRankingResultsPage : RoomRankingResultsPage
{
public TestRoomRankingResultsPage(ScoreInfo score, WorkingBeatmap beatmap, Room room)
: base(score, beatmap, room)
{
}
protected override MatchLeaderboard CreateLeaderboard(Room room) => new TestMatchLeaderboard(room);
}
private class TestMatchLeaderboard : MatchLeaderboard
{
public TestMatchLeaderboard(Room room)
: base(room)
{
}
protected override APIRequest FetchScores(Action<IEnumerable<RoomScore>> scoresCallback)
{
var scores = Enumerable.Range(0, 50).Select(createRoomScore).ToArray();
scoresCallback?.Invoke(scores);
ScoresLoaded?.Invoke(scores);
return null;
}
private RoomScore createRoomScore(int id) => new RoomScore
{
User = new User { Id = id, Username = $"User {id}" },
Accuracy = 0.98,
TotalScore = 987654,
TotalAttempts = 13,
CompletedAttempts = 5
};
} }
} }
} }

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Lists; using osu.Framework.Lists;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.Leaderboards;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Match.Components;
@ -39,6 +38,8 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
{ {
this.colours = colours; this.colours = colours;
MatchLeaderboard leaderboard;
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -50,18 +51,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
BackgroundColour = colours.GrayE, BackgroundColour = colours.GrayE,
Children = new Drawable[] Child = leaderboard = CreateLeaderboard(room)
{
new MatchLeaderboard(room)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Height = 0.8f,
Y = 95,
ScoresLoaded = scoresLoaded
}
}
}, },
rankText = new TextFlowContainer rankText = new TextFlowContainer
{ {
@ -74,6 +64,13 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
TextAnchor = Anchor.TopCentre TextAnchor = Anchor.TopCentre
}, },
}; };
leaderboard.Origin = Anchor.Centre;
leaderboard.Anchor = Anchor.Centre;
leaderboard.RelativeSizeAxes = Axes.Both;
leaderboard.Height = 0.8f;
leaderboard.Y = 95;
leaderboard.ScoresLoaded = scoresLoaded;
} }
private void scoresLoaded(IEnumerable<RoomScore> scores) private void scoresLoaded(IEnumerable<RoomScore> scores)
@ -92,5 +89,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
rankText.AddText("in the room!", gray); rankText.AddText("in the room!", gray);
} }
protected virtual MatchLeaderboard CreateLeaderboard(Room room) => new MatchLeaderboard(room);
} }
} }

View File

@ -26,6 +26,6 @@ namespace osu.Game.Screens.Multi.Ranking.Types
public FontAwesome Icon => FontAwesome.fa_list; public FontAwesome Icon => FontAwesome.fa_list;
public ResultsPage CreatePage() => new RoomRankingResultsPage(score, beatmap, room); public virtual ResultsPage CreatePage() => new RoomRankingResultsPage(score, beatmap, room);
} }
} }