Example #1
0
        public LeaderboardScore(Score score, int rank)
        {
            Score        = score;
            RankPosition = rank;

            RelativeSizeAxes = Axes.X;
            Height           = HEIGHT;

            Children = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = rank_width,
                    Children         = new[]
                    {
                        new OsuSpriteText
                        {
                            Anchor   = Anchor.CentreLeft,
                            Origin   = Anchor.CentreLeft,
                            Font     = @"Exo2.0-MediumItalic",
                            TextSize = 22,
                            Text     = RankPosition.ToString(),
                        },
                    },
                },
                content = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = rank_width,
                    },
                    Children = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            CornerRadius     = corner_radius,
                            Masking          = true,
                            Children         = new[]
                            {
                                background = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                    Alpha            = background_alpha,
                                },
                            },
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding(edge_margin),
                            Children         = new Drawable[]
                            {
                                avatar = new DelayedLoadWrapper(
                                    new Avatar(Score.User)
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    CornerRadius     = corner_radius,
                                    Masking          = true,
                                    OnLoadComplete   = d => d.FadeInFromZero(200),
                                    EdgeEffect       = new EdgeEffectParameters
                                    {
                                        Type   = EdgeEffectType.Shadow,
                                        Radius = 1,
                                        Colour = Color4.Black.Opacity(0.2f),
                                    },
                                })
                                {
                                    TimeBeforeLoad   = 500,
                                    RelativeSizeAxes = Axes.None,
                                    Size             = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
                                },
                                new Container
                                {
                                    RelativeSizeAxes = Axes.Y,
                                    AutoSizeAxes     = Axes.X,
                                    Position         = new Vector2(HEIGHT - edge_margin, 0f),
                                    Children         = new Drawable[]
                                    {
                                        nameLabel = new OsuSpriteText
                                        {
                                            Text     = Score.User.Username,
                                            Font     = @"Exo2.0-BoldItalic",
                                            TextSize = 23,
                                        },
                                        new FillFlowContainer
                                        {
                                            Origin       = Anchor.BottomLeft,
                                            Anchor       = Anchor.BottomLeft,
                                            AutoSizeAxes = Axes.Both,
                                            Direction    = FillDirection.Horizontal,
                                            Spacing      = new Vector2(10f, 0f),
                                            Children     = new Drawable[]
                                            {
                                                flagBadgeContainer = new Container
                                                {
                                                    Size     = new Vector2(87f, 20f),
                                                    Masking  = true,
                                                    Children = new Drawable[]
                                                    {
                                                        new DrawableFlag(Score.User?.Country?.FlagName)
                                                        {
                                                            Width            = 30,
                                                            RelativeSizeAxes = Axes.Y,
                                                        },
                                                    },
                                                },
                                                new FillFlowContainer
                                                {
                                                    AutoSizeAxes = Axes.Both,
                                                    Direction    = FillDirection.Horizontal,
                                                    Spacing      = new Vector2(10f, 0f),
                                                    Margin       = new MarginPadding {
                                                        Left = edge_margin,
                                                    },
                                                    Children = new Drawable[]
                                                    {
                                                        maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()),
                                                        accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy)),
                                                    },
                                                },
                                            },
                                        },
                                    },
                                },
                                new FillFlowContainer
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Anchor       = Anchor.TopRight,
                                    Origin       = Anchor.TopRight,
                                    Direction    = FillDirection.Horizontal,
                                    Spacing      = new Vector2(5f, 0f),
                                    Children     = new Drawable[]
                                    {
                                        scoreLabel = new GlowingSpriteText(Score.TotalScore.ToString(@"N0"), @"Venera", 23, Color4.White, OsuColour.FromHex(@"83ccfa")),
                                        new Container
                                        {
                                            Size     = new Vector2(40f, 20f),
                                            Children = new[]
                                            {
                                                scoreRank = new DrawableRank(Score.Rank)
                                                {
                                                    Anchor = Anchor.Centre,
                                                    Origin = Anchor.Centre,
                                                    Size   = new Vector2(40f),
                                                },
                                            },
                                        },
                                    },
                                },
                                modsContainer = new FillFlowContainer <ScoreModIcon>
                                {
                                    Anchor       = Anchor.BottomRight,
                                    Origin       = Anchor.BottomRight,
                                    AutoSizeAxes = Axes.Both,
                                    Direction    = FillDirection.Horizontal,
                                },
                            },
                        },
                    },
                },
            };

            if (Score.Mods != null)
            {
                foreach (Mod mod in Score.Mods)
                {
                    // TODO: Get actual mod colours
                    modsContainer.Add(new ScoreModIcon(mod.Icon, OsuColour.FromHex(@"ffcc22")));
                }
            }
        }
