Пример #1
0
        private BeatmapStore createBeatmapStore(Func <OsuDbContext> context)
        {
            var store = new BeatmapStore(context);

            store.BeatmapSetAdded   += s => BeatmapSetAdded?.Invoke(s);
            store.BeatmapSetRemoved += s => BeatmapSetRemoved?.Invoke(s);
            store.BeatmapHidden     += b => BeatmapHidden?.Invoke(b);
            store.BeatmapRestored   += b => BeatmapRestored?.Invoke(b);
            return(store);
        }
Пример #2
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null)
            : base(storage, contextFactory, new BeatmapStore(contextFactory), importHost)
        {
            beatmaps = (BeatmapStore)ModelStore;
            beatmaps.BeatmapHidden   += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);

            this.rulesets = rulesets;
            this.api      = api;
        }
Пример #3
0
        public BeatmapModelManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, GameHost host = null)
            : base(storage, contextFactory, new BeatmapStore(contextFactory), host)
        {
            this.rulesets = rulesets;

            beatmaps = (BeatmapStore)ModelStore;
            beatmaps.BeatmapHidden   += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
            beatmaps.ItemRemoved     += b => WorkingBeatmapCache?.Invalidate(b);
            beatmaps.ItemUpdated     += obj => WorkingBeatmapCache?.Invalidate(obj);
        }
Пример #4
0
        /// <summary>
        /// Restore a previously hidden <see cref="BeatmapInfo"/>.
        /// </summary>
        /// <param name="beatmap">The beatmap to restore.</param>
        /// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
        public bool Restore(BeatmapInfo beatmap)
        {
            if (!beatmap.Hidden)
            {
                return(false);
            }

            beatmap.Hidden = false;
            Connection.Update(beatmap);

            BeatmapRestored?.Invoke(beatmap);
            return(true);
        }
Пример #5
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, AudioManager audioManager, IIpcHost importHost = null,
                              WorkingBeatmap defaultBeatmap = null)
            : base(storage, contextFactory, new BeatmapStore(contextFactory), importHost)
        {
            this.rulesets     = rulesets;
            this.api          = api;
            this.audioManager = audioManager;

            DefaultBeatmap = defaultBeatmap;

            beatmaps = (BeatmapStore)ModelStore;
            beatmaps.BeatmapHidden   += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
        }
Пример #6
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null,
                              WorkingBeatmap defaultBeatmap = null)
            : base(storage, contextFactory, new BeatmapStore(contextFactory), host)
        {
            this.rulesets     = rulesets;
            this.api          = api;
            this.audioManager = audioManager;
            this.host         = host;

            DefaultBeatmap = defaultBeatmap;

            beatmaps = (BeatmapStore)ModelStore;
            beatmaps.BeatmapHidden   += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
        }
Пример #7
0
        /// <summary>
        /// Restore a previously hidden <see cref="BeatmapInfo"/>.
        /// </summary>
        /// <param name="beatmap">The beatmap to restore.</param>
        /// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
        public bool Restore(BeatmapInfo beatmap)
        {
            var context = GetContext();

            if (!beatmap.Hidden)
            {
                return(false);
            }

            beatmap.Hidden = false;
            context.SaveChanges();

            BeatmapRestored?.Invoke(beatmap);
            return(true);
        }
Пример #8
0
        /// <summary>
        /// Restore a previously hidden <see cref="BeatmapInfo"/>.
        /// </summary>
        /// <param name="beatmap">The beatmap to restore.</param>
        /// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
        public bool Restore(BeatmapInfo beatmap)
        {
            using (ContextFactory.GetForWrite())
            {
                Refresh(ref beatmap, Beatmaps);

                if (!beatmap.Hidden)
                {
                    return(false);
                }
                beatmap.Hidden = false;
            }

            BeatmapRestored?.Invoke(beatmap);
            return(true);
        }
Пример #9
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null,
                              WorkingBeatmap defaultBeatmap = null)
            : base(storage, contextFactory, api, new BeatmapStore(contextFactory), host)
        {
            this.rulesets     = rulesets;
            this.audioManager = audioManager;
            this.host         = host;

            DefaultBeatmap = defaultBeatmap;

            beatmaps = (BeatmapStore)ModelStore;
            beatmaps.BeatmapHidden   += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);

            onlineLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
            exportStorage     = storage.GetStorageForDirectory("exports");
        }
Пример #10
0
        public BeatmapManager(Storage storage, FileStore files, SQLiteConnection connection, RulesetStore rulesets, IIpcHost importHost = null)
        {
            beatmaps = new BeatmapStore(connection);
            beatmaps.BeatmapSetAdded   += s => BeatmapSetAdded?.Invoke(s);
            beatmaps.BeatmapSetRemoved += s => BeatmapSetRemoved?.Invoke(s);
            beatmaps.BeatmapHidden     += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored   += b => BeatmapRestored?.Invoke(b);

            this.storage    = storage;
            this.files      = files;
            this.connection = connection;
            this.rulesets   = rulesets;

            if (importHost != null)
            {
                ipc = new BeatmapIPCChannel(importHost, this);
            }
        }
Пример #11
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null)
        {
            this.contextFactory = contextFactory;

            beatmaps = new BeatmapStore(contextFactory);

            beatmaps.BeatmapSetAdded   += s => BeatmapSetAdded?.Invoke(s);
            beatmaps.BeatmapSetRemoved += s => BeatmapSetRemoved?.Invoke(s);
            beatmaps.BeatmapHidden     += b => BeatmapHidden?.Invoke(b);
            beatmaps.BeatmapRestored   += b => BeatmapRestored?.Invoke(b);

            files = new FileStore(contextFactory, storage);

            this.rulesets = rulesets;
            this.api      = api;

            if (importHost != null)
            {
                ipc = new BeatmapIPCChannel(importHost, this);
            }

            beatmaps.Cleanup();
        }