1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

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 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,
}

View File

@ -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<bool>(OsuSetting.MouseDisableWheel);
showStoryboard = config.GetBindable<bool>(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<int> combo)
{
if (combo.NewValue == 0 && combo.OldValue > 20)
sampleComboBreak?.Play();
}
private void onCompletion()
{
// Only show the completion screen if the player hasn't failed

View File

@ -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<bool> beatmapHitsounds = new Bindable<bool>();
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<AudioManager>();
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<int> combo)
{
if (combo.NewValue == 0 && combo.OldValue > 20)
SampleComboBreak?.Play();
}
}
}
}