Exemplo n.º 1
0
        private void load(BeatmapDifficultyCache beatmapDifficultyCache)
        {
            var beatmap  = score.Beatmap;
            var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
            var creator  = metadata.Author?.Username;

            var topStatistics = new List <StatisticDisplay>
            {
                new AccuracyStatistic(score.Accuracy),
                new ComboStatistic(score.MaxCombo, !score.Statistics.TryGetValue(HitResult.Miss, out var missCount) || missCount == 0),
                new PerformanceStatistic(score),
            };

            var bottomStatistics = new List <HitResultStatistic>();

            foreach (var result in score.GetStatisticsForDisplay())
            {
                bottomStatistics.Add(new HitResultStatistic(result));
            }

            statisticDisplays.AddRange(topStatistics);
            statisticDisplays.AddRange(bottomStatistics);

            var starDifficulty = beatmapDifficultyCache.GetDifficultyAsync(beatmap, score.Ruleset, score.Mods).Result;

            InternalChildren = new Drawable[]
            {
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Direction        = FillDirection.Vertical,
                    Spacing          = new Vector2(20),
                    Children         = new Drawable[]
                    {
                        new FillFlowContainer
                        {
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.TopCentre,
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Vertical,
                            Children         = new Drawable[]
                            {
                                new OsuSpriteText
                                {
                                    Anchor   = Anchor.TopCentre,
                                    Origin   = Anchor.TopCentre,
                                    Text     = new LocalisedString((metadata.TitleUnicode, metadata.Title)),
                                    Font     = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
                                    MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
                                    Truncate = true,
                                },
 private void load()
 {
     InternalChild = new GridContainer
     {
         RelativeSizeAxes = Axes.Both,
         Content          = new[]
         {
             new Drawable[]
             {
                 new Container
                 {
                     RelativeSizeAxes = Axes.Both,
                     Masking          = true,
                     CornerExponent   = 2.5f,
                     CornerRadius     = 20,
                     EdgeEffect       = new EdgeEffectParameters
                     {
                         Colour = Color4.Black.Opacity(0.25f),
                         Type   = EdgeEffectType.Shadow,
                         Radius = 1,
                         Offset = new Vector2(0, 4)
                     },
                     Children = new Drawable[]
                     {
                         new Box
                         {
                             RelativeSizeAxes = Axes.Both,
                             Colour           = Color4Extensions.FromHex("444")
                         },
                         new UserCoverBackground
                         {
                             RelativeSizeAxes = Axes.Both,
                             User             = score.User,
                             Colour           = ColourInfo.GradientVertical(Color4.White.Opacity(0.5f), Color4Extensions.FromHex("#444").Opacity(0))
                         },
                         new FillFlowContainer
                         {
                             RelativeSizeAxes = Axes.Both,
                             Padding          = new MarginPadding(10),
                             Direction        = FillDirection.Vertical,
                             Spacing          = new Vector2(0, 10),
                             Children         = new Drawable[]
                             {
                                 new UpdateableAvatar(score.User)
                                 {
                                     Anchor         = Anchor.TopCentre,
                                     Origin         = Anchor.TopCentre,
                                     Size           = new Vector2(110),
                                     Masking        = true,
                                     CornerExponent = 2.5f,
                                     CornerRadius   = 20,
                                     EdgeEffect     = new EdgeEffectParameters
                                     {
                                         Colour = Color4.Black.Opacity(0.25f),
                                         Type   = EdgeEffectType.Shadow,
                                         Radius = 8,
                                         Offset = new Vector2(0, 4),
                                     }
                                 },
                                 new OsuSpriteText
                                 {
                                     Anchor = Anchor.TopCentre,
                                     Origin = Anchor.TopCentre,
                                     Text   = score.UserString,
                                     Font   = OsuFont.GetFont(size: 16, weight: FontWeight.SemiBold)
                                 },
                                 new FillFlowContainer
                                 {
                                     RelativeSizeAxes   = Axes.X,
                                     AutoSizeAxes       = Axes.Y,
                                     Direction          = FillDirection.Vertical,
                                     Spacing            = new Vector2(0, 5),
                                     ChildrenEnumerable = score.GetStatisticsForDisplay().Where(s => !s.Result.IsBonus()).Select(createStatistic)
                                 },
                                 new FillFlowContainer
                                 {
                                     RelativeSizeAxes = Axes.X,
                                     AutoSizeAxes     = Axes.Y,
                                     Margin           = new MarginPadding {
                                         Top = 10
                                     },
                                     Direction = FillDirection.Vertical,
                                     Spacing   = new Vector2(0, 5),
                                     Children  = new[]
                                     {
                                         createStatistic("Max Combo", $"x{score.MaxCombo}"),
                                         createStatistic("Accuracy", $"{score.Accuracy.FormatAccuracy()}"),
                                     }
                                 },
                                 new ModDisplay
                                 {
                                     Anchor              = Anchor.TopCentre,
                                     Origin              = Anchor.TopCentre,
                                     AutoSizeAxes        = Axes.Both,
                                     ExpansionMode       = ExpansionMode.AlwaysExpanded,
                                     DisplayUnrankedText = false,
                                     Current             = { Value = score.Mods },
                                     Scale = new Vector2(0.5f),
                                 }
                             }
                         }
                     }
                 },
             },
             new Drawable[]
             {
                 new Container
                 {
                     RelativeSizeAxes = Axes.Both,
                     Padding          = new MarginPadding {
                         Vertical = 5
                     },
                     Child = new GridContainer
                     {
                         RelativeSizeAxes = Axes.Both,
                         Content          = new[]
                         {
                             new Drawable[]
                             {
                                 new OsuSpriteText
                                 {
                                     Anchor  = Anchor.Centre,
                                     Origin  = Anchor.Centre,
                                     Current = scoreManager.GetBindableTotalScoreString(score),
                                     Font    = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true),
                                     Spacing = new Vector2(-1, 0)
                                 },
                             },
                             new Drawable[]
                             {
                                 new Container
                                 {
                                     RelativeSizeAxes = Axes.Both,
                                     Padding          = new MarginPadding {
                                         Top = 2
                                     },
                                     Child = new DrawableRank(score.Rank)
                                     {
                                         Anchor = Anchor.Centre,
                                         Origin = Anchor.Centre,
                                     }
                                 }
                             },
                         },
                         RowDimensions = new[]
                         {
                             new Dimension(GridSizeMode.AutoSize),
                         }
                     }
                 }
             },
         },
         RowDimensions = new[]
         {
             new Dimension(),
             new Dimension(GridSizeMode.Absolute, 45),
         }
     };
 }
Exemplo n.º 3
0
        private Drawable[] createContent(int index, ScoreInfo score)
        {
            var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: text_size))
            {
                AutoSizeAxes = Axes.Both
            };

            username.AddUserLink(score.User);

            var content = new List <Drawable>
            {
                new OsuSpriteText
                {
                    Text = $"#{index + 1}",
                    Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
                },
                new UpdateableRank(score.Rank)
                {
                    Size = new Vector2(28, 14)
                },
                new OsuSpriteText
                {
                    Margin = new MarginPadding {
                        Right = horizontal_inset
                    },
                    Current = scoreManager.GetBindableTotalScoreString(score),
                    Font    = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium)
                },
                new OsuSpriteText
                {
                    Margin = new MarginPadding {
                        Right = horizontal_inset
                    },
                    Text   = score.DisplayAccuracy,
                    Font   = OsuFont.GetFont(size: text_size),
                    Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White
                },
                new UpdateableFlag(score.User.Country)
                {
                    Size = new Vector2(19, 13),
                    ShowPlaceholderOnNull = false,
                },
                username,
                new OsuSpriteText
                {
                    Text   = $@"{score.MaxCombo:N0}x",
                    Font   = OsuFont.GetFont(size: text_size),
                    Colour = score.MaxCombo == score.Beatmap?.MaxCombo ? highAccuracyColour : Color4.White
                }
            };

            var availableStatistics = score.GetStatisticsForDisplay().ToDictionary(tuple => tuple.result);

            foreach (var result in statisticResultTypes)
            {
                if (!availableStatistics.TryGetValue(result, out var stat))
                {
                    stat = (result, 0, null);
                }

                content.Add(new OsuSpriteText
                {
                    Text   = stat.maxCount == null ? $"{stat.count}" : $"{stat.count}/{stat.maxCount}",
                    Font   = OsuFont.GetFont(size: text_size),
                    Colour = stat.count == 0 ? Color4.Gray : Color4.White
                });
            }

            if (showPerformancePoints)
            {
                content.Add(new OsuSpriteText
                {
                    Text = $@"{score.PP:N0}",
                    Font = OsuFont.GetFont(size: text_size)
                });
            }

            content.Add(new FillFlowContainer
            {
                Direction          = FillDirection.Horizontal,
                AutoSizeAxes       = Axes.Both,
                Spacing            = new Vector2(1),
                ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m)
                {
                    AutoSizeAxes = Axes.Both,
                    Scale        = new Vector2(0.3f)
                })
            });

            return(content.ToArray());
        }
