2019-06-30 00:28:40 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-06-30 20:58:30 +08:00
|
|
|
using osu.Game.Audio;
|
2020-04-19 17:23:41 +08:00
|
|
|
using osu.Game.Configuration;
|
2019-06-30 00:28:40 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
|
|
|
public class ComboEffects : CompositeDrawable
|
|
|
|
{
|
2019-06-30 20:58:30 +08:00
|
|
|
private readonly ScoreProcessor processor;
|
|
|
|
|
|
|
|
private SkinnableSound comboBreakSample;
|
2019-06-30 00:28:40 +08:00
|
|
|
|
2020-04-19 17:23:41 +08:00
|
|
|
private Bindable<bool> alwaysPlay;
|
|
|
|
private bool firstTime = true;
|
|
|
|
|
2019-06-30 00:28:40 +08:00
|
|
|
public ComboEffects(ScoreProcessor processor)
|
|
|
|
{
|
2019-06-30 20:58:30 +08:00
|
|
|
this.processor = processor;
|
2019-06-30 00:28:40 +08:00
|
|
|
}
|
|
|
|
|
2019-06-30 20:58:30 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-04-19 17:23:41 +08:00
|
|
|
private void load(OsuConfigManager config)
|
2019-06-30 00:28:40 +08:00
|
|
|
{
|
2019-06-30 20:58:30 +08:00
|
|
|
InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("combobreak"));
|
2020-07-14 19:11:54 +08:00
|
|
|
alwaysPlay = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak);
|
2019-06-30 00:28:40 +08:00
|
|
|
}
|
|
|
|
|
2019-06-30 20:58:30 +08:00
|
|
|
protected override void LoadComplete()
|
2019-06-30 00:28:40 +08:00
|
|
|
{
|
2019-06-30 20:58:30 +08:00
|
|
|
base.LoadComplete();
|
2020-04-19 17:23:41 +08:00
|
|
|
processor.Combo.BindValueChanged(onComboChange);
|
2019-06-30 20:58:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onComboChange(ValueChangedEvent<int> combo)
|
|
|
|
{
|
2020-07-14 19:15:29 +08:00
|
|
|
if (combo.NewValue == 0 && (combo.OldValue > 20 || (alwaysPlay.Value && firstTime)))
|
2020-04-19 17:23:41 +08:00
|
|
|
{
|
2019-06-30 20:58:30 +08:00
|
|
|
comboBreakSample?.Play();
|
2020-04-19 17:23:41 +08:00
|
|
|
firstTime = false;
|
|
|
|
}
|
2019-06-30 00:28:40 +08:00
|
|
|
}
|
|
|
|
}
|
2019-06-30 20:58:30 +08:00
|
|
|
}
|