mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09:00
Populate users centrally, using the correct ruleset
This commit is contained in:
parent
702a1c496b
commit
5d96e6d90a
@ -12,7 +12,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Tournament.Components;
|
using osu.Game.Tournament.Components;
|
||||||
using osu.Game.Tournament.Models;
|
using osu.Game.Tournament.Models;
|
||||||
@ -24,7 +23,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
public class TeamEditorScreen : TournamentEditorScreen<TeamEditorScreen.TeamRow, TournamentTeam>
|
public class TeamEditorScreen : TournamentEditorScreen<TeamEditorScreen.TeamRow, TournamentTeam>
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Framework.Game game { get; set; }
|
private TournamentGameBase game { get; set; }
|
||||||
|
|
||||||
protected override BindableList<TournamentTeam> Storage => LadderInfo.Teams;
|
protected override BindableList<TournamentTeam> Storage => LadderInfo.Teams;
|
||||||
|
|
||||||
@ -198,6 +197,9 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected IAPIProvider API { get; private set; }
|
protected IAPIProvider API { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private TournamentGameBase game { get; set; }
|
||||||
|
|
||||||
private readonly Bindable<string> userId = new Bindable<string>();
|
private readonly Bindable<string> userId = new Bindable<string>();
|
||||||
|
|
||||||
private readonly Container drawableContainer;
|
private readonly Container drawableContainer;
|
||||||
@ -280,25 +282,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var req = new GetUserRequest(user.Id);
|
game.PopulateUser(user, updatePanel, updatePanel);
|
||||||
|
|
||||||
req.Success += res =>
|
|
||||||
{
|
|
||||||
// TODO: this should be done in a better way.
|
|
||||||
user.Username = res.Username;
|
|
||||||
user.Country = res.Country;
|
|
||||||
user.Cover = res.Cover;
|
|
||||||
|
|
||||||
updatePanel();
|
|
||||||
};
|
|
||||||
|
|
||||||
req.Failure += _ =>
|
|
||||||
{
|
|
||||||
user.Id = 1;
|
|
||||||
updatePanel();
|
|
||||||
};
|
|
||||||
|
|
||||||
API.Queue(req);
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -21,11 +22,13 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Tournament.IPC;
|
using osu.Game.Tournament.IPC;
|
||||||
using osu.Game.Tournament.Models;
|
using osu.Game.Tournament.Models;
|
||||||
|
using osu.Game.Users;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tournament
|
namespace osu.Game.Tournament
|
||||||
{
|
{
|
||||||
|
[Cached(typeof(TournamentGameBase))]
|
||||||
public abstract class TournamentGameBase : OsuGameBase
|
public abstract class TournamentGameBase : OsuGameBase
|
||||||
{
|
{
|
||||||
private const string bracket_filename = "bracket.json";
|
private const string bracket_filename = "bracket.json";
|
||||||
@ -197,10 +200,7 @@ namespace osu.Game.Tournament
|
|||||||
foreach (var p in t.Players)
|
foreach (var p in t.Players)
|
||||||
if (string.IsNullOrEmpty(p.Username))
|
if (string.IsNullOrEmpty(p.Username))
|
||||||
{
|
{
|
||||||
var req = new GetUserRequest(p.Id);
|
PopulateUser(p);
|
||||||
req.Perform(API);
|
|
||||||
p.Username = req.Result.Username;
|
|
||||||
|
|
||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +228,30 @@ namespace osu.Game.Tournament
|
|||||||
return addedInfo;
|
return addedInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PopulateUser(User user, Action success = null, Action failure = null)
|
||||||
|
{
|
||||||
|
var req = new GetUserRequest(user.Id, Ruleset.Value);
|
||||||
|
|
||||||
|
req.Success += res =>
|
||||||
|
{
|
||||||
|
user.Username = res.Username;
|
||||||
|
user.Statistics = res.Statistics;
|
||||||
|
user.Username = res.Username;
|
||||||
|
user.Country = res.Country;
|
||||||
|
user.Cover = res.Cover;
|
||||||
|
|
||||||
|
success?.Invoke();
|
||||||
|
};
|
||||||
|
|
||||||
|
req.Failure += _ =>
|
||||||
|
{
|
||||||
|
user.Id = 1;
|
||||||
|
failure?.Invoke();
|
||||||
|
};
|
||||||
|
|
||||||
|
API.Queue(req);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
MenuCursorContainer.Cursor.AlwaysPresent = true; // required for tooltip display
|
MenuCursorContainer.Cursor.AlwaysPresent = true; // required for tooltip display
|
||||||
|
Loading…
x
Reference in New Issue
Block a user