protected DownloadableArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, IAPIProvider api, MutableDatabaseBackedStoreWithFileIncludes <TModel, TFileModel> modelStore,
                                           IIpcHost importHost = null)
     : base(storage, contextFactory, modelStore, importHost)
 {
     this.api        = api;
     this.modelStore = modelStore;
 }
예제 #2
0
        public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio, IResourceStore <byte[]> legacyDefaultResources)
            : base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
        {
            this.audio = audio;
            this.legacyDefaultResources = legacyDefaultResources;

            ItemRemoved += removedInfo =>
            {
                // check the removed skin is not the current user choice. if it is, switch back to default.
                if (removedInfo.ID == CurrentSkinInfo.Value.ID)
                {
                    CurrentSkinInfo.Value = SkinInfo.Default;
                }
            };

            CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
            CurrentSkin.ValueChanged     += skin =>
            {
                if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value)
                {
                    throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead.");
                }

                SourceChanged?.Invoke();
            };
        }
예제 #3
0
        public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio)
            : base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
        {
            this.audio = audio;

            CurrentSkinInfo.ValueChanged += info => CurrentSkin.Value = GetSkin(info);
            CurrentSkin.ValueChanged     += skin =>
            {
                if (skin.SkinInfo != CurrentSkinInfo.Value)
                {
                    throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead.");
                }

                SourceChanged?.Invoke();
            };

            // migrate older imports which didn't have access to skin.ini
            using (ContextFactory.GetForWrite())
            {
                foreach (var skinInfo in ModelStore.ConsumableItems.Where(s => s.Name.EndsWith(".osk")))
                {
                    populate(skinInfo);
                    Update(skinInfo);
                }
            }
        }
예제 #4
0
        public ScoreManager(RulesetStore rulesets, Func <BeatmapManager> beatmaps, Storage storage, IDatabaseContextFactory contextFactory, Scheduler scheduler,
                            IIpcHost importHost = null, Func <BeatmapDifficultyCache> difficulties = null, OsuConfigManager configManager = null)
        {
            this.scheduler     = scheduler;
            this.difficulties  = difficulties;
            this.configManager = configManager;

            scoreModelManager = new ScoreModelManager(rulesets, beatmaps, storage, contextFactory, importHost);
        }
예제 #5
0
 public ScoreManager(RulesetStore rulesets, Func <BeatmapManager> beatmaps, Storage storage, IAPIProvider api, IDatabaseContextFactory contextFactory, Scheduler scheduler,
                     IIpcHost importHost = null, Func <BeatmapDifficultyCache> difficulties = null, OsuConfigManager configManager = null)
     : base(storage, contextFactory, api, new ScoreStore(contextFactory, storage), importHost)
 {
     this.rulesets      = rulesets;
     this.beatmaps      = beatmaps;
     this.scheduler     = scheduler;
     this.difficulties  = difficulties;
     this.configManager = configManager;
 }
예제 #6
0
 public BeatmapIPCChannel(IIpcHost host, BeatmapDatabase beatmaps = null)
     : base(host)
 {
     this.beatmaps    = beatmaps;
     MessageReceived += (msg) =>
     {
         Debug.Assert(beatmaps != null);
         ImportAsync(msg.Path);
     };
 }
예제 #7
0
 public ScoreIPCChannel(IIpcHost host, ScoreDatabase scores = null)
     : base(host)
 {
     this.scores      = scores;
     MessageReceived += (msg) =>
     {
         Debug.Assert(scores != null);
         ImportAsync(msg.Path);
     };
 }
예제 #8
0
        public ScoreStore(DatabaseContextFactory factory, IIpcHost importHost = null, BeatmapManager beatmaps = null, RulesetStore rulesets = null) : base(factory)
        {
            this.beatmaps = beatmaps;
            this.rulesets = rulesets;

            if (importHost != null)
            {
                ipc = new ScoreIPCChannel(importHost, this);
            }
        }
예제 #9
0
        public ScoreDatabase(Storage storage, IIpcHost importHost = null, BeatmapDatabase beatmaps = null)
        {
            this.storage  = storage;
            this.beatmaps = beatmaps;

            if (importHost != null)
            {
                ipc = new ScoreIPCChannel(importHost, this);
            }
        }
예제 #10
0
파일: ScoreStore.cs 프로젝트: weebaka/osu
        public ScoreStore(Storage storage, Func <OsuDbContext> factory, IIpcHost importHost = null, BeatmapManager beatmaps = null, RulesetStore rulesets = null) : base(factory)
        {
            this.storage  = storage;
            this.beatmaps = beatmaps;
            this.rulesets = rulesets;

            if (importHost != null)
            {
                ipc = new ScoreIPCChannel(importHost, this);
            }
        }
예제 #11
0
        public ScoreDatabase(Storage storage, SQLiteConnection connection, IIpcHost importHost = null, BeatmapDatabase beatmaps = null, RulesetDatabase rulesets = null) : base(storage, connection)
        {
            this.storage  = storage;
            this.beatmaps = beatmaps;
            this.rulesets = rulesets;

            if (importHost != null)
            {
                ipc = new ScoreIPCChannel(importHost, this);
            }
        }
예제 #12
0
        public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio)
            : base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
        {
            this.audio = audio;

            CurrentSkinInfo.ValueChanged += info => CurrentSkin.Value = GetSkin(info);
            CurrentSkin.ValueChanged     += skin =>
            {
                if (skin.SkinInfo != CurrentSkinInfo.Value)
                {
                    throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead.");
                }
            };
        }
