mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Add the ability to duck volume when the game is inactive
This commit is contained in:
@ -19,6 +19,7 @@ using OpenTK;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
@ -121,6 +122,8 @@ namespace osu.Game
|
||||
configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset);
|
||||
Ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
|
||||
Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
|
||||
|
||||
LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust);
|
||||
}
|
||||
|
||||
private ScheduledDelegate scoreLoad;
|
||||
@ -398,6 +401,21 @@ namespace osu.Game
|
||||
return false;
|
||||
}
|
||||
|
||||
private readonly BindableDouble inactiveVolumeAdjust = new BindableDouble();
|
||||
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
base.OnDeactivated();
|
||||
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust);
|
||||
}
|
||||
|
||||
protected override void OnActivated()
|
||||
{
|
||||
base.OnActivated();
|
||||
Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust);
|
||||
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
|
||||
private Container mainContent;
|
||||
|
Reference in New Issue
Block a user