From 46dfb761c57e1804576760ce217ddf4a44544cba Mon Sep 17 00:00:00 2001 From: jorolf Date: Wed, 28 Feb 2018 16:14:52 +0100 Subject: [PATCH 01/24] basic volume meter and testcase --- .../Visual/TestCaseVolumeControl.cs | 29 +++ osu.Game.Tests/osu.Game.Tests.csproj | 1 + osu.Game/Overlays/Volume/MuteButton.cs | 58 ++++++ osu.Game/Overlays/Volume/VolumeMeter.cs | 193 ++++++++++++++++++ osu.Game/osu.Game.csproj | 2 + 5 files changed, 283 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseVolumeControl.cs create mode 100644 osu.Game/Overlays/Volume/MuteButton.cs create mode 100644 osu.Game/Overlays/Volume/VolumeMeter.cs diff --git a/osu.Game.Tests/Visual/TestCaseVolumeControl.cs b/osu.Game.Tests/Visual/TestCaseVolumeControl.cs new file mode 100644 index 0000000000..04390d6d19 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseVolumeControl.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Graphics; +using osu.Framework.Testing; +using osu.Game.Graphics; +using osu.Game.Overlays.Volume; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseVolumeControl : TestCase + { + public override IReadOnlyList RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) }; + + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuColour colours) + { + VolumeMeter meter; + Add(meter = new VolumeMeter("MASTER", 125, colours.PinkDarker)); + Add(new MuteButton + { + Margin = new MarginPadding { Top = 200 } + }); + + meter.Bindable.BindTo(audio.Volume); + } + } +} diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 8301f1f734..63adbc8b43 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -162,6 +162,7 @@ + diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs new file mode 100644 index 0000000000..b45034c166 --- /dev/null +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -0,0 +1,58 @@ +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Volume +{ + public class MuteButton : Container, IHasCurrentValue + { + public Bindable Current { get; } = new Bindable(); + + private Color4 hoveredColour, unhoveredColour; + + public MuteButton() + { + Masking = true; + BorderThickness = 3; + CornerRadius = 20; + Size = new Vector2(100, 40); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + hoveredColour = colours.YellowDark; + BorderColour = unhoveredColour = colours.Gray1.Opacity(0.9f); + + AddRange(new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Alpha = 0.9f, + }, + }); + } + + protected override bool OnHover(InputState state) + { + this.TransformTo("BorderColour", hoveredColour, 500, Easing.OutQuint); + return true; + } + + protected override void OnHoverLost(InputState state) + { + this.TransformTo("BorderColour", unhoveredColour, 500, Easing.OutQuint); + } + } +} diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs new file mode 100644 index 0000000000..3351dbed9a --- /dev/null +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -0,0 +1,193 @@ +using System; +using System.Globalization; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input.Bindings; +using osu.Framework.MathUtils; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Input.Bindings; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Volume +{ + public class VolumeMeter : Container, IKeyBindingHandler + { + private CircularProgress volumeCircle; + public BindableDouble Bindable { get; } = new BindableDouble(); + private readonly float circleSize; + private readonly Color4 meterColour; + private readonly string name; + + public VolumeMeter(string name, float circleSize, Color4 meterColour) + { + this.circleSize = circleSize; + this.meterColour = meterColour; + this.name = name; + + AutoSizeAxes = Axes.Both; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Add(new Container + { + Size = new Vector2(120, 20), + CornerRadius = 10, + Masking = true, + Margin = new MarginPadding { Left = circleSize + 10 }, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Alpha = 0.9f, + }, + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = "Exo2.0-Bold", + Text = name + } + } + }); + + + OsuSpriteText text, maxText; + CircularProgress bgProgress; + BufferedContainer maxGlow; + + Add(new CircularContainer + { + Masking = true, + Size = new Vector2(circleSize), + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Alpha = 0.9f, + }, + bgProgress = new CircularProgress + { + RelativeSizeAxes = Axes.Both, + InnerRadius = 0.05f, + Rotation = 180, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = colours.Gray2, + Size = new Vector2(0.8f) + }, + (volumeCircle = new CircularProgress + { + RelativeSizeAxes = Axes.Both, + InnerRadius = 0.05f, + Rotation = 180, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(0.8f) + }).WithEffect(new GlowEffect + { + Colour = meterColour, + Strength = 2 + }), + maxGlow = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = "Venera", + Text = "MAX", + TextSize = 0.16f * circleSize + }.WithEffect(new GlowEffect + { + Colour = meterColour, + PadExtent = true, + Strength = 2, + }), + text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = "Venera", + TextSize = 0.16f * circleSize + } + } + }); + + Bindable.ValueChanged += newVolume => this.TransformTo("circleBindable", newVolume * 0.75, 250, Easing.OutQuint); + volumeCircle.Current.ValueChanged += newVolume => + { + if (newVolume > 0.745) + { + text.Alpha = 0; + maxGlow.Alpha = 1; //show "MAX" + } + else + { + text.Text = Math.Round(newVolume / 0.0075).ToString(CultureInfo.CurrentCulture); + text.Alpha = 1; + maxGlow.Alpha = 0; + } + }; + + bgProgress.Current.Value = 0.75f; + } + + /// + /// This is needed because doesn't support + /// + private double circleBindable + { + get => volumeCircle.Current; + set => volumeCircle.Current.Value = value; + } + + public double Volume + { + get => Bindable; + private set => Bindable.Value = value; + } + + public void Increase() + { + Volume += 0.05f; + } + + public void Decrease() + { + Volume -= 0.05f; + } + + public bool OnPressed(GlobalAction action) + { + if (!IsHovered) return false; + + switch (action) + { + case GlobalAction.DecreaseVolume: + Decrease(); + return true; + case GlobalAction.IncreaseVolume: + Increase(); + return true; + } + + return false; + } + + public bool OnReleased(GlobalAction action) => false; + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4944613828..b94da5badb 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -330,6 +330,8 @@ + + From 3a420ba8269920c45ba166076a14a82f6f6815da Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 19:08:35 +0100 Subject: [PATCH 02/24] add the volume overlay --- ...lumeControl.cs => TestCaseVolumePieces.cs} | 3 +- osu.Game.Tests/osu.Game.Tests.csproj | 2 +- .../UserInterface/Volume/VolumeMeter.cs | 108 ------------- osu.Game/OsuGame.cs | 6 +- osu.Game/Overlays/Volume/MuteButton.cs | 27 +++- .../Volume/VolumeControlReceptor.cs | 2 +- osu.Game/Overlays/Volume/VolumeMeter.cs | 4 +- .../VolumeOverlay.cs} | 145 +++++++++--------- osu.Game/osu.Game.csproj | 5 +- 9 files changed, 109 insertions(+), 193 deletions(-) rename osu.Game.Tests/Visual/{TestCaseVolumeControl.cs => TestCaseVolumePieces.cs} (90%) delete mode 100644 osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs rename osu.Game/{Graphics/UserInterface => Overlays}/Volume/VolumeControlReceptor.cs (90%) rename osu.Game/{Graphics/UserInterface/Volume/VolumeControl.cs => Overlays/VolumeOverlay.cs} (54%) diff --git a/osu.Game.Tests/Visual/TestCaseVolumeControl.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs similarity index 90% rename from osu.Game.Tests/Visual/TestCaseVolumeControl.cs rename to osu.Game.Tests/Visual/TestCaseVolumePieces.cs index 04390d6d19..5a43574a9d 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumeControl.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -9,7 +9,7 @@ using osu.Game.Overlays.Volume; namespace osu.Game.Tests.Visual { - public class TestCaseVolumeControl : TestCase + public class TestCaseVolumePieces : TestCase { public override IReadOnlyList RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) }; @@ -24,6 +24,7 @@ namespace osu.Game.Tests.Visual }); meter.Bindable.BindTo(audio.Volume); + } } } diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index dde04201f2..8cbeb6aab6 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -174,7 +174,7 @@ - + diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs deleted file mode 100644 index ef3702fdf3..0000000000 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics.Sprites; -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Bindings; -using osu.Game.Input.Bindings; - -namespace osu.Game.Graphics.UserInterface.Volume -{ - public class VolumeMeter : Container, IKeyBindingHandler - { - private readonly Box meterFill; - public BindableDouble Bindable { get; } = new BindableDouble(); - - public VolumeMeter(string meterName) - { - Size = new Vector2(40, 180); - Children = new Drawable[] - { - new Box - { - Colour = Color4.Black, - RelativeSizeAxes = Axes.Both - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.5f, 0.9f), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new Drawable[] - { - new Box - { - Colour = Color4.DarkGray, - RelativeSizeAxes = Axes.Both - }, - meterFill = new Box - { - Colour = Color4.White, - Scale = new Vector2(1, 0), - RelativeSizeAxes = Axes.Both, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre - } - } - }, - new OsuSpriteText - { - Text = meterName, - Anchor = Anchor.BottomCentre, - Origin = Anchor.TopCentre - } - }; - - Bindable.ValueChanged += delegate { updateFill(); }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - updateFill(); - } - - public double Volume - { - get => Bindable.Value; - private set => Bindable.Value = value; - } - - public void Increase() - { - Volume += 0.05f; - } - - public void Decrease() - { - Volume -= 0.05f; - } - - private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, Easing.OutQuint); - - public bool OnPressed(GlobalAction action) - { - if (!IsHovered) return false; - - switch (action) - { - case GlobalAction.DecreaseVolume: - Decrease(); - return true; - case GlobalAction.IncreaseVolume: - Increase(); - return true; - } - - return false; - } - - public bool OnReleased(GlobalAction action) => false; - } -} diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index aeb23dccd7..a6f650d23d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; using osu.Framework.Logging; -using osu.Game.Graphics.UserInterface.Volume; using osu.Framework.Allocation; using osu.Game.Overlays.Toolbar; using osu.Game.Screens; @@ -33,6 +32,7 @@ using osu.Game.Input.Bindings; using osu.Game.Rulesets.Mods; using osu.Game.Skinning; using OpenTK.Graphics; +using osu.Game.Overlays.Volume; namespace osu.Game { @@ -75,7 +75,7 @@ namespace osu.Game private OsuScreen screenStack; - private VolumeControl volume; + private VolumeOverlay volume; private OnScreenDisplay onscreenDisplay; private Bindable configRuleset; @@ -232,7 +232,7 @@ namespace osu.Game }, }, overlayContent.Add); - loadComponentSingleFile(volume = new VolumeControl(), Add); + loadComponentSingleFile(volume = new VolumeOverlay(), Add); loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add); //overlay elements diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs index b45034c166..82e61c8f0b 100644 --- a/osu.Game/Overlays/Volume/MuteButton.cs +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -18,13 +18,15 @@ namespace osu.Game.Overlays.Volume public Bindable Current { get; } = new Bindable(); private Color4 hoveredColour, unhoveredColour; + private const float width = 100; + public const float HEIGHT = 35; public MuteButton() { Masking = true; BorderThickness = 3; - CornerRadius = 20; - Size = new Vector2(100, 40); + CornerRadius = HEIGHT / 2; + Size = new Vector2(width, HEIGHT); } [BackgroundDependencyLoader] @@ -33,6 +35,8 @@ namespace osu.Game.Overlays.Volume hoveredColour = colours.YellowDark; BorderColour = unhoveredColour = colours.Gray1.Opacity(0.9f); + + SpriteIcon icon; AddRange(new Drawable[] { new Box @@ -41,7 +45,20 @@ namespace osu.Game.Overlays.Volume Colour = colours.Gray1, Alpha = 0.9f, }, + icon = new SpriteIcon + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(20), + } }); + + Current.ValueChanged += newValue => + { + icon.Icon = newValue ? FontAwesome.fa_volume_off : FontAwesome.fa_volume_up; + icon.Margin = new MarginPadding { Left = newValue ? width / 2 - 15 : width / 2 - 10 }; //Magic numbers to line up both icons because they're different widths + }; + Current.TriggerChange(); } protected override bool OnHover(InputState state) @@ -54,5 +71,11 @@ namespace osu.Game.Overlays.Volume { this.TransformTo("BorderColour", unhoveredColour, 500, Easing.OutQuint); } + + protected override bool OnClick(InputState state) + { + Current.Value = !Current.Value; + return true; + } } } diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs b/osu.Game/Overlays/Volume/VolumeControlReceptor.cs similarity index 90% rename from osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs rename to osu.Game/Overlays/Volume/VolumeControlReceptor.cs index 2328533665..a5be7dc445 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs +++ b/osu.Game/Overlays/Volume/VolumeControlReceptor.cs @@ -7,7 +7,7 @@ using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Game.Input.Bindings; -namespace osu.Game.Graphics.UserInterface.Volume +namespace osu.Game.Overlays.Volume { public class VolumeControlReceptor : Container, IKeyBindingHandler, IHandleGlobalInput { diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 3351dbed9a..92b5c3f0bd 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -128,9 +128,9 @@ namespace osu.Game.Overlays.Volume }); Bindable.ValueChanged += newVolume => this.TransformTo("circleBindable", newVolume * 0.75, 250, Easing.OutQuint); - volumeCircle.Current.ValueChanged += newVolume => + volumeCircle.Current.ValueChanged += newVolume => //by using this event we sync the meter with the text. newValue has to be divided by 0.75 to give the actual percentage { - if (newVolume > 0.745) + if (Precision.DefinitelyBigger(newVolume, 0.74)) { text.Alpha = 0; maxGlow.Alpha = 1; //show "MAX" diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Overlays/VolumeOverlay.cs similarity index 54% rename from osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs rename to osu.Game/Overlays/VolumeOverlay.cs index ccf70af6ed..aa94667901 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -1,57 +1,87 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Threading; -using OpenTK; +using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Allocation; using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Threading; +using osu.Game.Graphics; using osu.Game.Input.Bindings; +using osu.Game.Overlays.Volume; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Graphics.UserInterface.Volume +namespace osu.Game.Overlays { - public class VolumeControl : OverlayContainer + public class VolumeOverlay : OverlayContainer { - private readonly VolumeMeter volumeMeterMaster; - private readonly IconButton muteIcon; + private const float offset = 10; + + private VolumeMeter volumeMeterMaster; + private VolumeMeter volumeMeterEffect; + private VolumeMeter volumeMeterMusic; + private MuteButton muteButton; protected override bool BlockPassThroughMouse => false; - public VolumeControl() - { - AutoSizeAxes = Axes.Both; - Anchor = Anchor.BottomRight; - Origin = Anchor.BottomRight; + private readonly BindableDouble muteAdjustment = new BindableDouble(); - Children = new Drawable[] + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuColour colours) + { + RelativeSizeAxes = Axes.Both; + + AddRange(new Drawable[] { + new Box + { + RelativeSizeAxes = Axes.Y, + Width = 300, + Colour = new ColourInfo + { + TopLeft = Color4.Black.Opacity(0.5f), + BottomLeft = Color4.Black.Opacity(0.5f), + TopRight = Color4.Black.Opacity(0), + BottomRight = Color4.Black.Opacity(0), + } + }, new FillFlowContainer { + Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Both, - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Margin = new MarginPadding { Left = 10, Right = 10, Top = 30, Bottom = 30 }, - Spacing = new Vector2(15, 0), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Spacing = new Vector2(0, offset), + Margin = new MarginPadding { Left = offset }, Children = new Drawable[] { - new Container + volumeMeterEffect = new VolumeMeter("EFFECTS", 125, colours.Blue) { - Size = new Vector2(IconButton.BUTTON_SIZE), - Child = muteIcon = new IconButton - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.fa_volume_up, - Action = () => Adjust(GlobalAction.ToggleMute), - } + Margin = new MarginPadding { Top = 100 + MuteButton.HEIGHT } //to counter the mute button and re-center the volume meters }, - volumeMeterMaster = new VolumeMeter("Master"), - volumeMeterEffect = new VolumeMeter("Effects"), - volumeMeterMusic = new VolumeMeter("Music") + volumeMeterMaster = new VolumeMeter("MASTER", 150, colours.Pink), + volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.Blue), + muteButton = new MuteButton + { + Margin = new MarginPadding { Top = 100 } + } } - } + }, + }); + + + volumeMeterMaster.Bindable.BindTo(audio.Volume); + volumeMeterEffect.Bindable.BindTo(audio.VolumeSample); + volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack); + + muteButton.Current.ValueChanged += mute => + { + if (mute) + audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment); + else + audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment); }; } @@ -62,7 +92,13 @@ namespace osu.Game.Graphics.UserInterface.Volume volumeMeterMaster.Bindable.ValueChanged += _ => settingChanged(); volumeMeterEffect.Bindable.ValueChanged += _ => settingChanged(); volumeMeterMusic.Bindable.ValueChanged += _ => settingChanged(); - muted.ValueChanged += _ => settingChanged(); + muteButton.Current.ValueChanged += _ => settingChanged(); + } + + private void settingChanged() + { + Show(); + schedulePopOut(); } public bool Adjust(GlobalAction action) @@ -83,50 +119,15 @@ namespace osu.Game.Graphics.UserInterface.Volume return true; case GlobalAction.ToggleMute: Show(); - muted.Toggle(); + muteButton.Current.Value = !muteButton.Current; return true; } return false; } - private void settingChanged() - { - Show(); - schedulePopOut(); - } - - private readonly BindableDouble muteAdjustment = new BindableDouble(); - - private readonly BindableBool muted = new BindableBool(); - - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - volumeMeterMaster.Bindable.BindTo(audio.Volume); - volumeMeterEffect.Bindable.BindTo(audio.VolumeSample); - volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack); - - muted.ValueChanged += mute => - { - if (mute) - { - audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment); - muteIcon.Icon = FontAwesome.fa_volume_off; - } - else - { - audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment); - muteIcon.Icon = FontAwesome.fa_volume_up; - } - }; - } - private ScheduledDelegate popOutDelegate; - private readonly VolumeMeter volumeMeterEffect; - private readonly VolumeMeter volumeMeterMusic; - protected override void PopIn() { ClearTransforms(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 847b4469e5..e99fd16aef 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -351,7 +351,9 @@ + + @@ -471,9 +473,6 @@ - - - From ef63366d91028c93f1478618793abff7de97e29c Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 19:25:34 +0100 Subject: [PATCH 03/24] simplify VolumeMeter --- osu.Game/Overlays/Volume/VolumeMeter.cs | 30 ++++++++++--------------- osu.Game/Overlays/VolumeOverlay.cs | 3 ++- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 92b5c3f0bd..525b4e315a 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -1,7 +1,9 @@ using System; using System.Globalization; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; @@ -65,7 +67,7 @@ namespace osu.Game.Overlays.Volume }); - OsuSpriteText text, maxText; + OsuSpriteText text; CircularProgress bgProgress; BufferedContainer maxGlow; @@ -104,26 +106,17 @@ namespace osu.Game.Overlays.Volume Colour = meterColour, Strength = 2 }), - maxGlow = new OsuSpriteText + maxGlow = (text = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Font = "Venera", - Text = "MAX", TextSize = 0.16f * circleSize - }.WithEffect(new GlowEffect + }).WithEffect(new GlowEffect { - Colour = meterColour, + Colour = Color4.Transparent, PadExtent = true, - Strength = 2, - }), - text = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = "Venera", - TextSize = 0.16f * circleSize - } + }) } }); @@ -132,14 +125,14 @@ namespace osu.Game.Overlays.Volume { if (Precision.DefinitelyBigger(newVolume, 0.74)) { - text.Alpha = 0; - maxGlow.Alpha = 1; //show "MAX" + text.Text = "MAX"; + maxGlow.EffectColour = meterColour.Opacity(2f); } else { + if (text.Text == "MAX") + maxGlow.EffectColour = Color4.Transparent; text.Text = Math.Round(newVolume / 0.0075).ToString(CultureInfo.CurrentCulture); - text.Alpha = 1; - maxGlow.Alpha = 0; } }; @@ -149,6 +142,7 @@ namespace osu.Game.Overlays.Volume /// /// This is needed because doesn't support /// + [UsedImplicitly] private double circleBindable { get => volumeCircle.Current; diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index aa94667901..a8be219fc4 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -31,7 +31,8 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colours) { - RelativeSizeAxes = Axes.Both; + AutoSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Y; AddRange(new Drawable[] { From 8e0a524c4d6368469fe11072c0465409cf766b6b Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 19:31:29 +0100 Subject: [PATCH 04/24] change colours --- osu.Game/Overlays/VolumeOverlay.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index a8be219fc4..cc57b468fb 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -42,8 +42,8 @@ namespace osu.Game.Overlays Width = 300, Colour = new ColourInfo { - TopLeft = Color4.Black.Opacity(0.5f), - BottomLeft = Color4.Black.Opacity(0.5f), + TopLeft = Color4.Black.Opacity(0.75f), + BottomLeft = Color4.Black.Opacity(0.75f), TopRight = Color4.Black.Opacity(0), BottomRight = Color4.Black.Opacity(0), } @@ -58,12 +58,12 @@ namespace osu.Game.Overlays Margin = new MarginPadding { Left = offset }, Children = new Drawable[] { - volumeMeterEffect = new VolumeMeter("EFFECTS", 125, colours.Blue) + volumeMeterEffect = new VolumeMeter("EFFECTS", 125, colours.BlueDarker) { Margin = new MarginPadding { Top = 100 + MuteButton.HEIGHT } //to counter the mute button and re-center the volume meters }, - volumeMeterMaster = new VolumeMeter("MASTER", 150, colours.Pink), - volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.Blue), + volumeMeterMaster = new VolumeMeter("MASTER", 150, colours.PinkDarker), + volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.BlueDarker), muteButton = new MuteButton { Margin = new MarginPadding { Top = 100 } From 9293ec635a44b4ca679fcea02048b5315f9ee8f5 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 19:49:38 +0100 Subject: [PATCH 05/24] add license headers and remove blank line --- osu.Game.Tests/Visual/TestCaseVolumePieces.cs | 5 ++++- osu.Game/Overlays/Volume/MuteButton.cs | 5 ++++- osu.Game/Overlays/Volume/VolumeMeter.cs | 6 ++++-- osu.Game/Overlays/VolumeOverlay.cs | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs index 5a43574a9d..1894470df9 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Audio; diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs index 82e61c8f0b..f056bf62ba 100644 --- a/osu.Game/Overlays/Volume/MuteButton.cs +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 525b4e315a..984ade9de0 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using System.Globalization; using JetBrains.Annotations; using osu.Framework.Allocation; @@ -66,7 +69,6 @@ namespace osu.Game.Overlays.Volume } }); - OsuSpriteText text; CircularProgress bgProgress; BufferedContainer maxGlow; diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index cc57b468fb..27c699e365 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; From 1cda58fe29b16dfb624fc2895bc0cc2772032f16 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 19:51:11 +0100 Subject: [PATCH 06/24] another blank line --- osu.Game/Overlays/Volume/MuteButton.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs index f056bf62ba..adfc9c610f 100644 --- a/osu.Game/Overlays/Volume/MuteButton.cs +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -38,7 +38,6 @@ namespace osu.Game.Overlays.Volume hoveredColour = colours.YellowDark; BorderColour = unhoveredColour = colours.Gray1.Opacity(0.9f); - SpriteIcon icon; AddRange(new Drawable[] { From ba80cd5f34823a8048928ea4d5eedd2caa4573c9 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 20:01:39 +0100 Subject: [PATCH 07/24] OsuColour can't be used in TestCases..? --- osu.Game.Tests/Visual/TestCaseVolumePieces.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs index 1894470df9..5c97c3e368 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -7,8 +7,8 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; using osu.Framework.Testing; -using osu.Game.Graphics; using osu.Game.Overlays.Volume; +using OpenTK.Graphics; namespace osu.Game.Tests.Visual { @@ -17,10 +17,10 @@ namespace osu.Game.Tests.Visual public override IReadOnlyList RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) }; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + private void load(AudioManager audio) { VolumeMeter meter; - Add(meter = new VolumeMeter("MASTER", 125, colours.PinkDarker)); + Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue)); Add(new MuteButton { Margin = new MarginPadding { Top = 200 } From 033d06652095019b39c4c84b85b2183255e07129 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 20:03:24 +0100 Subject: [PATCH 08/24] blank line --- osu.Game.Tests/Visual/TestCaseVolumePieces.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs index 5c97c3e368..db868c00d7 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -27,7 +27,6 @@ namespace osu.Game.Tests.Visual }); meter.Bindable.BindTo(audio.Volume); - } } } From bafcab1349266a40e8c4c36a2aaddebc05bb0e36 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 20:20:07 +0100 Subject: [PATCH 09/24] redo the test case --- osu.Game.Tests/Visual/TestCaseVolumePieces.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs index db868c00d7..7bfdca82c3 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; -using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Game.Overlays.Volume; @@ -16,17 +14,18 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) }; - [BackgroundDependencyLoader] - private void load(AudioManager audio) + protected override void LoadComplete() { VolumeMeter meter; + MuteButton mute; Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue)); - Add(new MuteButton + Add(mute = new MuteButton { Margin = new MarginPadding { Top = 200 } }); - meter.Bindable.BindTo(audio.Volume); + AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1); + AddToggleStep("mute", b => mute.Current.Value = b); } } } From ec013dbee860fdd170889f81103adfdbd0c00241 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 3 Mar 2018 21:55:19 +0100 Subject: [PATCH 10/24] remove blank line and try to get test case working --- osu.Game.Tests/Visual/TestCaseVolumePieces.cs | 6 +++--- osu.Game/Overlays/VolumeOverlay.cs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs index 7bfdca82c3..5bacdf1f58 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -18,11 +18,11 @@ namespace osu.Game.Tests.Visual { VolumeMeter meter; MuteButton mute; - Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue)); - Add(mute = new MuteButton + LoadComponentAsync(meter = new VolumeMeter("MASTER", 125, Color4.Blue), Add); + LoadComponentAsync(mute = new MuteButton { Margin = new MarginPadding { Top = 200 } - }); + }, Add); AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1); AddToggleStep("mute", b => mute.Current.Value = b); diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index 27c699e365..f764a83c7a 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -75,7 +75,6 @@ namespace osu.Game.Overlays }, }); - volumeMeterMaster.Bindable.BindTo(audio.Volume); volumeMeterEffect.Bindable.BindTo(audio.VolumeSample); volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack); From 0a571278c975c3f496b928afed9f576d88c52769 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 4 Mar 2018 14:03:53 +0100 Subject: [PATCH 11/24] change TestCase to OsuTestCase --- osu.Game.Tests/Visual/TestCaseVolumePieces.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs index 5bacdf1f58..cfbf7fdb4d 100644 --- a/osu.Game.Tests/Visual/TestCaseVolumePieces.cs +++ b/osu.Game.Tests/Visual/TestCaseVolumePieces.cs @@ -4,13 +4,12 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; -using osu.Framework.Testing; using osu.Game.Overlays.Volume; using OpenTK.Graphics; namespace osu.Game.Tests.Visual { - public class TestCaseVolumePieces : TestCase + public class TestCaseVolumePieces : OsuTestCase { public override IReadOnlyList RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) }; @@ -18,11 +17,11 @@ namespace osu.Game.Tests.Visual { VolumeMeter meter; MuteButton mute; - LoadComponentAsync(meter = new VolumeMeter("MASTER", 125, Color4.Blue), Add); - LoadComponentAsync(mute = new MuteButton + Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue)); + Add(mute = new MuteButton { Margin = new MarginPadding { Top = 200 } - }, Add); + }); AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1); AddToggleStep("mute", b => mute.Current.Value = b); From 90828cca8fcf5b692564eafa5b43203165567bdb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Mar 2018 08:59:02 +0900 Subject: [PATCH 12/24] Fix left and right arrows keys in chat overlay not working Misplaced override. Resolves ppy/osu-framework#1444 --- osu.Game/Graphics/UserInterface/FocusedTextBox.cs | 2 -- osu.Game/Graphics/UserInterface/SearchTextBox.cs | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs index 43a3f06236..6d9bf231c3 100644 --- a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs +++ b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs @@ -18,8 +18,6 @@ namespace osu.Game.Graphics.UserInterface public Action Exit; - public override bool HandleLeftRightArrows => false; - private bool focus; public bool HoldFocus { diff --git a/osu.Game/Graphics/UserInterface/SearchTextBox.cs b/osu.Game/Graphics/UserInterface/SearchTextBox.cs index 9398eb55f3..28d33bbacd 100644 --- a/osu.Game/Graphics/UserInterface/SearchTextBox.cs +++ b/osu.Game/Graphics/UserInterface/SearchTextBox.cs @@ -12,6 +12,8 @@ namespace osu.Game.Graphics.UserInterface { protected virtual bool AllowCommit => false; + public override bool HandleLeftRightArrows => false; + public SearchTextBox() { Height = 35; From 148551afa2874088f34319a20c0ed967d377a526 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 6 Mar 2018 14:12:37 +0900 Subject: [PATCH 13/24] osu!-side changes in-line with framework layout changes --- osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs | 2 +- osu.Game/Screens/Menu/FlowContainerWithOrigin.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs index 9f028490ef..5e92eead46 100644 --- a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs +++ b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs @@ -12,6 +12,6 @@ namespace osu.Game.Graphics.Containers { protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y); - protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); + public override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); } } diff --git a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs index 29ae35fca4..e61c309931 100644 --- a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs +++ b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y); - protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); + public override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); public override Anchor Origin => Anchor.Custom; From 27e0ed4ea8fb6299ddc8b8c54949fbd9bbf6dccc Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 6 Mar 2018 14:16:17 +0900 Subject: [PATCH 14/24] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 71900dc350..adf1e9548d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 71900dc350bcebbb60d912d4023a1d2a6bbbc3c1 +Subproject commit adf1e9548d1fff8717c87eedb358a3c2517358a8 From 78d73d4c11c40772221a75a9dd859a5e92aec1b9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 6 Mar 2018 17:20:58 +0900 Subject: [PATCH 15/24] Additional fixes for flow ordering after framework changes --- .../ReverseChildIDFillFlowContainer.cs | 4 --- .../Graphics/UserInterface/OsuTabControl.cs | 14 +++++++++ osu.Game/Overlays/Chat/ChatTabControl.cs | 4 +-- osu.Game/Overlays/Music/PlaylistList.cs | 20 +++++-------- osu.Game/Overlays/NotificationOverlay.cs | 5 ++-- .../Notifications/NotificationSection.cs | 7 +++-- .../Sections/Ranks/DrawableProfileScore.cs | 10 ++++--- osu.Game/Overlays/Settings/SettingsItem.cs | 3 +- .../Screens/Menu/FlowContainerWithOrigin.cs | 4 --- osu.Game/Screens/Select/Footer.cs | 30 +++++++++++-------- .../Select/Options/BeatmapOptionsOverlay.cs | 7 +++-- 11 files changed, 63 insertions(+), 45 deletions(-) diff --git a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs index 5e92eead46..5803c8a5db 100644 --- a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs +++ b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; -using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -11,7 +9,5 @@ namespace osu.Game.Graphics.Containers public class ReverseChildIDFillFlowContainer : FillFlowContainer where T : Drawable { protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y); - - public override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 7ad9bc73a8..20385a7dae 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -9,6 +9,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -56,6 +57,14 @@ namespace osu.Game.Graphics.UserInterface } } + protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer + { + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.Both, + Depth = -1, + Masking = true + }; + public class OsuTabItem : TabItem, IHasAccentColour { protected readonly SpriteText Text; @@ -239,5 +248,10 @@ namespace osu.Game.Graphics.UserInterface } } } + + private class OsuTabFillFlowContainer : TabFillFlowContainer + { + protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y); + } } } diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index f028590bb4..1d3dab249d 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -53,9 +53,9 @@ namespace osu.Game.Overlays.Chat protected override void AddTabItem(TabItem item, bool addToDropdown = true) { - if (selectorTab.Depth < float.MaxValue) + if (item != selectorTab && TabContainer.GetLayoutPosition(selectorTab) < float.MaxValue) // performTabSort might've made selectorTab's position wonky, fix it - TabContainer.ChangeChildDepth(selectorTab, float.MaxValue); + TabContainer.SetLayoutPosition(selectorTab, float.MaxValue); base.AddTabItem(item, addToDropdown); diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 31b7d0f9aa..03ce7fd88f 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -101,11 +101,10 @@ namespace osu.Game.Overlays.Music public void AddBeatmapSet(BeatmapSetInfo beatmapSet) { - items.Add(new PlaylistItem(beatmapSet) - { - OnSelect = set => OnSelect?.Invoke(set), - Depth = items.Count - }); + var newItem = new PlaylistItem(beatmapSet) { OnSelect = set => OnSelect?.Invoke(set) }; + + items.Add(newItem); + items.SetLayoutPosition(newItem, items.Count); } public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) @@ -197,7 +196,7 @@ namespace osu.Game.Overlays.Music { var itemsPos = items.ToLocalSpace(nativeDragPosition); - int srcIndex = (int)draggedItem.Depth; + int srcIndex = (int)items.GetLayoutPosition(draggedItem); // Find the last item with position < mouse position. Note we can't directly use // the item positions as they are being transformed @@ -219,15 +218,15 @@ namespace osu.Game.Overlays.Music if (srcIndex < dstIndex) { for (int i = srcIndex + 1; i <= dstIndex; i++) - items.ChangeChildDepth(items[i], i - 1); + items.SetLayoutPosition(items[i], i - 1); } else { for (int i = dstIndex; i < srcIndex; i++) - items.ChangeChildDepth(items[i], i + 1); + items.SetLayoutPosition(items[i], i + 1); } - items.ChangeChildDepth(draggedItem, dstIndex); + items.SetLayoutPosition(draggedItem, dstIndex); } private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren @@ -243,9 +242,6 @@ namespace osu.Game.Overlays.Music } } - // Compare with reversed ChildID and Depth - protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x); - public IEnumerable FilterableChildren => Children; public ItemSearchContainer() diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 2f46bb4a71..48ad507d88 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -129,7 +129,6 @@ namespace osu.Game.Overlays public void Post(Notification notification) => postScheduler.Add(() => { ++runningDepth; - notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth; notification.Closed += notificationClosed; @@ -138,7 +137,9 @@ namespace osu.Game.Overlays hasCompletionTarget.CompletionTarget = Post; var ourType = notification.GetType(); - sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification); + + var section = sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType))); + section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth); updateCounts(); }); diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index 13a69fbe3a..533f5326e3 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -25,10 +25,13 @@ namespace osu.Game.Overlays.Notifications private FlowContainer notifications; public int DisplayedCount => notifications.Count(n => !n.WasClosed); - public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read); - public void Add(Notification notification) => notifications.Add(notification); + public void Add(Notification notification, float position) + { + notifications.Add(notification); + notifications.SetLayoutPosition(notification, position); + } public IEnumerable AcceptTypes; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 51b202844a..bb1a409f2e 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -40,16 +40,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [BackgroundDependencyLoader(true)] private void load(OsuColour colour) { - RightFlowContainer.Add(new OsuSpriteText + var text = new OsuSpriteText { Text = $"accuracy: {Score.Accuracy:P2}", Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Colour = colour.GrayA, TextSize = 11, - Font = "Exo2.0-RegularItalic", - Depth = -1, - }); + Font = "Exo2.0-RegularItalic" + }; + + RightFlowContainer.Add(text); + RightFlowContainer.SetLayoutPosition(text, 1); LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap)); LeftFlowContainer.Add(new OsuSpriteText diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index 5afc415d83..cc290fe1bb 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -45,7 +45,8 @@ namespace osu.Game.Overlays.Settings if (text == null) { // construct lazily for cases where the label is not needed (may be provided by the Control). - Add(text = new OsuSpriteText { Depth = 1 }); + Add(text = new OsuSpriteText()); + FlowContent.SetLayoutPosition(text, -1); } text.Text = value; diff --git a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs index e61c309931..ae1e995373 100644 --- a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs +++ b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs @@ -4,8 +4,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Screens.Menu { @@ -22,8 +20,6 @@ namespace osu.Game.Screens.Menu protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y); - public override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); - public override Anchor Origin => Anchor.Custom; public override Vector2 OriginPosition diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 21e6108489..be83d7b500 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -41,19 +41,25 @@ namespace osu.Game.Screens.Select /// Higher depth to be put on the left, and lower to be put on the right. /// Notice this is different to ! /// - public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton + public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { - Text = text, - Height = play_song_select_button_height, - Width = play_song_select_button_width, - Depth = depth, - SelectedColour = colour, - DeselectedColour = colour.Opacity(0.5f), - Hotkey = hotkey, - Hovered = updateModeLight, - HoverLost = updateModeLight, - Action = action, - }); + var button = new FooterButton + { + Text = text, + Height = play_song_select_button_height, + Width = play_song_select_button_width, + Depth = depth, + SelectedColour = colour, + DeselectedColour = colour.Opacity(0.5f), + Hotkey = hotkey, + Hovered = updateModeLight, + HoverLost = updateModeLight, + Action = action, + }; + + buttons.Add(button); + buttons.SetLayoutPosition(button, -depth); + } private readonly List overlays = new List(); diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index 2e8b2f9014..dee1ec4511 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -95,7 +95,7 @@ namespace osu.Game.Screens.Select.Options /// public void AddButton(string firstLine, string secondLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { - buttonsContainer.Add(new BeatmapOptionsButton + var button = new BeatmapOptionsButton { FirstLineText = firstLine, SecondLineText = secondLine, @@ -108,7 +108,10 @@ namespace osu.Game.Screens.Select.Options action?.Invoke(); }, HotKey = hotkey - }); + }; + + buttonsContainer.Add(button); + buttonsContainer.SetLayoutPosition(button, depth); } } } From e82cadc811de0413e6b566b2a6b8762c26f5ab55 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Mar 2018 17:29:58 +0900 Subject: [PATCH 16/24] Make LegacyID nullable The -1 default was getting stored to the database. --- osu.Game.Rulesets.Catch/CatchRuleset.cs | 2 +- osu.Game.Rulesets.Mania/ManiaRuleset.cs | 2 +- osu.Game.Rulesets.Osu/OsuRuleset.cs | 2 +- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 +- osu.Game/Rulesets/Ruleset.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index d49e9c7c26..4dbe65b3ce 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Catch public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new CatchDifficultyCalculator(beatmap); - public override int LegacyID => 2; + public override int? LegacyID => 2; public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame(); diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 3ad498e6ea..16b6888f2b 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.Mania public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new ManiaDifficultyCalculator(beatmap); - public override int LegacyID => 3; + public override int? LegacyID => 3; public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame(); diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 3f0aea5cb2..d407835a96 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -145,7 +145,7 @@ namespace osu.Game.Rulesets.Osu public override SettingsSubsection CreateSettings() => new OsuSettings(); - public override int LegacyID => 0; + public override int? LegacyID => 0; public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame(); diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 713506e831..0a9719f27b 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Taiko public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new TaikoDifficultyCalculator(beatmap); - public override int LegacyID => 1; + public override int? LegacyID => 1; public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame(); diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index f9b64995f9..cba849a491 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -64,7 +64,7 @@ namespace osu.Game.Rulesets /// /// Do not override this unless you are a legacy mode. /// - public virtual int LegacyID => -1; + public virtual int? LegacyID => null; /// /// A unique short name to reference this ruleset in online requests. From 08c469a8b3494446ea5d4d9e7294164a86cfc9f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 13:22:08 +0900 Subject: [PATCH 17/24] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index adf1e9548d..6372fb22c1 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit adf1e9548d1fff8717c87eedb358a3c2517358a8 +Subproject commit 6372fb22c1c85f600921a139849b8dedf71026d5 From e2f9e237e8dc8e73174f62cf7fc35744041c86e6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:07:04 +0900 Subject: [PATCH 18/24] Use GradientHorizontal helper function --- osu.Game/Overlays/VolumeOverlay.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index f764a83c7a..17a4b139b0 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -43,13 +43,7 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Y, Width = 300, - Colour = new ColourInfo - { - TopLeft = Color4.Black.Opacity(0.75f), - BottomLeft = Color4.Black.Opacity(0.75f), - TopRight = Color4.Black.Opacity(0), - BottomRight = Color4.Black.Opacity(0), - } + Colour = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.75f), Color4.Black.Opacity(0)) }, new FillFlowContainer { From fac4cd6a32b63463163c6a91bd5490bf6149c525 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:19:31 +0900 Subject: [PATCH 19/24] Move to overlayContent --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a6f650d23d..e2bc240e8c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -232,7 +232,7 @@ namespace osu.Game }, }, overlayContent.Add); - loadComponentSingleFile(volume = new VolumeOverlay(), Add); + loadComponentSingleFile(volume = new VolumeOverlay(), overlayContent.Add); loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add); //overlay elements From 51a9dd038ee5c09b429706e71710c85bfb0e3b71 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:38:41 +0900 Subject: [PATCH 20/24] Add default bindable values --- osu.Game/Overlays/Volume/VolumeMeter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 984ade9de0..c840eb790d 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.Volume public class VolumeMeter : Container, IKeyBindingHandler { private CircularProgress volumeCircle; - public BindableDouble Bindable { get; } = new BindableDouble(); + public BindableDouble Bindable { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 }; private readonly float circleSize; private readonly Color4 meterColour; private readonly string name; From 05a13d4d393e10cdd87e06ebb9ef7c89cf8b7de8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:50:50 +0900 Subject: [PATCH 21/24] Improve the way bindings are done --- osu.Game/Overlays/Volume/VolumeMeter.cs | 46 +++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index c840eb790d..99ac4d3a79 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -3,7 +3,6 @@ using System; using System.Globalization; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; @@ -14,7 +13,6 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Bindings; -using osu.Framework.MathUtils; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Input.Bindings; @@ -31,6 +29,9 @@ namespace osu.Game.Overlays.Volume private readonly Color4 meterColour; private readonly string name; + private OsuSpriteText text; + private BufferedContainer maxGlow; + public VolumeMeter(string name, float circleSize, Color4 meterColour) { this.circleSize = circleSize; @@ -69,9 +70,7 @@ namespace osu.Game.Overlays.Volume } }); - OsuSpriteText text; CircularProgress bgProgress; - BufferedContainer maxGlow; Add(new CircularContainer { @@ -122,33 +121,36 @@ namespace osu.Game.Overlays.Volume } }); - Bindable.ValueChanged += newVolume => this.TransformTo("circleBindable", newVolume * 0.75, 250, Easing.OutQuint); - volumeCircle.Current.ValueChanged += newVolume => //by using this event we sync the meter with the text. newValue has to be divided by 0.75 to give the actual percentage + Bindable.ValueChanged += newVolume => { this.TransformTo("DisplayVolume", newVolume, 400, Easing.OutQuint); }; + + bgProgress.Current.Value = 0.75f; + } + + private double displayVolume; + + /// + /// This is needed because doesn't support + /// + protected double DisplayVolume + { + get => displayVolume; + set { - if (Precision.DefinitelyBigger(newVolume, 0.74)) + displayVolume = value; + + if (displayVolume > 0.99f) { text.Text = "MAX"; maxGlow.EffectColour = meterColour.Opacity(2f); } else { - if (text.Text == "MAX") - maxGlow.EffectColour = Color4.Transparent; - text.Text = Math.Round(newVolume / 0.0075).ToString(CultureInfo.CurrentCulture); + maxGlow.EffectColour = Color4.Transparent; + text.Text = Math.Round(displayVolume * 100).ToString(CultureInfo.CurrentCulture); } - }; - bgProgress.Current.Value = 0.75f; - } - - /// - /// This is needed because doesn't support - /// - [UsedImplicitly] - private double circleBindable - { - get => volumeCircle.Current; - set => volumeCircle.Current.Value = value; + volumeCircle.Current.Value = displayVolume * 0.75f; + } } public double Volume From 96ea42d3ba8353c2b812108ce610e2322fe5298a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:51:34 +0900 Subject: [PATCH 22/24] Ensure initial value is set even if that value is zero --- osu.Game/Overlays/Volume/VolumeMeter.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 99ac4d3a79..b9bd39163a 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -122,10 +122,15 @@ namespace osu.Game.Overlays.Volume }); Bindable.ValueChanged += newVolume => { this.TransformTo("DisplayVolume", newVolume, 400, Easing.OutQuint); }; - bgProgress.Current.Value = 0.75f; } + protected override void LoadComplete() + { + base.LoadComplete(); + Bindable.TriggerChange(); + } + private double displayVolume; /// From 4094ffbddd141ced057da4a9283931ac37ecf271 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:54:15 +0900 Subject: [PATCH 23/24] Remove unnecessary comment --- osu.Game/Overlays/Volume/VolumeMeter.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index b9bd39163a..056ba6aa8d 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -133,9 +133,6 @@ namespace osu.Game.Overlays.Volume private double displayVolume; - /// - /// This is needed because doesn't support - /// protected double DisplayVolume { get => displayVolume; From a71e5ce19c1f42eb2d0dc18e40d925644dad63d8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 7 Mar 2018 14:54:54 +0900 Subject: [PATCH 24/24] Tidy up --- osu.Game/Overlays/Volume/VolumeMeter.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 056ba6aa8d..64b9e513c4 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Bindings; using osu.Game.Graphics; @@ -161,15 +160,9 @@ namespace osu.Game.Overlays.Volume private set => Bindable.Value = value; } - public void Increase() - { - Volume += 0.05f; - } + public void Increase() => Volume += 0.05f; - public void Decrease() - { - Volume -= 0.05f; - } + public void Decrease() => Volume -= 0.05f; public bool OnPressed(GlobalAction action) {