Пример #1
0
        public virtual void TestPlayIntroWithFailingAudioDevice()
        {
            AddStep("hide notifications", () => notifications.Hide());
            AddStep("restart sequence", () =>
            {
                logo.FinishTransforms();
                logo.IsTracking = false;

                IntroStack?.Expire();

                Add(IntroStack = new OsuScreenStack
                {
                    RelativeSizeAxes = Axes.Both,
                });

                IntroStack.Push(intro = CreateScreen());
            });

            AddStep("trigger failure", () =>
            {
                trackResetDelegate = Scheduler.AddDelayed(() =>
                {
                    intro.Beatmap.Value.Track.Seek(0);
                }, 0, true);
            });

            AddUntilStep("wait for menu", () => intro.DidLoadMenu);

            if (IntroReliesOnTrack)
            {
                AddUntilStep("wait for notification", () => notifications.UnreadCount.Value == 1);
            }

            AddStep("uninstall delegate", () => trackResetDelegate?.Cancel());
        }
Пример #2
0
        public void LoadScore([NotNull] Score score)
        {
            if (Score != null)
            {
                throw new InvalidOperationException($"Cannot load a new score on a {nameof(PlayerArea)} that has an existing score.");
            }

            Score = score;

            gameplayContent.Child = new PlayerIsolationContainer(beatmapManager.GetWorkingBeatmap(Score.ScoreInfo.BeatmapInfo), Score.ScoreInfo.Ruleset, Score.ScoreInfo.Mods)
            {
                RelativeSizeAxes = Axes.Both,
                Child            = stack = new OsuScreenStack
                {
                    Name = nameof(PlayerArea),
                }
            };

            stack.Push(new MultiSpectatorPlayerLoader(Score, () =>
            {
                var player = new MultiSpectatorPlayer(Score, GameplayClock);
                player.OnGameplayStarted += () => OnGameplayStarted?.Invoke();
                return(player);
            }));

            loadingLayer.Hide();
        }
Пример #3
0
        public void TestOperationDisposalAfterScreenExit()
        {
            TestScreenWithTracker screen = null;
            OsuScreenStack stack;
            IDisposable operation = null;

            AddStep("create screen with tracker", () =>
            {
                Child = stack = new OsuScreenStack
                {
                    RelativeSizeAxes = Axes.Both
                };

                stack.Push(screen = new TestScreenWithTracker());
            });
            AddUntilStep("wait for loaded", () => screen.IsLoaded);

            AddStep("begin operation", () => operation = screen.OngoingOperationTracker.BeginOperation());
            AddAssert("operation in progress", () => screen.OngoingOperationTracker.InProgress.Value);

            AddStep("dispose after screen exit", () =>
            {
                screen.Exit();
                operation.Dispose();
            });
            AddAssert("operation ended", () => !screen.OngoingOperationTracker.InProgress.Value);
        }
Пример #4
0
 protected void LoadScreen(OsuScreen screen)
 {
     if (stack.CurrentScreen != null)
     {
         stack.Exit();
     }
     stack.Push(screen);
 }
Пример #5
0
        public virtual void SetUp() => Schedule(() =>
        {
            var stack = new OsuScreenStack {
                RelativeSizeAxes = Axes.Both
            };
            Child = stack;

            stack.Push(songSelect = new DummySongSelect());
        });
Пример #6
0
            public TestResultsContainer(IScreen screen)
            {
                RelativeSizeAxes = Axes.Both;
                OsuScreenStack stack;

                InternalChild = stack = new OsuScreenStack
                {
                    RelativeSizeAxes = Axes.Both,
                };

                stack.Push(screen);
            }
Пример #7
0
        public TestSceneScreenBreadcrumbControl()
        {
            OsuSpriteText titleText;

            IScreen startScreen = new TestScreenOne();

            screenStack = new OsuScreenStack {
                RelativeSizeAxes = Axes.Both
            };
            screenStack.Push(startScreen);

            Children = new Drawable[]
            {
                screenStack,
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FillDirection.Vertical,
                    Spacing          = new Vector2(10),
                    Children         = new Drawable[]
                    {
                        breadcrumbs = new ScreenBreadcrumbControl(screenStack)
                        {
                            RelativeSizeAxes = Axes.X,
                        },
                        titleText = new OsuSpriteText(),
                    },
                },
            };

            breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue}";
            breadcrumbs.Current.TriggerChange();

            waitForCurrent();
            pushNext();
            waitForCurrent();
            pushNext();
            waitForCurrent();

            AddStep(@"make start current", () => startScreen.MakeCurrent());

            waitForCurrent();
            pushNext();
            waitForCurrent();
            AddAssert(@"only 2 items", () => breadcrumbs.Items.Count == 2);
            AddStep(@"exit current", () => screenStack.CurrentScreen.Exit());
            AddAssert(@"current screen is first", () => startScreen == screenStack.CurrentScreen);
        }
Пример #8
0
        public void TestResultsWithoutPlayer()
        {
            TestResultsScreen screen = null;
            OsuScreenStack    stack;

            AddStep("load results", () =>
            {
                Child = stack = new OsuScreenStack
                {
                    RelativeSizeAxes = Axes.Both
                };

                stack.Push(screen = createResultsScreen());
            });
            AddUntilStep("wait for loaded", () => screen.IsLoaded);
            AddAssert("retry overlay not present", () => screen.RetryOverlay == null);
        }
Пример #9
0
        public TestSceneMultiHeader()
        {
            int index = 0;

            OsuScreenStack screenStack = new OsuScreenStack {
                RelativeSizeAxes = Axes.Both
            };

            screenStack.Push(new TestOnlinePlaySubScreen(index));

            Children = new Drawable[]
            {
                screenStack,
                new Header("Multiplayer", screenStack)
            };

            AddStep("push multi screen", () => screenStack.CurrentScreen.Push(new TestOnlinePlaySubScreen(++index)));
        }
