示例#1
0
 public BeatmapCardNormal(APIBeatmapSet beatmapSet, bool allowExpansion = true)
     : base(beatmapSet, allowExpansion)
 {
     content = new BeatmapCardContent(height);
 }
示例#2
0
        private void load(BeatmapSetOverlay?beatmapSetOverlay)
        {
            Width  = width;
            Height = height;

            FillFlowContainer leftIconArea;
            GridContainer     titleContainer;
            GridContainer     artistContainer;

            InternalChild = content = new BeatmapCardContent(height)
            {
                MainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new Drawable[]
                    {
                        downloadTracker,
                        rightAreaBackground = new Container
                        {
                            RelativeSizeAxes = Axes.Y,
                            Width            = icon_area_width + 2 * CORNER_RADIUS,
                            Anchor           = Anchor.CentreRight,
                            Origin           = Anchor.CentreRight,
                            // workaround for masking artifacts at the top & bottom of card,
                            // which become especially visible on downloaded beatmaps (when the icon area has a lime background).
                            Padding = new MarginPadding {
                                Vertical = 1
                            },
                            Child = new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Colour           = Colour4.White
                            },
                        },
                        thumbnail = new BeatmapCardThumbnail(beatmapSet)
                        {
                            Name    = @"Left (icon) area",
                            Size    = new Vector2(height),
                            Padding = new MarginPadding {
                                Right = CORNER_RADIUS
                            },
                            Child = leftIconArea = new FillFlowContainer
                            {
                                Margin       = new MarginPadding(5),
                                AutoSizeAxes = Axes.Both,
                                Direction    = FillDirection.Horizontal,
                                Spacing      = new Vector2(1)
                            }
                        },
                        new Container
                        {
                            Name             = @"Right (button) area",
                            Width            = 30,
                            RelativeSizeAxes = Axes.Y,
                            Origin           = Anchor.TopRight,
                            Anchor           = Anchor.TopRight,
                            Padding          = new MarginPadding {
                                Vertical = 17.5f
                            },
                            Child = rightAreaButtons = new Container <BeatmapCardIconButton>
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new BeatmapCardIconButton[]
                                {
                                    new FavouriteButton(beatmapSet)
                                    {
                                        Current = favouriteState,
                                        Anchor  = Anchor.TopCentre,
                                        Origin  = Anchor.TopCentre
                                    },
                                    new DownloadButton(beatmapSet)
                                    {
                                        Anchor = Anchor.BottomCentre,
                                        Origin = Anchor.BottomCentre,
                                        State  = { BindTarget = downloadTracker.State }
                                    },
                                    new GoToBeatmapButton(beatmapSet)
                                    {
                                        Anchor = Anchor.BottomCentre,
                                        Origin = Anchor.BottomCentre,
                                        State  = { BindTarget = downloadTracker.State }
                                    }
                                }
                            }
                        },
                        mainContent = new Container
                        {
                            Name         = @"Main content",
                            X            = height - CORNER_RADIUS,
                            Height       = height,
                            CornerRadius = CORNER_RADIUS,
                            Masking      = true,
                            Children     = new Drawable[]
                            {
                                mainContentBackground = new BeatmapCardContentBackground(beatmapSet)
                                {
                                    RelativeSizeAxes = Axes.Both,
                                },
                                new FillFlowContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Padding          = new MarginPadding
                                    {
                                        Horizontal = 10,
                                        Vertical   = 4
                                    },
                                    Direction = FillDirection.Vertical,
                                    Children  = new Drawable[]
                                    {
                                        titleContainer = new GridContainer
                                        {
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes     = Axes.Y,
                                            ColumnDimensions = new[]
                                            {
                                                new Dimension(),
                                                new Dimension(GridSizeMode.AutoSize)
                                            },
                                            RowDimensions = new[]
                                            {
                                                new Dimension(GridSizeMode.AutoSize)
                                            },
                                            Content = new[]
                                            {
                                                new[]
                                                {
                                                    new OsuSpriteText
                                                    {
                                                        Text             = new RomanisableString(beatmapSet.TitleUnicode, beatmapSet.Title),
                                                        Font             = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold),
                                                        RelativeSizeAxes = Axes.X,
                                                        Truncate         = true
                                                    },
                                                    Empty()
                                                }
                                            }
                                        },
                                        artistContainer = new GridContainer
                                        {
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes     = Axes.Y,
                                            ColumnDimensions = new[]
                                            {
                                                new Dimension(),
                                                new Dimension(GridSizeMode.AutoSize)
                                            },
                                            RowDimensions = new[]
                                            {
                                                new Dimension(GridSizeMode.AutoSize)
                                            },
                                            Content = new[]
                                            {
                                                new[]
                                                {
                                                    new OsuSpriteText
                                                    {
                                                        Text             = createArtistText(),
                                                        Font             = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold),
                                                        RelativeSizeAxes = Axes.X,
                                                        Truncate         = true
                                                    },
                                                    Empty()
                                                },
                                            }
                                        },
                                        new LinkFlowContainer(s =>
                                        {
                                            s.Shadow = false;
                                            s.Font   = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold);
                                        }).With(d =>
                                        {
                                            d.AutoSizeAxes = Axes.Both;
                                            d.Margin       = new MarginPadding {
                                                Top = 2
                                            };
                                            d.AddText("mapped by ", t => t.Colour = colourProvider.Content2);
                                            d.AddUserLink(beatmapSet.Author);
                                        }),
                                    }
                                },
                                new Container
                                {
                                    Name             = @"Bottom content",
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    Padding          = new MarginPadding
                                    {
                                        Horizontal = 10,
                                        Vertical   = 4
                                    },
                                    Children = new Drawable[]
                                    {
                                        idleBottomContent = new FillFlowContainer
                                        {
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes     = Axes.Y,
                                            Direction        = FillDirection.Vertical,
                                            Spacing          = new Vector2(0, 3),
                                            AlwaysPresent    = true,
                                            Children         = new Drawable[]
                                            {
                                                statisticsContainer = new FillFlowContainer <BeatmapCardStatistic>
                                                {
                                                    RelativeSizeAxes   = Axes.X,
                                                    AutoSizeAxes       = Axes.Y,
                                                    Direction          = FillDirection.Horizontal,
                                                    Spacing            = new Vector2(10, 0),
                                                    Alpha              = 0,
                                                    AlwaysPresent      = true,
                                                    ChildrenEnumerable = createStatistics()
                                                },
                                                new BeatmapCardExtraInfoRow(beatmapSet)
                                                {
                                                    Hovered = _ =>
                                                    {
                                                        content.ExpandAfterDelay();
                                                        return(false);
                                                    },
                                                    Unhovered = _ =>
                                                    {
                                                        // Handles the case where a user has not shown explicit intent to view expanded info.
                                                        // ie. quickly moved over the info row area but didn't remain within it.
                                                        if (!Expanded.Value)
                                                        {
                                                            content.CancelExpand();
                                                        }
                                                    }
                                                }
                                            }
                                        },
                                        downloadProgressBar = new BeatmapCardDownloadProgressBar
                                        {
                                            RelativeSizeAxes = Axes.X,
                                            Height           = 6,
                                            Anchor           = Anchor.Centre,
                                            Origin           = Anchor.Centre,
                                            State            = { BindTarget = downloadTracker.State },
                                            Progress         = { BindTarget = downloadTracker.Progress }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                ExpandedContent = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Padding          = new MarginPadding {
                        Horizontal = 10, Vertical = 13
                    },
                    Child = new BeatmapCardDifficultyList(beatmapSet)
                },
                Expanded = { BindTarget = Expanded }
            };

            if (beatmapSet.HasVideo)
            {
                leftIconArea.Add(new IconPill(FontAwesome.Solid.Film)
                {
                    IconSize = new Vector2(20)
                });
            }

            if (beatmapSet.HasStoryboard)
            {
                leftIconArea.Add(new IconPill(FontAwesome.Solid.Image)
                {
                    IconSize = new Vector2(20)
                });
            }

            if (beatmapSet.HasExplicitContent)
            {
                titleContainer.Content[0][1] = new ExplicitContentBeatmapPill
                {
                    Anchor = Anchor.BottomRight,
                    Origin = Anchor.BottomRight,
                    Margin = new MarginPadding {
                        Left = 5
                    }
                };
            }

            if (beatmapSet.TrackId != null)
            {
                artistContainer.Content[0][1] = new FeaturedArtistBeatmapPill
                {
                    Anchor = Anchor.BottomRight,
                    Origin = Anchor.BottomRight,
                    Margin = new MarginPadding {
                        Left = 5
                    }
                };
            }

            Action = () => beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmapSet.OnlineID);
        }