private void load()
        {
            Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);

            base.Content.AddRange(new Drawable[]
            {
                new OsuContextMenuContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Child            = Content
                },
                dialogOverlay = new DialogOverlay()
            });

            var beatDivisor = new BindableBeatDivisor
            {
                Value = Beatmap.Value.BeatmapInfo.BeatDivisor
            };
            var editorClock = new EditorClock(Beatmap.Value.Beatmap, beatDivisor)
            {
                IsCoupled = false
            };

            Dependencies.CacheAs(editorClock);
            Dependencies.Cache(beatDivisor);
            Dependencies.Cache(dialogOverlay);
        }
Exemple #2
0
        private void load()
        {
            Beatmap.Value = new TestWorkingBeatmap(new Beatmap
            {
                HitObjects = new List <HitObject>
                {
                    new HitCircle {
                        Position = new Vector2(256, 192), Scale = 0.5f
                    },
                    new HitCircle {
                        Position = new Vector2(344, 148), Scale = 0.5f
                    },
                    new Slider
                    {
                        Position      = new Vector2(128, 256),
                        ControlPoints = new[]
                        {
                            Vector2.Zero,
                            new Vector2(216, 0),
                        },
                        Distance = 216,
                        Scale    = 0.5f,
                    }
                },
            });

            var clock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            Dependencies.CacheAs <IAdjustableClock>(clock);
            Dependencies.CacheAs <IFrameBasedClock>(clock);

            Child = new OsuHitObjectComposer(new OsuRuleset());
        }
Exemple #3
0
        private void load(AudioManager audio)
        {
            Beatmap.Value = new WaveformTestBeatmap(audio);

            var playable = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);

            EditorBeatmap = new EditorBeatmap(playable);

            Dependencies.Cache(EditorBeatmap);
            Dependencies.CacheAs <IBeatSnapProvider>(EditorBeatmap);

            Composer = playable.BeatmapInfo.Ruleset.CreateInstance().CreateHitObjectComposer().With(d => d.Alpha = 0);

            AddRange(new Drawable[]
            {
                EditorBeatmap,
                Composer,
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Spacing      = new Vector2(0, 5),
                    Children     = new Drawable[]
                    {
                        new StartStopButton(),
                        new AudioVisualiser(),
                    }
                },
                TimelineArea = new TimelineArea(CreateTestComponent())
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                }
            });
        }
Exemple #4
0
        private void load(AudioManager audio)
        {
            Beatmap.Value = new WaveformTestBeatmap(audio);

            var editorBeatmap = new EditorBeatmap((Beatmap <HitObject>)Beatmap.Value.Beatmap, BeatDivisor);

            Dependencies.Cache(editorBeatmap);
            Dependencies.CacheAs <IBeatSnapProvider>(editorBeatmap);

            AddRange(new Drawable[]
            {
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Spacing      = new Vector2(0, 5),
                    Children     = new Drawable[]
                    {
                        new StartStopButton(),
                        new AudioVisualiser(),
                    }
                },
                TimelineArea = new TimelineArea
                {
                    Child            = CreateTestComponent(),
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.X,
                    Size             = new Vector2(0.8f, 100),
                }
            });
        }
        private void load()
        {
            Dependencies.Cache(BeatDivisor);
            Dependencies.CacheAs <IFrameBasedClock>(Clock);
            Dependencies.CacheAs <IAdjustableClock>(Clock);

            Beatmap.BindValueChanged(beatmapChanged, true);
        }
Exemple #6
0
        private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
        {
            Add(logo);

            if (IsolateSavingFromDatabase)
            {
                Dependencies.CacheAs <BeatmapManager>(testBeatmapManager = new TestBeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
            }
        }
        private void load()
        {
            Add(dialogOverlay = new DialogOverlay
            {
                Depth = -1
            });

            Dependencies.CacheAs <IDialogOverlay>(dialogOverlay);
        }
        private void load()
        {
            Dependencies.CacheAs(multiplayerClient.Object);
            Dependencies.CacheAs(ongoingOperationTracker = new OngoingOperationTracker());
            Dependencies.CacheAs(availabilityTracker.Object);

            availabilityTracker.SetupGet(a => a.Availability).Returns(beatmapAvailability);

            multiplayerClient.SetupGet(m => m.LocalUser).Returns(() => localUser);
            multiplayerClient.SetupGet(m => m.Room).Returns(() => multiplayerRoom);

            // By default, the local user is to be the host.
            multiplayerClient.SetupGet(m => m.IsHost).Returns(() => ReferenceEquals(multiplayerRoom.Host, localUser));

            // Assume all state changes are accepted by the server.
            multiplayerClient.Setup(m => m.ChangeState(It.IsAny <MultiplayerUserState>()))
            .Callback((MultiplayerUserState r) =>
            {
                Logger.Log($"Changing local user state from {localUser.State} to {r}");
                localUser.State = r;
                raiseRoomUpdated();
            });

            multiplayerClient.Setup(m => m.StartMatch())
            .Callback(() =>
            {
                multiplayerClient.Raise(m => m.LoadRequested -= null);

                // immediately "end" gameplay, as we don't care about that part of the process.
                changeUserState(localUser.UserID, MultiplayerUserState.Idle);
            });

            multiplayerClient.Setup(m => m.SendMatchRequest(It.IsAny <MatchUserRequest>()))
            .Callback((MatchUserRequest request) =>
            {
                switch (request)
                {
                case StartMatchCountdownRequest countdownStart:
                    setRoomCountdown(countdownStart.Duration);
                    break;

                case StopCountdownRequest _:
                    multiplayerRoom.Countdown = null;
                    raiseRoomUpdated();
                    break;
                }
            });

            Children = new Drawable[]
            {
                ongoingOperationTracker,
                content = new PopoverContainer {
                    RelativeSizeAxes = Axes.Both
                }
            };
        }
Exemple #9
0
        private void load()
        {
            Dependencies.CacheAs(multiplayerClient.Object);

            Child = new RankRangePill
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre
            };
        }
