Welcome back.
So now we have the ability to know when we've had an effect applied to us, such as when picking up
one of our pickups and we know which gameplay tags those pickups have.
In the case of our mana potion, we have two gameplay tags in that gameplay effect.
Specifically, we're accessing the asset tags in the gameplay effect.
These are tags that are not given to the actor that the gameplay effect is applied to.
They're just carried along in the gameplay effect and we're retrieving them and we're sending them over
to our widget controller.
So back in Writer, we can see right here where we're taking the ability system component Member On
our overlay widget controller, we're casting that to an aura ability system component and we're getting
the effect asset tags delegate that we created and we're adding a lambda to it.
So we created this lambda, which is an anonymous function that doesn't even have a name.
It's not a member function, it's just an anonymous function that has its own body here and its own
input parameters.
The only input parameters it takes is a const reference to a gameplay tag container, and we're looping
through that and printing a message to the screen.
That's all we're doing so far.
Now we'd like to take those gameplay tags and do something with them and broadcast some information
that our widgets can receive.
Now, rather than just broadcasting a gameplay tag up to the widget side of things, I'd like to have
some kind of asset that we can use to look up information that we can broadcast to the widgets.
For example, we may have a asset such as a data table that can look things up by tag, by gameplay
tag and retrieve some kind of information, some kind of struct that we can pass up to the widgets.
So I'd like to make a data table that has information related to gameplay tags specifically for showing
messages to the screen.
And this data table is going to have its row structure defined here in C plus plus we can define the
row structure as a struct in C plus plus, and I'd like to do that in our overlay widget controller
header file.
So I'm going to go over to that header file.
And up here at the top I'm going to make a struct that will be our row structure.
So we need to give this a name.
So we're going to say struct and I'll call this f UI widget and it's a row structure, so I'm going
to call it f UI widget row and it's going to inherit from the F table row base struct.
That's the base class for a row structure for data tables.
Now it's going to be a UI struct, so we'll give it the use struct macro.
I'm going to make it blueprint type so we can use it as a type in blueprints and it needs the generated
body macro.
Now this row structure that we'll use in our data asset is going to obviously need a gameplay tag.
So I'm going to make an F gameplay tag and call this asset tag.
Now, this is going to be specifically for messages to display to the screen.
So we could call this message tag if we wanted to do that.
In fact, let's do it.
And we're going to make this a new property edit anywhere.
And we'll go ahead and make it Blueprint read only or blueprint read, write.
Either one is fine and we'll make sure these are all initialized.
So I'll initialize it to an empty gameplay tag.
So there's the tag.
We're also going to want a message to display.
And in the realm of widgets, when we display text to the user in the form of a widget, we use text
that's user facing text that we show in widgets.
I'm going to make an F text called Message.
We'll initialize this to an F text and we'll give all of these the same view property.
Now in this data table, I'd like to have a widget class that we can show to the screen.
So for any given gameplay tag, there will be a widget that we can create and add to the viewport whenever
we receive this tag in the form of a gameplay effect.
So I'm going to make a subclass of and it's going to be of type you or a user widget because we're going
to only use aura user widgets for this.
I'm going to add the forward declaration for it at the top here.
So there it is and this will be the message widget.
And again, same property.
Now, our message widget may or may not want to have some kind of image associated with our message.
Maybe we'd like to show an icon of a health potion, for example, and along with that, have some kind
of text that says Picked up health Potion.
And really, there could be any other data that we'd like to pass up that we want.
If we wanted to harvest more data, such as the magnitude of the modifier, whatever we want, you can
put anything in here, but I'm just going to have an image that could be optional and it's going to
be a new texture 2D.
We'll call this image and initialize it to a null pointer and give this a new property as well.
And I think that's enough info for now.
We'll just use this.
We can always add more to this if we find that we need more information in this data table.
But now we have a row structure we can use in a data table.
Now I have my editor running, so I'm going to go ahead and close it down and launch the editor from
here.
So we get a fresh compile.
Okay.
So back in the editor.
Now I'm going to make a data table and I'd like to go into my blueprints folder into UI, and here in
the UI folder, I'm going to make a new folder called Data.
And that way any data tables or perhaps data assets, anything related to data can come here and I'm
going to right click and make a new data table.
So I'll go to miscellaneous and choose data table.
And for the row structure I have to choose my structure that I created called UI, Widget Row and the
F is gone here in the editor, so it's just UI widget row.
I'm going to select it, click okay and call this DBT for data table and this can be our message widget
data.
So we're going to say message widget data and we'll open it up and here we can add a new row and we
can give it a name, it can be associated with a tag, we can choose a tag here, we can set the message
here, we can set a widget and an image, all that stuff.
It's all there.
So I'm going to save that.
I'm not going to fill in any data.
But what we do need are some message tags for any messages.
And right now we have four types of pickups, so we can make some message gameplay tags and we can do
that by going into project settings.
So in project settings we can go to gameplay tags and we can have tags that we add here.
We can even make a new data table for those tags if we wanted to do that, I leave it up to you, but
I'd like a new type of gameplay tag.
I'm going to add new gameplay tag here and this will be message dot.
Health potion.
So I'll have a message health potion.
And that's going to add that here.
And I'd like to add more messages, one for each type of pickup we have.
So next to message, I'm going to click add sub tag and that gives me message dot and I'm going to have
message dot mana potion.
That gives me the mana potion and we'll do another couple of these.
We'll have message dot health crystal.
And once again we'll click it again and have message dot mana crystal.
And now we have four new gameplay tags under the message parent tag.
Okay, great.
So now that we have this, we need a way to let our widgets know or at least our overlay know when our
widget controller has received a message tag so we can go into our overlay.
And here's WB overlay here we have our widget controller and we can bind to delegates on the widget
controller that we may wish to broadcast up here into the blueprint realm.
And if we go back into our widget controller C plus plus code overlay, widget controller CP right here
is where we're binding our lambda to whenever we receive a tag container that's associated with a given
effect.
So once we receive this tag container, we can see if any of those tags have the message parent tag.
And if they do well, then we can look up something from a data table, which means since we have a
new data table that has those assets in UI slash data right here, message data table.
I'd like to have a variable of this type on my widget controller and that way we can always look up
from this table to get any assets that we want to broadcast to the widgets.
So that's the last thing I'm going to do in this video is close out of the editor and we're going to
add a variable to our widget controller, our overlay widget controller class for the data table.
So we'll make this a protected variable.
We'll go down to the protected section and above our function callbacks.
I'm going to have my data table t object pointer and this will be simply a U data table.
And we're going to call this message widget data table.
And I want to be able to set this from my widget controller's blueprint.
So I'm going to make a uproperty macro for it.
Edit Defaults only we can make it edit anywhere, but really we're only going to be editing the defaults
as we just have a default blueprint.
There's only going to be one of these in existence, but I would like to expose to blueprint event graph,
so I'll make it blueprint read only and I'll give it the category of widget data.
So we'll have a data table we can set here.
And then once we receive any gameplay tags from events here in our lambda, we can perform some kind
of lookup and broadcast data from that data table up to the widgets.
So I'm going to go ahead and compile and run.
We can hit, run or debug.
Either one is fine.
And I'm just going to set the widget data table for our widget controller.
So I'm going to go to Blueprints, UI, widget Controller and open my overlay widget controller.
There's my variable.
I can expand the dropdown and we have a message widget data.
I'm going to set that as the message widget data table, and now we can access that and we can perform
the lookup and cplusplus.
So we'll be doing that next.
I'll go ahead and close project settings and I'll see you in the next video.