Move to LocalSkinOverride

This commit is contained in:
Welsar55 2019-06-28 20:45:11 -05:00
parent 826699a7e7
commit a57218e50e
3 changed files with 29 additions and 13 deletions

View File

@ -4,6 +4,7 @@
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -28,7 +29,7 @@ namespace osu.Game.Tests.Visual.Gameplay
Child = new SkinSourceContainer Child = new SkinSourceContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = new LocalSkinOverrideContainer(secondarySource) Child = new LocalSkinOverrideContainer(secondarySource, new BindableInt())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true) 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 Child = new SkinSourceContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = target = new LocalSkinOverrideContainer(secondarySource) Child = target = new LocalSkinOverrideContainer(secondarySource, new BindableInt())
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
} }

View File

@ -66,7 +66,6 @@ namespace osu.Game.Screens.Play
private IAPIProvider api; private IAPIProvider api;
private SampleChannel sampleRestart; private SampleChannel sampleRestart;
private SampleChannel sampleComboBreak;
protected ScoreProcessor ScoreProcessor { get; private set; } protected ScoreProcessor ScoreProcessor { get; private set; }
protected DrawableRuleset DrawableRuleset { get; private set; } protected DrawableRuleset DrawableRuleset { get; private set; }
@ -108,14 +107,12 @@ namespace osu.Game.Screens.Play
return; return;
sampleRestart = audio.Samples.Get(@"Gameplay/restart"); sampleRestart = audio.Samples.Get(@"Gameplay/restart");
sampleComboBreak = audio.Samples.Get(@"Gameplay/combobreak");
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel); mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard); showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
ScoreProcessor = DrawableRuleset.CreateScoreProcessor(); ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
ScoreProcessor.Mods.BindTo(Mods); ScoreProcessor.Mods.BindTo(Mods);
ScoreProcessor.Combo.BindValueChanged(onComboChange);
if (!ScoreProcessor.Mode.Disabled) if (!ScoreProcessor.Mode.Disabled)
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode); config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
@ -127,7 +124,7 @@ namespace osu.Game.Screens.Play
StoryboardContainer = CreateStoryboardContainer(), StoryboardContainer = CreateStoryboardContainer(),
new ScalingContainer(ScalingMode.Gameplay) new ScalingContainer(ScalingMode.Gameplay)
{ {
Child = new LocalSkinOverrideContainer(working.Skin) Child = new LocalSkinOverrideContainer(working.Skin, ScoreProcessor.Combo)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = DrawableRuleset Child = DrawableRuleset
@ -267,12 +264,6 @@ namespace osu.Game.Screens.Play
private ScheduledDelegate onCompletionEvent; private ScheduledDelegate onCompletionEvent;
private void onComboChange(ValueChangedEvent<int> combo)
{
if (combo.NewValue == 0 && combo.OldValue > 20)
sampleComboBreak?.Play();
}
private void onCompletion() private void onCompletion()
{ {
// Only show the completion screen if the player hasn't failed // Only show the completion screen if the player hasn't failed

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -23,11 +24,15 @@ namespace osu.Game.Skinning
private readonly Bindable<bool> beatmapHitsounds = new Bindable<bool>(); private readonly Bindable<bool> beatmapHitsounds = new Bindable<bool>();
private readonly ISkin skin; private readonly ISkin skin;
private readonly ComboEffects comboEffects;
private ISkinSource fallbackSource; private ISkinSource fallbackSource;
public LocalSkinOverrideContainer(ISkin skin) public LocalSkinOverrideContainer(ISkin skin, BindableInt combo)
{ {
this.skin = skin; this.skin = skin;
comboEffects = new ComboEffects(combo);
} }
public Drawable GetDrawableComponent(string componentName) public Drawable GetDrawableComponent(string componentName)
@ -87,6 +92,9 @@ namespace osu.Game.Skinning
beatmapSkins.BindValueChanged(_ => onSourceChanged()); beatmapSkins.BindValueChanged(_ => onSourceChanged());
beatmapHitsounds.BindValueChanged(_ => onSourceChanged()); beatmapHitsounds.BindValueChanged(_ => onSourceChanged());
AudioManager audio = dependencies.Get<AudioManager>();
comboEffects.SampleComboBreak = GetSample(@"Gameplay/combobreak") ?? audio.Samples.Get(@"Gameplay/combobreak");
return dependencies; return dependencies;
} }
@ -100,5 +108,21 @@ namespace osu.Game.Skinning
if (fallbackSource != null) if (fallbackSource != null)
fallbackSource.SourceChanged -= onSourceChanged; fallbackSource.SourceChanged -= onSourceChanged;
} }
private class ComboEffects
{
public SampleChannel SampleComboBreak;
public ComboEffects(BindableInt combo)
{
combo.BindValueChanged(onComboChange);
}
private void onComboChange(ValueChangedEvent<int> combo)
{
if (combo.NewValue == 0 && combo.OldValue > 20)
SampleComboBreak?.Play();
}
}
} }
} }