Expose DrawableRuleset audio adjustments as non-container

This commit is contained in:
Dean Herbert 2021-07-31 15:05:54 +09:00
parent 29328bdf7f
commit 53c901bfa8
3 changed files with 15 additions and 5 deletions

View File

@ -22,5 +22,11 @@ namespace osu.Game.Extensions
/// <returns>An editor formatted display string.</returns> /// <returns>An editor formatted display string.</returns>
public static string ToEditorFormattedString(this TimeSpan timeSpan) => public static string ToEditorFormattedString(this TimeSpan timeSpan) =>
$"{(timeSpan < TimeSpan.Zero ? "-" : string.Empty)}{timeSpan:mm\\:ss\\:fff}"; $"{(timeSpan < TimeSpan.Zero ? "-" : string.Empty)}{timeSpan:mm\\:ss\\:fff}";
public static string ToFormattedDuration(this double milliseconds) =>
ToFormattedDuration(TimeSpan.FromMilliseconds(milliseconds));
public static string ToFormattedDuration(this TimeSpan timeSpan) =>
timeSpan.Hours == 0 ? $"{timeSpan:mm\\:ss}" : $"{timeSpan:HH\\:mm\\:ss}";
} }
} }

View File

@ -7,7 +7,6 @@ using osu.Framework.Audio;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -82,7 +81,7 @@ namespace osu.Game.Rulesets.Mods
} }
if (AffectsHitSounds.Value) if (AffectsHitSounds.Value)
drawableRuleset.AudioContainer.AddAdjustment(AdjustableProperty.Volume, mainVolumeAdjust); drawableRuleset.Audio.AddAdjustment(AdjustableProperty.Volume, mainVolumeAdjust);
} }
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor) public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -99,12 +100,12 @@ namespace osu.Game.Rulesets.UI
private DrawableRulesetDependencies dependencies; private DrawableRulesetDependencies dependencies;
/// <summary> /// <summary>
/// An audio container which can be used to apply adjustments to playfield content. /// Audio adjustments which are applied to the playfield.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Does not affect <see cref="Overlays"/>. /// Does not affect <see cref="Overlays"/>.
/// </remarks> /// </remarks>
public AudioContainer AudioContainer { get; private set; } public IAdjustableAudioComponent Audio { get; private set; }
/// <summary> /// <summary>
/// Creates a ruleset visualisation for the provided ruleset and beatmap. /// Creates a ruleset visualisation for the provided ruleset and beatmap.
@ -163,13 +164,15 @@ namespace osu.Game.Rulesets.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(CancellationToken? cancellationToken) private void load(CancellationToken? cancellationToken)
{ {
AudioContainer audioContainer;
InternalChild = frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime) InternalChild = frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime)
{ {
FrameStablePlayback = FrameStablePlayback, FrameStablePlayback = FrameStablePlayback,
Children = new Drawable[] Children = new Drawable[]
{ {
FrameStableComponents, FrameStableComponents,
AudioContainer = new AudioContainer audioContainer = new AudioContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = KeyBindingInputManager Child = KeyBindingInputManager
@ -181,6 +184,8 @@ namespace osu.Game.Rulesets.UI
} }
}; };
Audio = audioContainer;
if ((ResumeOverlay = CreateResumeOverlay()) != null) if ((ResumeOverlay = CreateResumeOverlay()) != null)
{ {
AddInternal(CreateInputManager() AddInternal(CreateInputManager()