示例#1
0
        private void load()
        {
            Masking = true;

            AddRange(new[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = ColourProvider?.Background5 ?? Colours.Gray1
                },
                Background = new UserCoverBackground
                {
                    RelativeSizeAxes = Axes.Both,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    User             = User,
                },
                CreateLayout()
            });

            base.Action = ViewProfile = () =>
            {
                Action?.Invoke();
                profileOverlay?.ShowUser(User);
            };
        }
示例#2
0
文件: UserPanel.cs 项目: xMikeyHD/osu
        private void load(OsuColour colours, UserProfileOverlay profile)
        {
            if (colours == null)
            {
                throw new ArgumentNullException(nameof(colours));
            }

            FillFlowContainer infoContainer;

            UserCoverBackground coverBackground;

            AddInternal(content = new Container
            {
                RelativeSizeAxes = Axes.Both,
                Masking          = true,
                CornerRadius     = 5,
                EdgeEffect       = new EdgeEffectParameters
                {
                    Type   = EdgeEffectType.Shadow,
                    Colour = Color4.Black.Opacity(0.25f),
                    Radius = 4,
                },

                Children = new Drawable[]
                {
                    new DelayedLoadWrapper(coverBackground = new UserCoverBackground(user)
                    {
                        RelativeSizeAxes = Axes.Both,
                        Anchor           = Anchor.Centre,
                        Origin           = Anchor.Centre,
                        FillMode         = FillMode.Fill,
                    }, 300)
                    {
                        RelativeSizeAxes = Axes.Both
                    },
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = Color4.Black.Opacity(0.7f),
                    },
                    new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Padding          = new MarginPadding {
                            Top = content_padding, Horizontal = content_padding
                        },
                        Children = new Drawable[]
                        {
                            new UpdateableAvatar
                            {
                                Size         = new Vector2(height - status_height - content_padding * 2),
                                User         = user,
                                Masking      = true,
                                CornerRadius = 5,
                                OpenOnClick  = { Value = false },
                                EdgeEffect   = new EdgeEffectParameters
                                {
                                    Type   = EdgeEffectType.Shadow,
                                    Colour = Color4.Black.Opacity(0.25f),
                                    Radius = 4,
                                },
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Left = height - status_height - content_padding
                                },
                                Children = new Drawable[]
                                {
                                    new OsuSpriteText
                                    {
                                        Text = user.Username,
                                        Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 18, italics: true),
                                    },
                                    infoContainer = new FillFlowContainer
                                    {
                                        Anchor       = Anchor.BottomLeft,
                                        Origin       = Anchor.BottomLeft,
                                        AutoSizeAxes = Axes.X,
                                        Height       = 20f,
                                        Direction    = FillDirection.Horizontal,
                                        Spacing      = new Vector2(5f, 0f),
                                        Children     = new Drawable[]
                                        {
                                            new DrawableFlag(user.Country)
                                            {
                                                Width            = 30f,
                                                RelativeSizeAxes = Axes.Y,
                                            },
                                        },
                                    },
                                },
                            },
                        },
                    },
                    statusBar = new Container
                    {
                        Anchor           = Anchor.BottomLeft,
                        Origin           = Anchor.BottomLeft,
                        RelativeSizeAxes = Axes.X,
                        Alpha            = 0f,
                        Children         = new Drawable[]
                        {
                            statusBg = new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Alpha            = 0.5f,
                            },
                            new FillFlowContainer
                            {
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                AutoSizeAxes = Axes.Both,
                                Spacing      = new Vector2(5f, 0f),
                                Children     = new Drawable[]
                                {
                                    new SpriteIcon
                                    {
                                        Anchor = Anchor.CentreLeft,
                                        Origin = Anchor.CentreLeft,
                                        Icon   = FontAwesome.Regular.Circle,
                                        Shadow = true,
                                        Size   = new Vector2(14),
                                    },
                                    statusMessage = new OsuSpriteText
                                    {
                                        Anchor = Anchor.CentreLeft,
                                        Origin = Anchor.CentreLeft,
                                        Font   = OsuFont.GetFont(weight: FontWeight.SemiBold),
                                    },
                                },
                            },
                        },
                    },
                }
            });

            coverBackground.OnLoadComplete += d => d.FadeInFromZero(400, Easing.Out);

            if (user.IsSupporter)
            {
                infoContainer.Add(new SupporterIcon
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = 20f,
                });
            }

            Status.ValueChanged += status => displayStatus(status.NewValue);
            Status.ValueChanged += status => statusBg.FadeColour(status.NewValue?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint);

            base.Action = ViewProfile = () =>
            {
                Action?.Invoke();
                profile?.ShowUser(user);
            };
        }