public TestSceneAccountCreationOverlay()
        {
            Container userPanelArea;
            AccountCreationOverlay accountCreation;

            Children = new Drawable[]
            {
                api,
                accountCreation = new AccountCreationOverlay(),
                userPanelArea   = new Container
                {
                    Padding      = new MarginPadding(10),
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.TopRight,
                    Origin       = Anchor.TopRight,
                },
            };

            api.Logout();
            api.LocalUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue)
                                                     {
                                                         Width = 200
                                                     }; }, true);

            AddStep("show", () => accountCreation.State = Visibility.Visible);
            AddStep("logout", () => api.Logout());
        }
Exemplo n.º 2
0
        public TestCaseAccountCreationOverlay()
        {
            var accountCreation = new AccountCreationOverlay();

            Child = accountCreation;

            accountCreation.State = Visibility.Visible;
        }
Exemplo n.º 3
0
 private void load(APIAccess api, OsuConfigManager config, AccountCreationOverlay accountCreation)
 {
     this.api         = api;
     Direction        = FillDirection.Vertical;
     Spacing          = new Vector2(0, 5);
     AutoSizeAxes     = Axes.Y;
     RelativeSizeAxes = Axes.X;
     Children         = new Drawable[]
     {
         username = new OsuTextBox
         {
             PlaceholderText          = "email address",
             RelativeSizeAxes         = Axes.X,
             Text                     = api?.ProvidedUsername ?? string.Empty,
             TabbableContentContainer = this
         },
         password = new OsuPasswordTextBox
         {
             PlaceholderText          = "password",
             RelativeSizeAxes         = Axes.X,
             TabbableContentContainer = this,
             OnCommit = (sender, newText) => performLogin()
         },
         new SettingsCheckbox
         {
             LabelText = "Remember email address",
             Bindable  = config.GetBindable <bool>(OsuSetting.SaveUsername),
         },
         new SettingsCheckbox
         {
             LabelText = "Stay signed in",
             Bindable  = config.GetBindable <bool>(OsuSetting.SavePassword),
         },
         new SettingsButton
         {
             Text   = "Sign in",
             Action = performLogin
         },
         new SettingsButton
         {
             Text   = "Register",
             Action = () =>
             {
                 RequestHide();
                 accountCreation.Show();
             }
         }
     };
 }
Exemplo n.º 4
0
        private void load(OsuConfigManager config, AccountCreationOverlay accountCreation)
        {
            Direction        = FillDirection.Vertical;
            Spacing          = new Vector2(0, 5);
            AutoSizeAxes     = Axes.Y;
            RelativeSizeAxes = Axes.X;

            ErrorTextFlowContainer errorText;

            Children = new Drawable[]
            {
                username = new OsuTextBox
                {
                    PlaceholderText          = UsersStrings.LoginUsername.ToLower(),
                    RelativeSizeAxes         = Axes.X,
                    Text                     = api?.ProvidedUsername ?? string.Empty,
                    TabbableContentContainer = this
                },
                password = new OsuPasswordTextBox
                {
                    PlaceholderText          = UsersStrings.LoginPassword.ToLower(),
                    RelativeSizeAxes         = Axes.X,
                    TabbableContentContainer = this,
                },
                errorText = new ErrorTextFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                },
                new SettingsCheckbox
                {
                    LabelText = "Remember username",
                    Current   = config.GetBindable <bool>(OsuSetting.SaveUsername),
                },
                new SettingsCheckbox
                {
                    LabelText = "Stay signed in",
                    Current   = config.GetBindable <bool>(OsuSetting.SavePassword),
                },
                new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Children         = new Drawable[]
                    {
                        shakeSignIn = new ShakeContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Child            = new SettingsButton
                            {
                                Text   = UsersStrings.LoginButton,
                                Action = performLogin
                            },
                        }
                    }
                },
                new SettingsButton
                {
                    Text   = "Register",
                    Action = () =>
                    {
                        RequestHide();
                        accountCreation.Show();
                    }
                }
            };

            password.OnCommit += (sender, newText) => performLogin();

            if (api?.LastLoginError?.Message is string error)
            {
                errorText.AddErrors(new[] { error });
            }
        }
