From d7d6feb00182330a55bb77b6032703546e27b892 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Mon, 17 Jun 2019 12:31:23 +0200 Subject: [PATCH 1/4] Fade volume in / out when game window becomes active / inactive --- osu.Game/OsuGame.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d5fbcdfee3..978d9cc20c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -181,7 +181,7 @@ private void load(FrameworkConfigManager frameworkConfig) configSkin.ValueChanged += skinId => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == skinId.NewValue) ?? SkinInfo.Default; configSkin.TriggerChange(); - LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust); + LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolume); IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true); } @@ -686,14 +686,22 @@ public bool OnPressed(GlobalAction action) return false; } - private readonly BindableDouble inactiveVolumeAdjust = new BindableDouble(); + private readonly BindableDouble inactiveVolume = new BindableDouble(); + + private readonly BindableDouble inactiveVolAdjust = new BindableDouble(); private void updateActiveState(bool isActive) { if (isActive) - Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); + { + this.TransformBindableTo(inactiveVolAdjust, 1, 750, Easing.In) + .Finally(_ => Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolAdjust)); //wait for the transition to finish to remove the inactive audio adjustement + } else - Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); + { + Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolAdjust); + this.TransformBindableTo(inactiveVolAdjust, inactiveVolume.Value, 750, Easing.Out); + } } public bool OnReleased(GlobalAction action) => false; From ad4c9babe791346402a193c0de2dd4f5d4c10b8e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jun 2019 23:24:52 +0900 Subject: [PATCH 2/4] Adjust naming and transitions --- osu.Game/OsuGame.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 978d9cc20c..7f9da9a645 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -181,7 +181,7 @@ private void load(FrameworkConfigManager frameworkConfig) configSkin.ValueChanged += skinId => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == skinId.NewValue) ?? SkinInfo.Default; configSkin.TriggerChange(); - LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolume); + LocalConfig.BindWith(OsuSetting.VolumeInactive, userInactiveVolume); IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true); } @@ -686,21 +686,21 @@ public bool OnPressed(GlobalAction action) return false; } - private readonly BindableDouble inactiveVolume = new BindableDouble(); + private readonly BindableDouble userInactiveVolume = new BindableDouble(); - private readonly BindableDouble inactiveVolAdjust = new BindableDouble(); + private readonly BindableDouble inactiveVolumeFade = new BindableDouble(); private void updateActiveState(bool isActive) { if (isActive) { - this.TransformBindableTo(inactiveVolAdjust, 1, 750, Easing.In) - .Finally(_ => Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolAdjust)); //wait for the transition to finish to remove the inactive audio adjustement + this.TransformBindableTo(inactiveVolumeFade, 1, 500, Easing.OutQuint) + .Finally(_ => Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeFade)); //wait for the transition to finish to remove the inactive audio adjustement } else { - Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolAdjust); - this.TransformBindableTo(inactiveVolAdjust, inactiveVolume.Value, 750, Easing.Out); + Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade); + this.TransformBindableTo(inactiveVolumeFade, userInactiveVolume.Value, 1500, Easing.OutSine); } } From 3a04684efb21ace6ff19d3d9226c04cfc6583f71 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jun 2019 23:25:16 +0900 Subject: [PATCH 3/4] Add region --- osu.Game/OsuGame.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7f9da9a645..aa891f6c87 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -686,6 +686,8 @@ public bool OnPressed(GlobalAction action) return false; } + #region Inactive audio dimming + private readonly BindableDouble userInactiveVolume = new BindableDouble(); private readonly BindableDouble inactiveVolumeFade = new BindableDouble(); @@ -704,6 +706,8 @@ private void updateActiveState(bool isActive) } } + #endregion + public bool OnReleased(GlobalAction action) => false; private Container overlayContent; From 04dc1c1744da9f4e7c1efe33da66192d6d6c8d51 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Mon, 17 Jun 2019 16:44:53 +0200 Subject: [PATCH 4/4] Fix typo in comment Co-Authored-By: Joseph Madamba --- 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 aa891f6c87..f38eecef81 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -697,7 +697,7 @@ private void updateActiveState(bool isActive) if (isActive) { this.TransformBindableTo(inactiveVolumeFade, 1, 500, Easing.OutQuint) - .Finally(_ => Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeFade)); //wait for the transition to finish to remove the inactive audio adjustement + .Finally(_ => Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeFade)); //wait for the transition to finish to remove the inactive audio adjustment } else {