From bf386598b6abe4be1758bf2b7045a26cb3208679 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 30 Nov 2017 10:58:32 +0100 Subject: [PATCH 01/20] Added a new "undelete" button that restores every beatmap with "DeletePending" set to true. --- osu.Game/Beatmaps/BeatmapManager.cs | 22 +++++++++++++++++++ .../Sections/Maintenance/GeneralSettings.cs | 14 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 0641cabcd8..376cbe183a 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -338,6 +338,28 @@ namespace osu.Game.Beatmaps } } + public void Undelete(BeatmapSetInfo beatmapSet) + { + lock (importContext) + { + var context = importContext.Value; + + using (var transaction = context.BeginTransaction()) + { + context.ChangeTracker.AutoDetectChangesEnabled = false; + + var iFiles = new FileStore(() => context, storage); + var iBeatmaps = createBeatmapStore(() => context); + + if (iBeatmaps.Undelete(beatmapSet)) + iFiles.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); + + context.ChangeTracker.AutoDetectChangesEnabled = true; + context.SaveChanges(transaction); + } + } + } + /// /// Delete a beatmap difficulty. /// diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 4f4f381ae1..dcad5ab52c 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -15,6 +15,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance private TriangleButton importButton; private TriangleButton deleteButton; private TriangleButton restoreButton; + private TriangleButton undeleteButton; protected override string Header => "General"; @@ -55,6 +56,19 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance }).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true)); } }, + undeleteButton = new SettingsButton + { + Text = "Restore all recently deleted beatmaps", + Action = () => + { + undeleteButton.Enabled.Value = false; + Task.Run(() => + { + foreach (var bs in beatmaps.QueryBeatmapSets(bs => bs.DeletePending).ToList()) + beatmaps.Undelete(bs); + }).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true)); + } + }, }; } } From b09ba19d3fa45a3b650014f6f7ec057d788ca5d3 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 30 Nov 2017 11:02:53 +0100 Subject: [PATCH 02/20] Used the already-existing private method to undelete a mapset --- osu.Game/Beatmaps/BeatmapManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 376cbe183a..cfebaf083e 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -351,8 +351,7 @@ namespace osu.Game.Beatmaps var iFiles = new FileStore(() => context, storage); var iBeatmaps = createBeatmapStore(() => context); - if (iBeatmaps.Undelete(beatmapSet)) - iFiles.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); + undelete(iBeatmaps, iFiles, beatmapSet); context.ChangeTracker.AutoDetectChangesEnabled = true; context.SaveChanges(transaction); From e1c04a1f445933c1deb21b26a4bc39e190eb130c Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Fri, 8 Dec 2017 12:50:04 +0100 Subject: [PATCH 03/20] Added check for "menu music beatmap hash" before undeleting so circles.osu doesn't get imported on Undelete. Also moved the const property to BeatmapManager. --- osu.Game/Beatmaps/BeatmapManager.cs | 9 +++++++++ osu.Game/Screens/Menu/Intro.cs | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index e00505d9b3..bc9a3bbacb 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -34,6 +34,11 @@ namespace osu.Game.Beatmaps /// public class BeatmapManager { + /// + /// The hash of the supplied menu music's beatmap set. + /// + public const string MENU_MUSIC_BEATMAP_HASH = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; + /// /// Fired when a new becomes available in the database. /// @@ -341,6 +346,10 @@ namespace osu.Game.Beatmaps public void Undelete(BeatmapSetInfo beatmapSet) { + // So circles.osz doesn't get added as a map + if (beatmapSet.Hash == MENU_MUSIC_BEATMAP_HASH) + return; + lock (importContext) { var context = importContext.Value; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index d7beb34a2f..6a6351305b 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -20,8 +20,6 @@ namespace osu.Game.Screens.Menu { public class Intro : OsuScreen { - private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; - /// /// Whether we have loaded the menu previously. /// @@ -58,7 +56,7 @@ namespace osu.Game.Screens.Menu if (setInfo == null) { - setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == menu_music_beatmap_hash); + setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapManager.MENU_MUSIC_BEATMAP_HASH); if (setInfo == null) { From c97646bea6f8a5e422d433ddae9494e02a9274b0 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Fri, 8 Dec 2017 14:27:07 +0100 Subject: [PATCH 04/20] added confirmation dialog for `Delete ALL beatmaps` --- .../Maintenance/DeleteAllBeatmapsDialog.cs | 46 +++++++++++++++++++ .../Sections/Maintenance/GeneralSettings.cs | 15 ++++-- osu.Game/osu.Game.csproj | 1 + 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs new file mode 100644 index 0000000000..7eb2ade562 --- /dev/null +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs @@ -0,0 +1,46 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Overlays.Dialog; + +namespace osu.Game.Overlays.Settings.Sections.Maintenance +{ + public class DeleteAllBeatmapsDialog : PopupDialog + { + private BeatmapManager manager; + + [BackgroundDependencyLoader] + private void load(BeatmapManager beatmapManager) + { + manager = beatmapManager; + } + + public DeleteAllBeatmapsDialog(Action deleteAction) + { + BodyText = "Everything?"; + + Icon = FontAwesome.fa_trash_o; + HeaderText = @"Confirm deletion of"; + Buttons = new PopupDialogButton[] + { + new PopupDialogOkButton + { + Text = @"Yes. Go for it.", + Action = deleteAction + }, + new PopupDialogCancelButton + { + Text = @"No! Abort mission!", + }, + }; + } + } +} diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 4f4f381ae1..18776b4c4c 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; @@ -16,11 +17,15 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance private TriangleButton deleteButton; private TriangleButton restoreButton; + private DialogOverlay dialogOverlay; + protected override string Header => "General"; [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps) + private void load(BeatmapManager beatmaps, DialogOverlay dialog) { + dialogOverlay = dialog; + Children = new Drawable[] { importButton = new SettingsButton @@ -38,8 +43,12 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Text = "Delete ALL beatmaps", Action = () => { - deleteButton.Enabled.Value = false; - Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); + Action deletion = delegate + { + deleteButton.Enabled.Value = false; + Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); + }; + dialogOverlay?.Push(new DeleteAllBeatmapsDialog(deletion)); } }, restoreButton = new SettingsButton diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 59f6682569..3f75aab04c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -300,6 +300,7 @@ + From 114604a64205bd108966c6ead5c7c69aa3bc8eb1 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Fri, 8 Dec 2017 14:45:40 +0100 Subject: [PATCH 05/20] removed unused DI --- .../Maintenance/DeleteAllBeatmapsDialog.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs index 7eb2ade562..8ae520651a 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/DeleteAllBeatmapsDialog.cs @@ -2,12 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework.Allocation; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Overlays.Dialog; @@ -15,14 +9,6 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance { public class DeleteAllBeatmapsDialog : PopupDialog { - private BeatmapManager manager; - - [BackgroundDependencyLoader] - private void load(BeatmapManager beatmapManager) - { - manager = beatmapManager; - } - public DeleteAllBeatmapsDialog(Action deleteAction) { BodyText = "Everything?"; From cdf9ea0d01ddcf43d4728c10dd114faeedd483a0 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sat, 9 Dec 2017 13:39:11 +0100 Subject: [PATCH 06/20] removed unnecessary variable and fixed the test because of new DI letting it fail --- osu.Game.Tests/Visual/TestCaseSettings.cs | 24 +++++++++++++++---- .../Sections/Maintenance/GeneralSettings.cs | 6 +---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseSettings.cs b/osu.Game.Tests/Visual/TestCaseSettings.cs index 63d798cd53..d7855a22bf 100644 --- a/osu.Game.Tests/Visual/TestCaseSettings.cs +++ b/osu.Game.Tests/Visual/TestCaseSettings.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; using osu.Game.Overlays; namespace osu.Game.Tests.Visual @@ -8,16 +10,30 @@ namespace osu.Game.Tests.Visual internal class TestCaseSettings : OsuTestCase { private readonly SettingsOverlay settings; + private readonly DialogOverlay dialogOverlay; + + private DependencyContainer dependencies; + + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); public TestCaseSettings() { - Children = new[] { settings = new MainSettings() }; + settings = new MainSettings + { + State = Visibility.Visible + }; + Add(dialogOverlay = new DialogOverlay + { + Depth = -1 + }); } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load() { - base.LoadComplete(); - settings.ToggleVisibility(); + dependencies.Cache(dialogOverlay); + + Add(settings); } } } diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 18776b4c4c..66be5bc0ac 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -17,15 +17,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance private TriangleButton deleteButton; private TriangleButton restoreButton; - private DialogOverlay dialogOverlay; - protected override string Header => "General"; [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps, DialogOverlay dialog) + private void load(BeatmapManager beatmaps, DialogOverlay dialogOverlay) { - dialogOverlay = dialog; - Children = new Drawable[] { importButton = new SettingsButton From 8cbd6f32cbe8d9bbb82dd7cae8ccb6748c23b614 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Sun, 10 Dec 2017 11:31:37 +0100 Subject: [PATCH 07/20] Moved menu music hash property back to intro and changed check (before undeleting) to "Protected" field. --- osu.Game/Beatmaps/BeatmapManager.cs | 8 +------- osu.Game/Screens/Menu/Intro.cs | 4 +++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 6dba8106ae..b70f11185f 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -34,11 +34,6 @@ namespace osu.Game.Beatmaps /// public class BeatmapManager { - /// - /// The hash of the supplied menu music's beatmap set. - /// - public const string MENU_MUSIC_BEATMAP_HASH = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; - /// /// Fired when a new becomes available in the database. /// @@ -346,8 +341,7 @@ namespace osu.Game.Beatmaps public void Undelete(BeatmapSetInfo beatmapSet) { - // So circles.osz doesn't get added as a map - if (beatmapSet.Hash == MENU_MUSIC_BEATMAP_HASH) + if (beatmapSet.Protected) return; lock (importContext) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 6a6351305b..d7beb34a2f 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -20,6 +20,8 @@ namespace osu.Game.Screens.Menu { public class Intro : OsuScreen { + private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; + /// /// Whether we have loaded the menu previously. /// @@ -56,7 +58,7 @@ namespace osu.Game.Screens.Menu if (setInfo == null) { - setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapManager.MENU_MUSIC_BEATMAP_HASH); + setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == menu_music_beatmap_hash); if (setInfo == null) { From 59e8536ff7b5ff490f31bb55c5882addf7e640c5 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Thu, 14 Dec 2017 17:33:56 +0100 Subject: [PATCH 08/20] moved action to construction arguments --- .../Settings/Sections/Maintenance/GeneralSettings.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 66be5bc0ac..2c554a7e6b 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; @@ -39,12 +38,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Text = "Delete ALL beatmaps", Action = () => { - Action deletion = delegate + dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() => { deleteButton.Enabled.Value = false; Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); - }; - dialogOverlay?.Push(new DeleteAllBeatmapsDialog(deletion)); + })); } }, restoreButton = new SettingsButton From d2b80fdbfc9bc3e85cd32594a25b44a893cb4b27 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Mon, 18 Dec 2017 10:55:07 +0100 Subject: [PATCH 09/20] Moved "undelete all" logic to BeatmapManager and added a progress notification --- osu.Game/Beatmaps/BeatmapManager.cs | 30 +++++++++++++++++++ .../Sections/Maintenance/GeneralSettings.cs | 6 +--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 1acca352a7..8170ec959c 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -339,6 +339,36 @@ namespace osu.Game.Beatmaps } } + public void UndeleteAll() + { + var mapSets = QueryBeatmapSets(bs => bs.DeletePending); + + if (mapSets.Count() == 0) return; + + var notification = new ProgressNotification + { + Progress = 0, + State = ProgressNotificationState.Active, + }; + + PostNotification?.Invoke(notification); + + int i = 0; + + foreach (var bs in mapSets) + { + if (notification.State == ProgressNotificationState.Cancelled) + // user requested abort + return; + + notification.Text = $"Restoring ({i} of {mapSets.Count()})"; + notification.Progress = (float)++i / mapSets.Count(); + Undelete(bs); + } + + notification.State = ProgressNotificationState.Completed; + } + public void Undelete(BeatmapSetInfo beatmapSet) { if (beatmapSet.Protected) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index dcad5ab52c..0b0cc1a17f 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -62,11 +62,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Action = () => { undeleteButton.Enabled.Value = false; - Task.Run(() => - { - foreach (var bs in beatmaps.QueryBeatmapSets(bs => bs.DeletePending).ToList()) - beatmaps.Undelete(bs); - }).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true)); + Task.Run(() => beatmaps.UndeleteAll()).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true)); } }, }; From ba614883ea9140de83abe64bb5031cea6c87f372 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Mon, 18 Dec 2017 11:16:57 +0100 Subject: [PATCH 10/20] used Any() instead of manually checking count == 0 (CI) --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 8170ec959c..9933606952 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -343,7 +343,7 @@ namespace osu.Game.Beatmaps { var mapSets = QueryBeatmapSets(bs => bs.DeletePending); - if (mapSets.Count() == 0) return; + if (!mapSets.Any()) return; var notification = new ProgressNotification { From 6ac33e3c007b91e89dfd1f4b5cadb9273a156168 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Mon, 18 Dec 2017 17:04:35 +0100 Subject: [PATCH 11/20] made DeleteAll-button pink --- .../Settings/DangerousSettingsButton.cs | 23 +++++++++++++++++++ .../Sections/Maintenance/GeneralSettings.cs | 2 +- osu.Game/osu.Game.csproj | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Overlays/Settings/DangerousSettingsButton.cs diff --git a/osu.Game/Overlays/Settings/DangerousSettingsButton.cs b/osu.Game/Overlays/Settings/DangerousSettingsButton.cs new file mode 100644 index 0000000000..7c324658a3 --- /dev/null +++ b/osu.Game/Overlays/Settings/DangerousSettingsButton.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Settings +{ + /// + /// A with pink colours to mark dangerous/destructive actions. + /// + public class DangerousSettingsButton : SettingsButton + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Pink; + + Triangles.ColourDark = colours.PinkDark; + Triangles.ColourLight = colours.PinkLight; + } + } +} diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 2c554a7e6b..1f389a22a1 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance .ContinueWith(t => Schedule(() => importButton.Enabled.Value = true), TaskContinuationOptions.LongRunning); } }, - deleteButton = new SettingsButton + deleteButton = new DangerousSettingsButton { Text = "Delete ALL beatmaps", Action = () => diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index adc422857b..1174a1c76d 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -270,6 +270,7 @@ + @@ -856,4 +857,4 @@ - + \ No newline at end of file From dfd532ed4409eee59159252d483bc96465c5bb19 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Mon, 18 Dec 2017 17:28:55 +0100 Subject: [PATCH 12/20] Updated submodule osu-framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 797a351db2..5da6990a8e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 797a351db2e852fef5296453641ffbf6b2f6dc11 +Subproject commit 5da6990a8e68dea852495950996e1362a293dbd5 From 1895b16d6791a552cf3bab66ca52238fa0023ca1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 19:34:20 +0900 Subject: [PATCH 13/20] Correctly make fullscreen overlays block keyboard input from drawables behind them - [ ] Depends on #1711 to get correct global binding handling. --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 ++ osu.Game/Overlays/WaveOverlayContainer.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index e3be23ebc6..9639907914 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -31,6 +31,8 @@ namespace osu.Game.Overlays.Mods protected readonly OsuSpriteText MultiplierLabel; private readonly FillFlowContainer footerContainer; + protected override bool BlockPassThroughKeyboard => false; + protected readonly FillFlowContainer ModSectionsContainer; public readonly Bindable> SelectedMods = new Bindable>(); diff --git a/osu.Game/Overlays/WaveOverlayContainer.cs b/osu.Game/Overlays/WaveOverlayContainer.cs index 50150b6660..3f9703a523 100644 --- a/osu.Game/Overlays/WaveOverlayContainer.cs +++ b/osu.Game/Overlays/WaveOverlayContainer.cs @@ -28,6 +28,8 @@ namespace osu.Game.Overlays private readonly Container contentContainer; + protected override bool BlockPassThroughKeyboard => true; + protected override Container Content => contentContainer; protected Color4 FirstWaveColour From 6fbd06f96735179655a8d260866d38b131c7a107 Mon Sep 17 00:00:00 2001 From: Seokho Song <0xdevssh@gmail.com> Date: Tue, 19 Dec 2017 00:53:17 +0900 Subject: [PATCH 14/20] Fix Not update retry counter on PauseOverlay I've find "You've retried xx time(s)" message that something weird. That is not displayed pause overlay and only see count on FailOverlay I change code that PauseContainer.Retries property can be set call-back function. Signed-off-by: Seokho Song <0xdevssh@gmail.com> --- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 70 +++++++++++--------- osu.Game/Screens/Play/Player.cs | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 182c4efe89..cf3eba00a8 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -122,44 +122,20 @@ namespace osu.Game.Screens.Play }, }; - Retries = 0; + updateRetryCount(); } + private int retries; public int Retries { set { - if (retryCounterContainer != null) - { - // "You've retried 1,065 times in this session" - // "You've retried 1 time in this session" + if (value == retries) + return; - retryCounterContainer.Children = new Drawable[] - { - new OsuSpriteText - { - Text = "You've retried ", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new OsuSpriteText - { - Text = $"{value:n0}", - Font = @"Exo2.0-Bold", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new OsuSpriteText - { - Text = $" time{(value == 1 ? "" : "s")} in this session", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - } - }; - } + retries = value; + if (retryCounterContainer != null) + updateRetryCount(); } } @@ -249,6 +225,38 @@ namespace osu.Game.Screens.Play selectionIndex = InternalButtons.IndexOf(button); } + private void updateRetryCount() + { + // "You've retried 1,065 times in this session" + // "You've retried 1 time in this session" + + retryCounterContainer.Children = new Drawable[] + { + new OsuSpriteText + { + Text = "You've retried ", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new OsuSpriteText + { + Text = $"{retries:n0}", + Font = @"Exo2.0-Bold", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new OsuSpriteText + { + Text = $" time{(retries == 1 ? "" : "s")} in this session", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + } + }; + } + private class Button : DialogButton { protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b5b09504da..e9992f2df7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -161,8 +161,8 @@ namespace osu.Game.Screens.Play OnRetry = Restart, OnQuit = Exit, CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded, - Retries = RestartCount, OnPause = () => { + pauseContainer.Retries = RestartCount; hudOverlay.KeyCounter.IsCounting = pauseContainer.IsPaused; }, OnResume = () => { From e4ead365446526371a51d5d172be61db12fd05bb Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 21 Dec 2017 13:01:14 +0100 Subject: [PATCH 15/20] Added completion text --- osu.Game/Beatmaps/BeatmapManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index e0285e7ae0..1544d4fc01 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -349,6 +349,7 @@ namespace osu.Game.Beatmaps var notification = new ProgressNotification { + CompletionText = "Restored all deleted beatmaps!", Progress = 0, State = ProgressNotificationState.Active, }; From abe465358c2a2994808833a7430c0358a9ac7f22 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 21:46:57 +0900 Subject: [PATCH 16/20] Fix formatting --- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 45 ++++++++++---------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index ac355b82ca..6969cd915b 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -128,6 +128,7 @@ namespace osu.Game.Screens.Play } private int retries; + public int Retries { set @@ -235,28 +236,28 @@ namespace osu.Game.Screens.Play retryCounterContainer.Children = new Drawable[] { - new OsuSpriteText - { - Text = "You've retried ", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new OsuSpriteText - { - Text = $"{retries:n0}", - Font = @"Exo2.0-Bold", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new OsuSpriteText - { - Text = $" time{(retries == 1 ? "" : "s")} in this session", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - } + new OsuSpriteText + { + Text = "You've retried ", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new OsuSpriteText + { + Text = $"{retries:n0}", + Font = @"Exo2.0-Bold", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new OsuSpriteText + { + Text = $" time{(retries == 1 ? "" : "s")} in this session", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + } }; } From 87e790080b25a371c6251a9ea43f5d96d890127c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 22:22:28 +0900 Subject: [PATCH 17/20] Remove manual audio thread synchronisation logic No longer required as calls are blocking. --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 6 ------ osu.Game/Screens/Play/Player.cs | 5 ----- 2 files changed, 11 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 23bec53014..d913895159 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -13,7 +13,6 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; -using System.Threading; namespace osu.Game.Overlays.Music { @@ -153,11 +152,6 @@ namespace osu.Game.Overlays.Music var track = beatmapBacking.Value.Track; track.Restart(); - - // this is temporary until we have blocking (async.Wait()) audio component methods. - // then we can call RestartAsync().Wait() or the blocking version above. - while (!track.IsRunning) - Thread.Sleep(1); } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e9992f2df7..c7111e57f2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -327,11 +327,6 @@ namespace osu.Game.Screens.Play { adjustableSourceClock.Reset(); - // this is temporary until we have blocking (async.Wait()) audio component methods. - // then we can call ResetAsync().Wait() or the blocking version above. - while (adjustableSourceClock.IsRunning) - Thread.Sleep(1); - Schedule(() => { decoupledClock.ChangeSource(adjustableSourceClock); From 620e9737c33a9d02626d4cbf8fcf579f267e3471 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 22:33:16 +0900 Subject: [PATCH 18/20] Avoid many many unnecessary enumerations --- osu.Game/Beatmaps/BeatmapManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 1544d4fc01..0325785016 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -343,9 +343,9 @@ namespace osu.Game.Beatmaps public void UndeleteAll() { - var mapSets = QueryBeatmapSets(bs => bs.DeletePending); + var deleteMaps = QueryBeatmapSets(bs => bs.DeletePending).ToList(); - if (!mapSets.Any()) return; + if (!deleteMaps.Any()) return; var notification = new ProgressNotification { @@ -358,14 +358,14 @@ namespace osu.Game.Beatmaps int i = 0; - foreach (var bs in mapSets) + foreach (var bs in deleteMaps) { if (notification.State == ProgressNotificationState.Cancelled) // user requested abort return; - notification.Text = $"Restoring ({i} of {mapSets.Count()})"; - notification.Progress = (float)++i / mapSets.Count(); + notification.Text = $"Restoring ({i} of {deleteMaps.Count})"; + notification.Progress = (float)++i / deleteMaps.Count; Undelete(bs); } From 0121692919333f959fb9bbf3d4290cfdea20e978 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 23:14:42 +0900 Subject: [PATCH 19/20] Ignore bugged inspectcode inspection --- .../OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs index 972677a6f1..89821a10fb 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -93,6 +93,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing float approxFollowCircleRadius = (float)(slider.Radius * 3); var computeVertex = new Action(t => { + // ReSharper disable once PossibleInvalidOperationException (bugged in current r# version) var diff = slider.PositionAt(t) - slider.LazyEndPosition.Value; float dist = diff.Length; From 13fee5402a54d160160f98603a69d7e94a4fe89d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 23:20:11 +0900 Subject: [PATCH 20/20] Remove unnecessary using visual studio doesn't save --- osu.Game/Screens/Play/Player.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c7111e57f2..340fc39d52 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -17,7 +17,6 @@ using osu.Game.Rulesets.UI; using osu.Game.Screens.Backgrounds; using System; using System.Linq; -using System.Threading; using System.Threading.Tasks; using osu.Framework.Threading; using osu.Game.Rulesets.Mods;