Merge pull request #7047 from peppy/decouple-legacy-score-info

Decouple LegacyScoreInfo/APILegacyScoreInfo from ScoreInfo
This commit is contained in:
Dan Balasescu 2019-12-04 12:24:32 +09:00 committed by GitHub
commit 8dbb46d083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 302 additions and 269 deletions

View File

@ -34,12 +34,10 @@ namespace osu.Game.Rulesets.Catch.Difficulty
{ {
mods = Score.Mods; mods = Score.Mods;
var legacyScore = Score as LegacyScoreInfo; fruitsHit = Score?.GetCount300() ?? Score.Statistics[HitResult.Perfect];
ticksHit = Score?.GetCount100() ?? 0;
fruitsHit = legacyScore?.Count300 ?? Score.Statistics[HitResult.Perfect]; tinyTicksHit = Score?.GetCount50() ?? 0;
ticksHit = legacyScore?.Count100 ?? 0; tinyTicksMissed = Score?.GetCountKatu() ?? 0;
tinyTicksHit = legacyScore?.Count50 ?? 0;
tinyTicksMissed = legacyScore?.CountKatu ?? 0;
misses = Score.Statistics[HitResult.Miss]; misses = Score.Statistics[HitResult.Miss];
// Don't count scores made with supposedly unranked mods // Don't count scores made with supposedly unranked mods

View File

@ -5,11 +5,12 @@ using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Osu;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Users; using osu.Game.Users;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Rulesets;
using osu.Game.Screens.Ranking.Pages; using osu.Game.Screens.Ranking.Pages;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
@ -17,6 +18,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[TestFixture] [TestFixture]
public class TestSceneReplayDownloadButton : OsuTestScene public class TestSceneReplayDownloadButton : OsuTestScene
{ {
[Resolved]
private RulesetStore rulesets { get; set; }
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(ReplayDownloadButton) typeof(ReplayDownloadButton)
@ -49,16 +53,15 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
return new APILegacyScoreInfo return new APILegacyScoreInfo
{ {
ID = 1,
OnlineScoreID = 2553163309, OnlineScoreID = 2553163309,
Ruleset = new OsuRuleset().RulesetInfo, OnlineRulesetID = 0,
Replay = replayAvailable, Replay = replayAvailable,
User = new User User = new User
{ {
Id = 39828, Id = 39828,
Username = @"WubWoofWolf", Username = @"WubWoofWolf",
} }
}; }.CreateScoreInfo(rulesets);
} }
private class TestReplayDownloadButton : ReplayDownloadButton private class TestReplayDownloadButton : ReplayDownloadButton

View File

@ -1,4 +1,4 @@
// 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;
@ -9,9 +9,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Users; using osu.Game.Users;
using osuTK.Graphics; using osuTK.Graphics;
@ -66,12 +64,12 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"ES", FlagName = @"ES",
}, },
}, },
Mods = new Mod[] Mods = new[]
{ {
new OsuModDoubleTime(), new OsuModDoubleTime().Acronym,
new OsuModHidden(), new OsuModHidden().Acronym,
new OsuModFlashlight(), new OsuModFlashlight().Acronym,
new OsuModHardRock(), new OsuModHardRock().Acronym,
}, },
Rank = ScoreRank.XH, Rank = ScoreRank.XH,
PP = 200, PP = 200,
@ -91,11 +89,11 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"BR", FlagName = @"BR",
}, },
}, },
Mods = new Mod[] Mods = new[]
{ {
new OsuModDoubleTime(), new OsuModDoubleTime().Acronym,
new OsuModHidden(), new OsuModHidden().Acronym,
new OsuModFlashlight(), new OsuModFlashlight().Acronym,
}, },
Rank = ScoreRank.S, Rank = ScoreRank.S,
PP = 190, PP = 190,
@ -115,10 +113,10 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"JP", FlagName = @"JP",
}, },
}, },
Mods = new Mod[] Mods = new[]
{ {
new OsuModDoubleTime(), new OsuModDoubleTime().Acronym,
new OsuModHidden(), new OsuModHidden().Acronym,
}, },
Rank = ScoreRank.B, Rank = ScoreRank.B,
PP = 180, PP = 180,
@ -138,9 +136,9 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"CA", FlagName = @"CA",
}, },
}, },
Mods = new Mod[] Mods = new[]
{ {
new OsuModDoubleTime(), new OsuModDoubleTime().Acronym,
}, },
Rank = ScoreRank.C, Rank = ScoreRank.C,
PP = 170, PP = 170,
@ -208,12 +206,12 @@ namespace osu.Game.Tests.Visual.Online
FlagName = @"ES", FlagName = @"ES",
}, },
}, },
Mods = new Mod[] Mods = new[]
{ {
new OsuModDoubleTime(), new OsuModDoubleTime().Acronym,
new OsuModHidden(), new OsuModHidden().Acronym,
new OsuModFlashlight(), new OsuModFlashlight().Acronym,
new OsuModHardRock(), new OsuModHardRock().Acronym,
}, },
Rank = ScoreRank.XH, Rank = ScoreRank.XH,
PP = 200, PP = 200,
@ -226,10 +224,13 @@ namespace osu.Game.Tests.Visual.Online
foreach (var s in allScores.Scores) foreach (var s in allScores.Scores)
{ {
s.Statistics.Add(HitResult.Great, RNG.Next(2000)); s.Statistics = new Dictionary<string, int>
s.Statistics.Add(HitResult.Good, RNG.Next(2000)); {
s.Statistics.Add(HitResult.Meh, RNG.Next(2000)); { "count_300", RNG.Next(2000) },
s.Statistics.Add(HitResult.Miss, RNG.Next(2000)); { "count_100", RNG.Next(2000) },
{ "count_50", RNG.Next(2000) },
{ "count_miss", RNG.Next(2000) }
};
} }
AddStep("Load all scores", () => AddStep("Load all scores", () =>

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
@ -62,7 +61,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1, Accuracy = 1,
MaxCombo = 244, MaxCombo = 244,
TotalScore = 1707827, TotalScore = 1707827,
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User User = new User
{ {
Id = 6602580, Id = 6602580,

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics.Shapes;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users; using osu.Game.Users;
@ -52,7 +51,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Accuracy = 1, Accuracy = 1,
MaxCombo = 244, MaxCombo = 244,
TotalScore = 1707827, TotalScore = 1707827,
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, Mods = new[] { new OsuModHidden().Acronym, new OsuModHardRock().Acronym, },
User = new User User = new User
{ {
Id = 6602580, Id = 6602580,

View File

@ -9,6 +9,7 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
@ -37,10 +38,12 @@ namespace osu.Game.Online.API.Requests
private void onSuccess(APILegacyScores r) private void onSuccess(APILegacyScores r)
{ {
Debug.Assert(ruleset.ID != null, "ruleset.ID != null");
foreach (APILegacyScoreInfo score in r.Scores) foreach (APILegacyScoreInfo score in r.Scores)
{ {
score.Beatmap = beatmap; score.Beatmap = beatmap;
score.Ruleset = ruleset; score.OnlineRulesetID = ruleset.ID.Value;
} }
var userScore = r.UserScore; var userScore = r.UserScore;
@ -48,7 +51,7 @@ namespace osu.Game.Online.API.Requests
if (userScore != null) if (userScore != null)
{ {
userScore.Score.Beatmap = beatmap; userScore.Score.Beatmap = beatmap;
userScore.Score.Ruleset = ruleset; userScore.Score.OnlineRulesetID = ruleset.ID.Value;
} }
} }

View File

@ -5,56 +5,106 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy; using osu.Game.Scoring.Legacy;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Online.API.Requests.Responses namespace osu.Game.Online.API.Requests.Responses
{ {
public class APILegacyScoreInfo : LegacyScoreInfo public class APILegacyScoreInfo
{ {
[JsonProperty(@"score")] public ScoreInfo CreateScoreInfo(RulesetStore rulesets)
private int totalScore
{ {
set => TotalScore = value; var ruleset = rulesets.GetRuleset(OnlineRulesetID);
var mods = Mods != null ? ruleset.CreateInstance().GetAllMods().Where(mod => Mods.Contains(mod.Acronym)).ToArray() : Array.Empty<Mod>();
var scoreInfo = new ScoreInfo
{
TotalScore = TotalScore,
MaxCombo = MaxCombo,
User = User,
Accuracy = Accuracy,
OnlineScoreID = OnlineScoreID,
Date = Date,
PP = PP,
Beatmap = Beatmap,
RulesetID = OnlineRulesetID,
Hash = "online", // todo: temporary?
Rank = Rank,
Ruleset = ruleset,
Mods = mods,
};
if (Statistics != null)
{
foreach (var kvp in Statistics)
{
switch (kvp.Key)
{
case @"count_geki":
scoreInfo.SetCountGeki(kvp.Value);
break;
case @"count_300":
scoreInfo.SetCount300(kvp.Value);
break;
case @"count_katu":
scoreInfo.SetCountKatu(kvp.Value);
break;
case @"count_100":
scoreInfo.SetCount100(kvp.Value);
break;
case @"count_50":
scoreInfo.SetCount50(kvp.Value);
break;
case @"count_miss":
scoreInfo.SetCountMiss(kvp.Value);
break;
}
}
}
return scoreInfo;
} }
[JsonProperty(@"score")]
public int TotalScore { get; set; }
[JsonProperty(@"max_combo")] [JsonProperty(@"max_combo")]
private int maxCombo public int MaxCombo { get; set; }
{
set => MaxCombo = value;
}
[JsonProperty(@"user")] [JsonProperty(@"user")]
private User user public User User { get; set; }
{
set => User = value;
}
[JsonProperty(@"id")] [JsonProperty(@"id")]
private long onlineScoreID public long OnlineScoreID { get; set; }
{
set => OnlineScoreID = value;
}
[JsonProperty(@"replay")] [JsonProperty(@"replay")]
public bool Replay { get; set; } public bool Replay { get; set; }
[JsonProperty(@"created_at")] [JsonProperty(@"created_at")]
private DateTimeOffset date public DateTimeOffset Date { get; set; }
{
set => Date = value;
}
[JsonProperty(@"beatmap")] [JsonProperty(@"beatmap")]
private BeatmapInfo beatmap public BeatmapInfo Beatmap { get; set; }
{
set => Beatmap = value; [JsonProperty("accuracy")]
} public double Accuracy { get; set; }
[JsonProperty(@"pp")]
public double? PP { get; set; }
[JsonProperty(@"beatmapset")] [JsonProperty(@"beatmapset")]
private BeatmapMetadata metadata public BeatmapMetadata Metadata
{ {
set set
{ {
@ -67,68 +117,16 @@ namespace osu.Game.Online.API.Requests.Responses
} }
[JsonProperty(@"statistics")] [JsonProperty(@"statistics")]
private Dictionary<string, int> jsonStats public Dictionary<string, int> Statistics { get; set; }
{
set
{
foreach (var kvp in value)
{
switch (kvp.Key)
{
case @"count_geki":
CountGeki = kvp.Value;
break;
case @"count_300":
Count300 = kvp.Value;
break;
case @"count_katu":
CountKatu = kvp.Value;
break;
case @"count_100":
Count100 = kvp.Value;
break;
case @"count_50":
Count50 = kvp.Value;
break;
case @"count_miss":
CountMiss = kvp.Value;
break;
default:
continue;
}
}
}
}
[JsonProperty(@"mode_int")] [JsonProperty(@"mode_int")]
public int OnlineRulesetID public int OnlineRulesetID { get; set; }
{
get => RulesetID;
set => RulesetID = value;
}
[JsonProperty(@"mods")] [JsonProperty(@"mods")]
private string[] modStrings { get; set; } public string[] Mods { get; set; }
public override RulesetInfo Ruleset [JsonProperty("rank")]
{ [JsonConverter(typeof(StringEnumConverter))]
get => base.Ruleset; public ScoreRank Rank { get; set; }
set
{
base.Ruleset = value;
if (modStrings != null)
{
// Evaluate the mod string
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.Acronym)).ToArray();
}
}
}
} }
} }

View File

@ -41,6 +41,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
[Resolved]
private RulesetStore rulesets { get; set; }
private GetScoresRequest getScoresRequest; private GetScoresRequest getScoresRequest;
protected APILegacyScores Scores protected APILegacyScores Scores
@ -56,16 +59,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
return; return;
} }
scoreTable.Scores = value.Scores; var scoreInfos = value.Scores.Select(s => s.CreateScoreInfo(rulesets)).ToList();
scoreTable.Scores = scoreInfos;
scoreTable.Show(); scoreTable.Show();
var topScore = value.Scores.First(); var topScore = scoreInfos.First();
var userScore = value.UserScore; var userScore = value.UserScore;
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets);
topScoresContainer.Add(new DrawableTopScore(topScore)); topScoresContainer.Add(new DrawableTopScore(topScore));
if (userScore != null && userScore.Score.OnlineScoreID != topScore.OnlineScoreID) if (userScoreInfo != null && userScoreInfo.OnlineScoreID != topScore.OnlineScoreID)
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position)); topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position));
}); });
} }

