Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions osu.Game.Tests/Visual/UserInterface/TestSceneOverlayContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,29 @@
{
public partial class TestSceneOverlayContainer : OsuManualInputManagerTestScene
{
[SetUp]
public void SetUp() => Schedule(() => Child = new TestOverlay
private TestOverlay createOverlay() => new TestOverlay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f)
});
};

private void loadOverlay() => Schedule(() => Child = createOverlay());
private void loadBlockingOverlay() => Schedule(() => Child = createOverlay().With(d =>

Check warning

Code scanning / InspectCode

Incorrect blank lines: Blank lines are missing elsewhere Warning test

Blank lines are missing, expected minimum 1 instead of 0
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
{
d.Child = new BlockingContainer
{
RelativeSizeAxes = Axes.Both,
};
}));

[Test]
public void TestScrollBlocked()
{
OsuScrollContainer scroll = null!;

AddStep("load overlay", () => loadOverlay());

Check warning

Code scanning / InspectCode

Convert lambda expression into method group Warning test

Convert into method group
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
AddStep("add scroll container", () =>
{
Add(scroll = new OsuScrollContainer
Expand Down Expand Up @@ -60,9 +69,10 @@
[Test]
public void TestAltScrollNotBlocked()
{
TestGlobalScrollAdjustsVolume volumeAdjust = null!;
TestGlobalAltScrollAdjustsVolume volumeAdjust = null!;

AddStep("add volume control receptor", () => Add(volumeAdjust = new TestGlobalScrollAdjustsVolume
AddStep("load overlay", () => loadOverlay());

Check warning

Code scanning / InspectCode

Convert lambda expression into method group Warning test

Convert into method group
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
AddStep("add volume control receptor", () => Add(volumeAdjust = new TestGlobalAltScrollAdjustsVolume
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
Expand All @@ -79,7 +89,33 @@
AddStep("release alt", () => InputManager.ReleaseKey(Key.AltLeft));
}

public partial class TestGlobalScrollAdjustsVolume : GlobalScrollAdjustsVolume
[Test]
public void TestAltScrollBlockedByOptOut()
{
TestGlobalAltScrollAdjustsVolume volumeAdjust = null!;

AddStep("add blocker and receptor", () =>
{
Add(volumeAdjust = new TestGlobalAltScrollAdjustsVolume
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
});
});
AddStep("load blocking overlay", () => loadBlockingOverlay());

Check warning

Code scanning / InspectCode

Convert lambda expression into method group Warning test

Convert into method group
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

AddStep("hold alt", () => InputManager.PressKey(Key.AltLeft));
AddStep("perform scroll", () =>
{
InputManager.MoveMouseTo(Content);
InputManager.ScrollVerticalBy(10);
});

AddAssert("receptor did not receive scroll input", () => !volumeAdjust.ScrollReceived);
AddStep("release alt", () => InputManager.ReleaseKey(Key.AltLeft));
}

public partial class TestGlobalAltScrollAdjustsVolume : GlobalAltScrollAdjustsVolume
{
public bool ScrollReceived { get; private set; }

Expand All @@ -90,6 +126,13 @@
}
}

private partial class BlockingContainer : Container, IBlockGlobalAltScrollVolume
{
public BlockingContainer()

Check warning

Code scanning / InspectCode

Empty constructor Warning test

Empty constructor is redundant. The compiler generates the same by default.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
{
}
}

private partial class TestOverlay : OsuFocusedOverlayContainer
{
[BackgroundDependencyLoader]
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/OsuGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
using osu.Game.Overlays.OSD;
using osu.Game.Overlays.SkinEditor;
using osu.Game.Overlays.Toolbar;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
Expand Down Expand Up @@ -1188,6 +1189,7 @@ protected override void LoadComplete()
}, topMostOverlayContent.Add);

loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add, true);
topMostOverlayContent.Add(new GlobalAltScrollAdjustsVolume());

onScreenDisplay = new OnScreenDisplay();

Expand Down
27 changes: 27 additions & 0 deletions osu.Game/Overlays/Volume/GlobalAltScrollAdjustsVolume.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Linq;
using osu.Framework.Input.Events;

namespace osu.Game.Overlays.Volume
{
/// <summary>
/// Allows adjusting volume via mouse scroll while holding alt, regardless of the current game state.
/// </summary>
public partial class GlobalAltScrollAdjustsVolume : GlobalScrollAdjustsVolume
{
protected override bool OnScroll(ScrollEvent e)
{
if (!e.AltPressed || e.ControlPressed || e.ShiftPressed || e.SuperPressed)
return false;

var hoveredDrawables = GetContainingInputManager()?.HoveredDrawables;

if (hoveredDrawables?.Any(d => d is IBlockGlobalAltScrollVolume) == true)
return false;

return base.OnScroll(e);
}
}
}
12 changes: 12 additions & 0 deletions osu.Game/Overlays/Volume/IBlockGlobalAltScrollVolume.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

namespace osu.Game.Overlays.Volume
{
/// <summary>
/// Marks hovered drawables that should suppress the global Alt-scroll volume fallback.
/// </summary>
public interface IBlockGlobalAltScrollVolume
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Volume;
using osuTK;

namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
public partial class ZoomableScrollContainer : OsuScrollContainer
public partial class ZoomableScrollContainer : OsuScrollContainer, IBlockGlobalAltScrollVolume
{
/// <summary>
/// The time to zoom into/out of a point.
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Screens/Menu/IntroScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds;
using osu.Game.Skinning;
Expand Down Expand Up @@ -184,7 +183,6 @@ bool loadThemedIntro()
return UsingThemedIntro = initialBeatmap != null;
}

AddInternal(new GlobalScrollAdjustsVolume());
}

public override void OnEntering(ScreenTransitionEvent e)
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.SkinEditor;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
Expand Down Expand Up @@ -141,7 +140,6 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
AddRangeInternal(new[]
{
SeasonalUIConfig.ENABLED ? new MainMenuSeasonalLighting() : Empty(),
new GlobalScrollAdjustsVolume(),
buttonsContainer = new ParallaxContainer
{
ParallaxAmount = 0.01f,
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Screens/OnlinePlay/Matchmaking/Queue/ScreenQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
using osu.Game.Overlays;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets;
using osu.Game.Screens.Footer;
using osu.Game.Screens.OnlinePlay.Matchmaking.Match;
Expand Down Expand Up @@ -124,7 +123,6 @@ private void load(AudioManager audio, IAPIProvider api)
Children = new Drawable[]
{
waitingLoop = new DrawableSample(audio.Samples.Get(@"Multiplayer/Matchmaking/waiting-loop")),
new GlobalScrollAdjustsVolume(),
mainGrid = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Matchmaking.Match.Gameplay;
Expand Down Expand Up @@ -131,7 +130,6 @@ public RankedPlayScreen(MultiplayerRoom room)
matchInfo = new RankedPlayMatchInfo(),
backgroundMusic = new BackgroundMusicManager(),
new RankedPlayBeatmapAvailabilityTracker(),
new GlobalScrollAdjustsVolume(),
content = new InverseScalingDrawSizePreservingFillContainer
{
Anchor = Anchor.Centre,
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Screens/Play/PlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.Volume;
using osu.Game.Performance;
using osu.Game.Screens.Footer;
using osu.Game.Screens.Menu;
Expand Down Expand Up @@ -206,7 +205,6 @@ private void load(SessionStatics sessionStatics, OsuConfigManager config)

InternalChildren = new Drawable[]
{
new GlobalScrollAdjustsVolume(),
(content = new LogoTrackingContainer
{
Anchor = Anchor.Centre,
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Screens/Ranking/ResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using osu.Game.Localisation;
using osu.Game.Online.Placeholders;
using osu.Game.Overlays;
using osu.Game.Overlays.Volume;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking.Expanded.Accuracy;
Expand Down Expand Up @@ -122,7 +121,6 @@ private void load(AudioManager audio)
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new GlobalScrollAdjustsVolume(),
StatisticsPanel = new StatisticsPanel
{
RelativeSizeAxes = Axes.Both,
Expand Down
2 changes: 0 additions & 2 deletions osu.Game/Screens/Select/SongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
Expand Down Expand Up @@ -178,7 +177,6 @@ private void load(AudioManager audio, OsuConfigManager config)

AddRangeInternal(new Drawable[]
{
new GlobalScrollAdjustsVolume(),
onlineLookupSource,
mainContent = new Container
{
Expand Down
Loading