Exemplo n.º 1
0
        public DownloadButton(BeatmapSetInfo set, bool noVideo = false)
        {
            Width = 120;

            BeatmapSetDownloader downloader;

            Add(new Container
            {
                Depth            = -1,
                RelativeSizeAxes = Axes.Both,
                Padding          = new MarginPadding {
                    Horizontal = 10
                },
                Children = new Drawable[]
                {
                    downloader = new BeatmapSetDownloader(set, noVideo),
                    new FillFlowContainer
                    {
                        Anchor       = Anchor.CentreLeft,
                        Origin       = Anchor.CentreLeft,
                        AutoSizeAxes = Axes.Both,
                        Direction    = FillDirection.Vertical,
                        Children     = new[]
                        {
                            new OsuSpriteText
                            {
                                Text     = "Download",
                                TextSize = 13,
                                Font     = @"Exo2.0-Bold",
                            },
                            new OsuSpriteText
                            {
                                Text     = set.OnlineInfo.HasVideo && noVideo ? "without Video" : string.Empty,
                                TextSize = 11,
                                Font     = @"Exo2.0-Bold",
                            },
                        },
                    },
                    new SpriteIcon
                    {
                        Anchor = Anchor.CentreRight,
                        Origin = Anchor.CentreRight,
                        Icon   = FontAwesome.fa_download,
                        Size   = new Vector2(16),
                        Margin = new MarginPadding {
                            Right = 5
                        },
                    },
                },
            });

            Action = () =>
            {
                if (downloader.DownloadState.Value == BeatmapSetDownloader.DownloadStatus.Downloading)
                {
                    Content.MoveToX(-5, 50, Easing.OutSine).Then()
                    .MoveToX(5, 100, Easing.InOutSine).Then()
                    .MoveToX(-5, 100, Easing.InOutSine).Then()
                    .MoveToX(0, 50, Easing.InSine);
                    return;
                }

                downloader.Download();
            };

            downloader.DownloadState.ValueChanged += d =>
            {
                if (d == BeatmapSetDownloader.DownloadStatus.Downloaded)
                {
                    this.FadeOut(200);
                }
                else if (d == BeatmapSetDownloader.DownloadStatus.NotDownloaded)
                {
                    this.FadeIn(200);
                }
            };
        }