View File

@ -29,14 +29,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
ItemsContainer.Direction = FillDirection.Vertical; ItemsContainer.Direction = FillDirection.Vertical;
} }
protected override void UpdateItems(List<APILegacyScoreInfo> items)
{
foreach (var item in items)
item.Ruleset = Rulesets.GetRuleset(item.RulesetID);
base.UpdateItems(items);
}
protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest() => protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest() =>
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
@ -45,10 +37,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
switch (type) switch (type)
{ {
default: default:
return new DrawablePerformanceScore(model, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null); return new DrawablePerformanceScore(model.CreateScoreInfo(Rulesets), includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null);
case ScoreType.Recent: case ScoreType.Recent:
return new DrawableTotalScore(model); return new DrawableTotalScore(model.CreateScoreInfo(Rulesets));
} }
} }
} }

View File

@ -1,118 +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 osu.Game.Rulesets.Scoring;
namespace osu.Game.Scoring.Legacy
{
public class LegacyScoreInfo : ScoreInfo
{
private int countGeki;
public int CountGeki
{
get => countGeki;
set
{
countGeki = value;
switch (Ruleset?.ID ?? RulesetID)
{
case 3:
Statistics[HitResult.Perfect] = value;
break;
}
}
}
private int count300;
public int Count300
{
get => count300;
set
{
count300 = value;
switch (Ruleset?.ID ?? RulesetID)
{
case 0:
case 1:
case 3:
Statistics[HitResult.Great] = value;
break;
case 2:
Statistics[HitResult.Perfect] = value;
break;
}
}
}
private int countKatu;
public int CountKatu
{
get => countKatu;
set
{
countKatu = value;
switch (Ruleset?.ID ?? RulesetID)
{
case 3:
Statistics[HitResult.Good] = value;
break;
}
}
}
private int count100;
public int Count100
{
get => count100;
set
{
count100 = value;
switch (Ruleset?.ID ?? RulesetID)
{
case 0:
case 1:
Statistics[HitResult.Good] = value;
break;
case 3:
Statistics[HitResult.Ok] = value;
break;
}
}
}
private int count50;
public int Count50
{
get => count50;
set
{
count50 = value;
switch (Ruleset?.ID ?? RulesetID)
{
case 0:
case 3:
Statistics[HitResult.Meh] = value;
break;
}
}
}
public int CountMiss
{
get => Statistics[HitResult.Miss];
set => Statistics[HitResult.Miss] = value;
}
}
}