Exemplo n.º 4
0
        private void load(BeatmapDifficultyCache beatmapDifficultyCache)
        {
            var beatmap  = score.Beatmap;
            var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
            var creator  = metadata.Author?.Username;

            var topStatistics = new List <StatisticDisplay>
            {
                new AccuracyStatistic(score.Accuracy),
                new ComboStatistic(score.MaxCombo, !score.Statistics.TryGetValue(HitResult.Miss, out var missCount) || missCount == 0),
                new PerformanceStatistic(score),
            };

            var bottomStatistics = new List <HitResultStatistic>();

            foreach (var result in score.GetStatisticsForDisplay())
            {
                bottomStatistics.Add(new HitResultStatistic(result));
            }

            statisticDisplays.AddRange(topStatistics);
            statisticDisplays.AddRange(bottomStatistics);

            var starDifficulty = beatmapDifficultyCache.GetDifficultyAsync(beatmap, score.Ruleset, score.Mods).Result;

            InternalChildren = new Drawable[]
            {
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Direction        = FillDirection.Vertical,
                    Spacing          = new Vector2(20),
                    Children         = new Drawable[]
                    {
                        new FillFlowContainer
                        {
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.TopCentre,
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Vertical,
                            Children         = new Drawable[]
                            {
                                new OsuSpriteText
                                {
                                    Anchor   = Anchor.TopCentre,
                                    Origin   = Anchor.TopCentre,
                                    Text     = new RomanisableString(metadata.TitleUnicode, metadata.Title),
                                    Font     = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
                                    MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
                                    Truncate = true,
                                },
                                new OsuSpriteText
                                {
                                    Anchor   = Anchor.TopCentre,
                                    Origin   = Anchor.TopCentre,
                                    Text     = new RomanisableString(metadata.ArtistUnicode, metadata.Artist),
                                    Font     = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold),
                                    MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
                                    Truncate = true,
                                },
                                new Container
                                {
                                    Anchor = Anchor.TopCentre,
                                    Origin = Anchor.TopCentre,
                                    Margin = new MarginPadding {
                                        Top = 40
                                    },
                                    RelativeSizeAxes = Axes.X,
                                    Height           = 230,
                                    Child            = new AccuracyCircle(score, withFlair)
                                    {
                                        Anchor           = Anchor.Centre,
                                        Origin           = Anchor.Centre,
                                        RelativeSizeAxes = Axes.Both,
                                        FillMode         = FillMode.Fit,
                                    }
                                },
                                scoreCounter = new TotalScoreCounter
                                {
                                    Margin = new MarginPadding {
                                        Top = 0, Bottom = 5
                                    },
                                    Current       = { Value = 0 },
                                    Alpha         = 0,
                                    AlwaysPresent = true
                                },
                                starAndModDisplay = new FillFlowContainer
                                {
                                    Anchor       = Anchor.TopCentre,
                                    Origin       = Anchor.TopCentre,
                                    AutoSizeAxes = Axes.Both,
                                    Spacing      = new Vector2(5, 0),
                                    Children     = new Drawable[]
                                    {
                                        new StarRatingDisplay(starDifficulty)
                                        {
                                            Anchor = Anchor.CentreLeft,
                                            Origin = Anchor.CentreLeft
                                        },
                                    }
                                },
                                new FillFlowContainer
                                {
                                    Anchor       = Anchor.TopCentre,
                                    Origin       = Anchor.TopCentre,
                                    Direction    = FillDirection.Vertical,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new OsuSpriteText
                                        {
                                            Anchor = Anchor.TopCentre,
                                            Origin = Anchor.TopCentre,
                                            Text   = beatmap.Version,
                                            Font   = OsuFont.Torus.With(size: 16, weight: FontWeight.SemiBold),
                                        },
                                        new OsuTextFlowContainer(s => s.Font = OsuFont.Torus.With(size: 12))
                                        {
                                            Anchor       = Anchor.TopCentre,
                                            Origin       = Anchor.TopCentre,
                                            AutoSizeAxes = Axes.Both,
                                            Direction    = FillDirection.Horizontal,
                                        }.With(t =>
                                        {
                                            if (!string.IsNullOrEmpty(creator))
                                            {
                                                t.AddText("mapped by ");
                                                t.AddText(creator, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
                                            }
                                        })
                                    }
                                },
                            }
                        },
                        new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Vertical,
                            Spacing          = new Vector2(0, 5),
                            Children         = new Drawable[]
                            {
                                new GridContainer
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Content          = new[] { topStatistics.Cast <Drawable>().ToArray() },
                                    RowDimensions    = new[]
                                    {
                                        new Dimension(GridSizeMode.AutoSize),
                                    }
                                },
                                new GridContainer
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Content          = new[] { bottomStatistics.Where(s => s.Result <= HitResult.Perfect).ToArray() },
                                    RowDimensions    = new[]
                                    {
                                        new Dimension(GridSizeMode.AutoSize),
                                    }
                                },
                                new GridContainer
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Content          = new[] { bottomStatistics.Where(s => s.Result > HitResult.Perfect).ToArray() },
                                    RowDimensions    = new[]
                                    {
                                        new Dimension(GridSizeMode.AutoSize),
                                    }
                                }
                            }
                        }
                    }
                },
                new OsuSpriteText
                {
                    Anchor = Anchor.BottomCentre,
                    Origin = Anchor.BottomCentre,
                    Font   = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold),
                    Text   = $"Played on {score.Date.ToLocalTime():d MMMM yyyy HH:mm}"
                }
            };

            if (score.Mods.Any())
            {
                starAndModDisplay.Add(new ModDisplay
                {
                    Anchor        = Anchor.CentreLeft,
                    Origin        = Anchor.CentreLeft,
                    ExpansionMode = ExpansionMode.AlwaysExpanded,
                    Scale         = new Vector2(0.5f),
                    Current       = { Value = score.Mods }
                });
            }
        }