From 9b4bed2ab223e8e81aafc49d9ee0d9012aa0e740 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 11 Jul 2020 16:02:47 -0700 Subject: [PATCH] Add ability to select mods from a specific score --- osu.Game/Online/Leaderboards/LeaderboardScore.cs | 13 +++++++++++++ osu.Game/Overlays/Mods/ModSection.cs | 2 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 6 +++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/osu.Game/Online/Leaderboards/LeaderboardScore.cs b/osu.Game/Online/Leaderboards/LeaderboardScore.cs index 1469f29874..c1771fbf3d 100644 --- a/osu.Game/Online/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Online/Leaderboards/LeaderboardScore.cs @@ -58,6 +58,9 @@ namespace osu.Game.Online.Leaderboards [Resolved(CanBeNull = true)] private DialogOverlay dialogOverlay { get; set; } + [Resolved(CanBeNull = true)] + private SongSelect songSelect { get; set; } + public LeaderboardScore(ScoreInfo score, int? rank, bool allowHighlight = true) { this.score = score; @@ -373,11 +376,21 @@ namespace osu.Game.Online.Leaderboards { List items = new List(); + if (score.Mods.Length > 0 && modsContainer.Any(s => s.IsHovered)) + items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => getMods())); + if (score.ID != 0) items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay?.Push(new LocalScoreDeleteDialog(score)))); return items.ToArray(); } } + + private void getMods() + { + songSelect.ModSelect.DeselectAll(true); + + songSelect.Mods.Value = score.Mods; + } } } diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 7235a18a23..45fae90a1e 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -95,7 +95,7 @@ namespace osu.Game.Overlays.Mods return base.OnKeyDown(e); } - public void DeselectAll() => DeselectTypes(buttons.Select(b => b.SelectedMod?.GetType()).Where(t => t != null)); + public void DeselectAll(bool immediate = false) => DeselectTypes(buttons.Select(b => b.SelectedMod?.GetType()).Where(t => t != null), immediate); /// /// Deselect one or more mods in this section. diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 3d0ad1a594..d83dd77401 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -231,7 +231,7 @@ namespace osu.Game.Overlays.Mods { Width = 180, Text = "Deselect All", - Action = DeselectAll, + Action = () => DeselectAll(), Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, }, @@ -328,10 +328,10 @@ namespace osu.Game.Overlays.Mods sampleOff = audio.Samples.Get(@"UI/check-off"); } - public void DeselectAll() + public void DeselectAll(bool immediate = false) { foreach (var section in ModSectionsContainer.Children) - section.DeselectAll(); + section.DeselectAll(immediate); refreshSelectedMods(); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e3705b15fa..23fa3cd724 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -86,7 +86,7 @@ namespace osu.Game.Screens.Select [Resolved] private BeatmapManager beatmaps { get; set; } - protected ModSelectOverlay ModSelect { get; private set; } + public ModSelectOverlay ModSelect { get; private set; } protected SampleChannel SampleConfirm { get; private set; }