From 78b22d89db1c8583cffa95f95c2021dec34e17b2 Mon Sep 17 00:00:00 2001 From: Derrick Timmermans Date: Thu, 22 Feb 2024 16:29:46 +0100 Subject: [PATCH] Fix receptor input causing a crash --- .../Mods/SentakkiModRelax.cs | 1 + .../Objects/Drawables/DrawableHold.cs | 6 +++-- .../SentakkiInputManager.cs | 25 ------------------- osu.Game.Rulesets.Sentakki/UI/Lane.cs | 10 ++++++-- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/osu.Game.Rulesets.Sentakki/Mods/SentakkiModRelax.cs b/osu.Game.Rulesets.Sentakki/Mods/SentakkiModRelax.cs index 9e4e73b5e..0ade0b6e1 100644 --- a/osu.Game.Rulesets.Sentakki/Mods/SentakkiModRelax.cs +++ b/osu.Game.Rulesets.Sentakki/Mods/SentakkiModRelax.cs @@ -16,6 +16,7 @@ public class SentakkiModRelax : Mod, IApplicableAfterBeatmapConversion public override string Name => "Relax"; public override string Acronym => "RX"; + public override ModType Type => ModType.DifficultyReduction; public override LocalisableString Description => "All notes are EX notes, you've got nothing to prove!"; diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs index 63184d050..603d251fa 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs @@ -250,8 +250,10 @@ public void OnReleased(KeyBindingReleaseEvent e) return; // We only release the hold once ALL inputs are released - if (--pressedCount == 0) - endHold(); + if (--pressedCount != 0) + return; + + endHold(); if (!AllJudged) NoteBody.FadeColour(Color4.Gray, 100); diff --git a/osu.Game.Rulesets.Sentakki/SentakkiInputManager.cs b/osu.Game.Rulesets.Sentakki/SentakkiInputManager.cs index 46f0a94ac..8d22ca8aa 100644 --- a/osu.Game.Rulesets.Sentakki/SentakkiInputManager.cs +++ b/osu.Game.Rulesets.Sentakki/SentakkiInputManager.cs @@ -1,9 +1,5 @@ -using System.Collections.Generic; -using osu.Framework.Extensions.ListExtensions; -using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Framework.Input.States; using osu.Framework.Lists; using osu.Framework.Localisation; using osu.Game.Rulesets.Sentakki.Localisation; @@ -38,27 +34,6 @@ protected override bool Handle(UIEvent e) return base.Handle(e); } - - // We want the press behavior of SimultaneousBindingMode.All, but we want the release behavior of SimultaneousBindingMode.Unique - // As long as there are more than one input source triggering the action, we manually remove the action from the list once, without propogating the release - // When the final source is released, we let the original handling take over, which would also propogate the release event - // This is so that multiple sources (virtual input/key) can trigger a press, but not release until the last key is released - protected override void PropagateReleased(IEnumerable drawables, InputState state, SentakkiAction released) - { - int actionCount = 0; - var pressed = PressedActions; - - for (int i = 0; i < pressed.Count; ++i) - { - if (pressed[i] == released && ++actionCount > 1) - break; - } - - if (actionCount > 1) - pressed.Remove(released); - else - base.PropagateReleased(drawables, state, released); - } } public SlimReadOnlyListWrapper PressedActions => KeyBindingContainer.PressedActions; diff --git a/osu.Game.Rulesets.Sentakki/UI/Lane.cs b/osu.Game.Rulesets.Sentakki/UI/Lane.cs index c24dae8c8..c69672446 100644 --- a/osu.Game.Rulesets.Sentakki/UI/Lane.cs +++ b/osu.Game.Rulesets.Sentakki/UI/Lane.cs @@ -131,10 +131,16 @@ private void updateInputState() private void handleKeyPress(ValueChangedEvent keys) { if (keys.NewValue < keys.OldValue) - SentakkiActionInputManager.TriggerReleased(SentakkiAction.Key1 + LaneNumber); + for (int i = 0; i < keys.OldValue - keys.NewValue; ++i) + { + SentakkiActionInputManager.TriggerReleased(SentakkiAction.Key1 + LaneNumber); + } if (keys.NewValue > keys.OldValue) - SentakkiActionInputManager.TriggerPressed(SentakkiAction.Key1 + LaneNumber); + for (int i = 0; i < keys.NewValue - keys.OldValue; ++i) + { + SentakkiActionInputManager.TriggerPressed(SentakkiAction.Key1 + LaneNumber); + } } public bool OnPressed(KeyBindingPressEvent e)