Exemple #10
0
        private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
        {
            var working = CreateWorkingBeatmap(Ruleset.Value);

            Beatmap.Value = working;

            if (IsolateSavingFromDatabase)
            {
                Dependencies.CacheAs <BeatmapManager>(new TestBeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default, working));
            }
        }
Exemple #11
0
        private void load(GameHost host)
        {
            var resources    = new KaraokeRuleset().CreateResourceStore();
            var textureStore = new TextureStore(host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(resources, @"Textures")));

            Dependencies.CacheAs(textureStore);

            Add(new ManageFontPreview
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
            });
        }
Exemple #12
0
        private void load(TournamentStorage storage)
        {
            Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();

            match = CreateSampleMatch();

            Ladder.Rounds.Add(match.Round.Value);
            Ladder.Matches.Add(match);
            Ladder.Teams.Add(match.Team1.Value);
            Ladder.Teams.Add(match.Team2.Value);

            Ruleset.BindTo(Ladder.Ruleset);
            Dependencies.CacheAs(new StableInfo(storage));
        }
Exemple #13
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            // Usually this would be placed between the host and the game, but that's a bit of a pain to do with the test scene hierarchy.

            // Add is required for the container to get a size (and give out correct metrics to the usages in SafeAreaContainer).
            Add(safeAreaContainer = new SafeAreaDefiningContainer(safeArea = new BindableSafeArea())
            {
                RelativeSizeAxes = Axes.Both
            });

            // Cache is required for the test game to see the safe area.
            Dependencies.CacheAs <ISafeArea>(safeAreaContainer);
        }
        private void load()
        {
            Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);

            // Copied from TestSceneHitObjectComposer
            var clock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            Dependencies.CacheAs <IAdjustableClock>(clock);
            Dependencies.CacheAs <IFrameBasedClock>(clock);
            Dependencies.CacheAs(editorBeatmap);
            Dependencies.CacheAs <IBeatSnapProvider>(editorBeatmap);

            Child = new LyricEditorScreen();
        }
Exemple #15
0
        private void Init()
        {
            Dependencies.CacheAs <IRecycler <ReplayableInput> >(replayInputRecycler);
            Dependencies.CacheAs <IRecycler <ReplayFrame> >(replayFrameRecycler);

            base.OnHardInit += () =>
            {
                InitGameProcessor();
            };
            base.OnHardDispose += () =>
            {
                Dependencies.Remove(gameProcessor);
                gameProcessor.Destroy();
                gameProcessor = null;
            };
        }
        private void load()
        {
            osuConfigManager = new OsuConfigManager(LocalStorage);

            Dependencies.CacheAs(osuConfigManager);

            Children = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new Drawable[]
                    {
                        scaling1 = new ScalingContainer(ScalingMode.Everything)
                        {
                            Anchor   = Anchor.Centre,
                            Origin   = Anchor.Centre,
                            Scale    = new Vector2(0.8f),
                            Children = new Drawable[]
                            {
                                scaling2 = new ScalingContainer(ScalingMode.Everything)
                                {
                                    Anchor   = Anchor.Centre,
                                    Origin   = Anchor.Centre,
                                    Scale    = new Vector2(0.8f),
                                    Children = new Drawable[]
                                    {
                                        new Box
                                        {
                                            Colour           = Color4.Purple,
                                            RelativeSizeAxes = Axes.Both,
                                        },
                                        scaleTarget = new Box
                                        {
                                            Anchor = Anchor.Centre,
                                            Origin = Anchor.Centre,
                                            Colour = Color4.White,
                                            Size   = new Vector2(100),
                                        },
                                    }
                                }
                            }
                        }
                    }
                },
            };
        }