Exemplo n.º 5
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            // The next time this is updated is in UpdateAfterChildren, which occurs too late and results
            // in the cursor being shown for a few frames during the intro.
            // This prevents the cursor from showing until we have a screen with CursorVisible = true
            MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;

            // todo: all archive managers should be able to be looped here.
            SkinManager.PostNotification = n => notifications?.Post(n);
            SkinManager.GetStableStorage = GetStorageForStableInstall;

            BeatmapManager.PostNotification = n => notifications?.Post(n);
            BeatmapManager.GetStableStorage = GetStorageForStableInstall;

            BeatmapManager.PresentBeatmap = PresentBeatmap;

            AddRange(new Drawable[]
            {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes      = Axes.Both,
                    ActionRequested       = action => volume.Adjust(action),
                    ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise),
                },
                screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays)
                {
                    RelativeSizeAxes = Axes.Both,
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both, Depth = float.MinValue
                },
                idleTracker = new IdleTracker(6000)
            });

            loadComponentSingleFile(screenStack = new Loader(), d =>
            {
                screenStack.ModePushed += screenAdded;
                screenStack.Exited     += screenRemoved;
                screenContainer.Add(screenStack);
            });

            loadComponentSingleFile(Toolbar = new Toolbar
            {
                Depth  = -5,
                OnHome = delegate
                {
                    CloseAllOverlays(false);
                    intro?.ChildScreen?.MakeCurrent();
                },
            }, overlayContent.Add);

            loadComponentSingleFile(volume          = new VolumeOverlay(), overlayContent.Add);
            loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add);

            loadComponentSingleFile(screenshotManager, Add);

            //overlay elements
            loadComponentSingleFile(direct = new DirectOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(social = new SocialOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal);
            loadComponentSingleFile(chatOverlay    = new ChatOverlay {
                Depth = -1
            }, mainContent.Add);
            loadComponentSingleFile(settings = new MainSettings
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -1
            }, overlayContent.Add);
            loadComponentSingleFile(userProfile = new UserProfileOverlay {
                Depth = -2
            }, mainContent.Add);
            loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay {
                Depth = -3
            }, mainContent.Add);
            loadComponentSingleFile(musicController = new MusicController
            {
                Depth    = -5,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor   = Anchor.TopRight,
                Origin   = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(notifications = new NotificationOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Depth            = -4,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, overlayContent.Add);

            loadComponentSingleFile(accountCreation = new AccountCreationOverlay
            {
                Depth = -6,
            }, overlayContent.Add);

            loadComponentSingleFile(dialogOverlay = new DialogOverlay
            {
                Depth = -7,
            }, overlayContent.Add);

            loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener
            {
                Depth = -8,
            }, overlayContent.Add);

            dependencies.Cache(idleTracker);
            dependencies.Cache(settings);
            dependencies.Cache(onscreenDisplay);
            dependencies.Cache(social);
            dependencies.Cache(direct);
            dependencies.Cache(chatOverlay);
            dependencies.Cache(channelManager);
            dependencies.Cache(userProfile);
            dependencies.Cache(musicController);
            dependencies.Cache(beatmapSetOverlay);
            dependencies.Cache(notifications);
            dependencies.Cache(dialogOverlay);
            dependencies.Cache(accountCreation);

            chatOverlay.StateChanged += state => channelManager.HighPollRate.Value = state == Visibility.Visible;

            Add(externalLinkOpener = new ExternalLinkOpener());

            var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications };

            overlays.AddRange(singleDisplaySideOverlays);

            foreach (var overlay in singleDisplaySideOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }
                    singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
            var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };

            overlays.AddRange(informationalOverlays);

            foreach (var overlay in informationalOverlays)
            {
                overlay.StateChanged += state =>
                {
                    if (state == Visibility.Hidden)
                    {
                        return;
                    }
                    informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            // ensure only one of these overlays are open at once.
            var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct };

            overlays.AddRange(singleDisplayOverlays);

            foreach (var overlay in singleDisplayOverlays)
            {
                overlay.StateChanged += state =>
                {
                    // informational overlays should be dismissed on a show or hide of a full overlay.
                    informationalOverlays.ForEach(o => o.Hide());

                    if (state == Visibility.Hidden)
                    {
                        return;
                    }

                    singleDisplayOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
                };
            }

            OverlayActivationMode.ValueChanged += v =>
            {
                if (v != OverlayActivation.All)
                {
                    CloseAllOverlays();
                }
            };

            void updateScreenOffset()
            {
                float offset = 0;

                if (settings.State == Visibility.Visible)
                {
                    offset += ToolbarButton.WIDTH / 2;
                }
                if (notifications.State == Visibility.Visible)
                {
                    offset -= ToolbarButton.WIDTH / 2;
                }

                screenContainer.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
            }

            settings.StateChanged      += _ => updateScreenOffset();
            notifications.StateChanged += _ => updateScreenOffset();
        }