mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Fix volume controls handling mouse wheel at a higher level than anything else game-wide.
This commit is contained in:
110
osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs
Normal file
110
osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs
Normal file
@ -0,0 +1,110 @@
|
||||
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;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
internal class VolumeControl : OverlayContainer
|
||||
{
|
||||
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, EventArgs e)
|
||||
{
|
||||
Show();
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
public VolumeControl()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.BottomRight;
|
||||
Origin = Anchor.BottomRight;
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
VolumeGlobal.ValueChanged += volumeChanged;
|
||||
VolumeSample.ValueChanged += volumeChanged;
|
||||
VolumeTrack.ValueChanged += volumeChanged;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Position = new Vector2(10, 30),
|
||||
Spacing = new Vector2(15,0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
|
||||
new VolumeMeter("Effects", VolumeSample),
|
||||
new VolumeMeter("Music", VolumeTrack)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
base.Load(game);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
VolumeGlobal.ValueChanged -= volumeChanged;
|
||||
VolumeSample.ValueChanged -= volumeChanged;
|
||||
VolumeTrack.ValueChanged -= volumeChanged;
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
ScheduledDelegate popOutDelegate;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
ClearTransformations();
|
||||
FadeIn(100);
|
||||
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
FadeOut(100);
|
||||
}
|
||||
|
||||
private void schedulePopOut()
|
||||
{
|
||||
popOutDelegate?.Cancel();
|
||||
Delay(1000);
|
||||
popOutDelegate = Schedule(Hide);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user