Exemple #17
0
        protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
        {
            var host = parent.Get <GameHost>();

            headlessHostStorage = (host as HeadlessGameHost)?.Storage;

            Resources = parent.Get <OsuGameBase>().Resources;

            realm = new Lazy <RealmAccess>(() => new RealmAccess(LocalStorage, OsuGameBase.CLIENT_DATABASE_FILENAME, host.UpdateThread));

            RecycleLocalStorage(false);

            var baseDependencies = base.CreateChildDependencies(parent);

            // to isolate ruleset configs in tests from the actual database and avoid state pollution problems,
            // as well as problems due to the implementation details of the "real" implementation (the configs only being available at `LoadComplete()`),
            // cache a test implementation of the ruleset config cache over the "real" one.
            var isolatedBaseDependencies = new DependencyContainer(baseDependencies);

            isolatedBaseDependencies.CacheAs(RulesetConfigs = new TestRulesetConfigCache());
            baseDependencies = isolatedBaseDependencies;

            var providedRuleset = CreateRuleset();

            if (providedRuleset != null)
            {
                isolatedBaseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies);
            }

            Dependencies = isolatedBaseDependencies;

            Beatmap.Default = parent.Get <Bindable <WorkingBeatmap> >().Default;
            Beatmap.SetDefault();

            Ruleset.Value = CreateRuleset()?.RulesetInfo ?? parent.Get <RulesetStore>().AvailableRulesets.First();

            SelectedMods.SetDefault();

            if (!UseOnlineAPI)
            {
                dummyAPI = new DummyAPIAccess();
                Dependencies.CacheAs <IAPIProvider>(dummyAPI);
                base.Content.Add(dummyAPI);
            }

            return(Dependencies);
        }
Exemple #18
0
        private void load(OsuColour colours)
        {
            linkColour = colours.Blue;

            var chatManager = new ChannelManager();
            BindableList <Channel> availableChannels = (BindableList <Channel>)chatManager.AvailableChannels;

            availableChannels.Add(new Channel {
                Name = "#english"
            });
            availableChannels.Add(new Channel {
                Name = "#japanese"
            });
            Dependencies.Cache(chatManager);

            Dependencies.Cache(new ChatOverlay());
            Dependencies.CacheAs <IDialogOverlay>(dialogOverlay);
        }
        private void load(GameHost host)
        {
            Dependencies.Cache(rulesets       = new RealmRulesetStore(Realm));
            Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, rulesets, null, Audio, Resources, host, Beatmap.Default));
            Dependencies.Cache(Realm);

            beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();

            base.Content.AddRange(new Drawable[]
            {
                manager = new CollectionManager(LocalStorage),
                Content,
                dialogOverlay = new DialogOverlay(),
            });

            Dependencies.Cache(manager);
            Dependencies.CacheAs <IDialogOverlay>(dialogOverlay);
        }
Exemple #20
0
        private void load()
        {
            var mockLounge = new Mock <LoungeSubScreen>();

            mockLounge
            .Setup(l => l.Join(It.IsAny <Room>(), It.IsAny <string>(), It.IsAny <Action <Room> >(), It.IsAny <Action <string> >()))
            .Callback <Room, string, Action <Room>, Action <string> >((a, b, c, d) =>
            {
                Task.Run(() =>
                {
                    allowResponseCallback.Wait();
                    allowResponseCallback.Reset();
                    Schedule(() => d?.Invoke("Incorrect password"));
                });
            });

            Dependencies.CacheAs(mockLounge.Object);
        }
Exemple #21
0
        private void load()
        {
            var clock = new EditorClock {
                IsCoupled = false
            };

            Dependencies.CacheAs(clock);

            var playback = new PlaybackControl
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size   = new Vector2(200, 100)
            };

            Beatmap.Value = CreateWorkingBeatmap(new Beatmap());

            Child = playback;
        }
        private void load()
        {
            Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
            Dependencies.CacheAs(spectatorClient.Object);
            Dependencies.CacheAs(multiplayerClient.Object);

            // To emulate `MultiplayerClient.CurrentMatchPlayingUserIds` we need a bindable list of *only IDs*.
            // This tracks the list of users 1:1.
            MultiplayerUsers.BindCollectionChanged((c, e) =>
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    Debug.Assert(e.NewItems != null);

                    foreach (var user in e.NewItems.OfType <MultiplayerRoomUser>())
                    {
                        multiplayerUserIds.Add(user.UserID);
                    }
                    break;

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

                    foreach (var user in e.OldItems.OfType <MultiplayerRoomUser>())
                    {
                        multiplayerUserIds.Remove(user.UserID);
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    multiplayerUserIds.Clear();
                    break;
                }
            });

            multiplayerClient.SetupGet(c => c.CurrentMatchPlayingUserIds)
            .Returns(() => multiplayerUserIds);

            spectatorClient.SetupGet(c => c.WatchedUserStates)
            .Returns(() => watchedUserStates);
        }
