Manually Switch from One Preset Array to Another?

Do you have this part? (and where?)

Yes, it’s right near the top of the prop. I cut and pasted that whole chunk you posted earlier, with a little tweak suggested by Brian and Ryry about the static void toggle, as it kept throwing compile errors without it.

Hmm, try moving all that stuff before the prop_base.h include.

1 Like

OMG!!!
That did it!!! :smiley:
:clap: :ok_hand:

Guys, thank you all so much! This is amazing and very much appreciated as always! :pray: :pray: :pray:
Will post the video of the finished hilt here once I’ve shot it. :smiley:
Sincere thanks again! :+1:

3 Likes

Is your mute case right below this?
It would make sense that was triggering because you didn’t return true here after calling FindBladeAgain() so it fell through to the following case.

1 Like

Ahh, yes it was. Yeh, I can see how that would work now you’ve pointed it out.
So it looks like I was right to tweak that bit of code so it now reads:

case EVENTID(BUTTON_POWER, EVENT_THIRD_SAVED_CLICK_SHORT, MODE_OFF):
      FakeBladeID::toggle();
      FindBladeAgain();
      SaberBase::DoBladeDetect(true);
   return true;

:smiley:

Why is this here though?

1 Like

Ahem… ermm… because in my coding ignorance, I cut and pasted that bit from the manual BladeID scan button press I’ve been using as I know that button press works. But it did occur to me to wonder whether it was actually needed. I’ll try it without, but I have a hunch that if nothing else, that line serves as the trigger to play the bladein.wav file, which is actually desired behaviour in this instance.

That hunch is correct.

2 Likes

Hey if you can document this and mark it as a solution so if some other mad peeps wants to do it we can point to this topic.

Sorry, yes, solution summary is:

At the top of the prop, just below the #define title line (i.e. the third line of actual code) paste this:

//  Toggle switch between blade arrays manually.
//  This goes in the prop file, but not in the prop class.
//  If using normal BladeID, this whole section must be commented out!

struct FakeBladeID {
   static int return_value;
   float id() { return return_value; }
   static void toggle() {
     return_value = NO_BLADE - return_value;
   }
};
int FakeBladeID::return_value = 0;
#undef BLADE_ID_CLASS_INTERNAL
#define BLADE_ID_CLASS_INTERNAL FakeBladeID
#undef BLADE_ID_CLASS
#define BLADE_ID_CLASS FakeBladeID

Then further down the prop amongst the regular button controls, paste this:

case EVENTID(BUTTON_POWER, EVENT_THIRD_SAVED_CLICK_SHORT, MODE_OFF):
      FakeBladeID::toggle();
      FindBladeAgain();
      SaberBase::DoBladeDetect(true);
   return true;

Works a treat and I actually only yesterday used it on an install that had multiple fonts each with light side and dark side variants. :slight_smile:

3 Likes