Exemplo n.º 1
0
        protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
        {
            var baseDependencies = base.CreateChildDependencies(parent);

            var providedRuleset = CreateRuleset();

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

            Dependencies = new OsuScreenDependencies(false, baseDependencies);

            Beatmap = Dependencies.Beatmap;
            Beatmap.SetDefault();

            Ruleset = Dependencies.Ruleset;
            Ruleset.SetDefault();

            SelectedMods = Dependencies.Mods;
            SelectedMods.SetDefault();

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

            return(Dependencies);
        }
Exemplo n.º 2
0
        protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
        {
            if (!UseFreshStoragePerRun)
            {
                isolatedHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage;
            }

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

            contextFactory = new Lazy <DatabaseContextFactory>(() =>
            {
                var factory = new DatabaseContextFactory(LocalStorage);

                // only reset the database if not using the host storage.
                // if we reset the host storage, it will delete global key bindings.
                if (isolatedHostStorage == null)
                {
                    factory.ResetDatabase();
                }

                using (var usage = factory.Get())
                    usage.Migrate();
                return(factory);
            });

            RecycleLocalStorage();

            var baseDependencies = base.CreateChildDependencies(parent);

            var providedRuleset = CreateRuleset();

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

            Dependencies = new OsuScreenDependencies(false, baseDependencies);

            Beatmap = Dependencies.Beatmap;
            Beatmap.SetDefault();

            Ruleset = Dependencies.Ruleset;
            Ruleset.SetDefault();

            SelectedMods = Dependencies.Mods;
            SelectedMods.SetDefault();

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

            return(Dependencies);
        }
Exemplo n.º 3
0
        protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
        {
            headlessHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage;

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

            contextFactory = new Lazy <DatabaseContextFactory>(() =>
            {
                var factory = new DatabaseContextFactory(LocalStorage);

                using (var usage = factory.Get())
                    usage.Migrate();
                return(factory);
            });

            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)
            {
                baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies);
            }

            Dependencies = new OsuScreenDependencies(false, baseDependencies);

            Beatmap = Dependencies.Beatmap;
            Beatmap.SetDefault();

            Ruleset = Dependencies.Ruleset;
            Ruleset.SetDefault();

            SelectedMods = Dependencies.Mods;
            SelectedMods.SetDefault();

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

            return(Dependencies);
        }
Exemplo n.º 4
0
        protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
        {
            headlessHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage;

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

            contextFactory = new Lazy <DatabaseContextFactory>(() =>
            {
                var factory = new DatabaseContextFactory(LocalStorage);

                using (var usage = factory.Get())
                    usage.Migrate();
                return(factory);
            });

            RecycleLocalStorage(false);

            var baseDependencies = base.CreateChildDependencies(parent);

            var providedRuleset = CreateRuleset();

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

            Dependencies = new OsuScreenDependencies(false, baseDependencies);

            Beatmap = Dependencies.Beatmap;
            Beatmap.SetDefault();

            Ruleset = Dependencies.Ruleset;
            Ruleset.SetDefault();

            SelectedMods = Dependencies.Mods;
            SelectedMods.SetDefault();

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

            return(Dependencies);
        }