Exemple #23
0
        private void load()
        {
            var clock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            Dependencies.CacheAs <IAdjustableClock>(clock);
            Dependencies.CacheAs <IFrameBasedClock>(clock);

            var playback = new PlaybackControl
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size   = new Vector2(200, 100)
            };

            Beatmap.Value = new TestWorkingBeatmap(new Beatmap(), Clock);

            Child = playback;
        }
        private void load()
        {
            Beatmap.Value = CreateWorkingBeatmap(new Beatmap
            {
                HitObjects = new List <HitObject>
                {
                    new HitCircle {
                        Position = new Vector2(256, 192), Scale = 0.5f
                    },
                    new HitCircle {
                        Position = new Vector2(344, 148), Scale = 0.5f
                    },
                    new Slider
                    {
                        Position = new Vector2(128, 256),
                        Path     = new SliderPath(PathType.Linear, new[]
                        {
                            Vector2.Zero,
                            new Vector2(216, 0),
                        }),
                        Scale = 0.5f,
                    }
                },
            });

            var editorBeatmap = new EditorBeatmap(Beatmap.Value.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));

            var clock = new DecoupleableInterpolatingFramedClock {
                IsCoupled = false
            };

            Dependencies.CacheAs <IAdjustableClock>(clock);
            Dependencies.CacheAs <IFrameBasedClock>(clock);
            Dependencies.CacheAs(editorBeatmap);
            Dependencies.CacheAs <IBeatSnapProvider>(editorBeatmap);

            Child = new OsuHitObjectComposer(new OsuRuleset());
        }
Exemple #25
0
        private void bootstrapSceneGraph(Game game)
        {
            var root = new UserInputManager
            {
                Child = new PlatformActionContainer
                {
                    Child = new FrameworkActionContainer
                    {
                        Child = game
                    }
                }
            };

            Dependencies.Cache(root);
            Dependencies.CacheAs(game);

            game.SetHost(this);

            root.Load(SceneGraphClock, Dependencies);

            //publish bootstrapped scene graph to all threads.
            Root = root;
        }
Exemple #26
0
        private void Init()
        {
            Dependencies.Cache(this);

            if (GameSession != null)
            {
                GameSession.OnHardInit    += OnHardInit;
                GameSession.OnSoftInit    += OnSoftInit;
                GameSession.OnSoftDispose += OnSoftDispose;
                GameSession.OnHardDispose += OnHardDispose;
            }

            hitCircleRecycler     = new ManagedRecycler <HitCircleView>(CreateHitCircle);
            draggerCircleRecycler = new ManagedRecycler <DraggerCircleView>(CreateDraggerCircle);
            tickRecycler          = new ManagedRecycler <DraggerTickView>(CreateTick);
            draggerRecycler       = new ManagedRecycler <DraggerView>(CreateDragger);

            hitObjectViews = new RangedList <HitObjectView>(400);

            // Add tick and drag circle as dependencies for dragger view to draw its nested objects.
            Dependencies.CacheAs <IRecycler <DraggerCircleView> >(draggerCircleRecycler);
            Dependencies.CacheAs <IRecycler <DraggerTickView> >(tickRecycler);
        }
 private void load(AudioManager audio, GameHost host)
 {
     Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
     Dependencies.CacheAs <BeatmapManager>(beatmaps = new TestBeatmapManager(LocalStorage, ContextFactory, rulesets, API, audio, host, Beatmap.Default));
 }
Exemple #28
0
 private void load()
 {
     Dependencies.CacheAs(notifications.Object);
     notifications.SetupGet(n => n.UnreadCount).Returns(unreadNotificationCount);
 }
Exemple #29
0
 private void load(AudioManager audio, GameHost host)
 {
     Dependencies.Cache(rulesets = new RulesetStore(Realm));
     Dependencies.CacheAs <BeatmapManager>(beatmaps = new TestBeatmapManager(LocalStorage, Realm, rulesets, API, audio, Resources, host, Beatmap.Default));
     Dependencies.CacheAs <BeatmapModelDownloader>(beatmapDownloader = new TestBeatmapModelDownloader(beatmaps, API));
 }
 private void load()
 {
     Dependencies.Cache(LocalConfig = new OsuConfigManager(LocalStorage));
     Dependencies.CacheAs <IPerformFromScreenRunner>(performer.Object);
     Dependencies.CacheAs <INotificationOverlay>(notificationOverlay.Object);
 }