Skip to content

Commit

Permalink
Merge pull request #128 from LumpBloom7/Pausable-Skinnable-Sample
Browse files Browse the repository at this point in the history
Use PausableSkinnableSample instead of SkinnableSample
  • Loading branch information
LumpBloom7 authored Oct 5, 2020
2 parents 5b229de + ac369e1 commit 1c12cdb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableSentakkiHitObject : DrawableHitObject<SentakkiHitObject>
{
private readonly Bindable<bool> userPositionalHitSounds = new Bindable<bool>(false);
private readonly SkinnableSound breakSound;

[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }
private readonly PausableSkinnableSound breakSound;

public bool IsHidden = false;
public bool IsFadeIn = false;
Expand Down Expand Up @@ -65,7 +61,7 @@ public DrawableSentakkiHitObject(SentakkiHitObject hitObject)
{
if (hitObject.IsBreak)
AddRangeInternal(new Drawable[]{
breakSound = new SkinnableSound(new SampleInfo("Break")),
breakSound = new PausableSkinnableSound(new SampleInfo("Break")),
});
AddInternal(scorePaddingObjects = new Container<DrawableScorePaddingObject>());
AdjustedAnimationDuration.BindValueChanged(_ => InvalidateTransforms());
Expand All @@ -78,10 +74,9 @@ public DrawableSentakkiHitObject(SentakkiHitObject hitObject)
private readonly Bindable<bool> breakEnabled = new Bindable<bool>(true);

[BackgroundDependencyLoader(true)]
private void load(DrawableSentakkiRuleset drawableRuleset, OsuConfigManager osuConfig, SentakkiRulesetConfigManager sentakkiConfig)
private void load(DrawableSentakkiRuleset drawableRuleset, SentakkiRulesetConfigManager sentakkiConfig)
{
drawableSentakkiRuleset = drawableRuleset;
osuConfig.BindWith(OsuSetting.PositionalHitSounds, userPositionalHitSounds);
sentakkiConfig?.BindWith(SentakkiRulesetSettings.BreakSounds, breakEnabled);
}

Expand Down Expand Up @@ -116,10 +111,9 @@ protected virtual void InvalidateTransforms()
public override void PlaySamples()
{
base.PlaySamples();
if (PlayBreakSample && breakSound != null && Result.Type == HitResult.Great && breakEnabled.Value && (!gameplayClock?.IsSeeking ?? false))
if (PlayBreakSample && breakSound != null && Result.Type == Result.Judgement.MaxResult && breakEnabled.Value)
{
const float balance_adjust_amount = 0.4f;
breakSound.Balance.Value = balance_adjust_amount * (userPositionalHitSounds.Value ? SamplePlaybackPosition - 0.5f : 0);
breakSound.Balance.Value = CalculateSamplePlaybackBalance(SamplePlaybackPosition);
breakSound.Play();
}
}
Expand Down
16 changes: 5 additions & 11 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableSlideNode : DrawableSentakkiTouchHitObject
{
[Resolved(canBeNull: true)]
private GameplayClock gameplayClock { get; set; }

private readonly Bindable<bool> userPositionalHitSounds = new Bindable<bool>(false);
private SkinnableSound slideSound;
private PausableSkinnableSound slideSound;

public override bool HandlePositionalInput => true;
public override bool DisplayResult => false;
Expand Down Expand Up @@ -65,7 +61,7 @@ protected override void LoadComplete()
protected override void LoadSamples()
{
base.LoadSamples();
AddInternal(slideSound = new SkinnableSound(new SampleInfo("slide")));
AddInternal(slideSound = new PausableSkinnableSound(new SampleInfo("slide")));
}

protected bool IsHittable => ThisIndex < 2 || Slide.SlideNodes[ThisIndex - 2].IsHit;
Expand All @@ -83,9 +79,8 @@ private void hitPreviousNodes(bool successful = false)

private readonly Bindable<bool> playSlideSample = new Bindable<bool>(true);
[BackgroundDependencyLoader(true)]
private void load(OsuConfigManager osuConfig, SentakkiRulesetConfigManager sentakkiConfig)
private void load(SentakkiRulesetConfigManager sentakkiConfig)
{
osuConfig.BindWith(OsuSetting.PositionalHitSounds, userPositionalHitSounds);
sentakkiConfig?.BindWith(SentakkiRulesetSettings.SlideSounds, playSlideSample);
}

Expand Down Expand Up @@ -123,10 +118,9 @@ protected override void Update()
public override void PlaySamples()
{
base.PlaySamples();
if (ThisIndex == 0 && playSlideSample.Value && slideSound != null && Result.Type != HitResult.Miss && (!gameplayClock?.IsSeeking ?? false))
if (ThisIndex == 0 && playSlideSample.Value && slideSound != null && Result.Type != Result.Judgement.MinResult)
{
const float balance_adjust_amount = 0.4f;
slideSound.Balance.Value = balance_adjust_amount * (userPositionalHitSounds.Value ? SamplePlaybackPosition - 0.5f : 0);
slideSound.Balance.Value = CalculateSamplePlaybackBalance(SamplePlaybackPosition);
slideSound.Play();
}
}
Expand Down

0 comments on commit 1c12cdb

Please sign in to comment.