View File

@ -35,7 +35,7 @@ namespace osu.Game.Scoring.Legacy
using (SerializationReader sr = new SerializationReader(stream)) using (SerializationReader sr = new SerializationReader(stream))
{ {
currentRuleset = GetRuleset(sr.ReadByte()); currentRuleset = GetRuleset(sr.ReadByte());
var scoreInfo = new LegacyScoreInfo { Ruleset = currentRuleset.RulesetInfo }; var scoreInfo = new ScoreInfo { Ruleset = currentRuleset.RulesetInfo };
score.ScoreInfo = scoreInfo; score.ScoreInfo = scoreInfo;
@ -53,12 +53,12 @@ namespace osu.Game.Scoring.Legacy
// MD5Hash // MD5Hash
sr.ReadString(); sr.ReadString();
scoreInfo.Count300 = sr.ReadUInt16(); scoreInfo.SetCount300(sr.ReadUInt16());
scoreInfo.Count100 = sr.ReadUInt16(); scoreInfo.SetCount100(sr.ReadUInt16());
scoreInfo.Count50 = sr.ReadUInt16(); scoreInfo.SetCount50(sr.ReadUInt16());
scoreInfo.CountGeki = sr.ReadUInt16(); scoreInfo.SetCountGeki(sr.ReadUInt16());
scoreInfo.CountKatu = sr.ReadUInt16(); scoreInfo.SetCountKatu(sr.ReadUInt16());
scoreInfo.CountMiss = sr.ReadUInt16(); scoreInfo.SetCountMiss(sr.ReadUInt16());
scoreInfo.TotalScore = sr.ReadInt32(); scoreInfo.TotalScore = sr.ReadInt32();
scoreInfo.MaxCombo = sr.ReadUInt16(); scoreInfo.MaxCombo = sr.ReadUInt16();

View File

@ -0,0 +1,143 @@
// 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 osu.Game.Rulesets.Scoring;
namespace osu.Game.Scoring.Legacy
{
public static class ScoreInfoExtensions
{
public static int? GetCountGeki(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 3:
return scoreInfo.Statistics[HitResult.Perfect];
}
return null;
}
public static void SetCountGeki(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 3:
scoreInfo.Statistics[HitResult.Perfect] = value;
break;
}
}
public static int? GetCount300(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 0:
case 1:
case 3:
return scoreInfo.Statistics[HitResult.Great];
case 2:
return scoreInfo.Statistics[HitResult.Perfect];
}
return null;
}
public static void SetCount300(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 0:
case 1:
case 3:
scoreInfo.Statistics[HitResult.Great] = value;
break;
case 2:
scoreInfo.Statistics[HitResult.Perfect] = value;
break;
}
}
public static int? GetCountKatu(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 3:
return scoreInfo.Statistics[HitResult.Good];
}
return null;
}
public static void SetCountKatu(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 3:
scoreInfo.Statistics[HitResult.Good] = value;
break;
}
}
public static int? GetCount100(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 0:
case 1:
return scoreInfo.Statistics[HitResult.Good];
case 3:
return scoreInfo.Statistics[HitResult.Ok];
}
return null;
}
public static void SetCount100(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 0:
case 1:
scoreInfo.Statistics[HitResult.Good] = value;
break;
case 3:
scoreInfo.Statistics[HitResult.Ok] = value;
break;
}
}
public static int? GetCount50(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 0:
case 3:
return scoreInfo.Statistics[HitResult.Meh];
}
return null;
}
public static void SetCount50(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{
case 0:
case 3:
scoreInfo.Statistics[HitResult.Meh] = value;
break;
}
}
public static int? GetCountMiss(this ScoreInfo scoreInfo) =>
scoreInfo.Statistics[HitResult.Miss];
public static void SetCountMiss(this ScoreInfo scoreInfo, int value) =>
scoreInfo.Statistics[HitResult.Miss] = value;
}
}

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
@ -24,7 +23,7 @@ namespace osu.Game.Screens.Ranking.Pages
if (State.Value == DownloadState.LocallyAvailable) if (State.Value == DownloadState.LocallyAvailable)
return ReplayAvailability.Local; return ReplayAvailability.Local;
if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) if (!string.IsNullOrEmpty(Model.Value.Hash))
return ReplayAvailability.Online; return ReplayAvailability.Online;
return ReplayAvailability.NotAvailable; return ReplayAvailability.NotAvailable;

