Exemplo n.º 1
0
 private void cleanUpState()
 {
     // Ensure previous recorder is disposed else it may affect the global playing state of `SpectatorClient`.
     recorder?.RemoveAndDisposeImmediately();
     recorder = null;
     spectatorClient.OnNewFrames -= onNewFrames;
 }
Exemplo n.º 2
0
        public void SetUp() => Schedule(() =>
        {
            replay = new Replay();

            Add(new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                Content          = new[]
                {
                    new Drawable[]
                    {
                        recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
                        {
                            Recorder = recorder = new TestReplayRecorder(new Score
                            {
                                Replay    = replay,
                                ScoreInfo = { Beatmap = gameplayBeatmap.BeatmapInfo }
                            })
                            {
                                ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
                            },
                            Child = new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        Colour           = Color4.Brown,
                                        RelativeSizeAxes = Axes.Both,
                                    },
                                    new OsuSpriteText
                                    {
                                        Text   = "Recording",
                                        Scale  = new Vector2(3),
                                        Anchor = Anchor.Centre,
                                        Origin = Anchor.Centre,
                                    },
                                    new TestInputConsumer()
                                }
                            },
                        }
                    },
                    new Drawable[]
                    {
                        playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
                        {
                            ReplayInputHandler = new TestFramedReplayInputHandler(replay)
                            {
                                GamefieldToScreenSpace = pos => playbackManager.ToScreenSpace(pos),
                            },
                            Child = new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        Colour           = Color4.DarkBlue,
                                        RelativeSizeAxes = Axes.Both,
                                    },
                                    new OsuSpriteText
                                    {
                                        Text   = "Playback",
                                        Scale  = new Vector2(3),
                                        Anchor = Anchor.Centre,
                                        Origin = Anchor.Centre,
                                    },
                                    new TestInputConsumer()
                                }
                            },
                        }
                    }
                }
            });
        });
Exemplo n.º 3
0
        public void SetUp() => Schedule(() =>
        {
            replay = new Replay();

            users.BindTo(streamingClient.PlayingUsers);
            users.BindCollectionChanged((obj, args) =>
            {
                switch (args.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    Debug.Assert(args.NewItems != null);

                    foreach (int user in args.NewItems)
                    {
                        if (user == api.LocalUser.Value.Id)
                        {
                            streamingClient.WatchUser(user);
                        }
                    }

                    break;

                case NotifyCollectionChangedAction.Remove:
                    Debug.Assert(args.OldItems != null);

                    foreach (int user in args.OldItems)
                    {
                        if (user == api.LocalUser.Value.Id)
                        {
                            streamingClient.StopWatchingUser(user);
                        }
                    }

                    break;
                }
            }, true);

            streamingClient.OnNewFrames += onNewFrames;

            Add(new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                Content          = new[]
                {
                    new Drawable[]
                    {
                        recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
                        {
                            Recorder = recorder = new TestReplayRecorder
                            {
                                ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
                            },
                            Child = new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        Colour           = Color4.Brown,
                                        RelativeSizeAxes = Axes.Both,
                                    },
                                    new OsuSpriteText
                                    {
                                        Text   = "Sending",
                                        Scale  = new Vector2(3),
                                        Anchor = Anchor.Centre,
                                        Origin = Anchor.Centre,
                                    },
                                    new TestInputConsumer()
                                }
                            },
                        }
                    },
                    new Drawable[]
                    {
                        playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
                        {
                            Clock = new FramedClock(manualClock),
                            ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay)
                            {
                                GamefieldToScreenSpace = pos => playbackManager.ToScreenSpace(pos),
                            },
                            Child = new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        Colour           = Color4.DarkBlue,
                                        RelativeSizeAxes = Axes.Both,
                                    },
                                    new OsuSpriteText
                                    {
                                        Text   = "Receiving",
                                        Scale  = new Vector2(3),
                                        Anchor = Anchor.Centre,
                                        Origin = Anchor.Centre,
                                    },
                                    new TestInputConsumer()
                                }
                            },
                        }
                    }
                }
            });

            Add(latencyDisplay = new OsuSpriteText());
        });
Exemplo n.º 4
0
        public void SetUpSteps()
        {
            AddStep("Reset recorder state", cleanUpState);

            AddStep("Setup containers", () =>
            {
                replay = new Replay();

                Add(new GridContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            recordingManager = new TestRulesetInputManager(TestCustomisableModRuleset.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
                            {
                                Recorder = recorder = new TestReplayRecorder(new Score
                                {
                                    Replay    = replay,
                                    ScoreInfo =
                                    {
                                        BeatmapInfo = gameplayState.Beatmap.BeatmapInfo,
                                        Ruleset     = new OsuRuleset().RulesetInfo,
                                    }
                                })
                                {
                                    ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
                                },
                                Child = new Container
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Children         = new Drawable[]
                                    {
                                        new Box
                                        {
                                            Colour           = Color4.Brown,
                                            RelativeSizeAxes = Axes.Both,
                                        },
                                        new OsuSpriteText
                                        {
                                            Text   = "Recording",
                                            Scale  = new Vector2(3),
                                            Anchor = Anchor.Centre,
                                            Origin = Anchor.Centre,
                                        },
                                        new TestInputConsumer()
                                    }
                                },
                            }
                        },
                        new Drawable[]
                        {
                            playbackManager = new TestRulesetInputManager(TestCustomisableModRuleset.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
                            {
                                ReplayInputHandler = new TestFramedReplayInputHandler(replay)
                                {
                                    GamefieldToScreenSpace = pos => playbackManager.ToScreenSpace(pos),
                                },
                                Child = new Container
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Children         = new Drawable[]
                                    {
                                        new Box
                                        {
                                            Colour           = Color4.DarkBlue,
                                            RelativeSizeAxes = Axes.Both,
                                        },
                                        new OsuSpriteText
                                        {
                                            Text   = "Playback",
                                            Scale  = new Vector2(3),
                                            Anchor = Anchor.Centre,
                                            Origin = Anchor.Centre,
                                        },
                                        new TestInputConsumer()
                                    }
                                },
                            }
                        }
                    }
                });
            });
        }