mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:42:54 +08:00
Merge branch 'master' into prevent-mistimed-metronome-beats
This commit is contained in:
commit
635d1d3095
@ -5,7 +5,6 @@
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -26,13 +25,13 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
FullName = { Value = "Australia" },
|
||||
Players =
|
||||
{
|
||||
new APIUser { Username = "ASecretBox" },
|
||||
new APIUser { Username = "Dereban" },
|
||||
new APIUser { Username = "mReKk" },
|
||||
new APIUser { Username = "uyghti" },
|
||||
new APIUser { Username = "Parkes" },
|
||||
new APIUser { Username = "Shiroha" },
|
||||
new APIUser { Username = "Jordan The Bear" },
|
||||
new TournamentUser { Username = "ASecretBox" },
|
||||
new TournamentUser { Username = "Dereban" },
|
||||
new TournamentUser { Username = "mReKk" },
|
||||
new TournamentUser { Username = "uyghti" },
|
||||
new TournamentUser { Username = "Parkes" },
|
||||
new TournamentUser { Username = "Shiroha" },
|
||||
new TournamentUser { Username = "Jordan The Bear" },
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
beatmap.Length = 123456;
|
||||
beatmap.BPM = 133;
|
||||
|
||||
songBar.Beatmap = beatmap;
|
||||
songBar.Beatmap = new TournamentBeatmap(beatmap);
|
||||
});
|
||||
AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
|
||||
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
@ -32,7 +33,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
private void success(APIBeatmap beatmap)
|
||||
{
|
||||
Add(new TournamentBeatmapPanel(beatmap)
|
||||
Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
|
@ -27,16 +27,16 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
Colour = "f2ca34"
|
||||
};
|
||||
|
||||
private readonly APIUser redUser = new APIUser
|
||||
private readonly TournamentUser redUser = new TournamentUser
|
||||
{
|
||||
Username = "BanchoBot",
|
||||
Id = 3,
|
||||
OnlineID = 3,
|
||||
};
|
||||
|
||||
private readonly APIUser blueUser = new APIUser
|
||||
private readonly TournamentUser blueUser = new TournamentUser
|
||||
{
|
||||
Username = "Zallius",
|
||||
Id = 4,
|
||||
OnlineID = 4,
|
||||
};
|
||||
|
||||
[Cached]
|
||||
@ -59,11 +59,11 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
Team1 =
|
||||
{
|
||||
Value = new TournamentTeam { Players = new BindableList<APIUser> { redUser } }
|
||||
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
|
||||
},
|
||||
Team2 =
|
||||
{
|
||||
Value = new TournamentTeam { Players = new BindableList<APIUser> { blueUser } }
|
||||
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser } }
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,19 +82,19 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||
{
|
||||
Sender = redUser,
|
||||
Sender = redUser.ToAPIUser(),
|
||||
Content = "I am team red."
|
||||
}));
|
||||
|
||||
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||
{
|
||||
Sender = redUser,
|
||||
Sender = redUser.ToAPIUser(),
|
||||
Content = "I plan to win!"
|
||||
}));
|
||||
|
||||
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId())
|
||||
{
|
||||
Sender = blueUser,
|
||||
Sender = blueUser.ToAPIUser(),
|
||||
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
|
||||
}));
|
||||
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
@ -53,7 +54,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
fillFlow.Add(new TournamentBeatmapPanel(beatmap, mod.Acronym)
|
||||
fillFlow.Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap), mod.Acronym)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
|
@ -9,14 +9,12 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Users;
|
||||
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
@ -123,11 +121,11 @@ namespace osu.Game.Tournament.Tests
|
||||
},
|
||||
Players =
|
||||
{
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 12 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 16 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 20 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 24 } },
|
||||
new APIUser { Username = "Hello", Statistics = new UserStatistics { GlobalRank = 30 } },
|
||||
new TournamentUser { Username = "Hello", Rank = 12 },
|
||||
new TournamentUser { Username = "Hello", Rank = 16 },
|
||||
new TournamentUser { Username = "Hello", Rank = 20 },
|
||||
new TournamentUser { Username = "Hello", Rank = 24 },
|
||||
new TournamentUser { Username = "Hello", Rank = 30 },
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -140,11 +138,11 @@ namespace osu.Game.Tournament.Tests
|
||||
FullName = { Value = "United States" },
|
||||
Players =
|
||||
{
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new APIUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
new TournamentUser { Username = "Hello" },
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -154,10 +152,10 @@ namespace osu.Game.Tournament.Tests
|
||||
}
|
||||
};
|
||||
|
||||
public static APIBeatmap CreateSampleBeatmap() =>
|
||||
new APIBeatmap
|
||||
public static TournamentBeatmap CreateSampleBeatmap() =>
|
||||
new TournamentBeatmap
|
||||
{
|
||||
BeatmapSet = new APIBeatmapSet
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Test Title",
|
||||
Artist = "Test Artist",
|
||||
|
@ -7,7 +7,6 @@ using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -56,7 +55,7 @@ namespace osu.Game.Tournament.Components
|
||||
},
|
||||
};
|
||||
|
||||
TournamentSpriteText createPlayerText(APIUser p) =>
|
||||
TournamentSpriteText createPlayerText(TournamentUser p) =>
|
||||
new TournamentSpriteText
|
||||
{
|
||||
Text = p.Username,
|
||||
|
@ -14,9 +14,9 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -24,14 +24,14 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class SongBar : CompositeDrawable
|
||||
{
|
||||
private APIBeatmap beatmap;
|
||||
private TournamentBeatmap beatmap;
|
||||
|
||||
public const float HEIGHT = 145 / 2f;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
public APIBeatmap Beatmap
|
||||
public TournamentBeatmap Beatmap
|
||||
{
|
||||
set
|
||||
{
|
||||
|
@ -14,7 +14,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class TournamentBeatmapPanel : CompositeDrawable
|
||||
{
|
||||
public readonly APIBeatmap Beatmap;
|
||||
public readonly TournamentBeatmap Beatmap;
|
||||
|
||||
private readonly string mod;
|
||||
|
||||
@ -31,7 +30,7 @@ namespace osu.Game.Tournament.Components
|
||||
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
||||
private Box flash;
|
||||
|
||||
public TournamentBeatmapPanel(APIBeatmap beatmap, string mod = null)
|
||||
public TournamentBeatmapPanel(TournamentBeatmap beatmap, string mod = null)
|
||||
{
|
||||
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
@ -61,7 +60,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(0.5f),
|
||||
OnlineInfo = Beatmap.BeatmapSet,
|
||||
OnlineInfo = Beatmap,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ namespace osu.Game.Tournament.IPC
|
||||
else
|
||||
{
|
||||
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = b;
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
|
||||
API.Queue(beatmapLookupRequest);
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.IPC
|
||||
{
|
||||
public class MatchIPCInfo : Component
|
||||
{
|
||||
public Bindable<APIBeatmap> Beatmap { get; } = new Bindable<APIBeatmap>();
|
||||
public Bindable<TournamentBeatmap> Beatmap { get; } = new Bindable<TournamentBeatmap>();
|
||||
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
|
||||
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
|
||||
public Bindable<string> ChatChannel { get; } = new Bindable<string>();
|
||||
|
@ -4,7 +4,6 @@
|
||||
#nullable disable
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -14,6 +13,6 @@ namespace osu.Game.Tournament.Models
|
||||
public string Mods;
|
||||
|
||||
[JsonProperty("BeatmapInfo")]
|
||||
public APIBeatmap Beatmap;
|
||||
public TournamentBeatmap Beatmap;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -14,7 +13,7 @@ namespace osu.Game.Tournament.Models
|
||||
public int ID;
|
||||
|
||||
[JsonProperty("BeatmapInfo")]
|
||||
public APIBeatmap Beatmap;
|
||||
public TournamentBeatmap Beatmap;
|
||||
|
||||
public long Score;
|
||||
|
||||
|
99
osu.Game.Tournament/Models/TournamentBeatmap.cs
Normal file
99
osu.Game.Tournament/Models/TournamentBeatmap.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// 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;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
public class TournamentBeatmap : IBeatmapInfo, IBeatmapSetOnlineInfo
|
||||
{
|
||||
public int OnlineID { get; set; }
|
||||
|
||||
public string DifficultyName { get; set; } = string.Empty;
|
||||
|
||||
public double BPM { get; set; }
|
||||
|
||||
public double Length { get; set; }
|
||||
|
||||
public double StarRating { get; set; }
|
||||
|
||||
public IBeatmapMetadataInfo Metadata { get; set; } = new BeatmapMetadata();
|
||||
|
||||
public IBeatmapDifficultyInfo Difficulty { get; set; } = new BeatmapDifficulty();
|
||||
|
||||
public BeatmapSetOnlineCovers Covers { get; set; }
|
||||
|
||||
public TournamentBeatmap()
|
||||
{
|
||||
}
|
||||
|
||||
public TournamentBeatmap(APIBeatmap beatmap)
|
||||
{
|
||||
OnlineID = beatmap.OnlineID;
|
||||
DifficultyName = beatmap.DifficultyName;
|
||||
BPM = beatmap.BPM;
|
||||
Length = beatmap.Length;
|
||||
StarRating = beatmap.StarRating;
|
||||
Metadata = beatmap.Metadata;
|
||||
Difficulty = beatmap.Difficulty;
|
||||
Covers = beatmap.BeatmapSet.AsNonNull().Covers;
|
||||
}
|
||||
|
||||
public bool Equals(IBeatmapInfo? other) => other is TournamentBeatmap b && this.MatchesOnlineID(b);
|
||||
|
||||
#region IBeatmapInfo/IBeatmapSetOnlineInfo explicit implementation
|
||||
|
||||
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => throw new NotImplementedException();
|
||||
|
||||
string IBeatmapSetOnlineInfo.Preview => throw new NotImplementedException();
|
||||
|
||||
double IBeatmapSetOnlineInfo.BPM => throw new NotImplementedException();
|
||||
|
||||
int IBeatmapSetOnlineInfo.PlayCount => throw new NotImplementedException();
|
||||
|
||||
int IBeatmapSetOnlineInfo.FavouriteCount => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasFavourited => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetOnlineAvailability IBeatmapSetOnlineInfo.Availability => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetOnlineGenre IBeatmapSetOnlineInfo.Genre => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetOnlineLanguage IBeatmapSetOnlineInfo.Language => throw new NotImplementedException();
|
||||
|
||||
int? IBeatmapSetOnlineInfo.TrackId => throw new NotImplementedException();
|
||||
|
||||
int[] IBeatmapSetOnlineInfo.Ratings => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetHypeStatus IBeatmapSetOnlineInfo.HypeStatus => throw new NotImplementedException();
|
||||
|
||||
BeatmapSetNominationStatus IBeatmapSetOnlineInfo.NominationStatus => throw new NotImplementedException();
|
||||
|
||||
string IBeatmapInfo.Hash => throw new NotImplementedException();
|
||||
|
||||
string IBeatmapInfo.MD5Hash => throw new NotImplementedException();
|
||||
|
||||
IRulesetInfo IBeatmapInfo.Ruleset => throw new NotImplementedException();
|
||||
|
||||
DateTimeOffset IBeatmapSetOnlineInfo.Submitted => throw new NotImplementedException();
|
||||
|
||||
DateTimeOffset? IBeatmapSetOnlineInfo.Ranked => throw new NotImplementedException();
|
||||
|
||||
DateTimeOffset? IBeatmapSetOnlineInfo.LastUpdated => throw new NotImplementedException();
|
||||
|
||||
BeatmapOnlineStatus IBeatmapSetOnlineInfo.Status => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasExplicitContent => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasVideo => throw new NotImplementedException();
|
||||
|
||||
bool IBeatmapSetOnlineInfo.HasStoryboard => throw new NotImplementedException();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ using System;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -38,7 +37,7 @@ namespace osu.Game.Tournament.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
int[] ranks = Players.Select(p => p.Statistics?.GlobalRank)
|
||||
int[] ranks = Players.Select(p => p.Rank)
|
||||
.Where(i => i.HasValue)
|
||||
.Select(i => i.Value)
|
||||
.ToArray();
|
||||
@ -59,7 +58,7 @@ namespace osu.Game.Tournament.Models
|
||||
};
|
||||
|
||||
[JsonProperty]
|
||||
public BindableList<APIUser> Players { get; set; } = new BindableList<APIUser>();
|
||||
public BindableList<TournamentUser> Players { get; set; } = new BindableList<TournamentUser>();
|
||||
|
||||
public TournamentTeam()
|
||||
{
|
||||
|
58
osu.Game.Tournament/Models/TournamentUser.cs
Normal file
58
osu.Game.Tournament/Models/TournamentUser.cs
Normal file
@ -0,0 +1,58 @@
|
||||
// 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;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A tournament player user, containing simple information about the player.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TournamentUser : IUser
|
||||
{
|
||||
[JsonProperty(@"id")]
|
||||
public int OnlineID { get; set; }
|
||||
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The player's country.
|
||||
/// </summary>
|
||||
public Country? Country { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The player's global rank, or null if not available.
|
||||
/// </summary>
|
||||
public int? Rank { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A URL to the player's profile cover.
|
||||
/// </summary>
|
||||
public string CoverUrl { get; set; } = string.Empty;
|
||||
|
||||
public APIUser ToAPIUser()
|
||||
{
|
||||
var user = new APIUser
|
||||
{
|
||||
Id = OnlineID,
|
||||
Username = Username,
|
||||
Country = Country,
|
||||
CoverUrl = CoverUrl,
|
||||
};
|
||||
|
||||
user.Statistics = new UserStatistics
|
||||
{
|
||||
User = user,
|
||||
GlobalRank = Rank
|
||||
};
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
bool IUser.IsBot => false;
|
||||
}
|
||||
}
|
@ -7,9 +7,9 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Screens
|
||||
{
|
||||
@ -39,7 +39,7 @@ namespace osu.Game.Tournament.Screens
|
||||
SongBar.Mods = mods.NewValue;
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
|
||||
{
|
||||
SongBar.FadeInFromZero(300, Easing.OutQuint);
|
||||
SongBar.Beatmap = beatmap.NewValue;
|
||||
|
@ -239,7 +239,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
req.Success += res =>
|
||||
{
|
||||
Model.Beatmap = res;
|
||||
Model.Beatmap = new TournamentBeatmap(res);
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
|
@ -241,7 +241,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
req.Success += res =>
|
||||
{
|
||||
Model.Beatmap = res;
|
||||
Model.Beatmap = new TournamentBeatmap(res);
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -202,14 +201,14 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
public void CreateNew()
|
||||
{
|
||||
var user = new APIUser();
|
||||
team.Players.Add(user);
|
||||
flow.Add(new PlayerRow(team, user));
|
||||
var player = new TournamentUser();
|
||||
team.Players.Add(player);
|
||||
flow.Add(new PlayerRow(team, player));
|
||||
}
|
||||
|
||||
public class PlayerRow : CompositeDrawable
|
||||
{
|
||||
private readonly APIUser user;
|
||||
private readonly TournamentUser user;
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; }
|
||||
@ -217,11 +216,11 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[Resolved]
|
||||
private TournamentGameBase game { get; set; }
|
||||
|
||||
private readonly Bindable<int?> userId = new Bindable<int?>();
|
||||
private readonly Bindable<int?> playerId = new Bindable<int?>();
|
||||
|
||||
private readonly Container drawableContainer;
|
||||
|
||||
public PlayerRow(TournamentTeam team, APIUser user)
|
||||
public PlayerRow(TournamentTeam team, TournamentUser user)
|
||||
{
|
||||
this.user = user;
|
||||
|
||||
@ -254,7 +253,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
LabelText = "User ID",
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 200,
|
||||
Current = userId,
|
||||
Current = playerId,
|
||||
},
|
||||
drawableContainer = new Container
|
||||
{
|
||||
@ -281,10 +280,10 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
userId.Value = user.Id;
|
||||
userId.BindValueChanged(id =>
|
||||
playerId.Value = user.OnlineID;
|
||||
playerId.BindValueChanged(id =>
|
||||
{
|
||||
user.Id = id.NewValue ?? 0;
|
||||
user.OnlineID = id.NewValue ?? 0;
|
||||
|
||||
if (id.NewValue != id.OldValue)
|
||||
user.Username = string.Empty;
|
||||
@ -295,13 +294,13 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
return;
|
||||
}
|
||||
|
||||
game.PopulateUser(user, updatePanel, updatePanel);
|
||||
game.PopulatePlayer(user, updatePanel, updatePanel);
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void updatePanel()
|
||||
{
|
||||
drawableContainer.Child = new UserGridPanel(user) { Width = 300 };
|
||||
drawableContainer.Child = new UserGridPanel(user.ToAPIUser()) { Width = 300 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -107,7 +106,7 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
ipc.Beatmap.BindValueChanged(beatmapChanged);
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
|
||||
{
|
||||
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
|
||||
return;
|
||||
|
@ -257,7 +257,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
||||
};
|
||||
|
||||
foreach (var p in team.Players)
|
||||
fill.Add(new RowDisplay(p.Username, p.Statistics?.GlobalRank?.ToString("\\##,0") ?? "-"));
|
||||
fill.Add(new RowDisplay(p.Username, p.Rank?.ToString("\\##,0") ?? "-"));
|
||||
}
|
||||
|
||||
internal class RowDisplay : CompositeDrawable
|
||||
|
@ -22,7 +22,6 @@ using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Input;
|
||||
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tournament
|
||||
{
|
||||
@ -187,9 +186,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
var playersRequiringPopulation = ladder.Teams
|
||||
.SelectMany(t => t.Players)
|
||||
.Where(p => string.IsNullOrEmpty(p.Username)
|
||||
|| p.Statistics?.GlobalRank == null
|
||||
|| p.Statistics?.CountryRank == null).ToList();
|
||||
.Where(p => string.IsNullOrEmpty(p.Username) || p.Rank == null).ToList();
|
||||
|
||||
if (playersRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -197,7 +194,7 @@ namespace osu.Game.Tournament
|
||||
for (int i = 0; i < playersRequiringPopulation.Count; i++)
|
||||
{
|
||||
var p = playersRequiringPopulation[i];
|
||||
PopulateUser(p, immediate: true);
|
||||
PopulatePlayer(p, immediate: true);
|
||||
updateLoadProgressMessage($"Populating user stats ({i} / {playersRequiringPopulation.Count})");
|
||||
}
|
||||
|
||||
@ -211,7 +208,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
var beatmapsRequiringPopulation = ladder.Rounds
|
||||
.SelectMany(r => r.Beatmaps)
|
||||
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList();
|
||||
.Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
|
||||
|
||||
if (beatmapsRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -222,7 +219,7 @@ namespace osu.Game.Tournament
|
||||
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
|
||||
API.Perform(req);
|
||||
b.Beatmap = req.Response ?? new APIBeatmap();
|
||||
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
|
||||
|
||||
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
|
||||
}
|
||||
@ -238,7 +235,7 @@ namespace osu.Game.Tournament
|
||||
var beatmapsRequiringPopulation = ladder.Teams
|
||||
.SelectMany(r => r.SeedingResults)
|
||||
.SelectMany(r => r.Beatmaps)
|
||||
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList();
|
||||
.Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
|
||||
|
||||
if (beatmapsRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -249,7 +246,7 @@ namespace osu.Game.Tournament
|
||||
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
|
||||
API.Perform(req);
|
||||
b.Beatmap = req.Response ?? new APIBeatmap();
|
||||
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
|
||||
|
||||
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
|
||||
}
|
||||
@ -259,9 +256,9 @@ namespace osu.Game.Tournament
|
||||
|
||||
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
|
||||
|
||||
public void PopulateUser(APIUser user, Action success = null, Action failure = null, bool immediate = false)
|
||||
public void PopulatePlayer(TournamentUser user, Action success = null, Action failure = null, bool immediate = false)
|
||||
{
|
||||
var req = new GetUserRequest(user.Id, ladder.Ruleset.Value);
|
||||
var req = new GetUserRequest(user.OnlineID, ladder.Ruleset.Value);
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
@ -273,7 +270,7 @@ namespace osu.Game.Tournament
|
||||
req.Success += res => { populate(); };
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
user.OnlineID = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
@ -287,12 +284,12 @@ namespace osu.Game.Tournament
|
||||
if (res == null)
|
||||
return;
|
||||
|
||||
user.Id = res.Id;
|
||||
user.OnlineID = res.Id;
|
||||
|
||||
user.Username = res.Username;
|
||||
user.Statistics = res.Statistics;
|
||||
user.CoverUrl = res.CoverUrl;
|
||||
user.Country = res.Country;
|
||||
user.Cover = res.Cover;
|
||||
user.Rank = res.Statistics?.GlobalRank;
|
||||
|
||||
success?.Invoke();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user