예제 #1
0
파일: ScreenEntry.cs 프로젝트: Wieku/osu
        private void performRegistration()
        {
            if (focusNextTextBox())
            {
                registerShake.Shake();
                return;
            }

            usernameDescription.ClearErrors();
            emailAddressDescription.ClearErrors();
            passwordDescription.ClearErrors();

            loadingLayer.Show();

            Task.Run(() =>
            {
                bool success;
                RegistrationRequest.RegistrationRequestErrors errors = null;

                try
                {
                    errors  = api.CreateAccount(emailTextBox.Text, usernameTextBox.Text, passwordTextBox.Text);
                    success = errors == null;
                }
                catch (Exception)
                {
                    success = false;
                }

                Schedule(() =>
                {
                    if (!success)
                    {
                        if (errors != null)
                        {
                            usernameDescription.AddErrors(errors.User.Username);
                            emailAddressDescription.AddErrors(errors.User.Email);
                            passwordDescription.AddErrors(errors.User.Password);
                        }
                        else
                        {
                            passwordDescription.AddErrors(new[] { "Something happened... but we're not sure what." });
                        }

                        registerShake.Shake();
                        loadingLayer.Hide();
                        return;
                    }

                    api.Login(usernameTextBox.Text, passwordTextBox.Text);
                });
            });
        }
예제 #2
0
        private void performRegistration()
        {
            if (focusNextTextbox())
            {
                registerShake.Shake();
                return;
            }

            usernameDescription.ClearErrors();
            emailAddressDescription.ClearErrors();
            passwordDescription.ClearErrors();

            processingOverlay.Show();

            Task.Run(() =>
            {
                bool success;
                RegistrationRequest.RegistrationRequestErrors errors = null;

                try
                {
                    errors  = api.CreateAccount(emailTextBox.Text, usernameTextBox.Text, passwordTextBox.Text);
                    success = errors == null;
                }
                catch (Exception)
                {
                    success = false;
                }

                Schedule(() =>
                {
                    if (!success)
                    {
                        if (errors != null)
                        {
                            usernameDescription.AddErrors(errors.User.Username);
                            emailAddressDescription.AddErrors(errors.User.Email);
                            passwordDescription.AddErrors(errors.User.Password);
                        }
                        else
                        {
                            passwordDescription.AddErrors(new[] { "出现了未知错误,请稍后再试" });
                        }

                        registerShake.Shake();
                        processingOverlay.Hide();
                        return;
                    }

                    api.Login(emailTextBox.Text, passwordTextBox.Text);
                });
            });
        }
예제 #3
0
        private void load(OsuGame game, BeatmapManager beatmaps)
        {
            if (BeatmapSet.Value?.OnlineInfo?.Availability?.DownloadDisabled ?? false)
            {
                button.Enabled.Value = false;
                button.TooltipText   = "this beatmap is currently not available for download.";
                return;
            }

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

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

                    game?.PresentBeatmap(BeatmapSet.Value, findPredicate);
                    break;

                default:
                    beatmaps.Download(BeatmapSet.Value, noVideo);
                    break;
                }
            };
        }
예제 #4
0
        private void load(OsuGame game, BeatmapManager beatmaps)
        {
            if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false)
            {
                button.Enabled.Value = false;
                button.TooltipText   = "该谱面暂时无法下载";
                return;
            }

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

                case DownloadState.LocallyAvailable:
                    game.PresentBeatmap(BeatmapSet.Value);
                    break;

                default:
                    beatmaps.Download(BeatmapSet.Value, noVideo);
                    break;
                }
            };
        }
예제 #5
0
        private void load(OsuColour colours, OsuGame game, BeatmapManager beatmaps)
        {
            this.colours = colours;

            if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false)
            {
                button.Enabled.Value = false;
                button.TooltipText   = "This beatmap is currently not available for download.";
                return;
            }

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

                case DownloadState.LocallyAvailable:
                    game.PresentBeatmap(BeatmapSet.Value);
                    break;

                default:
                    beatmaps.Download(BeatmapSet.Value, noVideo);
                    break;
                }
            };
        }