Пример #10
0
        public TestMultiplayerComponents()
        {
            multiplayerScreen = new TestMultiplayer();

            InternalChildren = new Drawable[]
            {
                userLookupCache,
                beatmapLookupCache,
                MultiplayerClient = new TestMultiplayerClient(RoomManager),
                screenStack       = new OsuScreenStack
                {
                    Name             = nameof(TestMultiplayerComponents),
                    RelativeSizeAxes = Axes.Both
                }
            };

            screenStack.Push(multiplayerScreen);
        }
Пример #11
0
        public virtual void TestPlayIntro()
        {
            AddStep("restart sequence", () =>
            {
                logo.FinishTransforms();
                logo.IsTracking = false;

                IntroStack?.Expire();

                Add(IntroStack = new OsuScreenStack
                {
                    RelativeSizeAxes = Axes.Both,
                });

                IntroStack.Push(intro = CreateScreen());
            });

            AddUntilStep("wait for menu", () => intro.DidLoadMenu);
        }
Пример #12
0
        protected IntroTestScene()
        {
            OsuScreenStack introStack = null;

            Children = new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Depth            = float.MaxValue,
                    Colour           = Color4.Black,
                },
                logo = new OsuLogo
                {
                    Alpha = 0,
                    RelativePositionAxes = Axes.Both,
                    Depth    = float.MinValue,
                    Position = new Vector2(0.5f),
                }
            };

            AddStep("restart sequence", () =>
            {
                logo.FinishTransforms();
                logo.IsTracking = false;

                introStack?.Expire();

                Add(introStack = new OsuScreenStack
                {
                    RelativeSizeAxes = Axes.Both,
                });

                introStack.Push(CreateScreen());
            });

            AddUntilStep("wait for menu", () => introStack.CurrentScreen is MainMenu);
        }
Пример #13
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 = menuScreen?.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.PresentImport    = items => PresentBeatmap(items.First());

            ScoreManager.PostNotification = n => notifications?.Post(n);
            ScoreManager.GetStableStorage = GetStorageForStableInstall;
            ScoreManager.PresentImport    = items => PresentScore(items.First());

            Container logoContainer;

            BackButton.Receptor receptor;

            dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));

            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,
                    Children         = new Drawable[]
                    {
                        receptor    = new BackButton.Receptor(),
                        ScreenStack = new OsuScreenStack {
                            RelativeSizeAxes = Axes.Both
                        },
                        BackButton = new BackButton(receptor)
                        {
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft,
                            Action = () =>
                            {
                                if ((ScreenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
                                {
                                    ScreenStack.Exit();
                                }
                            }
                        },
                        logoContainer = new Container {
                            RelativeSizeAxes = Axes.Both
                        },
                    }
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                rightFloatingOverlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                leftFloatingOverlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                topMostOverlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                idleTracker
            });

            ScreenStack.ScreenPushed += screenPushed;
            ScreenStack.ScreenExited += screenExited;

            loadComponentSingleFile(osuLogo, logo =>
            {
                logoContainer.Add(logo);

                // Loader has to be created after the logo has finished loading as Loader performs logo transformations on entering.
                ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));
            });

            loadComponentSingleFile(Toolbar = new Toolbar
            {
                OnHome = delegate
                {
                    CloseAllOverlays(false);
                    menuScreen?.MakeCurrent();
                },
            }, d =>
            {
                topMostOverlayContent.Add(d);
                toolbarElements.Add(d);
            });

            loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add, true);

            loadComponentSingleFile(new OnScreenDisplay(), Add, true);

            loadComponentSingleFile(musicController = new MusicController(), Add, true);

            loadComponentSingleFile(notifications = new NotificationOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, rightFloatingOverlayContent.Add, true);

            loadComponentSingleFile(screenshotManager, Add);

            //overlay elements
            loadComponentSingleFile(direct         = new DirectOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(social         = new SocialOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
            loadComponentSingleFile(chatOverlay    = new ChatOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(Settings       = new SettingsOverlay {
                GetToolbarHeight = () => ToolbarOffset
            }, leftFloatingOverlayContent.Add, true);
            var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);

            loadComponentSingleFile(userProfile       = new UserProfileOverlay(), overlayContent.Add, true);
            loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);

            loadComponentSingleFile(new LoginOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, rightFloatingOverlayContent.Add, true);

            loadComponentSingleFile(new NowPlayingOverlay
            {
                GetToolbarHeight = () => ToolbarOffset,
                Anchor           = Anchor.TopRight,
                Origin           = Anchor.TopRight,
            }, d =>
            {
                rightFloatingOverlayContent.Add(d);
                toolbarElements.Add(d);
            }, true);

            loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true);
            loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true);
            loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener(), topMostOverlayContent.Add);

            chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;

            Add(externalLinkOpener = new ExternalLinkOpener());

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

            overlays.AddRange(singleDisplaySideOverlays);

            foreach (var overlay in singleDisplaySideOverlays)
            {
                overlay.State.ValueChanged += state =>
                {
                    if (state.NewValue == 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.State.ValueChanged += state =>
                {
                    if (state.NewValue == 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, changelogOverlay };

            overlays.AddRange(singleDisplayOverlays);

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

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

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

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

            void updateScreenOffset()
            {
                float offset = 0;

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

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

            Settings.State.ValueChanged      += _ => updateScreenOffset();
            notifications.State.ValueChanged += _ => updateScreenOffset();
        }
Пример #14
0
 protected void LoadScreen(OsuScreen screen) => Stack.Push(screen);