public new void Setup() => Schedule(() =>
        {
            AvailabilityTracker.SelectedItem.BindTo(selectedItem);

            importedSet        = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
            Beatmap.Value      = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
            selectedItem.Value = new PlaylistItem
            {
                Beatmap = { Value = Beatmap.Value.BeatmapInfo },
                Ruleset = { Value = Beatmap.Value.BeatmapInfo.Ruleset },
            };

            Child = new FillFlowContainer
            {
                AutoSizeAxes = Axes.Both,
                Direction    = FillDirection.Vertical,
                Children     = new Drawable[]
                {
                    spectateButton = new MultiplayerSpectateButton
                    {
                        Anchor          = Anchor.Centre,
                        Origin          = Anchor.Centre,
                        Size            = new Vector2(200, 50),
                        OnSpectateClick = () =>
                        {
                            readyClickOperation = OngoingOperationTracker.BeginOperation();

                            Task.Run(async() =>
                            {
                                await Client.ToggleSpectate();
                                readyClickOperation.Dispose();
                            });
                        }
                    },
                    readyButton = new MultiplayerReadyButton
                    {
                        Anchor       = Anchor.Centre,
                        Origin       = Anchor.Centre,
                        Size         = new Vector2(200, 50),
                        OnReadyClick = () =>
                        {
                            readyClickOperation = OngoingOperationTracker.BeginOperation();

                            Task.Run(async() =>
                            {
                                if (Client.IsHost && Client.LocalUser?.State == MultiplayerUserState.Ready)
                                {
                                    await Client.StartMatch();
                                    return;
                                }

                                await Client.ToggleReady();

                                readyClickOperation.Dispose();
                            });
                        }
                    }
                }
            };
        });
Пример #2
0
        public new void Setup() => Schedule(() =>
        {
            importedSet        = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
            Beatmap.Value      = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
            selectedItem.Value = new PlaylistItem
            {
                Beatmap = { Value = Beatmap.Value.BeatmapInfo },
                Ruleset = { Value = Beatmap.Value.BeatmapInfo.Ruleset },
            };

            if (button != null)
            {
                Remove(button);
            }

            Add(button = new MultiplayerReadyButton
            {
                Anchor       = Anchor.Centre,
                Origin       = Anchor.Centre,
                Size         = new Vector2(200, 50),
                OnReadyClick = async() =>
                {
                    readyClickOperation = OngoingOperationTracker.BeginOperation();

                    if (Client.IsHost && Client.LocalUser?.State == MultiplayerUserState.Ready)
                    {
                        await Client.StartMatch();
                        return;
                    }

                    await Client.ToggleReady();
                    readyClickOperation.Dispose();
                }
            });
        });
Пример #3
0
        public void TestOperationTracking()
        {
            IDisposable firstOperation  = null;
            IDisposable secondOperation = null;

            AddStep("begin first operation", () => firstOperation = tracker.BeginOperation());
            AddAssert("first operation in progress", () => operationInProgress.Value);

            AddStep("cannot start another operation",
                    () => Assert.Throws <InvalidOperationException>(() => tracker.BeginOperation()));

            AddStep("end first operation", () => firstOperation.Dispose());
            AddAssert("first operation is ended", () => !operationInProgress.Value);

            AddStep("start second operation", () => secondOperation = tracker.BeginOperation());
            AddAssert("second operation in progress", () => operationInProgress.Value);

            AddStep("dispose first operation again", () => firstOperation.Dispose());
            AddAssert("second operation still in progress", () => operationInProgress.Value);

            AddStep("dispose second operation", () => secondOperation.Dispose());
            AddAssert("second operation is ended", () => !operationInProgress.Value);
        }
Пример #4
0
        public void TestButtonEnableStateChanges()
        {
            IDisposable joiningRoomOperation = null;

            assertButtonEnableState(true);

            AddStep("begin joining room", () => joiningRoomOperation = OngoingOperationTracker.BeginOperation());
            assertButtonEnableState(false);

            AddStep("end joining room", () => joiningRoomOperation.Dispose());
            assertButtonEnableState(true);

            AddStep("disconnect client", () => MultiplayerClient.Disconnect());
            assertButtonEnableState(false);

            AddStep("re-connect client", () => MultiplayerClient.Connect());
            assertButtonEnableState(true);
        }
        public new void Setup() => Schedule(() =>
        {
            AvailabilityTracker.SelectedItem.BindTo(selectedItem);

            beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
            importedSet   = beatmaps.GetAllUsableBeatmapSets().First();
            Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());

            selectedItem.Value = new PlaylistItem(Beatmap.Value.BeatmapInfo)
            {
                RulesetID = Beatmap.Value.BeatmapInfo.Ruleset.OnlineID
            };

            if (button != null)
            {
                Remove(button);
            }

            Add(button = new MultiplayerReadyButton
            {
                Anchor       = Anchor.Centre,
                Origin       = Anchor.Centre,
                Size         = new Vector2(200, 50),
                OnReadyClick = () =>
                {
                    readyClickOperation = OngoingOperationTracker.BeginOperation();

                    Task.Run(async() =>
                    {
                        if (MultiplayerClient.IsHost && MultiplayerClient.LocalUser?.State == MultiplayerUserState.Ready)
                        {
                            await MultiplayerClient.StartMatch();
                            return;
                        }

                        await MultiplayerClient.ToggleReady();

                        readyClickOperation.Dispose();
                    });
                }
            });
        });