Welcome back.
Now if I open my attribute menu, I have some buttons next to my primary attributes.
I'd like to be able to upgrade my attributes whenever I have attribute points, but when I don't have
attribute points, I want these buttons to be disabled.
So the first step to that is enabling or disabling them based on my attribute points.
And that's going to be your next quest.
I'd like you to enable the attribute buttons whenever we have attribute points.
So make sure that they're clickable.
And when we don't have attribute points, make sure they're disabled.
Now, there are a couple of different ways that you could go about this, so don't be too worried about
doing it the right way or the wrong way.
Do it the way that makes sense to you.
And then you can watch how I do it and see if you did it the same way or maybe a little different.
Go ahead and pause the video and conquer this quest now.
Okay, so the goal is to disable these buttons whenever we don't have attribute points and enable them
when we do.
Now, there are a couple of ways to go about this.
First of all, I'm going to go into my text value button row widget here and take a look at it.
Now our text value button row has its own widget controller set to the attribute menu widget controller.
So we can definitely know if we have attribute points or not because the attribute menu widget controller
broadcasts a delegate.
If we go to attribute menu widget controller, it's called attribute points changed delegate.
Now it's up to us if we'd like to listen for that in each of our attribute menu button rows, we could
or we could listen for that delegate only once in the attribute menu and then based on the attribute
points value, if it's zero, we could disable all the buttons on these four rows, either one.
I think is okay.
One is not terribly more performant than the other.
If we listen for the delegate and attribute menu, then we'll only have one delegate broadcast received.
If we listen to it in each attribute row, then that's just more delegates being broadcast and overall
more work being done, more operations being done.
So I personally think I'd like to listen to one delegate here in the attribute menu.
So I'm going to do that now.
I need to listen for delegates on the widget controller before broadcasting initial values broadcast
initial values should be the last thing done, So I'd like to put it well below everything else that
we do.
So my attribute menu widget controller should be promoted to a variable at this point, so I'm going
to go ahead and promote it.
And call it attribute menu widget controller.
It's not the blueprint version, but that's okay.
So I'm going to go ahead and just promote it and then set my widget controller with it and then get
rid of these reroute nodes by getting.
My variable I promoted and using that instead.
That makes it easier to break this up.
And I'm going to broadcast initial values very last.
That allows me to bind to my widget controllers.
Delegates here after I've set my widget controller.
So I'm going to add two more pins.
The fourth one will be very last broadcast initial values here.
But after I've set my widget controllers here, I can then bind to a delegate on my widget controller.
So I'm going to take attribute menu.
Widget Controller.
Drag off of it and type attribute points so I can assign attribute points change delegate.
I'll go ahead and rename this event to attribute points changed and this will be my third.
PIN in the sequence.
Now I can do whatever I want based on the attribute points value.
Now I'm going to make a function that takes in this value.
So new function.
I'm going to call this set buttons enabled.
This will set the buttons to be enabled or disabled based on the integer passed in for attribute points.
So this will be an int and it's going to be called attribute points.
And in the event graph I'm going to call this function set buttons enabled and pass in that information.
Now set buttons enabled is going to check the value of attribute points and see if it's greater than
zero.
We'll have a branch here.
If it is greater than zero, we can enable all the buttons.
And if it's not greater than zero, we can disable them.
Now the buttons all belong to our rows for the primary attributes.
So I'm going to get those.
We have row intelligence.
Row strength.
I'll put that above it.
Row resilience and row.
Vigor.
Each of these are text value button rows.
Each text value button row.
If we go and look at it, has this button I'm going to go ahead and check is variable.
So now it's a variable.
And in the attribute menu, I'm going to drag off and type button and get WB button.
Now WB button is a widget itself, right?
We can remind ourselves by going to blueprints UI button and we have a WB button and this button widget
has its own button inside of it called button.
So it's a little bit confusing, but to make this a little bit less confusing, we can take our text
value button row and add a function on this widget to disable or enable its own button.
So I'm going to add a function on it called set button enabled.
And this is going to handle getting our WB button, getting its button widget.
So get button on here and then calling set is enabled on it.
And set button enabled can take a boolean.
This just makes it a little bit less confusing.
The boolean will be called enabled and it'll call set button enabled here.
So now that text value button row has this function, our attribute menu doesn't have to access the
button.
It can just call the text value button row function set button enabled.
Now, if attribute points is greater than zero, we should enable the button.
So I'm going to go ahead and plug in all of these nodes to the same function call as that's a neat little
trick we can do.
And this results in the same thing as if we had duplicated the set button enabled function node.
Now I'm going to duplicate these and paste them, but uncheck enabled and will disable the buttons in
this case.
If attribute points is not greater than zero.
So now we have set buttons enabled which we're calling in response to attribute points changing.
So all we have to do now is test it out.
Now we see that our buttons are disabled.
And if I level up now that I have one attribute point, my buttons are enabled and every time attribute
points changes, then our attribute menu will listen and update these buttons based on the value of
attribute points.
So we're one step closer to implementing a working attribute menu where we can spend attribute points
on our different attributes.
And once we get everything working, we can fix it up cosmetically and make it look just tiptop.
Excellent job.
I'll see you soon.