Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blaster_BC_buttons #582

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Conversation

NoSloppy
Copy link
Contributor

@NoSloppy NoSloppy commented Aug 1, 2023

No description provided.

Copy link
Owner

@profezzorn profezzorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some initial comments.
IF this things were to inherit from the blaster prop, then there will be lots of changes, so I want to get that out of the way before I review in more detail.

@@ -77,6 +77,7 @@ extern SaberBase* saberbases;
DEFINE_EFFECT(UNJAM) \
DEFINE_EFFECT(PLI_ON) \
DEFINE_EFFECT(PLI_OFF) \
DEFINE_EFFECT(DESTRUCT) \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self-destruct is usually an off-type rather than an effect...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is,

        case NEXT_ACTION_BLOW:
          Off(OFF_BLAST);
          break;

But having EFFECT_DESTRUCT allows for blade animations.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a way for TrInOut to handle EFFECT_DESTRUCT so we can have a transition from the on to the off color.

Copy link
Contributor Author

@NoSloppy NoSloppy Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. oh, you mean like an "explosion"? Wouldn't that just be the OUT->IN transition, something like

InOutTrL<TrInstant,TrConcat<TrInstant,Blinking<White,Black,75,500>,TrFade<600>>>

That would play with boom.wav.
I'm not sure what you're saying the integration with EFFECT_DESTRUCT should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh well that's not right. It works for Destruct, but also shows if powering off normally.
So what did you have in mind?
I glanced at styles/inout_helper.h, but do not know what should happen here.
Maybe if EFFECT_DESTRUCT happens, we somehow bypass in_tr_.begin(); ?

Copy link
Contributor Author

@NoSloppy NoSloppy Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we just have an EFFECT_BOOM that layers in the blade style on top of the InOutTrL?
Actually, my blaster styles don't even use an InOutTrL.
It's just always on not showing anything most of the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added EFFECT_BOOM, tested, works well for Boom, unless you had a different idea?

props/blaster_BC_buttons.h Outdated Show resolved Hide resolved
PropBase::DoMotion(Vec3(0), clear);
}

RefPtr<BufferedWavPlayer> wav_player;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables should generally go at the bottom (and be indented)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it above Event2 where I saw it in other props, and
I just added more bools to the spot that blaster.h has them.
So should the RefPtr (and all the other declarations) be moved to the bottom of the file?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@profezzorn
Copy link
Owner

Needs fixes for dedicated power and reload buttons, esp if dual_prop used.
Guidance?

It would be easier to provide guidance if I knew what the problem was...

@NoSloppy
Copy link
Contributor Author

NoSloppy commented Aug 24, 2023

Needs fixes for dedicated power and reload buttons, esp if dual_prop used.
Guidance?

It would be easier to provide guidance if I knew what the problem was...

dual_prop doesn't account for these buttons I think was / is the issue.
How would that work if we already have a "power" button that gets swapped to a button named BUTTON_FIRE?
Would we just add the 2 additional non-remapped buttons something mostly like this?

#ifdef CONFIG_BUTTONS
Button PowerButton(BUTTON_POWER, powerButtonPin, "pow"); 
Button AuxButton(BUTTON_AUX, auxPin, "aux");
Button ReloadButton(BUTTON_RELOAD, aux2Pin, "reload");
Button ????Button (BUTTON_???? , 17, "???"); // using data3 on v2.2 or TX on v3.9 Proffieboards
#endif

Copy link
Owner

@profezzorn profezzorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dual_prop doesn't account for these buttons I think was / is the issue.

I guess the question is: what do we want it to do?

props/blaster_BC_buttons.h Outdated Show resolved Hide resolved
props/blaster_BC_buttons.h Outdated Show resolved Hide resolved
@@ -77,6 +77,7 @@ extern SaberBase* saberbases;
DEFINE_EFFECT(UNJAM) \
DEFINE_EFFECT(PLI_ON) \
DEFINE_EFFECT(PLI_OFF) \
DEFINE_EFFECT(DESTRUCT) \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a way for TrInOut to handle EFFECT_DESTRUCT so we can have a transition from the on to the off color.

props/blaster_BC_buttons.h Outdated Show resolved Hide resolved
return max_shots_ != -1 && shots_fired_ >= max_shots_;
}

void Fire() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of overrinding the whole Fire function, how about splitting Blaster::Fire into smaller functions and then overriding the ones that are actually different from the base.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

props/blaster_BC_buttons.h Show resolved Hide resolved
props/blaster_BC_buttons.h Outdated Show resolved Hide resolved
@NoSloppy
Copy link
Contributor Author

NoSloppy commented Jan 21, 2025

Needs fixes for dedicated power and reload buttons, esp if dual_prop used.
Guidance?

It would be easier to provide guidance if I knew what the problem was...

dual_prop doesn't account for these buttons I think was / is the issue. How would that work if we already have a "power" button that gets swapped to a button named BUTTON_FIRE? Would we just add the 2 additional non-remapped buttons something mostly like this?

