From ff9288204eaec93d1534573626c618dc6bed9655 Mon Sep 17 00:00:00 2001 From: NoSloppy <53964195+NoSloppy@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:12:46 -0500 Subject: [PATCH] BC_buttons. no effects during preon (#599) * BC_buttons. No effects during preon. * period restore. * sequential spelling. * whitespace --- props/saber_BC_buttons.h | 191 +++++++++++++++++++++------------------ 1 file changed, 104 insertions(+), 87 deletions(-) diff --git a/props/saber_BC_buttons.h b/props/saber_BC_buttons.h index 594f412ce..14688882c 100644 --- a/props/saber_BC_buttons.h +++ b/props/saber_BC_buttons.h @@ -34,6 +34,8 @@ Download your choice of language and variation here: other features. No limits, no lag when "rapid firing". - Swap feature with sound - Just an additional EFFECT that can be used to trigger blade animations. See below. +- No inadvertant effects during preon. + --------------------------------------------------------------------------- Optional Blade style elements: On-Demand battery level - A layer built into the blade styles that reacts @@ -851,29 +853,32 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { case EVENTID(BUTTON_NONE, EVENT_THRUST, MODE_ON): //Don't stab if in colorchange mode if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; - SaberBase::SetClashStrength(2.0); - SaberBase::DoStab(); - return true; + if (SaberBase::IsOn()) { // prevents triggering during preon + SaberBase::SetClashStrength(2.0); + SaberBase::DoStab(); + } + return true; // Blaster Deflection - case EVENTID(BUTTON_POWER, EVENT_FIRST_SAVED_CLICK_SHORT, MODE_ON): - case EVENTID(BUTTON_POWER, EVENT_SECOND_SAVED_CLICK_SHORT, MODE_ON): - if (!spam_blast_) { - //Don't blast if in colorchange mode - if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; - SaberBase::DoBlast(); - last_blast_ = millis(); - } - return true; + case EVENTID(BUTTON_POWER, EVENT_FIRST_SAVED_CLICK_SHORT, MODE_ON): + case EVENTID(BUTTON_POWER, EVENT_SECOND_SAVED_CLICK_SHORT, MODE_ON): + //Don't blast if in colorchange mode + if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; + if (!spam_blast_ && SaberBase::IsOn()) { + SaberBase::DoBlast(); + last_blast_ = millis(); + } + return true; + + case EVENTID(BUTTON_POWER, EVENT_PRESSED, MODE_ON): + //Don't blast if in colorchange mode + if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; + if (spam_blast_ && SaberBase::IsOn()) { + SaberBase::DoBlast(); + last_blast_ = millis(); + } + return true; - case EVENTID(BUTTON_POWER, EVENT_PRESSED, MODE_ON): - if (spam_blast_) { - //Don't blast if in colorchange mode - if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; - SaberBase::DoBlast(); - last_blast_ = millis(); - } - return true; #ifdef ENABLE_AUTO_SWING_BLAST // Auto enter/exit multi-blast block with swings if swing within 1 second. case EVENTID(BUTTON_NONE, EVENT_SWING, MODE_ON): @@ -894,7 +899,7 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { #endif //Don't lockup if in colorchange mode if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; - if (!SaberBase::Lockup()) { + if (!SaberBase::Lockup() && SaberBase::IsOn()) { // pointing down if (fusor.angle1() < - M_PI / 4) { SaberBase::SetLockup(SaberBase::LOCKUP_DRAG); @@ -915,11 +920,13 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { case EVENTID(BUTTON_NONE, EVENT_STAB, MODE_ON): //Don't melt if in colorchange mode if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; - clash_impact_millis_ = millis(); - if (!SaberBase::Lockup() && !swinging_) { - SaberBase::SetLockup(SaberBase::LOCKUP_MELT); - auto_melt_on_ = true; - SaberBase::DoBeginLockup(); + if (SaberBase::IsOn()) { // prevents triggering during preon + clash_impact_millis_ = millis(); + if (!SaberBase::Lockup() && !swinging_) { + SaberBase::SetLockup(SaberBase::LOCKUP_MELT); + auto_melt_on_ = true; + SaberBase::DoBeginLockup(); + } } return true; @@ -927,8 +934,10 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { case EVENTID(BUTTON_POWER, EVENT_SECOND_HELD_MEDIUM, MODE_ON): //Don't lightning block if in colorchange mode if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) return false; - SaberBase::SetLockup(SaberBase::LOCKUP_LIGHTNING_BLOCK); - SaberBase::DoBeginLockup(); + if (SaberBase::IsOn()) { // prevents triggering during preon + SaberBase::SetLockup(SaberBase::LOCKUP_LIGHTNING_BLOCK); + SaberBase::DoBeginLockup(); + } return true; // Spam Blast toggle - pointing up @@ -939,31 +948,33 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { // 2 button case EVENTID(BUTTON_AUX, EVENT_CLICK_SHORT, MODE_ON | BUTTON_POWER): #endif - if (fusor.angle1() > M_PI / 3) { - sound_library_.SayZoomingIn(); - spam_blast_ = !spam_blast_; - return true; - } -#ifndef BC_NO_BM - if (!battle_mode_) { - PVLOG_NORMAL << "Entering Battle Mode\n"; - battle_mode_ = true; - if (SFX_bmbegin) { - hybrid_font.PlayCommon(&SFX_bmbegin); - } else { - hybrid_font.DoEffect(EFFECT_FORCE, 0); + if (SaberBase::IsOn()) { // prevents triggering during preon + if (fusor.angle1() > M_PI / 3) { + sound_library_.SayZoomingIn(); + spam_blast_ = !spam_blast_; + return true; } - } else { - PVLOG_NORMAL << "Exiting Battle Mode\n"; - battle_mode_ = false; - if (SFX_bmend) { - hybrid_font.PlayCommon(&SFX_bmend); +#ifndef BC_NO_BM + if (!battle_mode_) { + PVLOG_NORMAL << "Entering Battle Mode\n"; + battle_mode_ = true; + if (SFX_bmbegin) { + hybrid_font.PlayCommon(&SFX_bmbegin); + } else { + hybrid_font.DoEffect(EFFECT_FORCE, 0); + } } else { - beeper.Beep(0.5, 3000); + PVLOG_NORMAL << "Exiting Battle Mode\n"; + battle_mode_ = false; + if (SFX_bmend) { + hybrid_font.PlayCommon(&SFX_bmend); + } else { + beeper.Beep(0.5, 3000); + } } +#endif } return true; -#endif // Auto Lockup Mode case EVENTID(BUTTON_NONE, EVENT_CLASH, MODE_ON): @@ -978,39 +989,43 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { // MonoForce - pointing up // Force - NOT pointing up or down case EVENTID(BUTTON_NONE, EVENT_TWIST, MODE_ON | BUTTON_POWER): - // pointing down + if (SaberBase::IsOn()) { // prevents triggering during preon + // pointing down #ifndef DISABLE_COLOR_CHANGE - if (fusor.angle1() < - M_PI / 4) { - ToggleColorChangeMode(); - return true; - } + if (fusor.angle1() < - M_PI / 4) { + ToggleColorChangeMode(); + return true; + } #endif - // pointing up - if (fusor.angle1() > M_PI / 3) { - SaberBase::DoEffect(EFFECT_USER2, 0); - } else { - // NOT pointing up OR down - SaberBase::DoForce(); + // pointing up + if (fusor.angle1() > M_PI / 3) { + SaberBase::DoEffect(EFFECT_USER2, 0); + } else { + // NOT pointing up OR down + SaberBase::DoForce(); + } } return true; // Quote -// Revert colorchange witout saving (reset to Variation == 0) +// Revert Color Change without saving (reset to Variation == 0) case EVENTID(BUTTON_POWER, EVENT_THIRD_SAVED_CLICK_SHORT, MODE_ON): - if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) { - ResetColorChangeMode(); - return true; - } else { - if (SFX_quote) { - // if (font_config.sequentialQuote > 0) { - if (sequential_quote_) { - SFX_quote.SelectNext(); + if (SaberBase::IsOn()) { // prevents triggering during preon + if (SaberBase::GetColorChangeMode() != SaberBase::COLOR_CHANGE_MODE_NONE) { + ResetColorChangeMode(); + return true; + } else { + if (SFX_quote) { + if (sequential_quote_) { + SFX_quote.SelectNext(); + } else { + SFX_quote.Select(-1); + } + SaberBase::DoEffect(EFFECT_QUOTE, 0); + // hybrid_font.PlayCommon(&SFX_quote); } else { - SFX_quote.Select(-1); + SaberBase::DoForce(); } - SaberBase::DoEffect(EFFECT_QUOTE, 0); - } else { - SaberBase::DoForce(); } } return true; @@ -1023,23 +1038,25 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase { #else case EVENTID(BUTTON_NONE, EVENT_TWIST, MODE_ON | BUTTON_AUX): #endif - // pointing up - if (fusor.angle1() > M_PI / 3) { - SaberBase::DoEffect(EFFECT_POWERSAVE, 0); - return true; - } else if (fusor.angle1() < - M_PI / 4) { - // pointing down - sequential_quote_ = !sequential_quote_; - sound_library_.SayRandom(); - if (sequential_quote_) { - sound_library_.SayDisabled(); + if (SaberBase::IsOn()) { // prevents triggering during preon + // pointing up + if (fusor.angle1() > M_PI / 3) { + SaberBase::DoEffect(EFFECT_POWERSAVE, 0); + return true; + } else if (fusor.angle1() < - M_PI / 4) { + // pointing down + sequential_quote_ = !sequential_quote_; + sound_library_.SayRandom(); + if (sequential_quote_) { + sound_library_.SayDisabled(); + } else { + sound_library_.SayEnabled(); + } + return true; } else { - sound_library_.SayEnabled(); + // NOT pointing up or down + SaberBase::DoEffect(EFFECT_USER1, 0); } - return true; - } else { - // NOT pointing up or down - SaberBase::DoEffect(EFFECT_USER1, 0); } return true;