コード例 #1
0
        public StartupPresenter(IStartupForm view, SidePanelActionsHandler sidePanelActionsHandler, IUserDialogs userDialogs, CollectionsManagerWithCounts collectionsManager)
        {
            _form = view;
            _view = view.StartupView;
            _sidePanelActionsHandler      = sidePanelActionsHandler;
            _userDialogs                  = userDialogs;
            _collectionsManager           = collectionsManager;
            _startupSettings              = JsonConvert.DeserializeObject <StartupSettings>(Settings.Default.StartupSettings);
            _cancellationTokenSource      = new CancellationTokenSource();
            _databaseLoadProgressReporter = new Progress <string>(report =>
            {
                if (string.IsNullOrEmpty(Initalizer.OsuDirectory))
                {
                    _view.LoadDatabaseStatusText = report;
                }
                else
                {
                    _view.LoadDatabaseStatusText = $"osu! location: \"{Initalizer.OsuDirectory}\"{Environment.NewLine}{report}";
                }
            });

            _view.UseSelectedOptionsOnStartup = _startupSettings.AutoLoadMode;
            _form.Closing += _view_Closing;
            _view.StartupCollectionOperation += _view_StartupCollectionOperation;
            _view.StartupDatabaseOperation   += _view_StartupDatabaseOperation;
        }
コード例 #2
0
        }                                             // = new GuiComponents.UserDialogs();


        public void Run()
        {
            //IUserDialogs can be implemented in WinForm or WPF or Gtk or Console or...?
            UserDialogs = GuiComponentsProvider.Instance.GetClassImplementing <IUserDialogs>();

            //Get osu! directory, or end if it can't be found
            OsuDirectory = OsuFileIo.OsuPathResolver.GetOsuDir(UserDialogs.IsThisPathCorrect, UserDialogs.SelectDirectory);
            if (OsuDirectory == string.Empty)
            {
                UserDialogs.OkMessageBox("Valid osu! directory is required to run Collection Manager" + Environment.NewLine + "Exiting...", "Error", MessageBoxType.Error);
                Quit();
            }

            //Load osu database and setting files
            var osuDbFile = Path.Combine(OsuDirectory, @"osu!.db");

            OsuFileIo.OsuDatabase.Load(osuDbFile);
            OsuFileIo.OsuSettings.Load(OsuDirectory);
            BeatmapUtils.OsuSongsDirectory = OsuFileIo.OsuSettings.CustomBeatmapDirectoryLocation;

            //Init "main" classes
            CollectionsManager = new CollectionsManagerWithCounts(LoadedBeatmaps);

            var collectionAddRemoveForm = GuiComponentsProvider.Instance.GetClassImplementing <ICollectionAddRenameForm>();

            CollectionEditor = new CollectionEditor(CollectionsManager, CollectionsManager, collectionAddRemoveForm, OsuFileIo.LoadedMaps);

            var UpdateChecker = new UpdateChecker();

            UpdateChecker.currentVersion = System.Reflection.Assembly.GetExecutingAssembly()
                                           .GetName()
                                           .Version
                                           .ToString();
            var infoTextModel = new InfoTextModel(UpdateChecker);

            var mainForm      = GuiComponentsProvider.Instance.GetClassImplementing <IMainFormView>();
            var mainPresenter = new MainFormPresenter(mainForm, new MainFormModel(CollectionEditor, UserDialogs), infoTextModel);

            //set initial text info and update events
            SetTextData(infoTextModel);


            var loginForm = GuiComponentsProvider.Instance.GetClassImplementing <ILoginFormView>();

            new GuiActionsHandler(OsuFileIo, CollectionsManager, UserDialogs, mainForm, mainPresenter, loginForm);

            HandleMainWindowActions(mainForm);

            mainForm.ShowAndBlock();
            Quit();
        }