예제 #13
0
 public ArchiveImportIPCChannel(IIpcHost host, ICanAcceptFiles importer = null)
     : base(host)
 {
     this.importer    = importer;
     MessageReceived += msg =>
     {
         Debug.Assert(importer != null);
         ImportAsync(msg.Path).ContinueWith(t =>
         {
             if (t.Exception != null)
             {
                 throw t.Exception;
             }
         }, TaskContinuationOptions.OnlyOnFaulted);
     };
 }
예제 #14
0
 public ScoreIPCChannel(IIpcHost host, ScoreDatabase scores = null)
     : base(host)
 {
     this.scores      = scores;
     MessageReceived += msg =>
     {
         Debug.Assert(scores != null);
         ImportAsync(msg.Path).ContinueWith(t =>
         {
             if (t.Exception != null)
             {
                 throw t.Exception;
             }
         }, TaskContinuationOptions.OnlyOnFaulted);
     };
 }
예제 #15
0
 public BeatmapIPCChannel(IIpcHost host, BeatmapManager beatmaps = null)
     : base(host)
 {
     this.beatmaps    = beatmaps;
     MessageReceived += msg =>
     {
         Debug.Assert(beatmaps != null);
         ImportAsync(msg.Path).ContinueWith(t =>
         {
             if (t.Exception != null)
             {
                 throw t.Exception;
             }
         }, TaskContinuationOptions.OnlyOnFaulted);
     };
 }
예제 #16
0
        public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio, IResourceStore <byte[]> legacyDefaultResources)
            : base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
        {
            this.audio = audio;
            this.legacyDefaultResources = legacyDefaultResources;

            CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
            CurrentSkin.ValueChanged     += skin =>
            {
                if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value)
                {
                    throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead.");
                }

                SourceChanged?.Invoke();
            };
        }
예제 #17
0
        public BeatmapDatabase(Storage storage, IIpcHost importHost = null)
        {
            this.storage = storage;

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

            if (connection == null)
            {
                try
                {
                    connection = prepareConnection();
                    deletePending();
                }
                catch (Exception e)
                {
                    Logger.Error(e, @"Failed to initialise the beatmap database! Trying again with a clean database...");
                    storage.DeleteDatabase(@"beatmaps");
                    connection = prepareConnection();
                }
            }
        }
예제 #18
0
 public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection)
 {
     this.rulesets = rulesets;
     if (importHost != null)
     {
         ipc = new BeatmapIPCChannel(importHost, this);
     }
 }
예제 #19
0
        public BeatmapManager(Storage storage, Func <OsuDbContext> context, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null)
        {
            createContext = context;
            importContext = new Lazy <OsuDbContext>(() =>
            {
                var c = createContext();
                c.Database.AutoTransactionsEnabled = false;
                return(c);
            });

            beatmaps = createBeatmapStore(context);
            files    = new FileStore(context, storage);

            this.storage  = files.Storage;
            this.rulesets = rulesets;
            this.api      = api;

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

            beatmaps.Cleanup();
        }
예제 #20
0
 public ScoreModelDownloader(ScoreModelManager scoreManager, IAPIProvider api, IIpcHost importHost = null)
     : base(scoreManager, api, importHost)
 {
 }
예제 #21
0
        public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, AudioManager audioManager, 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;
            this.audioManager = audioManager;
        }
예제 #22
0
 protected ModelDownloader(IModelImporter <TModel> importer, IAPIProvider api, IIpcHost importHost = null)
 {
     this.importer = importer;
     this.api      = api;
 }
예제 #23
0
 public ScoreModelManager(RulesetStore rulesets, Func <BeatmapManager> beatmaps, Storage storage, IDatabaseContextFactory contextFactory, IIpcHost importHost = null)
     : base(storage, contextFactory, new ScoreStore(contextFactory, storage), importHost)
 {
     this.rulesets = rulesets;
     this.beatmaps = beatmaps;
 }
예제 #24
0
 public IpcChannel(IIpcHost host)
 {
     this.host = host;
     this.host.MessageReceived += handleMessage;
 }
예제 #25
0
        public BeatmapManager(Storage storage, Func <OsuDbContext> context, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null)
        {
            createContext = context;

            refreshImportContext();

            beatmaps = createBeatmapStore(context);
            files    = new FileStore(context, storage);

            this.storage  = files.Storage;
            this.rulesets = rulesets;
            this.api      = api;

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

            beatmaps.Cleanup();
        }
예제 #26
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();
        }
예제 #27
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);

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

            if (importHost != null)
            {
                ipc = new BeatmapIPCChannel(importHost, this);
            }
        }
예제 #28
0
        protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes <TModel, TFileModel> modelStore, IIpcHost importHost = null)
        {
            ContextFactory = contextFactory;

            ModelStore              = modelStore;
            ModelStore.ItemUpdated += item => handleEvent(() => itemUpdated.Value = new WeakReference <TModel>(item));
            ModelStore.ItemRemoved += item => handleEvent(() => itemRemoved.Value = new WeakReference <TModel>(item));

            exportStorage = storage.GetStorageForDirectory("exports");

            Files = new FileStore(contextFactory, storage);

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

            ModelStore.Cleanup();
        }
예제 #29
0
        protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes <TModel, TFileModel> modelStore, IIpcHost importHost = null)
        {
            ContextFactory = contextFactory;

            ModelStore              = modelStore;
            ModelStore.ItemAdded   += item => handleEvent(() => ItemAdded?.Invoke(item));
            ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s));

            Files = new FileStore(contextFactory, storage);

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

            ModelStore.Cleanup();
        }
예제 #30
0
 protected ModelDownloader(IModelManager <TModel> modelManager, IAPIProvider api, IIpcHost importHost = null)
 {
     this.modelManager = modelManager;
     this.api          = api;
 }