diff --git a/osu.Game/Database/RealmAccess.cs b/osu.Game/Database/RealmAccess.cs index bebc101b1333..c4d65f4f10e8 100644 --- a/osu.Game/Database/RealmAccess.cs +++ b/osu.Game/Database/RealmAccess.cs @@ -60,8 +60,9 @@ public class RealmAccess : IDisposable /// 14 2022-03-01 Added BeatmapUserSettings to BeatmapInfo. /// 15 2022-07-13 Added LastPlayed to BeatmapInfo. /// 16 2022-07-15 Removed HasReplay from ScoreInfo. + /// 17 2022-07-16 Added CountryCode to RealmUser. /// - private const int schema_version = 16; + private const int schema_version = 17; /// /// Lock object which is held during sections, blocking realm retrieval during blocking periods. diff --git a/osu.Game/Models/RealmUser.cs b/osu.Game/Models/RealmUser.cs index 58fd7ff2a389..e20ffc080857 100644 --- a/osu.Game/Models/RealmUser.cs +++ b/osu.Game/Models/RealmUser.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Game.Database; using osu.Game.Users; @@ -17,6 +15,16 @@ public class RealmUser : EmbeddedObject, IUser, IEquatable, IDeepClon public string Username { get; set; } = string.Empty; + [Ignored] + public CountryCode CountryCode + { + get => Enum.TryParse(CountryString, out CountryCode country) ? country : CountryCode.Unknown; + set => CountryString = value.ToString(); + } + + [MapTo(nameof(CountryCode))] + public string CountryString { get; set; } = default(CountryCode).ToString(); + public bool IsBot => false; public bool Equals(RealmUser other) diff --git a/osu.Game/Rulesets/Mods/ICreateReplayData.cs b/osu.Game/Rulesets/Mods/ICreateReplayData.cs index 6058380eb318..3ed5c2b7f868 100644 --- a/osu.Game/Rulesets/Mods/ICreateReplayData.cs +++ b/osu.Game/Rulesets/Mods/ICreateReplayData.cs @@ -58,6 +58,7 @@ public ModReplayData(Replay replay, ModCreatedUser user = null) public class ModCreatedUser : IUser { public int OnlineID => APIUser.SYSTEM_USER_ID; + public CountryCode CountryCode => default; public bool IsBot => true; public string Username { get; set; } = string.Empty; diff --git a/osu.Game/Scoring/ScoreImporter.cs b/osu.Game/Scoring/ScoreImporter.cs index 53dd511d57ab..4107c66dfe95 100644 --- a/osu.Game/Scoring/ScoreImporter.cs +++ b/osu.Game/Scoring/ScoreImporter.cs @@ -84,7 +84,7 @@ protected override void PostImport(ScoreInfo model, Realm realm) api.Perform(userRequest); if (userRequest.Response is APIUser user) - model.RealmUser.OnlineID = user.Id; + model.User = user; } } } diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index 81ca5f0300e8..d32d611a273e 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -85,8 +85,9 @@ public APIUser User { get => user ??= new APIUser { - Username = RealmUser.Username, Id = RealmUser.OnlineID, + Username = RealmUser.Username, + CountryCode = RealmUser.CountryCode, }; set { @@ -95,7 +96,8 @@ public APIUser User RealmUser = new RealmUser { OnlineID = user.OnlineID, - Username = user.Username + Username = user.Username, + CountryCode = user.CountryCode, }; } } @@ -135,6 +137,7 @@ public ScoreInfo DeepClone() { OnlineID = RealmUser.OnlineID, Username = RealmUser.Username, + CountryCode = RealmUser.CountryCode, }; return clone; diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs index 43ae0a22528f..e8414b4c1158 100644 --- a/osu.Game/Skinning/LegacyBeatmapSkin.cs +++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs @@ -96,7 +96,7 @@ private static SkinInfo createSkinInfo(BeatmapInfo beatmapInfo) => new SkinInfo { Name = beatmapInfo.ToString(), - Creator = beatmapInfo.Metadata.Author.Username ?? string.Empty + Creator = beatmapInfo.Metadata.Author.Username }; } } diff --git a/osu.Game/Users/IUser.cs b/osu.Game/Users/IUser.cs index 7a233b5d8bab..b7f545f68b6c 100644 --- a/osu.Game/Users/IUser.cs +++ b/osu.Game/Users/IUser.cs @@ -10,6 +10,8 @@ public interface IUser : IHasOnlineID, IEquatable { string Username { get; } + CountryCode CountryCode { get; } + bool IsBot { get; } bool IEquatable.Equals(IUser? other)