From 56397dbea657759588b762734b39f3bf5ca78a57 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 24 Feb 2019 12:08:27 +0900 Subject: [PATCH 1/7] Ensure beatmap is not disabled before continuing with present --- osu.Game/OsuGame.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9f6adc373c..7170dc1685 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -248,6 +248,14 @@ namespace osu.Game // navigate to song select if we are not already there. menuScreen.MakeCurrent(); + + if (Beatmap.Disabled) + { + // we may need to wait for a lease to be returned. + Schedule(() => PresentBeatmap(beatmap)); + return; + } + menuScreen.LoadToSolo(); break; } From caef58675d78cade6a33e24136fb2a76aa23c703 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Feb 2019 12:58:58 +0900 Subject: [PATCH 2/7] Tidy up and standardise present logic --- osu.Game/OsuGame.cs | 157 ++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 84 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7170dc1685..006e2abf4b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -148,7 +148,11 @@ namespace osu.Game { this.frameworkConfig = frameworkConfig; - ScoreManager.ItemAdded += (score, _, silent) => Schedule(() => LoadScore(score, silent)); + ScoreManager.ItemAdded += (score, _, silent) => + { + if (!silent) + Schedule(() => PresentScore(score)); + }; if (!Host.IsPrimaryInstance) { @@ -198,71 +202,12 @@ namespace osu.Game externalLinkOpener.OpenUrlExternally(url); } - private ScheduledDelegate scoreLoad; - /// /// Show a beatmap set as an overlay. /// /// The set to display. public void ShowBeatmapSet(int setId) => beatmapSetOverlay.FetchAndShowBeatmapSet(setId); - /// - /// Present a beatmap at song select. - /// - /// The beatmap to select. - public void PresentBeatmap(BeatmapSetInfo beatmap) - { - if (menuScreen == null) - { - Schedule(() => PresentBeatmap(beatmap)); - return; - } - - CloseAllOverlays(false); - - void setBeatmap() - { - if (Beatmap.Disabled) - { - Schedule(setBeatmap); - return; - } - - var databasedSet = beatmap.OnlineBeatmapSetID != null ? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID) : BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash); - - if (databasedSet != null) - { - // Use first beatmap available for current ruleset, else switch ruleset. - var first = databasedSet.Beatmaps.Find(b => b.Ruleset == ruleset.Value) ?? databasedSet.Beatmaps.First(); - - ruleset.Value = first.Ruleset; - Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first); - } - } - - switch (screenStack.CurrentScreen) - { - case SongSelect _: - break; - default: - // navigate to song select if we are not already there. - - menuScreen.MakeCurrent(); - - if (Beatmap.Disabled) - { - // we may need to wait for a lease to be returned. - Schedule(() => PresentBeatmap(beatmap)); - return; - } - - menuScreen.LoadToSolo(); - break; - } - - setBeatmap(); - } - /// /// Show a user's profile as an overlay. /// @@ -275,19 +220,46 @@ namespace osu.Game /// The beatmap to show. public void ShowBeatmap(int beatmapId) => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId); - protected void LoadScore(ScoreInfo score, bool silent) + /// + /// Present a beatmap at song select. + /// + /// The beatmap to select. + public void PresentBeatmap(BeatmapSetInfo beatmap) { - if (silent) - return; + var databasedSet = beatmap.OnlineBeatmapSetID != null + ? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID) + : BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash); - scoreLoad?.Cancel(); - - if (menuScreen == null) + if (databasedSet == null) { - scoreLoad = Schedule(() => LoadScore(score, false)); + Logger.Log("The requested beatmap could not be loaded.", LoggingTarget.Information); return; } + if (screenStack.CurrentScreen is PlaySongSelect) + // if we're already at song select then we don't need to return to the main menu. + setBeatmap(); + else + performFromMainMenu(setBeatmap, $"load {beatmap}"); + + void setBeatmap() + { + menuScreen.LoadToSolo(); + + // Use first beatmap available for current ruleset, else switch ruleset. + var first = databasedSet.Beatmaps.Find(b => b.Ruleset == ruleset.Value) ?? databasedSet.Beatmaps.First(); + + ruleset.Value = first.Ruleset; + Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first); + } + } + + /// + /// Present a score's replay. + /// + /// The beatmap to select. + public void PresentScore(ScoreInfo score) + { var databasedScore = ScoreManager.GetScore(score); var databasedScoreInfo = databasedScore.ScoreInfo; if (databasedScore.Replay == null) @@ -303,14 +275,35 @@ namespace osu.Game return; } + performFromMainMenu(() => + { + ruleset.Value = databasedScoreInfo.Ruleset; + + Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); + Beatmap.Value.Mods.Value = databasedScoreInfo.Mods; + + menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); + }, $"watch {databasedScoreInfo.User.Username} play {databasedScoreInfo.Beatmap}"); + } + + private ScheduledDelegate performFromMainMenuTask; + + /// + /// Perform an action only after returning to the main menu. + /// Eagerly tries to exit the current screen until it succeeds. + /// + /// The action to perform once we are in the correct state. + /// The task name to display in a notification (if we can't immediately reach the main menu state). + private void performFromMainMenu(Action action, string taskName) + { if ((screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange == false) { notifications.Post(new SimpleNotification { - Text = $"Click here to watch {databasedScoreInfo.User.Username} on {databasedScoreInfo.Beatmap}", + Text = $"Click here to {taskName}", Activated = () => { - loadScore(); + action(); return true; } }); @@ -318,24 +311,20 @@ namespace osu.Game return; } - loadScore(); + performFromMainMenuTask?.Cancel(); - void loadScore() + CloseAllOverlays(false); + + if (menuScreen?.IsCurrentScreen() != true || Beatmap.Disabled) { - if (!menuScreen.IsCurrentScreen() || Beatmap.Disabled) - { - menuScreen.MakeCurrent(); - this.Delay(500).Schedule(loadScore, out scoreLoad); - return; - } - - ruleset.Value = databasedScoreInfo.Ruleset; - - Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap); - Beatmap.Value.Mods.Value = databasedScoreInfo.Mods; - - menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); + // menuScreen may not be initialised or not be current yet; keep trying. + menuScreen?.MakeCurrent(); + performFromMainMenuTask = Schedule(() => performFromMainMenu(action, taskName)); + return; } + + // success! + action(); } protected override void Dispose(bool isDisposing) From 706da017d71c091de385c14847526a4adc5a5318 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Feb 2019 14:01:51 +0900 Subject: [PATCH 3/7] Add target screen support and user bypass --- osu.Game/OsuGame.cs | 33 ++++++++++++++++++++++----------- osu.Game/Screens/IOsuScreen.cs | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 006e2abf4b..499814c5e3 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -294,16 +294,21 @@ namespace osu.Game /// /// The action to perform once we are in the correct state. /// The task name to display in a notification (if we can't immediately reach the main menu state). - private void performFromMainMenu(Action action, string taskName) + /// An optional target screen type. If this screen is already current we can immediately perform the action without returning to the menu. + /// Whether checking should be bypassed. + private void performFromMainMenu(Action action, string taskName, Type targetScreen = null, bool bypassScreenAllowChecks = false) { - if ((screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange == false) + performFromMainMenuTask?.Cancel(); + + // if the current screen does not allow screen changing, give the user an option to try again later. + if (!bypassScreenAllowChecks && (screenStack.CurrentScreen as IOsuScreen)?.AllowExternalScreenChange == false) { notifications.Post(new SimpleNotification { Text = $"Click here to {taskName}", Activated = () => { - action(); + performFromMainMenu(action, taskName, targetScreen, true); return true; } }); @@ -311,20 +316,26 @@ namespace osu.Game return; } - performFromMainMenuTask?.Cancel(); - CloseAllOverlays(false); - if (menuScreen?.IsCurrentScreen() != true || Beatmap.Disabled) + // we may already be at the target screen type. + if (targetScreen != null && screenStack.CurrentScreen?.GetType() == targetScreen) { - // menuScreen may not be initialised or not be current yet; keep trying. - menuScreen?.MakeCurrent(); - performFromMainMenuTask = Schedule(() => performFromMainMenu(action, taskName)); + action(); return; } - // success! - action(); + // all conditions have been met to continue with the action. + if (menuScreen?.IsCurrentScreen() == true && !Beatmap.Disabled) + { + action(); + return; + } + + // menuScreen may not be initialised yet (null check required). + menuScreen?.MakeCurrent(); + + performFromMainMenuTask = Schedule(() => performFromMainMenu(action, taskName)); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/IOsuScreen.cs b/osu.Game/Screens/IOsuScreen.cs index e665f401d9..b25bcdeab1 100644 --- a/osu.Game/Screens/IOsuScreen.cs +++ b/osu.Game/Screens/IOsuScreen.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens /// /// Whether a top-level component should be allowed to exit the current screen to, for example, - /// complete an import. + /// complete an import. Note that this can be overridden by a user if they specifically request. /// bool AllowExternalScreenChange { get; } From 80737b9ef825dc22470f50fc1897c4936501a861 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Feb 2019 18:24:06 +0900 Subject: [PATCH 4/7] Remove "silent" parameter; consolidate import logic --- .../Beatmaps/IO/ImportBeatmapTest.cs | 2 +- osu.Game/Beatmaps/BeatmapManager.cs | 24 +-------- osu.Game/Database/ArchiveModelManager.cs | 53 +++++++++++-------- .../Database/MutableDatabaseBackedStore.cs | 13 ++--- osu.Game/OsuGame.cs | 32 +++++------ .../Direct/DownloadTrackingComposite.cs | 2 +- osu.Game/Overlays/Music/PlaylistList.cs | 4 +- osu.Game/Overlays/MusicController.cs | 2 +- .../Overlays/Settings/Sections/SkinSection.cs | 2 +- .../Multi/Match/Components/ReadyButton.cs | 2 +- .../Screens/Multi/Match/MatchSubScreen.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 13 files changed, 60 insertions(+), 82 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index b6a8b3b06c..5b8bdd8a51 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -101,7 +101,7 @@ namespace osu.Game.Tests.Beatmaps.IO int fireCount = 0; // ReSharper disable once AccessToModifiedClosure - manager.ItemAdded += (_, __, ___) => fireCount++; + manager.ItemAdded += (_, __) => fireCount++; manager.ItemRemoved += _ => fireCount++; var imported = LoadOszIntoOsu(osu); diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 21739f16c2..002bd2063e 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore; using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Extensions; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.Textures; using osu.Framework.Logging; using osu.Framework.Platform; @@ -50,11 +49,6 @@ namespace osu.Game.Beatmaps /// public event Action BeatmapDownloadFailed; - /// - /// Fired when a beatmap load is requested (into the interactive game UI). - /// - public Action PresentBeatmap; - /// /// A default representation of a WorkingBeatmap to use when no beatmap is available. /// @@ -165,20 +159,10 @@ namespace osu.Game.Beatmaps request.Success += filename => { - downloadNotification.Text = $"Importing {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}"; - Task.Factory.StartNew(() => { // This gets scheduled back to the update thread, but we want the import to run in the background. - var importedBeatmap = Import(filename); - - downloadNotification.CompletionClickAction = () => - { - PresentCompletedImport(importedBeatmap.Yield()); - return true; - }; - downloadNotification.State = ProgressNotificationState.Completed; - + Import(downloadNotification, filename); currentDownloads.Remove(request); }, TaskCreationOptions.LongRunning); }; @@ -211,12 +195,6 @@ namespace osu.Game.Beatmaps return true; } - protected override void PresentCompletedImport(IEnumerable imported) - { - base.PresentCompletedImport(imported); - PresentBeatmap?.Invoke(imported.LastOrDefault()); - } - /// /// Get an existing download request if it exists. /// diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 6bf9e2ff37..f632865ba3 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -32,7 +32,7 @@ namespace osu.Game.Database where TModel : class, IHasFiles, IHasPrimaryKey, ISoftDelete where TFileModel : INamedFileInfo, new() { - public delegate void ItemAddedDelegate(TModel model, bool existing, bool silent); + public delegate void ItemAddedDelegate(TModel model, bool existing); /// /// Set an endpoint for notifications to be posted to. @@ -110,7 +110,7 @@ namespace osu.Game.Database ContextFactory = contextFactory; ModelStore = modelStore; - ModelStore.ItemAdded += (item, silent) => handleEvent(() => ItemAdded?.Invoke(item, false, silent)); + ModelStore.ItemAdded += item => handleEvent(() => ItemAdded?.Invoke(item, false)); ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s)); Files = new FileStore(contextFactory, storage); @@ -128,14 +128,16 @@ namespace osu.Game.Database /// One or more archive locations on disk. public void Import(params string[] paths) { - var notification = new ProgressNotification - { - Text = "Import is initialising...", - Progress = 0, - State = ProgressNotificationState.Active, - }; + var notification = new ProgressNotification { State = ProgressNotificationState.Active }; PostNotification?.Invoke(notification); + Import(notification, paths); + } + + protected void Import(ProgressNotification notification, params string[] paths) + { + notification.Progress = 0; + notification.Text = "Import is initialising..."; List imported = new List(); @@ -168,13 +170,20 @@ namespace osu.Game.Database } else { - notification.CompletionText = $"Imported {current} {typeof(TModel).Name.Replace("Info", "").ToLower()}s!"; - notification.CompletionClickAction += () => + notification.CompletionText = imported.Count == 1 + ? $"Imported {imported.First()}!" + : $"Imported {current} {typeof(TModel).Name.Replace("Info", "").ToLower()}s!"; + + if (imported.Count > 0 && PresentImport != null) { - if (imported.Count > 0) - PresentCompletedImport(imported); - return true; - }; + notification.CompletionText += " Click to view."; + notification.CompletionClickAction = () => + { + PresentImport?.Invoke(imported); + return true; + }; + } + notification.State = ProgressNotificationState.Completed; } } @@ -207,9 +216,10 @@ namespace osu.Game.Database return import; } - protected virtual void PresentCompletedImport(IEnumerable imported) - { - } + /// + /// Fired when the user requests to view the resulting import. + /// + public Action> PresentImport; /// /// Import an item from an . @@ -225,7 +235,7 @@ namespace osu.Game.Database model.Hash = computeHash(archive); - return Import(model, false, archive); + return Import(model, archive); } catch (Exception e) { @@ -259,9 +269,8 @@ namespace osu.Game.Database /// Import an item from a . /// /// The model to be imported. - /// Whether the user should be notified fo the import. /// An optional archive to use for model population. - public TModel Import(TModel item, bool silent = false, ArchiveReader archive = null) + public TModel Import(TModel item, ArchiveReader archive = null) { delayEvents(); @@ -281,7 +290,7 @@ namespace osu.Game.Database { Undelete(existing); Logger.Log($"Found existing {typeof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); - handleEvent(() => ItemAdded?.Invoke(existing, true, silent)); + handleEvent(() => ItemAdded?.Invoke(existing, true)); return existing; } @@ -291,7 +300,7 @@ namespace osu.Game.Database Populate(item, archive); // import to store - ModelStore.Add(item, silent); + ModelStore.Add(item); } catch (Exception e) { diff --git a/osu.Game/Database/MutableDatabaseBackedStore.cs b/osu.Game/Database/MutableDatabaseBackedStore.cs index 5e820d1478..5bf06d93f1 100644 --- a/osu.Game/Database/MutableDatabaseBackedStore.cs +++ b/osu.Game/Database/MutableDatabaseBackedStore.cs @@ -16,9 +16,7 @@ namespace osu.Game.Database public abstract class MutableDatabaseBackedStore : DatabaseBackedStore where T : class, IHasPrimaryKey, ISoftDelete { - public delegate void ItemAddedDelegate(T model, bool silent); - - public event ItemAddedDelegate ItemAdded; + public event Action ItemAdded; public event Action ItemRemoved; protected MutableDatabaseBackedStore(IDatabaseContextFactory contextFactory, Storage storage = null) @@ -35,8 +33,7 @@ namespace osu.Game.Database /// Add a to the database. /// /// The item to add. - /// Whether the user should be notified of the addition. - public void Add(T item, bool silent) + public void Add(T item) { using (var usage = ContextFactory.GetForWrite()) { @@ -44,7 +41,7 @@ namespace osu.Game.Database context.Attach(item); } - ItemAdded?.Invoke(item, silent); + ItemAdded?.Invoke(item); } /// @@ -57,7 +54,7 @@ namespace osu.Game.Database usage.Context.Update(item); ItemRemoved?.Invoke(item); - ItemAdded?.Invoke(item, true); + ItemAdded?.Invoke(item); } /// @@ -92,7 +89,7 @@ namespace osu.Game.Database item.DeletePending = false; } - ItemAdded?.Invoke(item, true); + ItemAdded?.Invoke(item); return true; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 499814c5e3..5aafc11c92 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -148,12 +148,6 @@ namespace osu.Game { this.frameworkConfig = frameworkConfig; - ScoreManager.ItemAdded += (score, _, silent) => - { - if (!silent) - Schedule(() => PresentScore(score)); - }; - if (!Host.IsPrimaryInstance) { Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error); @@ -221,7 +215,8 @@ namespace osu.Game public void ShowBeatmap(int beatmapId) => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId); /// - /// Present a beatmap at song select. + /// Present a beatmap at song select immediately.. + /// The user should have already requested this interactively. /// /// The beatmap to select. public void PresentBeatmap(BeatmapSetInfo beatmap) @@ -236,26 +231,23 @@ namespace osu.Game return; } - if (screenStack.CurrentScreen is PlaySongSelect) - // if we're already at song select then we don't need to return to the main menu. - setBeatmap(); - else - performFromMainMenu(setBeatmap, $"load {beatmap}"); - - void setBeatmap() + performFromMainMenu(() => { - menuScreen.LoadToSolo(); + // we might already be at song select, so a check is required before performing the load to solo. + if (menuScreen.IsCurrentScreen()) + menuScreen.LoadToSolo(); // Use first beatmap available for current ruleset, else switch ruleset. var first = databasedSet.Beatmaps.Find(b => b.Ruleset == ruleset.Value) ?? databasedSet.Beatmaps.First(); ruleset.Value = first.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first); - } + }, $"load {beatmap}", bypassScreenAllowChecks: true, targetScreen: typeof(PlaySongSelect)); } /// - /// Present a score's replay. + /// Present a score's replay immediately. + /// The user should have already requested this interactively. /// /// The beatmap to select. public void PresentScore(ScoreInfo score) @@ -283,7 +275,7 @@ namespace osu.Game Beatmap.Value.Mods.Value = databasedScoreInfo.Mods; menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); - }, $"watch {databasedScoreInfo.User.Username} play {databasedScoreInfo.Beatmap}"); + }, $"watch {databasedScoreInfo.User.Username} play {databasedScoreInfo.Beatmap}", bypassScreenAllowChecks: true); } private ScheduledDelegate performFromMainMenuTask; @@ -359,8 +351,10 @@ namespace osu.Game BeatmapManager.PostNotification = n => notifications?.Post(n); BeatmapManager.GetStableStorage = GetStorageForStableInstall; + BeatmapManager.PresentImport = items => PresentBeatmap(items.First()); - BeatmapManager.PresentBeatmap = PresentBeatmap; + ScoreManager.PostNotification = n => notifications?.Post(n); + ScoreManager.PresentImport = items => PresentScore(items.First()); Container logoContainer; diff --git a/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs b/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs index 58be491daf..813223dbc3 100644 --- a/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs +++ b/osu.Game/Overlays/Direct/DownloadTrackingComposite.cs @@ -115,7 +115,7 @@ namespace osu.Game.Overlays.Direct private void onRequestFailure(Exception e) => Schedule(() => attachDownload(null)); - private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => setDownloadStateFromManager(s, DownloadState.LocallyAvailable); + private void setAdded(BeatmapSetInfo s, bool existing) => setDownloadStateFromManager(s, DownloadState.LocallyAvailable); private void setRemoved(BeatmapSetInfo s) => setDownloadStateFromManager(s, DownloadState.NotDownloaded); diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index b02ad242aa..9ace13289b 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Music [BackgroundDependencyLoader] private void load(BeatmapManager beatmaps, IBindable beatmap) { - beatmaps.GetAllUsableBeatmapSets().ForEach(b => addBeatmapSet(b, false, false)); + beatmaps.GetAllUsableBeatmapSets().ForEach(b => addBeatmapSet(b, false)); beatmaps.ItemAdded += addBeatmapSet; beatmaps.ItemRemoved += removeBeatmapSet; @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.Music beatmapBacking.ValueChanged += _ => updateSelectedSet(); } - private void addBeatmapSet(BeatmapSetInfo obj, bool existing, bool silent) => Schedule(() => + private void addBeatmapSet(BeatmapSetInfo obj, bool existing) => Schedule(() => { if (existing) return; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index ff6bb4ee1a..e0b69a6747 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -212,7 +212,7 @@ namespace osu.Game.Overlays beatmapSets.Insert(index, beatmapSetInfo); } - private void handleBeatmapAdded(BeatmapSetInfo obj, bool existing, bool silent) + private void handleBeatmapAdded(BeatmapSetInfo obj, bool existing) { if (existing) return; diff --git a/osu.Game/Overlays/Settings/Sections/SkinSection.cs b/osu.Game/Overlays/Settings/Sections/SkinSection.cs index d1f47b6016..4b0147eb5d 100644 --- a/osu.Game/Overlays/Settings/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Settings/Sections/SkinSection.cs @@ -82,7 +82,7 @@ namespace osu.Game.Overlays.Settings.Sections private void itemRemoved(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => i.ID != s.ID).ToArray()); - private void itemAdded(SkinInfo s, bool existing, bool silent) + private void itemAdded(SkinInfo s, bool existing) { if (existing) return; diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs index 3e4694e232..795557b968 100644 --- a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs @@ -53,7 +53,7 @@ namespace osu.Game.Screens.Multi.Match.Components hasBeatmap = beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID) != null; } - private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) + private void beatmapAdded(BeatmapSetInfo model, bool existing) { if (Beatmap.Value == null) return; diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index c3f7cea43e..3a7d0f18f5 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -202,7 +202,7 @@ namespace osu.Game.Screens.Multi.Match /// /// Handle the case where a beatmap is imported (and can be used by this match). /// - private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => + private void beatmapAdded(BeatmapSetInfo model, bool existing) => Schedule(() => { if (Beatmap.Value != beatmapManager.DefaultBeatmap) return; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 9198d1a646..fbdc382d18 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -294,7 +294,7 @@ namespace osu.Game.Screens.Play var score = CreateScore(); if (RulesetContainer.ReplayScore == null) - scoreManager.Import(score, true); + scoreManager.Import(score); this.Push(CreateResults(score)); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 60fcbc9271..f10acfab22 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -587,7 +587,7 @@ namespace osu.Game.Screens.Select } } - private void onBeatmapSetAdded(BeatmapSetInfo s, bool existing, bool silent) => Carousel.UpdateBeatmapSet(s); + private void onBeatmapSetAdded(BeatmapSetInfo s, bool existing) => Carousel.UpdateBeatmapSet(s); private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s); private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID)); private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID)); From 314f35b0c51417c2ab91711e1b7ecbacaf415185 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Feb 2019 18:42:08 +0900 Subject: [PATCH 5/7] Further simplify import messaging --- osu.Game/Beatmaps/BeatmapManager.cs | 3 +-- osu.Game/Database/ArchiveModelManager.cs | 17 +++++++++++++++-- osu.Game/OsuGame.cs | 2 +- osu.Game/Scoring/ScoreInfo.cs | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 002bd2063e..64dfc497ee 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -145,8 +145,7 @@ namespace osu.Game.Beatmaps var downloadNotification = new DownloadNotification { - CompletionText = $"Imported {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}!", - Text = $"Downloading {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}", + Text = $"Downloading {beatmapSetInfo}", }; var request = new DownloadBeatmapSetRequest(beatmapSetInfo, noVideo); diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index f632865ba3..61f0867381 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -139,6 +139,8 @@ namespace osu.Game.Database notification.Progress = 0; notification.Text = "Import is initialising..."; + var term = $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; + List imported = new List(); int current = 0; @@ -150,7 +152,18 @@ namespace osu.Game.Database try { - notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}"; + var text = $"Importing "; + + if (path.Length > 1) + text += $"{++current} of {paths.Length} {term}s.."; + else + text += $"{term}.."; + + // only show the filename if it isn't a temporary one (as those look ugly). + if (!path.Contains(Path.GetTempPath())) + text += $"\n{Path.GetFileName(path)}"; + + notification.Text = text; imported.Add(Import(path)); @@ -172,7 +185,7 @@ namespace osu.Game.Database { notification.CompletionText = imported.Count == 1 ? $"Imported {imported.First()}!" - : $"Imported {current} {typeof(TModel).Name.Replace("Info", "").ToLower()}s!"; + : $"Imported {current} {term}s!"; if (imported.Count > 0 && PresentImport != null) { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 5aafc11c92..93acc949ef 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -275,7 +275,7 @@ namespace osu.Game Beatmap.Value.Mods.Value = databasedScoreInfo.Mods; menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore))); - }, $"watch {databasedScoreInfo.User.Username} play {databasedScoreInfo.Beatmap}", bypassScreenAllowChecks: true); + }, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true); } private ScheduledDelegate performFromMainMenuTask; diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index c88fd77eb2..6f1466fb6b 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -158,5 +158,7 @@ namespace osu.Game.Scoring { public string Acronym { get; set; } } + + public override string ToString() => $"{User} playing {Beatmap}"; } } From f84a84edaacbce252e2a10cf81892a9fa8523732 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Feb 2019 18:59:28 +0900 Subject: [PATCH 6/7] Fix oops --- osu.Game/Database/ArchiveModelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 61f0867381..42dbdfbd8a 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -152,7 +152,7 @@ namespace osu.Game.Database try { - var text = $"Importing "; + var text = "Importing "; if (path.Length > 1) text += $"{++current} of {paths.Length} {term}s.."; From 32b8bb2ccc8a5f5cd9f862709cc1b9005ca19778 Mon Sep 17 00:00:00 2001 From: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com> Date: Tue, 26 Feb 2019 12:28:49 +0900 Subject: [PATCH 7/7] Fix broken grammar Co-Authored-By: peppy --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 93acc949ef..f9676933cf 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -215,7 +215,7 @@ namespace osu.Game public void ShowBeatmap(int beatmapId) => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId); /// - /// Present a beatmap at song select immediately.. + /// Present a beatmap at song select immediately. /// The user should have already requested this interactively. /// /// The beatmap to select.