Example #1
0
        public void TestNotificationMessage(IBeatmapSetInfo model)
        {
            AddStep("clear recent notification", () => recentNotification = null);
            AddStep("download beatmap", () => beatmaps.Download(model));

            AddUntilStep("wait for notification", () => recentNotification != null);
            AddUntilStep("notification text correct", () => recentNotification.Text.ToString() == "Downloading test author - test title (mapper)");
        }
Example #2
0
        private void load(OsuGame game, BeatmapModelDownloader beatmaps, OsuConfigManager osuConfig)
        {
            noVideoSetting = osuConfig.GetBindable <bool>(OsuSetting.PreferNoVideo);

            button.Action = () =>
            {
                switch (DownloadTracker.State.Value)
                {
                case DownloadState.Downloading:
                case DownloadState.Importing:
                    shakeContainer.Shake();
                    break;

                case DownloadState.LocallyAvailable:
                    Predicate <BeatmapInfo> findPredicate = null;
                    if (SelectedBeatmap.Value != null)
                    {
                        findPredicate = b => b.MatchesOnlineID(SelectedBeatmap.Value);
                    }

                    game?.PresentBeatmap(beatmapSet, findPredicate);
                    break;

                default:
                    beatmaps.Download(beatmapSet, noVideoSetting.Value);
                    break;
                }
            };

            State.BindValueChanged(state =>
            {
                switch (state.NewValue)
                {
                case DownloadState.LocallyAvailable:
                    button.Enabled.Value = true;
                    button.TooltipText   = "Go to beatmap";
                    break;

                default:
                    if ((beatmapSet as IBeatmapSetOnlineInfo)?.Availability.DownloadDisabled == true)
                    {
                        button.Enabled.Value = false;
                        button.TooltipText   = "this beatmap is currently not available for download.";
                    }

                    break;
                }
            }, true);
        }
Example #3
0
        private void load(IAPIProvider api, BeatmapModelDownloader beatmaps)
        {
            FillFlowContainer textSprites;

            InternalChildren = new Drawable[]
            {
                shakeContainer = new ShakeContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Masking          = true,
                    CornerRadius     = 5,
                    Child            = button = new HeaderButton {
                        RelativeSizeAxes = Axes.Both
                    },
                },
                downloadTracker = new BeatmapDownloadTracker(beatmapSet),
            };

            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)
                {
                    Anchor = Anchor.BottomLeft,
                    Origin = Anchor.BottomLeft,
                },
            });

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

                beatmaps.Download(beatmapSet, noVideo);
            };

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

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

                case DownloadState.Importing:
                    textSprites.Children = new Drawable[]
                    {
                        new OsuSpriteText
                        {
                            Text = CommonStrings.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 = BeatmapsetsStrings.ShowDetailsDownloadDefault,
                            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);
        }