mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Change "Master" volume if particular meter is not selected.
This commit is contained in:
parent
f3c1c60ab7
commit
06288d3f7c
@ -1,4 +1,5 @@
|
|||||||
using osu.Framework.Configuration;
|
using System.Linq;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -9,6 +10,7 @@ namespace osu.Game
|
|||||||
internal class VolumeControl : Container
|
internal class VolumeControl : Container
|
||||||
{
|
{
|
||||||
private FlowContainer volumeMetersContainer;
|
private FlowContainer volumeMetersContainer;
|
||||||
|
private VolumeMeter volumeMeterMaster;
|
||||||
public BindableDouble VolumeGlobal { get; set; }
|
public BindableDouble VolumeGlobal { get; set; }
|
||||||
public BindableDouble VolumeSample { get; set; }
|
public BindableDouble VolumeSample { get; set; }
|
||||||
public BindableDouble VolumeTrack { get; set; }
|
public BindableDouble VolumeTrack { get; set; }
|
||||||
@ -32,7 +34,7 @@ namespace osu.Game
|
|||||||
Padding = new Vector2(15, 0),
|
Padding = new Vector2(15, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new VolumeMeter("Master", VolumeGlobal),
|
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
|
||||||
new VolumeMeter("Effects", VolumeSample),
|
new VolumeMeter("Effects", VolumeSample),
|
||||||
new VolumeMeter("Music", VolumeTrack)
|
new VolumeMeter("Music", VolumeTrack)
|
||||||
}
|
}
|
||||||
@ -43,12 +45,16 @@ namespace osu.Game
|
|||||||
protected override bool OnWheelDown(InputState state)
|
protected override bool OnWheelDown(InputState state)
|
||||||
{
|
{
|
||||||
appear();
|
appear();
|
||||||
|
if (volumeMetersContainer.Children.All(vm => !vm.Contains(state.Mouse.Position)))
|
||||||
|
volumeMeterMaster.TriggerWheelDown(state);
|
||||||
return base.OnWheelDown(state);
|
return base.OnWheelDown(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnWheelUp(InputState state)
|
protected override bool OnWheelUp(InputState state)
|
||||||
{
|
{
|
||||||
appear();
|
appear();
|
||||||
|
if (volumeMetersContainer.Children.All(vm => !vm.Contains(state.Mouse.Position)))
|
||||||
|
volumeMeterMaster.TriggerWheelUp(state);
|
||||||
return base.OnWheelUp(state);
|
return base.OnWheelUp(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,20 +12,19 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
internal class VolumeMeter : Container
|
internal class VolumeMeter : Container
|
||||||
{
|
{
|
||||||
public Box MeterFill { get; set; }
|
private Box meterFill;
|
||||||
|
private BindableDouble volume;
|
||||||
public BindableDouble Volume { get; set; }
|
|
||||||
|
|
||||||
public VolumeMeter(string meterName, BindableDouble volume)
|
public VolumeMeter(string meterName, BindableDouble volume)
|
||||||
{
|
{
|
||||||
Volume = volume;
|
this.volume = volume;
|
||||||
Size = new Vector2(40, 180);
|
Size = new Vector2(40, 180);
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -38,15 +37,15 @@ namespace osu.Game
|
|||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.DarkGray,
|
Colour = Color4.DarkGray,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both
|
||||||
},
|
},
|
||||||
MeterFill = new Box
|
meterFill = new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.White,
|
Colour = Color4.White,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.BottomCentre
|
Anchor = Anchor.BottomCentre
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new SpriteText {Text = meterName, Anchor = Anchor.BottomCentre,Origin = Anchor.BottomCentre,Position = new Vector2(0,-20)}
|
new SpriteText {Text = meterName, Anchor = Anchor.BottomCentre,Origin = Anchor.BottomCentre,Position = new Vector2(0,-20)}
|
||||||
@ -61,18 +60,18 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected override bool OnWheelUp(InputState state)
|
protected override bool OnWheelUp(InputState state)
|
||||||
{
|
{
|
||||||
Volume.Value += 0.05f;
|
volume.Value += 0.05f;
|
||||||
updateFill();
|
updateFill();
|
||||||
return base.OnWheelUp(state);
|
return base.OnWheelUp(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnWheelDown(InputState state)
|
protected override bool OnWheelDown(InputState state)
|
||||||
{
|
{
|
||||||
Volume.Value -= 0.05f;
|
volume.Value -= 0.05f;
|
||||||
updateFill();
|
updateFill();
|
||||||
return base.OnWheelDown(state);
|
return base.OnWheelDown(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFill() => MeterFill.ScaleTo(new Vector2(1, (float)Volume.Value), 300, EasingTypes.OutQuint);
|
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)volume.Value), 300, EasingTypes.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user