From b126700f01b206b4fc6fb97223b0c1ab8fc97913 Mon Sep 17 00:00:00 2001 From: phosphene47 Date: Wed, 27 Nov 2019 22:47:00 +1100 Subject: [PATCH 1/8] Debounce hover sounds --- .../UserInterface/HoverClickSounds.cs | 15 +++++++++++++- .../Graphics/UserInterface/HoverSounds.cs | 20 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index 4f678b7218..b1a58b5d57 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,12 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Extensions; using osu.Framework.Input.Events; +using osu.Framework.Threading; using osuTK.Input; namespace osu.Game.Graphics.UserInterface @@ -34,10 +36,21 @@ public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal, MouseB this.buttons = buttons ?? new[] { MouseButton.Left }; } + private ScheduledDelegate playDelegate; + protected override bool OnClick(ClickEvent e) { + playDelegate?.Cancel(); + if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) - sampleClick?.Play(); + { + var debounceMs = (int)DebounceTime.TotalMilliseconds; + + if (debounceMs == 0) + sampleClick?.Play(); + else + playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), debounceMs); + } return base.OnClick(e); } diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index f1ac8ced6e..f4258f2b6d 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.ComponentModel; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -9,6 +10,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; +using osu.Framework.Threading; namespace osu.Game.Graphics.UserInterface { @@ -20,6 +22,12 @@ public class HoverSounds : CompositeDrawable { private SampleChannel sampleHover; + /// + /// Length of debounce for sound playback. + /// Set this to to disable debouncing. + /// + public TimeSpan DebounceTime { get; set; } = TimeSpan.FromMilliseconds(50); + protected readonly HoverSampleSet SampleSet; public HoverSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) @@ -28,9 +36,19 @@ public HoverSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) RelativeSizeAxes = Axes.Both; } + private ScheduledDelegate playDelegate; + protected override bool OnHover(HoverEvent e) { - sampleHover?.Play(); + playDelegate?.Cancel(); + + var debounceMs = (int)DebounceTime.TotalMilliseconds; + + if (debounceMs == 0) + sampleHover?.Play(); + else + playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), debounceMs); + return base.OnHover(e); } From 037d927e4518ee16925ff08e4eb037f6b8b2d6dc Mon Sep 17 00:00:00 2001 From: phosphene47 Date: Wed, 27 Nov 2019 22:51:27 +1100 Subject: [PATCH 2/8] TimeSpans can be negative! --- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 2 +- osu.Game/Graphics/UserInterface/HoverSounds.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index b1a58b5d57..fcb8f8d6bd 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -46,7 +46,7 @@ protected override bool OnClick(ClickEvent e) { var debounceMs = (int)DebounceTime.TotalMilliseconds; - if (debounceMs == 0) + if (debounceMs <= 0) sampleClick?.Play(); else playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), debounceMs); diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index f4258f2b6d..2223ac21db 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -44,7 +44,7 @@ protected override bool OnHover(HoverEvent e) var debounceMs = (int)DebounceTime.TotalMilliseconds; - if (debounceMs == 0) + if (debounceMs <= 0) sampleHover?.Play(); else playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), debounceMs); From d4afea0b5e5197d81999ee7edbf774a5946e0319 Mon Sep 17 00:00:00 2001 From: phosphene47 Date: Wed, 27 Nov 2019 23:06:07 +1100 Subject: [PATCH 3/8] Use double instead of TimeSpan --- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 7 ++----- osu.Game/Graphics/UserInterface/HoverSounds.cs | 12 ++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index fcb8f8d6bd..a8e074d2ef 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -44,12 +43,10 @@ protected override bool OnClick(ClickEvent e) if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) { - var debounceMs = (int)DebounceTime.TotalMilliseconds; - - if (debounceMs <= 0) + if (DebounceTime <= 0) sampleClick?.Play(); else - playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), debounceMs); + playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), DebounceTime); } return base.OnClick(e); diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index 2223ac21db..c98d50efff 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.ComponentModel; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -23,10 +22,9 @@ public class HoverSounds : CompositeDrawable private SampleChannel sampleHover; /// - /// Length of debounce for sound playback. - /// Set this to to disable debouncing. + /// Length of debounce for sound playback, in milliseconds. Default is 50ms. /// - public TimeSpan DebounceTime { get; set; } = TimeSpan.FromMilliseconds(50); + public double DebounceTime { get; set; } = 50; protected readonly HoverSampleSet SampleSet; @@ -42,12 +40,10 @@ protected override bool OnHover(HoverEvent e) { playDelegate?.Cancel(); - var debounceMs = (int)DebounceTime.TotalMilliseconds; - - if (debounceMs <= 0) + if (DebounceTime <= 0) sampleHover?.Play(); else - playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), debounceMs); + playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), DebounceTime); return base.OnHover(e); } From 786fb9ede350164c1e9e79c760e5a472d3441b25 Mon Sep 17 00:00:00 2001 From: phosphene47 Date: Thu, 28 Nov 2019 00:44:01 +1100 Subject: [PATCH 4/8] Split click and hover and disable click debounce --- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 9 +++++++-- osu.Game/Graphics/UserInterface/HoverSounds.cs | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index a8e074d2ef..61cacee45f 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -21,6 +21,11 @@ public class HoverClickSounds : HoverSounds private SampleChannel sampleClick; private readonly MouseButton[] buttons; + /// + /// Length of debounce for click sound playback, in milliseconds. Default is 0ms. + /// + public double ClickDebounceTime { get; set; } + /// /// a container which plays sounds on hover and click for any specified s. /// @@ -43,10 +48,10 @@ protected override bool OnClick(ClickEvent e) if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) { - if (DebounceTime <= 0) + if (ClickDebounceTime <= 0) sampleClick?.Play(); else - playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), DebounceTime); + playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), ClickDebounceTime); } return base.OnClick(e); diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index c98d50efff..fcd8940348 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -22,9 +22,9 @@ public class HoverSounds : CompositeDrawable private SampleChannel sampleHover; /// - /// Length of debounce for sound playback, in milliseconds. Default is 50ms. + /// Length of debounce for hover sound playback, in milliseconds. Default is 50ms. /// - public double DebounceTime { get; set; } = 50; + public double HoverDebounceTime { get; set; } = 50; protected readonly HoverSampleSet SampleSet; @@ -40,10 +40,10 @@ protected override bool OnHover(HoverEvent e) { playDelegate?.Cancel(); - if (DebounceTime <= 0) + if (HoverDebounceTime <= 0) sampleHover?.Play(); else - playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), DebounceTime); + playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), HoverDebounceTime); return base.OnHover(e); } From 2865f320524dd149de900aa09516075df17162d4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 28 Nov 2019 00:13:44 +0900 Subject: [PATCH 5/8] Fix nullref on clicking links in tests --- osu.Game/Graphics/Containers/LinkFlowContainer.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs index 61391b7102..2bbac92f7f 100644 --- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs +++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs @@ -19,14 +19,8 @@ public LinkFlowContainer(Action defaultCreationParameters = null) { } - private OsuGame game; - - [BackgroundDependencyLoader(true)] - private void load(OsuGame game) - { - // will be null in tests - this.game = game; - } + [Resolved(CanBeNull = true)] + private OsuGame game { get; set; } public void AddLinks(string text, List links) { @@ -82,7 +76,7 @@ private void createLink(IEnumerable drawables, LinkDetails link, strin if (action != null) action(); else - game.HandleLink(link); + game?.HandleLink(link); }, }); } From 92ab8026a006bd9e7977bd659dcb3e9b1a41d63e Mon Sep 17 00:00:00 2001 From: Min Date: Thu, 28 Nov 2019 16:03:59 +1100 Subject: [PATCH 6/8] Completely remove click sound debounce --- .../UserInterface/HoverClickSounds.cs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index 61cacee45f..803facae04 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Linq; @@ -7,7 +7,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Extensions; using osu.Framework.Input.Events; -using osu.Framework.Threading; using osuTK.Input; namespace osu.Game.Graphics.UserInterface @@ -21,11 +20,6 @@ public class HoverClickSounds : HoverSounds private SampleChannel sampleClick; private readonly MouseButton[] buttons; - /// - /// Length of debounce for click sound playback, in milliseconds. Default is 0ms. - /// - public double ClickDebounceTime { get; set; } - /// /// a container which plays sounds on hover and click for any specified s. /// @@ -40,19 +34,10 @@ public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal, MouseB this.buttons = buttons ?? new[] { MouseButton.Left }; } - private ScheduledDelegate playDelegate; - protected override bool OnClick(ClickEvent e) { - playDelegate?.Cancel(); - if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) - { - if (ClickDebounceTime <= 0) - sampleClick?.Play(); - else - playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), ClickDebounceTime); - } + sampleClick?.Play(); return base.OnClick(e); } From 71a871d7d1dede52cc9d75b435b7a70b664befc3 Mon Sep 17 00:00:00 2001 From: Ganendra Afrasya Date: Thu, 28 Nov 2019 21:59:57 +0700 Subject: [PATCH 7/8] Add loved enum on BeatmapApproval --- osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs b/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs index 4908e5ecc2..123624d333 100644 --- a/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserRecentActivitiesRequest.cs @@ -42,5 +42,6 @@ public enum BeatmapApproval Ranked, Approved, Qualified, + Loved } } From 14277d714e11ecf7309e2b65b9b606be30880e31 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Nov 2019 01:01:25 +0900 Subject: [PATCH 8/8] Fix tournament client crashing due to null ruleset --- osu.Game.Tournament/TournamentGameBase.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index b5e4a2756a..6bff3fb725 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -129,6 +129,9 @@ private void readBracket() ladder = new LadderInfo(); } + if (ladder.Ruleset.Value == null) + ladder.Ruleset.Value = RulesetStore.AvailableRulesets.First(); + Ruleset.BindTo(ladder.Ruleset); dependencies.Cache(ladder);