-
Notifications
You must be signed in to change notification settings - Fork 94
Use IScoreInfo in ExtendedScore instead of SoloScoreInfo #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,14 +18,17 @@ | |||||
| using osu.Game.Graphics; | ||||||
| using osu.Game.Graphics.Containers; | ||||||
| using osu.Game.Graphics.Sprites; | ||||||
| using osu.Game.Online.API; | ||||||
| using osu.Game.Online.API.Requests.Responses; | ||||||
| using osu.Game.Online.Leaderboards; | ||||||
| using osu.Game.Overlays; | ||||||
| using osu.Game.Overlays.Profile.Sections; | ||||||
| using osu.Game.Rulesets; | ||||||
| using osu.Game.Rulesets.Difficulty; | ||||||
| using osu.Game.Rulesets.Mods; | ||||||
| using osu.Game.Rulesets.Scoring; | ||||||
| using osu.Game.Rulesets.UI; | ||||||
| using osu.Game.Scoring; | ||||||
| using osu.Game.Users.Drawables; | ||||||
| using osu.Game.Utils; | ||||||
| using osuTK; | ||||||
|
|
@@ -36,7 +39,7 @@ | |||||
| { | ||||||
| public class ExtendedScore | ||||||
| { | ||||||
| public SoloScoreInfo SoloScore { get; } | ||||||
| public IScoreInfo Score { get; } | ||||||
| public double? LivePP { get; } | ||||||
|
|
||||||
| public Bindable<int> Position { get; } = new Bindable<int>(); | ||||||
|
|
@@ -45,13 +48,40 @@ | |||||
| public PerformanceAttributes? PerformanceAttributes { get; } | ||||||
| public DifficultyAttributes DifficultyAttributes { get; } | ||||||
|
|
||||||
| public ExtendedScore(SoloScoreInfo score, DifficultyAttributes difficultyAttributes, PerformanceAttributes? performanceAttributes) | ||||||
| public ExtendedScore(IScoreInfo score, DifficultyAttributes difficultyAttributes, PerformanceAttributes? performanceAttributes) | ||||||
| { | ||||||
| SoloScore = score; | ||||||
| Score = score; | ||||||
| PerformanceAttributes = performanceAttributes; | ||||||
| DifficultyAttributes = difficultyAttributes; | ||||||
| LivePP = score.PP; | ||||||
| } | ||||||
|
|
||||||
| // IScoreInfo is missing statistics right now, but both SoloScoreInfo and ScoreInfo have it (and I believe it's planned for future) | ||||||
| // I think handling conversion at this level is the most elegant, although it means supporting any additional types that inherit from IScoreInfo will need to be manually added here | ||||||
| public Dictionary<HitResult, int>? Statistics | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just awful |
||||||
| { | ||||||
| get | ||||||
| { | ||||||
| if (Score is SoloScoreInfo soloScore) | ||||||
| return soloScore.Statistics; | ||||||
| if (Score is ScoreInfo scoreInfo) | ||||||
| return scoreInfo.Statistics; | ||||||
| return null; | ||||||
| } | ||||||
| } | ||||||
| // Exists for largely the same reasoning as Statistics, except rather than a missing field it's because APIMod doesn't inherit from IMod at all | ||||||
| // This returns APIMod[]? instead of Mod[]? because it means ruleset handling isn't necessary | ||||||
| public APIMod[]? Mods | ||||||
| { | ||||||
| get | ||||||
| { | ||||||
| if (Score is ScoreInfo scoreInfo) | ||||||
| return scoreInfo.Mods.Select(m => new APIMod(m)).ToArray(); | ||||||
| if (Score is SoloScoreInfo soloScoreInfo) | ||||||
| return soloScoreInfo.Mods; | ||||||
| return null; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| public partial class ExtendedProfileItemContainer : ProfileItemContainer | ||||||
|
|
@@ -88,7 +118,7 @@ | |||||
|
|
||||||
| private const float performance_background_shear = 0.45f; | ||||||
|
|
||||||
| public readonly ExtendedScore Score; | ||||||
| public readonly ExtendedScore ExtScore; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| public readonly bool ShowAvatar; | ||||||
|
|
||||||
|
|
@@ -102,7 +132,7 @@ | |||||
|
|
||||||
| public ExtendedProfileScore(ExtendedScore score, bool showAvatar = false) | ||||||
| { | ||||||
| Score = score; | ||||||
| ExtScore = score; | ||||||
| ShowAvatar = showAvatar; | ||||||
|
|
||||||
| RelativeSizeAxes = Axes.X; | ||||||
|
|
@@ -114,27 +144,27 @@ | |||||
| { | ||||||
| int avatarPadding = ShowAvatar ? avatar_size : 0; | ||||||
| int rankDifferenceWidth = ShowAvatar ? 8 : rank_difference_width; | ||||||
| var scoreRuleset = rulesets.GetRuleset(Score.SoloScore.RulesetID)?.CreateInstance() ?? throw new InvalidOperationException(); | ||||||
| var scoreRuleset = rulesets.GetRuleset(ExtScore.Score.Ruleset.OnlineID)?.CreateInstance() ?? throw new InvalidOperationException(); | ||||||
|
|
||||||
| AddInternal(new ExtendedProfileItemContainer | ||||||
| { | ||||||
| OnHoverAction = () => | ||||||
| { | ||||||
| positionChangeText.Text = $"#{Score.Position.Value}"; | ||||||
| positionChangeText.Text = $"#{ExtScore.Position.Value}"; | ||||||
| }, | ||||||
| OnUnhoverAction = () => | ||||||
| { | ||||||
| positionChangeText.Text = $"{Score.PositionChange.Value:+0;-0;-}"; | ||||||
| positionChangeText.Text = $"{ExtScore.PositionChange.Value:+0;-0;-}"; | ||||||
| }, | ||||||
| Children = new[] | ||||||
| { | ||||||
| ShowAvatar | ||||||
| ? new ClickableAvatar(Score.SoloScore.User, true) | ||||||
| ? new ClickableAvatar((APIUser)ExtScore.Score.User, true) | ||||||
| { | ||||||
| Masking = true, | ||||||
| CornerRadius = ExtendedLabelledTextBox.CORNER_RADIUS, | ||||||
| Size = new Vector2(avatar_size), | ||||||
| Action = () => { host.OpenUrlExternally($"https://osu.ppy.sh/users/{Score.SoloScore.User?.Id}"); } | ||||||
| Action = () => { host.OpenUrlExternally($"https://osu.ppy.sh/users/{ExtScore.Score.User?.OnlineID}"); } | ||||||
|
Check failure on line 167 in PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs
|
||||||
| } | ||||||
| : Empty(), | ||||||
| new Container | ||||||
|
|
@@ -151,7 +181,7 @@ | |||||
| Anchor = Anchor.Centre, | ||||||
| Origin = Anchor.Centre, | ||||||
| Colour = colourProvider.Light1, | ||||||
| Text = $"{Score.PositionChange.Value:+0;-0;-}" | ||||||
| Text = $"{ExtScore.PositionChange.Value:+0;-0;-}" | ||||||
| } | ||||||
| }, | ||||||
| new Container | ||||||
|
|
@@ -180,13 +210,13 @@ | |||||
| Padding = new MarginPadding { Top = 2 }, | ||||||
| Children = new Drawable[] | ||||||
| { | ||||||
| new UpdateableRank(Score.SoloScore.Rank) | ||||||
| new UpdateableRank(ExtScore.Score.Rank) | ||||||
| { | ||||||
| Anchor = Anchor.TopCentre, | ||||||
| Origin = Anchor.TopCentre, | ||||||
| Size = new Vector2(40, 12), | ||||||
| }, | ||||||
| new TinyStarRatingDisplay(Score.DifficultyAttributes) | ||||||
| new TinyStarRatingDisplay(ExtScore.DifficultyAttributes) | ||||||
| { | ||||||
| Anchor = Anchor.TopCentre, | ||||||
| Origin = Anchor.TopCentre, | ||||||
|
|
@@ -202,7 +232,7 @@ | |||||
| Spacing = new Vector2(0, 0.5f), | ||||||
| Children = new Drawable[] | ||||||
| { | ||||||
| new ScoreBeatmapMetadataContainer(Score.SoloScore.Beatmap), | ||||||
| new ScoreBeatmapMetadataContainer(ExtScore.Score.Beatmap), | ||||||
| new FillFlowContainer | ||||||
| { | ||||||
| AutoSizeAxes = Axes.Both, | ||||||
|
|
@@ -212,11 +242,11 @@ | |||||
| { | ||||||
| new OsuSpriteText | ||||||
| { | ||||||
| Text = $"{Score.SoloScore.Beatmap?.DifficultyName}", | ||||||
| Text = $"{ExtScore.Score.Beatmap?.DifficultyName}", | ||||||
| Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), | ||||||
| Colour = colours.Yellow | ||||||
| }, | ||||||
| new DrawableDate(Score.SoloScore.EndedAt, 12) | ||||||
| new DrawableDate(ExtScore.Score.Date, 12) | ||||||
| { | ||||||
| Colour = colourProvider.Foreground1 | ||||||
| } | ||||||
|
|
@@ -268,7 +298,7 @@ | |||||
| { | ||||||
| new OsuSpriteText | ||||||
| { | ||||||
| Text = Score.SoloScore.Accuracy.FormatAccuracy(), | ||||||
| Text = ExtScore.Score.Accuracy.FormatAccuracy(), | ||||||
| Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), | ||||||
| Colour = colours.Yellow, | ||||||
| Anchor = Anchor.TopCentre, | ||||||
|
|
@@ -285,7 +315,7 @@ | |||||
| formatCombo(), | ||||||
| new OsuSpriteText | ||||||
| { | ||||||
| Text = $"{{ {formatStatistics(Score.SoloScore.Statistics, scoreRuleset)} }}", | ||||||
| Text = $"{{ {formatStatistics(ExtScore.Statistics, scoreRuleset)} }}", | ||||||
|
Check failure on line 318 in PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs
|
||||||
| Font = OsuFont.GetFont(size: small_text_font_size, weight: FontWeight.Regular), | ||||||
| Colour = colourProvider.Light2, | ||||||
| Anchor = Anchor.TopCentre, | ||||||
|
|
@@ -310,7 +340,7 @@ | |||||
| Child = new OsuSpriteText | ||||||
| { | ||||||
| Font = OsuFont.GetFont(weight: FontWeight.Bold), | ||||||
| Text = Score.LivePP != null ? $"{Score.LivePP:0}pp" : "- pp" | ||||||
| Text = ExtScore.LivePP != null ? $"{ExtScore.LivePP:0}pp" : "- pp" | ||||||
| }, | ||||||
| }, | ||||||
| new OsuSpriteText | ||||||
|
|
@@ -332,7 +362,7 @@ | |||||
| Origin = Anchor.CentreRight, | ||||||
| Direction = FillDirection.Horizontal, | ||||||
| Spacing = new Vector2(2), | ||||||
| Children = Score.SoloScore.Mods.Select(mod => new ModIcon(mod.ToMod(scoreRuleset)) | ||||||
| Children = ExtScore.Mods.Select(mod => new ModIcon(mod.ToMod(scoreRuleset)) | ||||||
|
Check failure on line 365 in PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs
|
||||||
| { | ||||||
| Scale = new Vector2(0.35f) | ||||||
| }).ToList(), | ||||||
|
|
@@ -372,27 +402,27 @@ | |||||
| Shear = new Vector2(performance_background_shear, 0), | ||||||
| EdgeSmoothness = new Vector2(2, 0), | ||||||
| }, | ||||||
| new ScorePerformanceContainer(Score) | ||||||
| new ScorePerformanceContainer(ExtScore) | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
| Score.PositionChange.BindValueChanged(v => { positionChangeText.Text = $"{v.NewValue:+0;-0;-}"; }); | ||||||
| ExtScore.PositionChange.BindValueChanged(v => { positionChangeText.Text = $"{v.NewValue:+0;-0;-}"; }); | ||||||
| } | ||||||
|
|
||||||
| private OsuSpriteText formatCombo() | ||||||
| { | ||||||
| bool isFullCombo = Score.SoloScore.MaxCombo == Score.DifficultyAttributes.MaxCombo; | ||||||
| bool isFullCombo = ExtScore.Score.MaxCombo == ExtScore.DifficultyAttributes.MaxCombo; | ||||||
|
|
||||||
| return new ExtendedOsuSpriteText | ||||||
| { | ||||||
| Text = $"{Score.SoloScore.MaxCombo}x", | ||||||
| Text = $"{ExtScore.Score.MaxCombo}x", | ||||||
| Font = OsuFont.GetFont(size: small_text_font_size, weight: FontWeight.Regular), | ||||||
| Colour = isFullCombo ? colours.GreenLight : colourProvider.Light2, | ||||||
| Anchor = Anchor.TopCentre, | ||||||
| Origin = Anchor.TopCentre, | ||||||
| TooltipContent = $"{Score.SoloScore.MaxCombo} / {Score.DifficultyAttributes.MaxCombo}x" | ||||||
| TooltipContent = $"{ExtScore.Score.MaxCombo} / {ExtScore.DifficultyAttributes.MaxCombo}x" | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -471,14 +501,14 @@ | |||||
|
|
||||||
| private partial class ScorePerformanceContainer : OsuHoverContainer | ||||||
| { | ||||||
| private readonly ExtendedScore score; | ||||||
| private readonly ExtendedScore extScore; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| [Resolved] | ||||||
| private OverlayColourProvider colourProvider { get; set; } = null!; | ||||||
|
|
||||||
| public ScorePerformanceContainer(ExtendedScore score) | ||||||
| { | ||||||
| this.score = score; | ||||||
| this.extScore = score; | ||||||
| RelativeSizeAxes = Axes.Both; | ||||||
| Padding = new MarginPadding | ||||||
| { | ||||||
|
|
@@ -493,7 +523,7 @@ | |||||
| { | ||||||
| Action = () => | ||||||
| { | ||||||
| sceneManager.SwitchToSimulate(score.SoloScore.BeatmapID, score.SoloScore.ID); | ||||||
| sceneManager.SwitchToSimulate(extScore.Score.Beatmap.OnlineID, (ulong?)extScore.Score.OnlineID); | ||||||
| }; | ||||||
|
|
||||||
| Child = new FillFlowContainer | ||||||
|
|
@@ -507,16 +537,16 @@ | |||||
| new ExtendedOsuSpriteText | ||||||
| { | ||||||
| Font = OsuFont.GetFont(weight: FontWeight.Bold), | ||||||
| Text = $"{score.PerformanceAttributes?.Total:0}pp", | ||||||
| Text = $"{extScore.PerformanceAttributes?.Total:0}pp", | ||||||
| Colour = colourProvider.Highlight1, | ||||||
| Anchor = Anchor.TopCentre, | ||||||
| Origin = Anchor.TopCentre, | ||||||
| TooltipContent = $"{AttributeConversion.ToReadableString(score.PerformanceAttributes)}" | ||||||
| TooltipContent = $"{AttributeConversion.ToReadableString(extScore.PerformanceAttributes)}" | ||||||
| }, | ||||||
| new OsuSpriteText | ||||||
| { | ||||||
| Font = OsuFont.GetFont(size: small_text_font_size), | ||||||
| Text = $"{score.PerformanceAttributes?.Total - score.LivePP:+0.0;-0.0;-}", | ||||||
| Text = $"{extScore.PerformanceAttributes?.Total - extScore.LivePP:+0.0;-0.0;-}", | ||||||
| Colour = getPpDifferenceColor(), | ||||||
| Anchor = Anchor.TopCentre, | ||||||
| Origin = Anchor.TopCentre | ||||||
|
|
@@ -527,7 +557,7 @@ | |||||
|
|
||||||
| private Color4 getPpDifferenceColor() | ||||||
| { | ||||||
| double difference = score.PerformanceAttributes?.Total - score.LivePP ?? 0; | ||||||
| double difference = extScore.PerformanceAttributes?.Total - extScore.LivePP ?? 0; | ||||||
| var baseColor = colourProvider.Light1; | ||||||
|
|
||||||
| return difference switch | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |||||
| { | ||||||
| public partial class ScoreContainer : Container | ||||||
| { | ||||||
| public ExtendedScore Score { get; } | ||||||
| public ExtendedScore ExtScore { get; } | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| private readonly IconButton deleteButton; | ||||||
|
|
||||||
|
|
@@ -25,7 +25,7 @@ | |||||
| RelativeSizeAxes = Axes.X; | ||||||
| AutoSizeAxes = Axes.Y; | ||||||
|
|
||||||
| Score = score; | ||||||
| ExtScore = score; | ||||||
| Child = new GridContainer | ||||||
| { | ||||||
| RelativeSizeAxes = Axes.X, | ||||||
|
|
@@ -43,7 +43,7 @@ | |||||
| Icon = FontAwesome.Regular.TrashAlt, | ||||||
| Action = () => | ||||||
| { | ||||||
| OnDelete?.Invoke((long)score.SoloScore.ID!); | ||||||
| OnDelete?.Invoke(ExtScore.Score.OnlineID!); | ||||||
| } | ||||||
| }, | ||||||
| new ExtendedProfileScore(score, true) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just
ScoreInfo? The only reason this is usingSoloScoreInfonow is because the data is always sourced from the API so it was convenient, but we convert it toScoreInfoanyway to run pp calculation