#ifdef CONFIG_BUTTONS
Button PowerButton(BUTTON_POWER, powerButtonPin, "pow"); 
Button AuxButton(BUTTON_AUX, auxPin, "aux");
Button ReloadButton(BUTTON_RELOAD, aux2Pin, "reload");
Button ????Button (BUTTON_???? , 17, "???"); // using data3 on v2.2 or TX on v3.9 Proffieboards
#endif

Changes to blaster.h make this easier now I think. Working on it.

I'll just make the RELOAD button (AUX2) have the option to be dedicated POWER and hope no one brings a 4 button blaster :)

props/blaster.h Outdated
@@ -87,6 +87,8 @@ mdauto Sound made when switching to AUTO mode
#ifndef PROPS_BLASTER_H
#define PROPS_BLASTER_H

#define PROP_HAS_GETBLASTERMODE
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember what this was for. OLED maybe? Also not sure why I have it in my local copy but it's not in the master.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used here:

#ifdef PROP_HAS_GETBLASTERMODE

which is in turn used by BlasterModeF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes I remember that. Cool. I guess it just never made it into the blaster prop?

@NoSloppy
Copy link
Contributor Author

Still making changes as I keep testing and finding things. Getting closer.

@NoSloppy
Copy link
Contributor Author

Still making changes as I keep testing and finding things. Getting closer.

Ok Major revamping done. I guess since all but one comment here has been addressed, I'll just overwrite these with the latest versions and go from there for review.

@profezzorn
Copy link
Owner

Needs fixes for dedicated power and reload buttons, esp if dual_prop used.
Guidance?

It would be easier to provide guidance if I knew what the problem was...

dual_prop doesn't account for these buttons I think was / is the issue. How would that work if we already have a "power" button that gets swapped to a button named BUTTON_FIRE? Would we just add the 2 additional non-remapped buttons something mostly like this?

#ifdef CONFIG_BUTTONS
Button PowerButton(BUTTON_POWER, powerButtonPin, "pow"); 
Button AuxButton(BUTTON_AUX, auxPin, "aux");
Button ReloadButton(BUTTON_RELOAD, aux2Pin, "reload");
Button ????Button (BUTTON_???? , 17, "???"); // using data3 on v2.2 or TX on v3.9 Proffieboards
#endif

Changes to blaster.h make this easier now I think. Working on it.

I'll just make the RELOAD button (AUX2) have the option to be dedicated POWER and hope no one brings a 4 button blaster :)

I think we would need to add some code to dual_prop to handle these kind of scenarios.

props/blaster.h Outdated

#ifdef BLASTER_SHOTS_UNTIL_EMPTY
const int max_shots_ = BLASTER_SHOTS_UNTIL_EMPTY;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants don't usually go at the bottom with the variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't seem moved...
(It should be near the top of the class.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't seem moved... (It should be near the top of the class.)

I thought I moved that because I remember saying to myself "ok I'll just put it back where it was."
Now you're saying top, so I just put it there now, up above the first function.

EDIT - wait. I did move them? I thought so. Irrelevant now, just weird that they were on the bottom again just 20 minutes ago.
73c533c

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I found what happened.
Apparently I had duplicated that part, not moved it?
Should be all good now.

uint32_t auto_time_;
RefPtr<BufferedWavPlayer> auto_player_;
RefPtr<BufferedWavPlayer> wav_player;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

typedef SoundLibraryV2 SoundLibrary;
};

void Setup() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this global, and indented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean it's global, so fix the indent, or is it wrong to be global?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be inside the prop. (and I think you want an "override" on it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks. Not too aware of the startup routine yet.

props/blaster.h Outdated
@@ -87,6 +87,8 @@ mdauto Sound made when switching to AUTO mode
#ifndef PROPS_BLASTER_H
#define PROPS_BLASTER_H

#define PROP_HAS_GETBLASTERMODE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used here:

#ifdef PROP_HAS_GETBLASTERMODE

which is in turn used by BlasterModeF

props/blaster.h Outdated
}

virtual bool CheckJam(int percent) {
int random = rand() % 100;
return random < percent;
}

virtual void Fire() {
bool DoJam() {
#ifdef ENABLE_MOTION
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if defined(ENABLE_MOTION) && defined(BLASTER_JAM_PERCENTAGE)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup.
Done.

props/blaster.h Outdated
return;
}
}
virtual int GetBulletCount() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the same as the inherited version, so we don't need it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything overriding this.
Did you mean we don't need the virtual?
I think that's correct.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed what file this was in.
It shows up as new because the diff is dumb. Maybe just move it up to line 172 to make the diff nicer.

props/blaster.h Outdated

#ifdef BLASTER_SHOTS_UNTIL_EMPTY
const int max_shots_ = BLASTER_SHOTS_UNTIL_EMPTY;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't seem moved...
(It should be near the top of the class.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants