From 06288d3f7c0c55f41cbfcc1272b04783c904259f Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Wed, 12 Oct 2016 17:36:42 +0300 Subject: [PATCH] Change "Master" volume if particular meter is not selected. --- osu.Game/VolumeControl.cs | 10 ++++++++-- osu.Game/VolumeMeter.cs | 21 ++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/osu.Game/VolumeControl.cs b/osu.Game/VolumeControl.cs index fe69cc7b71..0317ef3406 100644 --- a/osu.Game/VolumeControl.cs +++ b/osu.Game/VolumeControl.cs @@ -1,4 +1,5 @@ -using osu.Framework.Configuration; +using System.Linq; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; @@ -9,6 +10,7 @@ namespace osu.Game internal class VolumeControl : Container { private FlowContainer volumeMetersContainer; + private VolumeMeter volumeMeterMaster; public BindableDouble VolumeGlobal { get; set; } public BindableDouble VolumeSample { get; set; } public BindableDouble VolumeTrack { get; set; } @@ -32,7 +34,7 @@ namespace osu.Game Padding = new Vector2(15, 0), Children = new Drawable[] { - new VolumeMeter("Master", VolumeGlobal), + volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal), new VolumeMeter("Effects", VolumeSample), new VolumeMeter("Music", VolumeTrack) } @@ -43,12 +45,16 @@ namespace osu.Game protected override bool OnWheelDown(InputState state) { appear(); + if (volumeMetersContainer.Children.All(vm => !vm.Contains(state.Mouse.Position))) + volumeMeterMaster.TriggerWheelDown(state); return base.OnWheelDown(state); } protected override bool OnWheelUp(InputState state) { appear(); + if (volumeMetersContainer.Children.All(vm => !vm.Contains(state.Mouse.Position))) + volumeMeterMaster.TriggerWheelUp(state); return base.OnWheelUp(state); } diff --git a/osu.Game/VolumeMeter.cs b/osu.Game/VolumeMeter.cs index 218126d3c8..0f173ea465 100644 --- a/osu.Game/VolumeMeter.cs +++ b/osu.Game/VolumeMeter.cs @@ -12,20 +12,19 @@ namespace osu.Game { internal class VolumeMeter : Container { - public Box MeterFill { get; set; } - - public BindableDouble Volume { get; set; } + private Box meterFill; + private BindableDouble volume; public VolumeMeter(string meterName, BindableDouble volume) { - Volume = volume; + this.volume = volume; Size = new Vector2(40, 180); Children = new Drawable[] { new Box { Colour = Color4.Black, - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Both }, new Container { @@ -38,15 +37,15 @@ namespace osu.Game new Box { Colour = Color4.DarkGray, - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Both }, - MeterFill = new Box + meterFill = new Box { Colour = Color4.White, RelativeSizeAxes = Axes.Both, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre - }, + } } }, 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) { - Volume.Value += 0.05f; + volume.Value += 0.05f; updateFill(); return base.OnWheelUp(state); } protected override bool OnWheelDown(InputState state) { - Volume.Value -= 0.05f; + volume.Value -= 0.05f; updateFill(); 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); } } \ No newline at end of file