Skip to content

Commit

Permalink
BC_buttons. no effects during preon (#599)
Browse files Browse the repository at this point in the history
* BC_buttons. No effects during preon.

* period restore.

* sequential spelling.

* whitespace
  • Loading branch information
NoSloppy authored Dec 8, 2023
1 parent 267be7c commit ff92882
Showing 1 changed file with 104 additions and 87 deletions.
191 changes: 104 additions & 87 deletions props/saber_BC_buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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);
Expand All @@ -915,20 +920,24 @@ 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;

// Lightning Block
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
Expand All @@ -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):
Expand All @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit ff92882

Please sign in to comment.