コード例 #3
0
        public async Task Run(string[] args)
        {
            //IUserDialogs can be implemented in WinForm or WPF or Gtk or Console or...?
            UserDialogs = GuiComponentsProvider.Instance.GetClassImplementing <IUserDialogs>();



            //Init "main" classes
            CollectionsManager = new CollectionsManagerWithCounts(LoadedBeatmaps);

            var collectionAddRemoveForm = GuiComponentsProvider.Instance.GetClassImplementing <ICollectionAddRenameForm>();

            CollectionEditor = new CollectionEditor(CollectionsManager, CollectionsManager, collectionAddRemoveForm, OsuFileIo.LoadedMaps);

            var updateChecker = new UpdateChecker();

            updateChecker.CheckForUpdates();
            var infoTextModel = new InfoTextModel(updateChecker);

            var mainForm      = GuiComponentsProvider.Instance.GetClassImplementing <IMainFormView>();
            var mainPresenter = new MainFormPresenter(mainForm, new MainFormModel(CollectionEditor, UserDialogs), infoTextModel, WebCollectionProvider);

            //set initial text info and update events
            SetTextData(infoTextModel);

            var loginForm         = GuiComponentsProvider.Instance.GetClassImplementing <ILoginFormView>();
            var guiActionsHandler = new GuiActionsHandler(OsuFileIo, CollectionsManager, UserDialogs, mainForm, mainPresenter, loginForm);

            if (!string.IsNullOrWhiteSpace(Settings.Default.Osustats_apiKey))
            {
                guiActionsHandler.SidePanelActionsHandler.OsustatsLogin(null, Settings.Default.Osustats_apiKey);
            }

            if (args.Length > 0)
            {
                if (File.Exists(args[0]))
                {
                    CollectionsManager.EditCollection(CollectionEditArgs.AddCollections(OsuFileIo.CollectionLoader.LoadCollection(args[0])));
                }
            }

            StartupPresenter = new StartupPresenter(GuiComponentsProvider.Instance.GetClassImplementing <IStartupForm>(), guiActionsHandler.SidePanelActionsHandler, UserDialogs, CollectionsManager);
            await StartupPresenter.Run();


            mainForm.ShowAndBlock();

            Quit();
        }
コード例 #4
0
        internal void Run()
        {
            var osuFileIo = new OsuFileIo(new BeatmapExtension());

            //Automatic Detection of osu! directory location
            string dir = osuFileIo.OsuPathResolver.GetOsuDir(ThisPathIsCorrect, SelectDirectoryDialog);



            string osuPath       = @"E:\osu!\";
            string osuDbFileName = "osu!.db";
            string ExampleCollectionFileLocation = @"E:\osuCollections\SomeCollectionThatExists.db";



            osuFileIo.OsuDatabase.Load(osuPath + osuDbFileName);

            //osu! configuration file is currently only used for getting a songs folder location
            osuFileIo.OsuSettings.Load(osuPath);

            //Data loaded using next 2 functions are going to be automatically correlated
            //with currently avalable beatmap data.
            osuFileIo.CollectionLoader.LoadOsuCollection(ExampleCollectionFileLocation);
            //osuFileIo.CollectionLoader.LoadOsdbCollection("");


            string osuSongsFolderLocation = osuFileIo.OsuSettings.CustomBeatmapDirectoryLocation;

            //Create Collection manager instance
            var collectionManager = new CollectionsManagerWithCounts(osuFileIo.OsuDatabase.LoadedMaps.Beatmaps);

            //or just this:
            //var collectionManager = new CollectionsManager(osuFileIo.OsuDatabase.LoadedMaps.Beatmaps);

            collectionManager.LoadedCollections.CollectionChanged += LoadedCollections_CollectionChanged;

            //Create some dummy collections
            Collection ourCollection = new Collection(osuFileIo.LoadedMaps)
            {
                Name = "Example collection1"
            };
            Collection ourSecondCollection = new Collection(osuFileIo.LoadedMaps)
            {
                Name = "Example collection2"
            };

            //Add these to our manager
            collectionManager.EditCollection(
                CollectionEditArgs.AddCollections(new Collections()
            {
                ourCollection, ourSecondCollection
            })
                );

            //Add some beatmaps to ourSecondCollection
            collectionManager.EditCollection(
                CollectionEditArgs.AddBeatmaps("Example collection2", new Beatmaps()
            {
                new BeatmapExtension()
                {
                    Md5 = "'known' md5"
                },
                new BeatmapExtension()
                {
                    Md5 = "another 'known' md5"
                },
                new BeatmapExtension()
                {
                    Md5 = "md5 that we have no idea about"
                }
            }));

            //Trying to issue any action on collection with unknown name will be just ignored
            collectionManager.EditCollection(
                CollectionEditArgs.AddBeatmaps("Collection that doesn't exist", new Beatmaps()
            {
                new BeatmapExtension()
                {
                    Md5 = "1234567890,yes I know these aren't valid md5s"
                }
            }));

            //Merge our collections into one.
            //Note that while I do not impose a limit on collection name length, osu! does and it will be truncated upon opening collection in osu! client.
            collectionManager.EditCollection(
                CollectionEditArgs.MergeCollections(new Collections()
            {
                ourCollection, ourSecondCollection
            }
                                                    , "Collection created from 2 Example collections")
                );

            //true
            bool isNameTaken = collectionManager.CollectionNameExists("Collection created from 2 Example collections");

            ICollection ourMergedCollection = collectionManager.GetCollectionByName("Collection created from 2 Example collections");

            //These are avaliable only when using CollectionsManagerWithCounts
            var TotalBeatmapCount    = collectionManager.BeatmapsInCollectionsCount;
            var MissingBeatmapsCount = collectionManager.MissingMapSetsCount;

            //Lets save our collections after edits
            //as .osdb
            osuFileIo.CollectionLoader.SaveOsdbCollection(collectionManager.LoadedCollections, ExampleCollectionFileLocation);
            //or .db
            osuFileIo.CollectionLoader.SaveOsuCollection(collectionManager.LoadedCollections, ExampleCollectionFileLocation);
        }
コード例 #5
0
        public void Run(string[] args)
        {
            //IUserDialogs can be implemented in WinForm or WPF or Gtk or Console or...?
            UserDialogs = GuiComponentsProvider.Instance.GetClassImplementing <IUserDialogs>();

            if (Settings.Default.DontAskAboutOsuDirectory)
            {
                OsuDirectory = OsuFileIo.OsuPathResolver.GetOsuDir(_ => false, _ => Settings.Default.OsuDirectory);
            }
            else
            {
                OsuDirectory = OsuFileIo.OsuPathResolver.GetOsuDir(dir =>
                {
                    var result = UserDialogs.YesNoMessageBox($"Detected osu! in \"{dir}\"{Environment.NewLine}Is that correct?", "osu! directory", MessageBoxType.Question,
                                                             "Don't ask me again");
                    Settings.Default.DontAskAboutOsuDirectory = result.doNotAskAgain;
                    Settings.Default.Save();
                    return(result.Result);
                }, UserDialogs.SelectDirectory);
            }

            if (string.IsNullOrEmpty(OsuDirectory) && UserDialogs.YesNoMessageBox(
                    "osu! could not be found. Do you want to continue regardless?" + Environment.NewLine +
                    "This will cause all .db collections to show only as beatmap hashes.", "osu! location",
                    MessageBoxType.Question) == false)
            {
                Quit();
            }

            if (!string.IsNullOrEmpty(OsuDirectory))
            {
                Settings.Default.OsuDirectory = OsuDirectory;
                Settings.Default.Save();
                //Load osu database and setting files
                var osuDbFile     = Path.Combine(OsuDirectory, @"osu!.db");
                var osuScoresFile = Path.Combine(OsuDirectory, @"scores.db");
                OsuFileIo.OsuDatabase.Load(osuDbFile);
                OsuFileIo.OsuSettings.Load(OsuDirectory);
                OsuFileIo.ScoresLoader.ReadDb(osuScoresFile);
                BeatmapUtils.OsuSongsDirectory = OsuFileIo.OsuSettings.CustomBeatmapDirectoryLocation;
            }

            //Init "main" classes
            CollectionsManager = new CollectionsManagerWithCounts(LoadedBeatmaps);

            var collectionAddRemoveForm = GuiComponentsProvider.Instance.GetClassImplementing <ICollectionAddRenameForm>();

            CollectionEditor = new CollectionEditor(CollectionsManager, CollectionsManager, collectionAddRemoveForm, OsuFileIo.LoadedMaps);

            if (args.Length > 0)
            {
                if (File.Exists(args[0]))
                {
                    CollectionsManager.EditCollection(CollectionEditArgs.AddCollections(OsuFileIo.CollectionLoader.LoadCollection(args[0])));
                }
            }

            var updateChecker = new UpdateChecker();

            updateChecker.CheckForUpdates();
            var infoTextModel = new InfoTextModel(updateChecker);

            var mainForm      = GuiComponentsProvider.Instance.GetClassImplementing <IMainFormView>();
            var mainPresenter = new MainFormPresenter(mainForm, new MainFormModel(CollectionEditor, UserDialogs), infoTextModel, WebCollectionProvider);

            //set initial text info and update events
            SetTextData(infoTextModel);


            var loginForm         = GuiComponentsProvider.Instance.GetClassImplementing <ILoginFormView>();
            var guiActionsHandler = new GuiActionsHandler(OsuFileIo, CollectionsManager, UserDialogs, mainForm, mainPresenter, loginForm);

            if (!string.IsNullOrWhiteSpace(Settings.Default.Osustats_apiKey))
            {
                guiActionsHandler.SidePanelActionsHandler.OsustatsLogin(null, Settings.Default.Osustats_apiKey);
            }

            mainForm.ShowAndBlock();
            Quit();
        }