From a57218e50ee3883d4fc938b87b7cbdf7f1998a2d Mon Sep 17 00:00:00 2001 From: Welsar55 Date: Fri, 28 Jun 2019 20:45:11 -0500 Subject: [PATCH] Move to LocalSkinOverride --- .../Gameplay/TestSceneSkinReloadable.cs | 5 ++-- osu.Game/Screens/Play/Player.cs | 11 +------- .../Skinning/LocalSkinOverrideContainer.cs | 26 ++++++++++++++++++- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs index c7a0df6e9f..f03ffea5dc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs @@ -4,6 +4,7 @@ using System; using NUnit.Framework; using osu.Framework.Audio.Sample; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -28,7 +29,7 @@ namespace osu.Game.Tests.Visual.Gameplay Child = new SkinSourceContainer { RelativeSizeAxes = Axes.Both, - Child = new LocalSkinOverrideContainer(secondarySource) + Child = new LocalSkinOverrideContainer(secondarySource, new BindableInt()) { RelativeSizeAxes = Axes.Both, Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true) @@ -53,7 +54,7 @@ namespace osu.Game.Tests.Visual.Gameplay Child = new SkinSourceContainer { RelativeSizeAxes = Axes.Both, - Child = target = new LocalSkinOverrideContainer(secondarySource) + Child = target = new LocalSkinOverrideContainer(secondarySource, new BindableInt()) { RelativeSizeAxes = Axes.Both, } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f620c790aa..55d43bb4c8 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -66,7 +66,6 @@ namespace osu.Game.Screens.Play private IAPIProvider api; private SampleChannel sampleRestart; - private SampleChannel sampleComboBreak; protected ScoreProcessor ScoreProcessor { get; private set; } protected DrawableRuleset DrawableRuleset { get; private set; } @@ -108,14 +107,12 @@ namespace osu.Game.Screens.Play return; sampleRestart = audio.Samples.Get(@"Gameplay/restart"); - sampleComboBreak = audio.Samples.Get(@"Gameplay/combobreak"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); ScoreProcessor = DrawableRuleset.CreateScoreProcessor(); ScoreProcessor.Mods.BindTo(Mods); - ScoreProcessor.Combo.BindValueChanged(onComboChange); if (!ScoreProcessor.Mode.Disabled) config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode); @@ -127,7 +124,7 @@ namespace osu.Game.Screens.Play StoryboardContainer = CreateStoryboardContainer(), new ScalingContainer(ScalingMode.Gameplay) { - Child = new LocalSkinOverrideContainer(working.Skin) + Child = new LocalSkinOverrideContainer(working.Skin, ScoreProcessor.Combo) { RelativeSizeAxes = Axes.Both, Child = DrawableRuleset @@ -267,12 +264,6 @@ namespace osu.Game.Screens.Play private ScheduledDelegate onCompletionEvent; - private void onComboChange(ValueChangedEvent combo) - { - if (combo.NewValue == 0 && combo.OldValue > 20) - sampleComboBreak?.Play(); - } - private void onCompletion() { // Only show the completion screen if the player hasn't failed diff --git a/osu.Game/Skinning/LocalSkinOverrideContainer.cs b/osu.Game/Skinning/LocalSkinOverrideContainer.cs index f1ed14595e..a3606ef00c 100644 --- a/osu.Game/Skinning/LocalSkinOverrideContainer.cs +++ b/osu.Game/Skinning/LocalSkinOverrideContainer.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -23,11 +24,15 @@ namespace osu.Game.Skinning private readonly Bindable beatmapHitsounds = new Bindable(); private readonly ISkin skin; + + private readonly ComboEffects comboEffects; + private ISkinSource fallbackSource; - public LocalSkinOverrideContainer(ISkin skin) + public LocalSkinOverrideContainer(ISkin skin, BindableInt combo) { this.skin = skin; + comboEffects = new ComboEffects(combo); } public Drawable GetDrawableComponent(string componentName) @@ -87,6 +92,9 @@ namespace osu.Game.Skinning beatmapSkins.BindValueChanged(_ => onSourceChanged()); beatmapHitsounds.BindValueChanged(_ => onSourceChanged()); + AudioManager audio = dependencies.Get(); + comboEffects.SampleComboBreak = GetSample(@"Gameplay/combobreak") ?? audio.Samples.Get(@"Gameplay/combobreak"); + return dependencies; } @@ -100,5 +108,21 @@ namespace osu.Game.Skinning if (fallbackSource != null) fallbackSource.SourceChanged -= onSourceChanged; } + + private class ComboEffects + { + public SampleChannel SampleComboBreak; + + public ComboEffects(BindableInt combo) + { + combo.BindValueChanged(onComboChange); + } + + private void onComboChange(ValueChangedEvent combo) + { + if (combo.NewValue == 0 && combo.OldValue > 20) + SampleComboBreak?.Play(); + } + } } }