mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Make Rankings a ctor variable
This commit is contained in:
parent
da01f0ee5a
commit
83e3ad9e69
@ -73,11 +73,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
request = new GetCountryRankingsRequest(ruleset, page);
|
||||
((GetCountryRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new CountriesTable(page)
|
||||
{
|
||||
Rankings = rankings.Countries,
|
||||
};
|
||||
|
||||
var table = new CountriesTable(page, rankings.Countries);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
@ -91,11 +87,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
request = new GetUserRankingsRequest(ruleset, country: country, page: page);
|
||||
((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new PerformanceTable(page)
|
||||
{
|
||||
Rankings = rankings.Users,
|
||||
};
|
||||
|
||||
var table = new PerformanceTable(page, rankings.Users);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
@ -109,11 +101,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
request = new GetUserRankingsRequest(ruleset, UserRankingsType.Score, page);
|
||||
((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new ScoresTable(page)
|
||||
{
|
||||
Rankings = rankings.Users,
|
||||
};
|
||||
|
||||
var table = new ScoresTable(page, rankings.Users);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
|
@ -7,13 +7,14 @@ using System;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings.Tables
|
||||
{
|
||||
public class CountriesTable : RankingsTable<CountryStatistics>
|
||||
{
|
||||
public CountriesTable(int page = 1)
|
||||
: base(page)
|
||||
public CountriesTable(int page, IReadOnlyList<CountryStatistics> rankings)
|
||||
: base(page, rankings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Users;
|
||||
@ -9,8 +10,8 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
{
|
||||
public class PerformanceTable : UserBasedTable
|
||||
{
|
||||
public PerformanceTable(int page = 1)
|
||||
: base(page)
|
||||
public PerformanceTable(int page, IReadOnlyList<UserStatistics> rankings)
|
||||
: base(page, rankings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,9 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
private const float row_height = 25;
|
||||
private const int items_per_page = 50;
|
||||
|
||||
private readonly int page;
|
||||
private readonly FillFlowContainer backgroundFlow;
|
||||
|
||||
protected RankingsTable(int page)
|
||||
protected RankingsTable(int page, IReadOnlyList<TModel> rankings)
|
||||
{
|
||||
this.page = page;
|
||||
FillFlowContainer backgroundFlow;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
@ -42,23 +39,11 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
Depth = 1f,
|
||||
Margin = new MarginPadding { Top = row_height }
|
||||
});
|
||||
}
|
||||
|
||||
public IReadOnlyList<TModel> Rankings
|
||||
{
|
||||
set
|
||||
{
|
||||
Content = null;
|
||||
backgroundFlow.Clear();
|
||||
rankings.ForEach(_ => backgroundFlow.Add(new TableRowBackground()));
|
||||
|
||||
if (value?.Any() != true)
|
||||
return;
|
||||
|
||||
value.ForEach(_ => backgroundFlow.Add(new TableRowBackground()));
|
||||
|
||||
Columns = mainHeaders.Concat(CreateAdditionalHeaders()).ToArray();
|
||||
Content = value.Select((s, i) => createContent((page - 1) * items_per_page + i, s)).ToArray().ToRectangular();
|
||||
}
|
||||
Columns = mainHeaders.Concat(CreateAdditionalHeaders()).ToArray();
|
||||
Content = rankings.Select((s, i) => createContent((page - 1) * items_per_page + i, s)).ToArray().ToRectangular();
|
||||
}
|
||||
|
||||
private Drawable[] createContent(int index, TModel item) => new Drawable[] { createIndexDrawable(index), createMainContent(item) }.Concat(CreateAdditionalContent(item)).ToArray();
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Users;
|
||||
@ -9,8 +10,8 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
{
|
||||
public class ScoresTable : UserBasedTable
|
||||
{
|
||||
public ScoresTable(int page = 1)
|
||||
: base(page)
|
||||
public ScoresTable(int page, IReadOnlyList<UserStatistics> rankings)
|
||||
: base(page, rankings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -12,8 +13,8 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
{
|
||||
public abstract class UserBasedTable : RankingsTable<UserStatistics>
|
||||
{
|
||||
protected UserBasedTable(int page)
|
||||
: base(page)
|
||||
protected UserBasedTable(int page, IReadOnlyList<UserStatistics> rankings)
|
||||
: base(page, rankings)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user