1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 05:52:56 +08:00

Refactor API logic

This commit is contained in:
Andrei Zavatski 2019-11-27 21:56:22 +03:00
parent 2135a7fd7b
commit c546df8a80
9 changed files with 19 additions and 41 deletions

View File

@ -3,13 +3,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Users;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class GetCountriesResponse : ResponseWithCursor public class GetCountriesResponse : ResponseWithCursor
{ {
[JsonProperty("ranking")] [JsonProperty("ranking")]
public List<APICountryRankings> Countries; public List<CountryStatistics> Countries;
} }
} }

View File

@ -3,13 +3,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Users;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class GetUsersResponse : ResponseWithCursor public class GetUsersResponse : ResponseWithCursor
{ {
[JsonProperty("ranking")] [JsonProperty("ranking")]
public List<APIUserRankings> Users; public List<UserStatistics> Users;
} }
} }

View File

@ -1,14 +0,0 @@
// 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 Newtonsoft.Json;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests.Responses
{
public class APICountryRankings : CountryStatistics
{
[JsonProperty]
public Country Country;
}
}

View File

@ -1,14 +0,0 @@
// 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 Newtonsoft.Json;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIUserRankings : UserStatistics
{
[JsonProperty]
public User User;
}
}

View File

@ -7,12 +7,12 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osuTK; using osuTK;
using osu.Game.Online.API.Requests.Responses;
using System; using System;
using osu.Game.Users;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
{ {
public class CountriesTable : RankingsTable<APICountryRankings> public class CountriesTable : RankingsTable<CountryStatistics>
{ {
public CountriesTable(int page = 1) public CountriesTable(int page = 1)
: base(page) : base(page)
@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Rankings.Tables
new TableColumn("Avg. Perf.", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new TableColumn("Avg. Perf.", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
}; };
protected override Drawable[] CreateContent(int index, APICountryRankings item) => new Drawable[] protected override Drawable[] CreateContent(int index, CountryStatistics item) => new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
{ {

View File

@ -9,11 +9,11 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osuTK; using osuTK;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Users;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
{ {
public class PerformanceTable : RankingsTable<APIUserRankings> public class PerformanceTable : RankingsTable<UserStatistics>
{ {
public PerformanceTable(int page = 1) public PerformanceTable(int page = 1)
: base(page) : base(page)
@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Rankings.Tables
new TableColumn("A", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new TableColumn("A", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
}; };
protected override Drawable[] CreateContent(int index, APIUserRankings item) protected override Drawable[] CreateContent(int index, UserStatistics item)
{ {
var content = new List<Drawable> var content = new List<Drawable>
{ {

View File

@ -7,13 +7,13 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osuTK; using osuTK;
using osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Users;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
{ {
public class ScoresTable : RankingsTable<APIUserRankings> public class ScoresTable : RankingsTable<UserStatistics>
{ {
public ScoresTable(int page = 1) public ScoresTable(int page = 1)
: base(page) : base(page)
@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Rankings.Tables
new TableColumn("A", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new TableColumn("A", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
}; };
protected override Drawable[] CreateContent(int index, APIUserRankings item) protected override Drawable[] CreateContent(int index, UserStatistics item)
{ {
var content = new List<Drawable> var content = new List<Drawable>
{ {

View File

@ -7,6 +7,9 @@ namespace osu.Game.Users
{ {
public class CountryStatistics public class CountryStatistics
{ {
[JsonProperty]
public Country Country;
[JsonProperty(@"code")] [JsonProperty(@"code")]
public string FlagName; public string FlagName;

View File

@ -10,6 +10,9 @@ namespace osu.Game.Users
{ {
public class UserStatistics public class UserStatistics
{ {
[JsonProperty]
public User User;
[JsonProperty(@"level")] [JsonProperty(@"level")]
public LevelInfo Level; public LevelInfo Level;