Ejemplo n.º 1
0
        private void load(IAPIProvider api, BeatmapManager beatmaps)
        {
            FillFlowContainer textSprites;

            AddRangeInternal(new Drawable[]
            {
                shakeContainer = new ShakeContainer
                {
                    Depth            = -1,
                    RelativeSizeAxes = Axes.Both,
                    Masking          = true,
                    CornerRadius     = 5,
                    Children         = new Drawable[]
                    {
                        button = new HeaderButton {
                            RelativeSizeAxes = Axes.Both
                        },
                        new Container
                        {
                            // cannot nest inside here due to the structure of button (putting things in its own content).
                            // requires framework fix.
                            Padding = new MarginPadding {
                                Horizontal = 10
                            },
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                textSprites = new FillFlowContainer
                                {
                                    Depth            = -1,
                                    Anchor           = Anchor.CentreLeft,
                                    Origin           = Anchor.CentreLeft,
                                    AutoSizeAxes     = Axes.Both,
                                    AutoSizeDuration = 500,
                                    AutoSizeEasing   = Easing.OutQuint,
                                    Direction        = FillDirection.Vertical,
                                },
                                new SpriteIcon
                                {
                                    Depth  = -1,
                                    Anchor = Anchor.CentreRight,
                                    Origin = Anchor.CentreRight,
                                    Icon   = FontAwesome.Solid.Download,
                                    Size   = new Vector2(16),
                                    Margin = new MarginPadding {
                                        Right = 5
                                    },
                                },
                            }
                        },
                        new DownloadProgressBar(BeatmapSet.Value)
                        {
                            Depth  = -2,
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft,
                        },
                    },
                },
            });

            button.Action = () =>
            {
                if (State.Value != DownloadState.NotDownloaded)
                {
                    shakeContainer.Shake();
                    return;
                }

                beatmaps.Download(BeatmapSet.Value, noVideo);
            };

            localUser.BindTo(api.LocalUser);
            localUser.BindValueChanged(userChanged, true);
            button.Enabled.BindValueChanged(enabledChanged, true);

            State.BindValueChanged(state =>
            {
                switch (state.NewValue)
                {
                case DownloadState.Downloading:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = "Downloading...",
                            Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold)
                        },
                    };
                    break;

                case DownloadState.Downloaded:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = "Importing...",
                            Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold)
                        },
                    };
                    break;

                case DownloadState.LocallyAvailable:
                    this.FadeOut(200);
                    break;

                case DownloadState.NotDownloaded:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = "Download",
                            Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold)
                        },
                        new OsuSpriteText
                        {
                            Text = BeatmapSet.Value.OnlineInfo.HasVideo && noVideo ? "without Video" : string.Empty,
                            Font = OsuFont.GetFont(size: 11, weight: FontWeight.Bold)
                        },
                    };
                    this.FadeIn(200);
                    break;
                }
            }, true);
        }
Ejemplo n.º 2
0
        private void load(IAPIProvider api, BeatmapManager beatmaps)
        {
            FillFlowContainer textSprites;

            AddInternal(shakeContainer = new ShakeContainer
            {
                RelativeSizeAxes = Axes.Both,
                Masking          = true,
                CornerRadius     = 5,
                Child            = button = new HeaderButton {
                    RelativeSizeAxes = Axes.Both
                },
            });

            button.AddRange(new Drawable[]
            {
                new Container
                {
                    Padding = new MarginPadding {
                        Horizontal = 10
                    },
                    RelativeSizeAxes = Axes.Both,
                    Children         = new Drawable[]
                    {
                        textSprites = new FillFlowContainer
                        {
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            AutoSizeAxes     = Axes.Both,
                            AutoSizeDuration = 500,
                            AutoSizeEasing   = Easing.OutQuint,
                            Direction        = FillDirection.Vertical,
                        },
                        new SpriteIcon
                        {
                            Anchor = Anchor.CentreRight,
                            Origin = Anchor.CentreRight,
                            Icon   = FontAwesome.Solid.Download,
                            Size   = new Vector2(18),
                        },
                    }
                },
                new DownloadProgressBar(BeatmapSet.Value)
                {
                    Anchor = Anchor.BottomLeft,
                    Origin = Anchor.BottomLeft,
                },
            });

            button.Action = () =>
            {
                if (State.Value != DownloadState.NotDownloaded)
                {
                    shakeContainer.Shake();
                    return;
                }

                beatmaps.Download(BeatmapSet.Value, noVideo);
            };

            localUser.BindTo(api.LocalUser);
            localUser.BindValueChanged(userChanged, true);
            button.Enabled.BindValueChanged(enabledChanged, true);

            State.BindValueChanged(state =>
            {
                switch (state.NewValue)
                {
                case DownloadState.Downloading:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = "Downloading...",
                            Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
                        },
                    };
                    break;

                case DownloadState.Importing:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = "Importing...",
                            Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
                        },
                    };
                    break;

                case DownloadState.LocallyAvailable:
                    this.FadeOut(200);
                    break;

                case DownloadState.NotDownloaded:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = "Download",
                            Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
                        },
                        new OsuSpriteText
                        {
                            Text = getVideoSuffixText(),
                            Font = OsuFont.GetFont(size: text_size - 2, weight: FontWeight.Bold)
                        },
                    };
                    this.FadeIn(200);
                    break;
                }
            }, true);
        }