Example #2
0
 private void load()
 {
     Children = new Drawable[]
     {
         new Container
         {
             RelativeSizeAxes = Axes.Y,
             Width            = rank_width,
             Children         = new[]
             {
                 new OsuSpriteText
                 {
                     Anchor   = Anchor.CentreLeft,
                     Origin   = Anchor.CentreLeft,
                     Font     = @"Exo2.0-MediumItalic",
                     TextSize = 22,
                     // ReSharper disable once ImpureMethodCallOnReadonlyValueField
                     Text = RankPosition.ToString(),
                 },
             },
         },
         content = new Container
         {
             RelativeSizeAxes = Axes.Both,
             Padding          = new MarginPadding {
                 Left = rank_width,
             },
             Children = new Drawable[]
             {
                 new Container
                 {
                     RelativeSizeAxes = Axes.Both,
                     CornerRadius     = corner_radius,
                     Masking          = true,
                     Children         = new[]
                     {
                         background = new Box
                         {
                             RelativeSizeAxes = Axes.Both,
                             Colour           = Color4.Black,
                             Alpha            = background_alpha,
                         },
                     },
                 },
                 new Container
                 {
                     RelativeSizeAxes = Axes.Both,
                     Padding          = new MarginPadding(edge_margin),
                     Children         = new[]
                     {
                         avatar = new DelayedLoadWrapper(
                             new Avatar(Score.User)
                         {
                             RelativeSizeAxes = Axes.Both,
                             CornerRadius     = corner_radius,
                             Masking          = true,
                             OnLoadComplete   = d => d.FadeInFromZero(200),
                             EdgeEffect       = new EdgeEffectParameters
                             {
                                 Type   = EdgeEffectType.Shadow,
                                 Radius = 1,
                                 Colour = Color4.Black.Opacity(0.2f),
                             },
                         })
                         {
                             RelativeSizeAxes = Axes.None,
                             Size             = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
                         },
                         new Container
                         {
                             RelativeSizeAxes = Axes.Y,
                             AutoSizeAxes     = Axes.X,
                             Position         = new Vector2(HEIGHT - edge_margin, 0f),
                             Children         = new Drawable[]
                             {
                                 nameLabel = new OsuSpriteText
                                 {
                                     Text     = Score.User.Username,
                                     Font     = @"Exo2.0-BoldItalic",
                                     TextSize = 23,
                                 },
                                 new FillFlowContainer
                                 {
                                     Origin       = Anchor.BottomLeft,
                                     Anchor       = Anchor.BottomLeft,
                                     AutoSizeAxes = Axes.Both,
                                     Direction    = FillDirection.Horizontal,
                                     Spacing      = new Vector2(10f, 0f),
                                     Children     = new Drawable[]
                                     {
                                         flagBadgeContainer = new Container
                                         {
                                             Origin   = Anchor.BottomLeft,
                                             Anchor   = Anchor.BottomLeft,
                                             Size     = new Vector2(87f, 20f),
                                             Masking  = true,
                                             Children = new Drawable[]
                                             {
                                                 new DrawableFlag(Score.User?.Country)
                                                 {
                                                     Width            = 30,
                                                     RelativeSizeAxes = Axes.Y,
                                                 },
                                             },
                                         },
                                         new FillFlowContainer
                                         {
                                             Origin       = Anchor.BottomLeft,
                                             Anchor       = Anchor.BottomLeft,
                                             AutoSizeAxes = Axes.Both,
                                             Direction    = FillDirection.Horizontal,
                                             Spacing      = new Vector2(10f, 0f),
                                             Margin       = new MarginPadding {
                                                 Left = edge_margin
                                             },
                                             Children = new Drawable[]
                                             {
                                                 maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString(), "Max Combo"),
                                                 accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy), "Accuracy"),
                                             },
                                         },
                                     },
                                 },
                             },
                         },
                         new FillFlowContainer
                         {
                             AutoSizeAxes = Axes.Both,
                             Anchor       = Anchor.TopRight,
                             Origin       = Anchor.TopRight,
                             Direction    = FillDirection.Horizontal,
                             Spacing      = new Vector2(5f, 0f),
                             Children     = new Drawable[]
                             {
                                 scoreLabel = new GlowingSpriteText(Score.TotalScore.ToString(@"N0"), @"Venera", 23, Color4.White, OsuColour.FromHex(@"83ccfa")),
                                 new Container
                                 {
                                     Size     = new Vector2(40f, 20f),
                                     Children = new[]
                                     {
                                         scoreRank = new DrawableRank(Score.Rank)
                                         {
                                             Anchor = Anchor.Centre,
                                             Origin = Anchor.Centre,
                                             Size   = new Vector2(40f),
                                         },
                                     },
                                 },
                             },
                         },
                         modsContainer = new FillFlowContainer <ModIcon>
                         {
                             Anchor             = Anchor.BottomRight,
                             Origin             = Anchor.BottomRight,
                             AutoSizeAxes       = Axes.Both,
                             Direction          = FillDirection.Horizontal,
                             ChildrenEnumerable = Score.Mods.Select(mod => new ModIcon(mod)
                             {
                                 Scale = new Vector2(0.375f)
                             })
                         },
                     },
                 },
             },
         },
     };
 }