mirror of
https://github.com/ppy/osu.git
synced 2025-03-24 19:17:20 +08:00
Merge branch 'master' into christmas
This commit is contained in:
commit
c16bfa010b
@ -131,21 +131,6 @@ namespace osu.Game.Tests.Visual.Background
|
||||
assertNoBackgrounds();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDelayedConnectivity()
|
||||
{
|
||||
registerBackgroundsResponse(DateTimeOffset.Now.AddDays(30));
|
||||
setSeasonalBackgroundMode(SeasonalBackgroundMode.Always);
|
||||
AddStep("go offline", () => dummyAPI.SetState(APIState.Offline));
|
||||
|
||||
createLoader();
|
||||
assertNoBackgrounds();
|
||||
|
||||
AddStep("go online", () => dummyAPI.SetState(APIState.Online));
|
||||
|
||||
assertAnyBackground();
|
||||
}
|
||||
|
||||
private void registerBackgroundsResponse(DateTimeOffset endDate)
|
||||
=> AddStep("setup request handler", () =>
|
||||
{
|
||||
@ -185,7 +170,8 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
previousBackground = (SeasonalBackground)backgroundContainer.SingleOrDefault();
|
||||
background = backgroundLoader.LoadNextBackground();
|
||||
LoadComponentAsync(background, bg => backgroundContainer.Child = bg);
|
||||
if (background != null)
|
||||
LoadComponentAsync(background, bg => backgroundContainer.Child = bg);
|
||||
});
|
||||
|
||||
AddUntilStep("background loaded", () => background.IsLoaded);
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Configuration;
|
||||
@ -58,7 +56,11 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
// First scroll makes volume controls appear, second adjusts volume.
|
||||
AddRepeatStep("Adjust volume using mouse wheel", () => InputManager.ScrollVerticalBy(5), 10);
|
||||
AddAssert("Volume is still zero", () => Game.Audio.Volume.Value == 0);
|
||||
AddAssert("Volume is still zero", () => Game.Audio.Volume.Value, () => Is.Zero);
|
||||
|
||||
AddStep("Pause", () => InputManager.PressKey(Key.Escape));
|
||||
AddRepeatStep("Adjust volume using mouse wheel", () => InputManager.ScrollVerticalBy(5), 10);
|
||||
AddAssert("Volume is above zero", () => Game.Audio.Volume.Value > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -80,8 +82,8 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
private void loadToPlayerNonBreakTime()
|
||||
{
|
||||
Player player = null;
|
||||
Screens.Select.SongSelect songSelect = null;
|
||||
Player? player = null;
|
||||
Screens.Select.SongSelect songSelect = null!;
|
||||
PushAndConfirm(() => songSelect = new TestSceneScreenNavigation.TestPlaySongSelect());
|
||||
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
|
||||
|
||||
@ -95,7 +97,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
return (player = Game.ScreenStack.CurrentScreen as Player) != null;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for play time active", () => !player.IsBreakTime.Value);
|
||||
AddUntilStep("wait for play time active", () => player!.IsBreakTime.Value, () => Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Volume;
|
||||
@ -59,13 +60,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestAltScrollNotBlocked()
|
||||
{
|
||||
bool scrollReceived = false;
|
||||
TestGlobalScrollAdjustsVolume volumeAdjust = null!;
|
||||
|
||||
AddStep("add volume control receptor", () => Add(new VolumeControlReceptor
|
||||
AddStep("add volume control receptor", () => Add(volumeAdjust = new TestGlobalScrollAdjustsVolume
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = float.MaxValue,
|
||||
ScrollActionRequested = (_, _, _) => scrollReceived = true,
|
||||
}));
|
||||
|
||||
AddStep("hold alt", () => InputManager.PressKey(Key.AltLeft));
|
||||
@ -75,10 +75,21 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
InputManager.ScrollVerticalBy(10);
|
||||
});
|
||||
|
||||
AddAssert("receptor received scroll input", () => scrollReceived);
|
||||
AddAssert("receptor received scroll input", () => volumeAdjust.ScrollReceived);
|
||||
AddStep("release alt", () => InputManager.ReleaseKey(Key.AltLeft));
|
||||
}
|
||||
|
||||
public partial class TestGlobalScrollAdjustsVolume : GlobalScrollAdjustsVolume
|
||||
{
|
||||
public bool ScrollReceived { get; private set; }
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
ScrollReceived = true;
|
||||
return base.OnScroll(e);
|
||||
}
|
||||
}
|
||||
|
||||
private partial class TestOverlay : OsuFocusedOverlayContainer
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -1,8 +1,7 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Volume;
|
||||
@ -11,7 +10,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public partial class TestSceneVolumeOverlay : OsuTestScene
|
||||
{
|
||||
private VolumeOverlay volume;
|
||||
private VolumeOverlay volume = null!;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
dependencies.CacheAs(volume = new VolumeOverlay());
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -19,12 +25,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
volume = new VolumeOverlay(),
|
||||
new VolumeControlReceptor
|
||||
volume,
|
||||
new GlobalScrollAdjustsVolume
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ActionRequested = action => volume.Adjust(action),
|
||||
ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise),
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -28,7 +28,6 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||
private Bindable<SeasonalBackgroundMode> seasonalBackgroundMode;
|
||||
private Bindable<APISeasonalBackgrounds> seasonalBackgrounds;
|
||||
|
||||
@ -47,13 +46,12 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
SeasonalBackgroundChanged?.Invoke();
|
||||
});
|
||||
|
||||
apiState.BindTo(api.State);
|
||||
apiState.BindValueChanged(fetchSeasonalBackgrounds, true);
|
||||
fetchSeasonalBackgrounds();
|
||||
}
|
||||
|
||||
private void fetchSeasonalBackgrounds(ValueChangedEvent<APIState> stateChanged)
|
||||
private void fetchSeasonalBackgrounds()
|
||||
{
|
||||
if (seasonalBackgrounds.Value != null || stateChanged.NewValue != APIState.Online)
|
||||
if (seasonalBackgrounds.Value != null)
|
||||
return;
|
||||
|
||||
var request = new GetSeasonalBackgroundsRequest();
|
||||
|
@ -57,7 +57,6 @@ using osu.Game.Overlays.Notifications;
|
||||
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.Screens;
|
||||
@ -984,12 +983,6 @@ namespace osu.Game
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new VolumeControlReceptor
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ActionRequested = action => volume.Adjust(action),
|
||||
ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise),
|
||||
},
|
||||
ScreenOffsetContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -1436,6 +1429,19 @@ namespace osu.Game
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.DecreaseVolume:
|
||||
case GlobalAction.IncreaseVolume:
|
||||
return volume.Adjust(e.Action);
|
||||
|
||||
case GlobalAction.ToggleMute:
|
||||
case GlobalAction.NextVolumeMeter:
|
||||
case GlobalAction.PreviousVolumeMeter:
|
||||
|
||||
if (e.Repeat)
|
||||
return true;
|
||||
|
||||
return volume.Adjust(e.Action);
|
||||
|
||||
case GlobalAction.ToggleFPSDisplay:
|
||||
fpsCounter.ToggleVisibility();
|
||||
return true;
|
||||
|
37
osu.Game/Overlays/Volume/GlobalScrollAdjustsVolume.cs
Normal file
37
osu.Game/Overlays/Volume/GlobalScrollAdjustsVolume.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Volume
|
||||
{
|
||||
/// <summary>
|
||||
/// Add to a container or screen to make scrolling anywhere in the container cause the global game volume to be adjusted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is generally expected behaviour in many locations in osu!stable.
|
||||
/// </remarks>
|
||||
public partial class GlobalScrollAdjustsVolume : Container
|
||||
{
|
||||
[Resolved]
|
||||
private VolumeOverlay? volumeOverlay { get; set; }
|
||||
|
||||
public GlobalScrollAdjustsVolume()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.ScrollDelta.Y == 0)
|
||||
return false;
|
||||
|
||||
// forward any unhandled mouse scroll events to the volume control.
|
||||
return volumeOverlay?.Adjust(GlobalAction.IncreaseVolume, e.ScrollDelta.Y, e.IsPrecise) ?? false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Volume
|
||||
{
|
||||
public partial class VolumeControlReceptor : Container, IScrollBindingHandler<GlobalAction>, IHandleGlobalKeyboardInput
|
||||
{
|
||||
public Func<GlobalAction, bool> ActionRequested;
|
||||
public Func<GlobalAction, float, bool, bool> ScrollActionRequested;
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.DecreaseVolume:
|
||||
case GlobalAction.IncreaseVolume:
|
||||
return ActionRequested?.Invoke(e.Action) == true;
|
||||
|
||||
case GlobalAction.ToggleMute:
|
||||
case GlobalAction.NextVolumeMeter:
|
||||
case GlobalAction.PreviousVolumeMeter:
|
||||
if (!e.Repeat)
|
||||
return ActionRequested?.Invoke(e.Action) == true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.ScrollDelta.Y == 0)
|
||||
return false;
|
||||
|
||||
// forward any unhandled mouse scroll events to the volume control.
|
||||
ScrollActionRequested?.Invoke(GlobalAction.IncreaseVolume, e.ScrollDelta.Y, e.IsPrecise);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnScroll(KeyBindingScrollEvent<GlobalAction> e) =>
|
||||
ScrollActionRequested?.Invoke(e.Action, e.ScrollAmount, e.IsPrecise) ?? false;
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ using osu.Game.Online.API;
|
||||
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;
|
||||
@ -126,6 +127,7 @@ namespace osu.Game.Screens.Menu
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
SeasonalUIConfig.ENABLED ? new MainMenuSeasonalLighting() : Empty(),
|
||||
new GlobalScrollAdjustsVolume(),
|
||||
buttonsContainer = new ParallaxContainer
|
||||
{
|
||||
ParallaxAmount = 0.01f,
|
||||
|
44
osu.Game/Screens/Play/GameplayScrollWheelHandling.cs
Normal file
44
osu.Game/Screens/Play/GameplayScrollWheelHandling.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays.Volume;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
/// <summary>
|
||||
/// Primarily handles volume adjustment in gameplay.
|
||||
///
|
||||
/// - If the user has mouse wheel disabled, only allow during break time or when holding alt. Also block scroll from parent handling.
|
||||
/// - Otherwise always allow, as per <see cref="GlobalScrollAdjustsVolume"/> implementation.
|
||||
/// </summary>
|
||||
internal partial class GameplayScrollWheelHandling : GlobalScrollAdjustsVolume
|
||||
{
|
||||
private Bindable<bool> mouseWheelDisabled = null!;
|
||||
|
||||
[Resolved]
|
||||
private IGameplayClock gameplayClock { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
// During pause, allow global volume adjust regardless of settings.
|
||||
if (gameplayClock.IsPaused.Value)
|
||||
return base.OnScroll(e);
|
||||
|
||||
// Block any parent handling of scroll if the user has asked for it (special case when holding "Alt").
|
||||
if (mouseWheelDisabled.Value && !e.AltPressed)
|
||||
return true;
|
||||
|
||||
return base.OnScroll(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Threading;
|
||||
@ -88,8 +87,6 @@ namespace osu.Game.Screens.Play
|
||||
private bool isRestarting;
|
||||
private bool skipExitTransition;
|
||||
|
||||
private Bindable<bool> mouseWheelDisabled;
|
||||
|
||||
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
public IBindable<bool> LocalUserPlaying => localUserPlaying;
|
||||
@ -228,8 +225,6 @@ namespace osu.Game.Screens.Play
|
||||
return;
|
||||
}
|
||||
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||
|
||||
if (game != null)
|
||||
gameActive.BindTo(game.IsActive);
|
||||
|
||||
@ -251,7 +246,10 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
dependencies.CacheAs(HealthProcessor);
|
||||
|
||||
InternalChild = GameplayClockContainer = CreateGameplayClockContainer(Beatmap.Value, DrawableRuleset.GameplayStartTime);
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
GameplayClockContainer = CreateGameplayClockContainer(Beatmap.Value, DrawableRuleset.GameplayStartTime),
|
||||
};
|
||||
|
||||
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));
|
||||
|
||||
@ -266,6 +264,7 @@ namespace osu.Game.Screens.Play
|
||||
dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor, HealthProcessor, Beatmap.Value.Storyboard));
|
||||
|
||||
var rulesetSkinProvider = new RulesetSkinProvidingContainer(ruleset, playableBeatmap, Beatmap.Value.Skin);
|
||||
GameplayClockContainer.Add(new GameplayScrollWheelHandling());
|
||||
|
||||
// load the skinning hierarchy first.
|
||||
// this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
|
||||
@ -894,16 +893,6 @@ namespace osu.Game.Screens.Play
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
// During pause, allow global volume adjust regardless of settings.
|
||||
if (GameplayClockContainer.IsPaused.Value)
|
||||
return false;
|
||||
|
||||
// Block global volume adjust if the user has asked for it (special case when holding "Alt").
|
||||
return mouseWheelDisabled.Value && !e.AltPressed;
|
||||
}
|
||||
|
||||
#region Gameplay leaderboard
|
||||
|
||||
protected readonly Bindable<bool> LeaderboardExpandedState = new BindableBool();
|
||||
|
@ -27,6 +27,7 @@ using osu.Game.Input;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using osu.Game.Performance;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Menu;
|
||||
@ -190,6 +191,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new GlobalScrollAdjustsVolume(),
|
||||
(content = new LogoTrackingContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -31,6 +31,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
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.Screens.Backgrounds;
|
||||
@ -169,10 +170,12 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new GlobalScrollAdjustsVolume(),
|
||||
new VerticalMaskingContainer
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new GlobalScrollAdjustsVolume(),
|
||||
new GridContainer // used for max width implementation
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
|
Loading…
x
Reference in New Issue
Block a user