diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs index 5501bb54d0..93da2a439e 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs @@ -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); }); diff --git a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs index b49583f0e2..a0e4f694bd 100644 --- a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs +++ b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs @@ -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 { - public CountriesTable(int page = 1) - : base(page) + public CountriesTable(int page, IReadOnlyList rankings) + : base(page, rankings) { } diff --git a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs index f604efb8d5..1e6b2307e0 100644 --- a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs +++ b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . 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 rankings) + : base(page, rankings) { } diff --git a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs index 7a20d60f6e..08d396d88e 100644 --- a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs +++ b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs @@ -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 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 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(); diff --git a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs index cc3c5ccf94..370ee506c2 100644 --- a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs +++ b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . 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 rankings) + : base(page, rankings) { } diff --git a/osu.Game/Overlays/Rankings/Tables/UserBasedTable.cs b/osu.Game/Overlays/Rankings/Tables/UserBasedTable.cs index 6ea145be9c..019a278771 100644 --- a/osu.Game/Overlays/Rankings/Tables/UserBasedTable.cs +++ b/osu.Game/Overlays/Rankings/Tables/UserBasedTable.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . 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 { - protected UserBasedTable(int page) - : base(page) + protected UserBasedTable(int page, IReadOnlyList rankings) + : base(page, rankings) { }