View File

@ -21,6 +21,9 @@ namespace osu.Game.Screens.Select.Leaderboards
{ {
public Action<ScoreInfo> ScoreSelected; public Action<ScoreInfo> ScoreSelected;
[Resolved]
private RulesetStore rulesets { get; set; }
private BeatmapInfo beatmap; private BeatmapInfo beatmap;
public BeatmapInfo Beatmap public BeatmapInfo Beatmap
@ -172,7 +175,7 @@ namespace osu.Game.Screens.Select.Leaderboards
req.Success += r => req.Success += r =>
{ {
scoresCallback?.Invoke(r.Scores); scoresCallback?.Invoke(r.Scores.Select(s => s.CreateScoreInfo(rulesets)));
TopScore = r.UserScore; TopScore = r.UserScore;
}; };

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Threading; using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -10,6 +11,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
@ -27,6 +29,9 @@ namespace osu.Game.Screens.Select.Leaderboards
protected override bool StartHidden => true; protected override bool StartHidden => true;
[Resolved]
private RulesetStore rulesets { get; set; }
public UserTopScoreContainer() public UserTopScoreContainer()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -77,9 +82,11 @@ namespace osu.Game.Screens.Select.Leaderboards
if (newScore == null) if (newScore == null)
return; return;
LoadComponentAsync(new LeaderboardScore(newScore.Score, newScore.Position, false) var scoreInfo = newScore.Score.CreateScoreInfo(rulesets);
LoadComponentAsync(new LeaderboardScore(scoreInfo, newScore.Position, false)
{ {
Action = () => ScoreSelected?.Invoke(newScore.Score) Action = () => ScoreSelected?.Invoke(scoreInfo)
}, drawableScore => }, drawableScore =>
{ {
scoreContainer.Child = drawableScore; scoreContainer.Child = drawableScore;