예제 #6
0
        private void load(OsuGame game, ScoreManager scores)
        {
            InternalChild = shakeContainer = new ShakeContainer
            {
                RelativeSizeAxes = Axes.Both,
                Child            = button = new DownloadButton
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            button.Action = () =>
            {
                switch (State.Value)
                {
                case DownloadState.LocallyAvailable:
                    game?.PresentScore(Model.Value);
                    break;

                case DownloadState.NotDownloaded:
                    scores.Download(Model.Value);
                    break;

                case DownloadState.Downloaded:
                case DownloadState.Downloading:
                    shakeContainer.Shake();
                    break;
                }
            };

            State.BindValueChanged(state =>
            {
                button.State.Value = state.NewValue;

                switch (replayAvailability)
                {
                case ReplayAvailability.Local:
                    button.TooltipText = @"Watch replay";
                    break;

                case ReplayAvailability.Online:
                    button.TooltipText = @"Download replay";
                    break;

                default:
                    button.TooltipText = @"Replay unavailable";
                    break;
                }
            }, true);

            if (replayAvailability == ReplayAvailability.NotAvailable)
            {
                button.Enabled.Value = false;
                button.Alpha         = 0.6f;
            }
        }
예제 #7
0
 private void performLogin()
 {
     if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
     {
         api?.Login(username.Text, password.Text);
     }
     else
     {
         shakeSignIn.Shake();
     }
 }
예제 #8
0
        private void load(OsuGame game, ScoreManager scores)
        {
            InternalChild = shakeContainer = new ShakeContainer
            {
                RelativeSizeAxes = Axes.Both,
                Child            = button = new DownloadButton
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            button.Action = () =>
            {
                switch (State.Value)
                {
                case DownloadState.LocallyAvailable:
                    game?.PresentScore(Score.Value, ScorePresentType.Gameplay);
                    break;

                case DownloadState.NotDownloaded:
                    scores.Download(Score.Value, false);
                    break;

                case DownloadState.Importing:
                case DownloadState.Downloading:
                    shakeContainer.Shake();
                    break;
                }
            };

            Score.BindValueChanged(score =>
            {
                downloadTracker?.RemoveAndDisposeImmediately();

                if (score.NewValue != null)
                {
                    AddInternal(downloadTracker = new ScoreDownloadTracker(score.NewValue)
                    {
                        State = { BindTarget = State }
                    });
                }

                button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;
                updateTooltip();
            }, true);

            State.BindValueChanged(state =>
            {
                button.State.Value = state.NewValue;
                updateTooltip();
            }, true);
        }
예제 #9
0
        private void load(OsuGame game, BeatmapManager 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.OnlineID == SelectedBeatmap.Value.OnlineID;
                    }

                    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);
        }
예제 #10
0
        private void load(OsuGame game, ScoreManager scores)
        {
            InternalChild = shakeContainer = new ShakeContainer
            {
                RelativeSizeAxes = Axes.Both,
                Child            = button = new DownloadButton
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            button.Action = () =>
            {
                switch (State.Value)
                {
                case DownloadState.LocallyAvailable:
                    game?.PresentScore(Model.Value, ScorePresentType.Gameplay);
                    break;

                case DownloadState.NotDownloaded:
                    scores.Download(Model.Value);
                    break;

                case DownloadState.Importing:
                case DownloadState.Downloading:
                    shakeContainer.Shake();
                    break;
                }
            };

            State.BindValueChanged(state =>
            {
                button.State.Value = state.NewValue;

                updateTooltip();
            }, true);

            Model.BindValueChanged(_ =>
            {
                button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;

                updateTooltip();
            }, true);
        }
예제 #11
0
        private void load(OsuColour colours, OsuGame game, BeatmapManager beatmaps)
        {
            this.colours = colours;

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

                case DownloadState.LocallyAvailable:
                    game.PresentBeatmap(BeatmapSet.Value);
                    break;

                default:
                    beatmaps.Download(BeatmapSet.Value, noVideo);
                    break;
                }
            };
        }
예제 #12
0
 protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength);
예제 #13
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);
        }
예제 #14
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);
        }
예제 #15
0
 public virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength);