} // = 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(); }
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(); }
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(); }