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)
        {
            // This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures
            var working = new DummyWorkingBeatmap(parent.Get <AudioManager>(), parent.Get <TextureStore>());

            beatmap = new NonNullableBindable <WorkingBeatmap>(working)
            {
                Default = working
            };
            beatmap.BindValueChanged(b => ScheduleAfterChildren(() =>
            {
                // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
                if (b.OldValue?.TrackLoaded == true && b.OldValue?.Track != b.NewValue?.Track)
                {
                    b.OldValue.RecycleTrack();
                }
            }));

            Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));

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

            return(Dependencies);
        }
Exemplo n.º 3
0
 public OsuGameSupporter()
 {
     API = new DummyAPIAccess();
     API.LocalUser.Value.IsSupporter = true;
     API.LocalUser.Value.Username    = "******";
     API.LocalUser.Value.Country     = new Country {
         FlagName = @"BE"
     };
 }
Exemplo n.º 4
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.º 5
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.º 6
0
 public OsuGameSupporter()
 {
     API = new DummyAPIAccess();
     API.LocalUser.Value = new User
     {
         IsSupporter = true,
         Username    = "******",
         Country     = new Country {
             FlagName = @"BE"
         }
     };
 }
Exemplo n.º 7
0
            public OsuGameSupporter()
            {
                API = new DummyAPIAccess();
                Bindable <User> testUser = new Bindable <User>(new User
                {
                    IsSupporter = true,
                    Username    = "******",
                    Country     = new Country {
                        FlagName = @"BE"
                    }
                });

                API.LocalUser.BindTo(testUser);
            }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
        {
            // This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures
            var working = new DummyWorkingBeatmap(parent.Get <AudioManager>(), parent.Get <TextureStore>());

            beatmap = new OsuTestBeatmap(working)
            {
                Default = working
            };

            Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));

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

            return(Dependencies);
        }