mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Fix volume controls handling mouse wheel at a higher level than anything else game-wide.
This commit is contained in:
parent
2ef516a6fa
commit
ee8b678989
@ -133,7 +133,7 @@ namespace osu.Game.GameModes.Menu
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onPlay()
|
||||
|
@ -1,53 +1,52 @@
|
||||
using osu.Framework;
|
||||
using System;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Threading;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
|
||||
namespace osu.Game
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
internal class VolumeControl : Container
|
||||
internal class VolumeControl : OverlayContainer
|
||||
{
|
||||
private FlowContainer volumeMetersContainer;
|
||||
private VolumeMeter volumeMeterMaster;
|
||||
public BindableDouble VolumeGlobal { get; set; }
|
||||
public BindableDouble VolumeSample { get; set; }
|
||||
public BindableDouble VolumeTrack { get; set; }
|
||||
|
||||
private VolumeMeter volumeMeterMaster;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
private void volumeChanged(object sender, System.EventArgs e)
|
||||
private void volumeChanged(object sender, EventArgs e)
|
||||
{
|
||||
appear();
|
||||
|
||||
Anchor = Anchor.BottomRight;
|
||||
Origin = Anchor.BottomRight;
|
||||
Show();
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
public VolumeControl()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.BottomRight;
|
||||
Origin = Anchor.BottomRight;
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
VolumeGlobal.ValueChanged += volumeChanged;
|
||||
VolumeSample.ValueChanged += volumeChanged;
|
||||
VolumeTrack.ValueChanged += volumeChanged;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
volumeMetersContainer = new FlowContainer
|
||||
new FlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Position = new Vector2(10, 30),
|
||||
Spacing = new Vector2(15,0),
|
||||
Alpha = 0,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
|
||||
@ -56,6 +55,8 @@ namespace osu.Game
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
base.Load(game);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -68,22 +69,42 @@ namespace osu.Game
|
||||
|
||||
protected override bool OnWheelDown(InputState state)
|
||||
{
|
||||
if (!IsVisible)
|
||||
return false;
|
||||
|
||||
volumeMeterMaster.TriggerWheelDown(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnWheelUp(InputState state)
|
||||
{
|
||||
if (!IsVisible)
|
||||
return false;
|
||||
|
||||
volumeMeterMaster.TriggerWheelUp(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void appear()
|
||||
ScheduledDelegate popOutDelegate;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
volumeMetersContainer.ClearTransformations();
|
||||
volumeMetersContainer.FadeIn(100);
|
||||
volumeMetersContainer.Delay(1000);
|
||||
volumeMetersContainer.FadeOut(100);
|
||||
ClearTransformations();
|
||||
FadeIn(100);
|
||||
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
FadeOut(100);
|
||||
}
|
||||
|
||||
private void schedulePopOut()
|
||||
{
|
||||
popOutDelegate?.Cancel();
|
||||
Delay(1000);
|
||||
popOutDelegate = Schedule(Hide);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
class VolumeControlReceptor : Container
|
||||
{
|
||||
public Action ActivateRequested;
|
||||
|
||||
protected override bool OnWheelDown(InputState state)
|
||||
{
|
||||
ActivateRequested?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnWheelUp(InputState state)
|
||||
{
|
||||
ActivateRequested?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
case Key.Down:
|
||||
ActivateRequested?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -6,9 +7,8 @@ using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework;
|
||||
|
||||
namespace osu.Game
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
internal class VolumeMeter : Container
|
||||
{
|
@ -23,6 +23,7 @@ using OpenTK.Input;
|
||||
using System.IO;
|
||||
using osu.Game.Beatmaps.IO;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Graphics.UserInterface.Volume;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -40,6 +41,8 @@ namespace osu.Game
|
||||
private string[] args;
|
||||
private IpcChannel<ImportBeatmap> BeatmapIPC;
|
||||
|
||||
private VolumeControl volume;
|
||||
|
||||
public Bindable<PlayMode> PlayMode;
|
||||
|
||||
public OsuGame(string[] args)
|
||||
@ -92,6 +95,11 @@ namespace osu.Game
|
||||
Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic));
|
||||
|
||||
Add(new Drawable[] {
|
||||
new VolumeControlReceptor
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ActivateRequested = delegate { volume.Show(); }
|
||||
},
|
||||
intro = new Intro(),
|
||||
Toolbar = new Toolbar
|
||||
{
|
||||
@ -100,7 +108,7 @@ namespace osu.Game
|
||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||
},
|
||||
Chat = new ChatConsole(API),
|
||||
new VolumeControl
|
||||
volume = new VolumeControl
|
||||
{
|
||||
VolumeGlobal = Audio.Volume,
|
||||
VolumeSample = Audio.VolumeSample,
|
||||
|
@ -138,6 +138,7 @@
|
||||
<Compile Include="GameModes\Play\ComboResultCounter.cs" />
|
||||
<Compile Include="Graphics\UserInterface\RollingCounter.cs" />
|
||||
<Compile Include="GameModes\Play\Taiko\TaikoComboCounter.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeControlReceptor.cs" />
|
||||
<Compile Include="Input\GlobalHotkeys.cs" />
|
||||
<Compile Include="Graphics\Background\Background.cs" />
|
||||
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
|
||||
@ -176,14 +177,14 @@
|
||||
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Users\User.cs" />
|
||||
<Compile Include="VolumeControl.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
|
||||
<Compile Include="Database\BeatmapDatabase.cs" />
|
||||
<Compile Include="Beatmaps\IO\ArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\Formats\BeatmapDecoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" />
|
||||
<Compile Include="Beatmaps\IO\OszArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\Events\EventType.cs" />
|
||||
<Compile Include="VolumeMeter.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeMeter.cs" />
|
||||
<Compile Include="Database\BeatmapSetInfo.cs" />
|
||||
<Compile Include="Database\BeatmapMetadata.cs" />
|
||||
<Compile Include="Database\BeatmapInfo.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user