WEBVTT

00:06.850 --> 00:08.030
Welcome back.

00:08.050 --> 00:13.150
So now we've created a spell menu widget controller, and we need to construct it.

00:13.180 --> 00:20.200
Now let's go ahead and close all tabs, and we're going to open up our HUD class.

00:20.590 --> 00:23.170
I'm going to go into UI, HUD, Aura.

00:23.200 --> 00:23.770
HUD.

00:23.860 --> 00:24.460
Why?

00:24.490 --> 00:29.950
Because we have our widget controllers for our project on this class.

00:29.950 --> 00:31.360
They live on the HUD.

00:31.660 --> 00:38.680
They're not technically singletons, but we only have one of each one and we access them through the

00:38.680 --> 00:39.040
HUD.

00:39.040 --> 00:45.880
Well, indirectly, actually, we access them usually with our aura ability system library functions

00:45.880 --> 00:48.400
and those access them through the HUD.

00:48.430 --> 00:54.910
We're going to now have a spell menu widget controller and it too is going to live on the HUD, just

00:54.910 --> 00:58.210
like the attribute menu and overlay widget controllers.

00:58.510 --> 01:04.600
So we're going to add variables to the HUD so that we can create our spell menu.

01:04.600 --> 01:05.800
Widget Controller.

01:05.800 --> 01:09.560
I'm going to copy our object pointer.

01:09.560 --> 01:15.770
You attribute menu widget controller called attribute menu, Widget Controller and the class for that

01:15.770 --> 01:18.500
attribute menu, widget controller and paste them.

01:18.950 --> 01:24.950
We're going to change these though to spell menu widget controller, which I'd now like to forward declare.

01:25.400 --> 01:28.340
So I'm going to go ahead and forward declare it here.

01:28.340 --> 01:36.710
You spell menu widget controller and that's going to be the type for my new object pointer, which I

01:36.710 --> 01:39.320
will call spell menu Widget Controller.

01:39.320 --> 01:46.550
I'm also going to have a subclass of of this type called spell menu Widget Controller class.

01:47.750 --> 01:53.690
Now that I have these, I'm going to need to set spell menu widget controller class on the HUD blueprint.

01:53.960 --> 02:00.710
Now we construct the other widget controllers with these get functions and these require widget controller

02:00.710 --> 02:01.610
params.

02:01.640 --> 02:06.200
We're going to make a get function for the spell menu widget controller as well.

02:06.200 --> 02:12.270
So we're going to copy one of them and change its return type to use spell menu widget controller.

02:12.290 --> 02:18.310
It's going to be called get spell menu widget controller and it's going to take widget controller params.

02:18.320 --> 02:20.690
We can go ahead and generate the definition.

02:20.690 --> 02:26.780
And what this will do is just the same thing as what the other get functions do.

02:26.900 --> 02:31.490
It checks to see if the spell menu widget controller is null.

02:31.490 --> 02:36.320
So we'll say if spell menu widget controller equals a null pointer.

02:37.430 --> 02:39.920
If it's null, it's going to create one.

02:39.920 --> 02:45.350
If it's not null, well, either way it'll return spell menu widget controller.

02:45.830 --> 02:49.740
So we need to create that widget so we can say spell menu.

02:49.740 --> 02:52.830
Widget controller equals new object.

02:52.860 --> 02:57.210
We're going to create a you spell menu widget controller.

02:57.240 --> 03:04.140
The header file will be auto included for me and we pass in this for the outer object and the class

03:04.140 --> 03:07.200
will be spell menu widget controller class.

03:07.410 --> 03:15.060
Once we've created it, we set its widget controller params calling spell menu widget controller set

03:15.090 --> 03:19.380
widget controller params passing in wc params.

03:21.870 --> 03:28.290
As the spell menu widget controller inherits set widget controller params and then we call bind callbacks

03:28.290 --> 03:29.380
to dependencies.

03:29.400 --> 03:35.060
Spell menu, widget controller bind callbacks to dependencies and then it returns.

03:35.070 --> 03:42.330
So the first time this is called and creates it, we have all this stuff happening The second time it

03:42.330 --> 03:42.870
gets called.

03:42.870 --> 03:45.690
After that we just return the pointer.

03:45.690 --> 03:48.750
We only create the spell menu widget controller once.

03:48.870 --> 03:55.920
Now this is great, but we want something on the aura ability system library to make this easier.

03:55.920 --> 04:02.790
So I'm going to go to Aura ability system library and go up to my get functions for the widget controllers.

04:02.790 --> 04:08.550
I'm going to copy one of them and simply paste it and this will be for the spell menu widget controller.

04:08.550 --> 04:16.230
So it can still be blueprint pure in the category of the others, but it's going to return a you spell

04:16.260 --> 04:23.110
menu widget controller, which we will add a forward declaration for and it's going to be called get

04:23.110 --> 04:26.950
spell menu widget controller so we can change its name.

04:27.520 --> 04:31.030
And it takes in a world context object just like the others.

04:31.030 --> 04:36.000
We can generate the definition for it and it's going to be just like the others.

04:36.010 --> 04:43.660
Well, let's go ahead and copy the contents of get attribute menu, widget controller and analyze it.

04:43.690 --> 04:47.590
First we get the player controller using get player controller.

04:47.590 --> 04:50.020
We get the HUD as well.

04:50.140 --> 04:52.840
We get the aura player state from the player controller.

04:52.840 --> 04:56.140
We get the ability system component and attribute set.

04:56.170 --> 05:04.210
We construct F widget controller params and then we take our aura HUD and we call well not get attribute

05:04.210 --> 05:09.250
menu widget controller, but rather get spell menu widget controller.

05:09.250 --> 05:10.900
That's all it's going to do.

05:10.930 --> 05:15.940
Now you may be thinking to yourself these three functions look awfully similar to each other.

05:15.970 --> 05:19.300
Is there a way to not repeat ourselves for a lot of this?

05:19.510 --> 05:20.890
Well, sure.

05:20.920 --> 05:24.100
We could make a function that could do most of this work for us.

05:24.130 --> 05:27.610
We can create a function that makes the widget controller params.

05:27.610 --> 05:30.180
That's what most of this stuff is for, right?

05:30.190 --> 05:33.910
In other words, we could create a new function here.

05:34.030 --> 05:39.040
It could be a static function, it could even be blueprint pure and this can be get widget controller

05:39.040 --> 05:47.980
params or actually make widget controller params more specifically and this can return an F widget controller

05:47.980 --> 05:49.000
params.

05:49.030 --> 05:54.130
We're going to have to add the include here if we're going to use it, which means we can remove the

05:54.130 --> 05:58.960
include from in the CPP file that's or a widget controller.

05:58.960 --> 06:01.810
So we can remove that from the CPP file.

06:01.930 --> 06:10.840
And this function is going to be called make widget controller params and it can take a world context

06:10.840 --> 06:11.710
object.

06:11.860 --> 06:17.860
Now what this function will do is what these other functions are repeating in each of them.

06:17.860 --> 06:25.760
We'll just get the player controller, get the HUD cast aura, HUD get the player state, get the AC,

06:25.840 --> 06:29.560
the AI's make widget controller params and return them.

06:29.890 --> 06:36.160
In fact, we can just return the f widget controller params that we make here.

06:36.160 --> 06:38.800
We don't have to make a local variable for them.

06:39.100 --> 06:43.990
Now at the end we have to return an empty f widget controller params.

06:44.290 --> 06:49.840
So f widget controller params like that.

06:50.080 --> 06:55.390
And now we have a function that we can use in each of these so we don't have to repeat ourselves.

06:56.010 --> 06:57.420
But here's the thing, though.

06:57.450 --> 07:00.130
What if some of these casts fail?

07:00.150 --> 07:05.520
Well, we should be able to know because if we get an empty widget controller params when we create

07:05.520 --> 07:08.010
our widget controller, that's not good.

07:08.010 --> 07:11.450
That's not going to be a very pleasant experience.

07:11.460 --> 07:16.830
So rather than returning an EF widget controller params, here's something we can do.

07:16.860 --> 07:25.200
We can pass the widget controller params in as a reference that's not const so ef widget controller

07:25.200 --> 07:30.270
params reference called out wc params.

07:31.580 --> 07:37.610
And instead of returning a widget controller params, we can return a boolean that will be representative

07:37.610 --> 07:38.930
of the success.

07:38.960 --> 07:42.580
Then we don't have to include or a widget controller here.

07:42.590 --> 07:46.070
We can forward declare a widget controller params.

07:46.070 --> 07:51.410
We can say struct f widget controller params here.

07:51.560 --> 07:55.400
And then we can just include that header back here.

07:56.600 --> 08:03.710
And we can change this function signature to return a bool and it also takes in a widget controller

08:03.710 --> 08:06.650
params out wc params.

08:07.310 --> 08:12.080
And then out wc params can simply have its members set.

08:12.110 --> 08:20.420
We can say out wc params dot attribute set equals as.

08:22.550 --> 08:29.690
Out wc params dot ability system component equals asc.

08:31.160 --> 08:42.920
Out wc params dot player state equals ps and out wc params dot player controller equals p c.

08:44.180 --> 08:51.080
And by the end of this out wc params will be filled in and if we fill it in we can return.

08:51.080 --> 08:51.860
True.

08:54.720 --> 08:59.070
And if we never get this far by the end of it, we'll return False.

08:59.220 --> 09:04.860
So now we have a function that tells us whether or not this was a success.

09:05.160 --> 09:10.960
And then here in, say, git overlay widget controller, we can check the Boolean.

09:10.980 --> 09:20.010
I'm just going to make some room here and create an EF widget controller params called WC params.

09:21.000 --> 09:28.560
I'm going to call make widget controller params right here passing in world context.

09:28.590 --> 09:29.130
Whoops.

09:29.130 --> 09:31.090
Not duplicate world.

09:31.110 --> 09:37.350
Passing in world context object and wc params.

09:37.770 --> 09:46.560
And this returns a boolean so we can say const bool be successful params.

09:47.460 --> 09:49.620
And if that's a success.

09:49.620 --> 09:55.570
So if be successful params then.

09:59.120 --> 10:05.660
Well return or git overlay widget controller passing in those wc params.

10:05.660 --> 10:06.860
But wait a minute.

10:06.890 --> 10:08.600
We don't have a HUD here.

10:08.600 --> 10:08.990
Right?

10:08.990 --> 10:10.580
So how do we get that aura?

10:10.610 --> 10:10.870
HUD?

10:10.880 --> 10:13.880
Do we just go and go through all this stuff again?

10:13.880 --> 10:17.000
Well, no, that would be silly, wouldn't it?

10:17.090 --> 10:24.050
What we can do instead is we can pass in a pointer to make widget controller params that we can fill

10:24.050 --> 10:24.640
in.

10:24.650 --> 10:32.120
In other words, we can pass in a out parameter, a pointer that we can pass in by reference, much

10:32.120 --> 10:34.220
like wc params.

10:34.220 --> 10:34.850
That's right.

10:34.850 --> 10:37.880
I said pass a pointer in by reference.

10:37.910 --> 10:41.840
Now that sounds kind of strange, but we can do it.

10:42.050 --> 10:53.300
We can have a third input parameter of type A or a HUD pointer, but it's a pointer passed in by reference.

10:53.300 --> 11:04.440
So we have asterisk and the reference operator here and we'll call this out or HUD looks kind of crazy,

11:04.440 --> 11:09.150
but all we need to do is treat it like any other reference.

11:09.150 --> 11:12.960
It just happens to be a pointer that we have a reference to.

11:12.990 --> 11:21.600
So here in make widget controller params, we're passing in a HUD, a reference to a pointer and now

11:21.600 --> 11:26.700
out aura HUD can be assigned the result of this cast.

11:26.700 --> 11:32.340
So what we can do is say out aura HUD equals and we can perform this cast here.

11:34.850 --> 11:36.120
Just like that.

11:36.170 --> 11:40.730
And now what we're checking in this if statement is the out or HUD.

11:41.090 --> 11:44.990
So as soon as we've made it to this, we'll be setting that pointer.

11:44.990 --> 11:47.090
And this is passed in by reference.

11:47.090 --> 11:52.880
So whatever pointer we pass in, it will be altered outside the function as well.

11:52.910 --> 11:57.570
So now we just need to pass a pointer in to make widget controller params.

11:57.590 --> 12:03.830
We're doing the same thing that we're doing with WC params making a variable and passing it in and expecting

12:03.830 --> 12:06.020
the function to fill that variable in.

12:06.050 --> 12:07.770
It just happens to be a pointer.

12:07.790 --> 12:13.010
We can say a or a HUD pointer called or a HUD.

12:14.360 --> 12:21.230
Now we set it equal to null pointer so that it's initialized to null, but we pass it in to make widget

12:21.230 --> 12:28.790
controller params and that way after this function has been called then on a HUD should be filled in

12:28.790 --> 12:31.400
and then we can call get overlay widget controller.

12:31.490 --> 12:35.700
Now we don't even really need a local variable successful params.

12:35.700 --> 12:38.950
We can just call this function since it returns a bool.

12:38.970 --> 12:41.220
Right here in the if statement.

12:41.220 --> 12:43.740
So this looks a little bit less amateur.

12:43.830 --> 12:52.800
And after this or a HUD, our local pointer has been set and we can call get overlay widget controller

12:52.830 --> 12:54.240
pretty nice.

12:54.240 --> 13:00.090
And then if we don't make it this far, if everything fails, we return a null pointer, no big deal

13:00.090 --> 13:00.930
and get overlay.

13:00.930 --> 13:06.060
Widget controller no longer needs to repeat itself by getting all this stuff.

13:06.060 --> 13:09.990
Instead, it can just do this stuff here.

13:10.080 --> 13:15.810
So we've saved a little bit of work and we can just test this out before we go and change the other

13:15.810 --> 13:22.830
two functions by just making sure that we have an overlay widget controller and that everything works

13:22.830 --> 13:29.550
from our health globe to our mana globe to whatever abilities we have equipped.

13:29.580 --> 13:32.250
We can just test out everything.

13:33.280 --> 13:35.140
So we can press play.

13:35.170 --> 13:37.300
Even in multiplayer, we're testing.

13:37.630 --> 13:40.210
Looks like Mana is updating.

13:40.210 --> 13:41.860
Let's see if we can take some damage.

13:41.860 --> 13:43.210
Yes we can.

13:43.970 --> 13:47.510
Even our cooldowns are being shown.

13:49.990 --> 13:52.100
So we see that everything's working.

13:52.120 --> 13:53.650
So we can do this.

13:53.680 --> 14:00.040
We can call make widget controller params now and we can do that in our other get functions for attribute

14:00.040 --> 14:02.880
menu controller and spell menu Widget controller.

14:02.890 --> 14:09.760
So I'm going to just copy these lines and come down here into get attribute menu, widget controller

14:09.760 --> 14:10.870
and paste them.

14:11.810 --> 14:19.070
The only difference with this is we're going to return our HUD get attribute menu widget controller.

14:19.070 --> 14:20.480
That's the only difference.

14:21.170 --> 14:26.030
And we'll go ahead and delete the rest and we'll copy these.

14:26.570 --> 14:29.270
I'm going to put that input parameter on the same line.

14:29.270 --> 14:31.910
And then here we'll do the same thing for spell menu.

14:31.910 --> 14:32.810
Widget controller.

14:32.840 --> 14:35.240
The difference is we'll call get spell menu.

14:35.240 --> 14:36.380
Widget controller.

14:38.380 --> 14:45.280
Okay, so now that we have a jet spell menu, widget controller, we can call that to get the spell

14:45.310 --> 14:47.560
menu widget controller for our project.

14:47.560 --> 14:53.260
And I'd like to do that for our spell menu as soon as it's constructed, which means we do need to make

14:53.260 --> 14:57.280
sure that our aura HUD has a spell menu widget controller.

14:57.280 --> 15:02.140
And that means we need to create a blueprint, as I'd like to have a blueprint for the spell menu.

15:02.140 --> 15:03.250
Widget Controller.

15:05.250 --> 15:10.800
Now, if we go back and look at our spell menu, widget controller header file and compare it to the

15:10.800 --> 15:12.420
overlay widget controller.

15:13.200 --> 15:17.040
We'll see that overlay widget controller is blueprint type, blueprint able.

15:17.400 --> 15:22.800
Let's go ahead and add that to spell menu widget controllers class so we can make a blueprint from it.

15:22.800 --> 15:25.320
And let's go ahead and launch the editor.

15:27.150 --> 15:28.890
Okay, so we're back now.

15:28.890 --> 15:29.640
A couple things.

15:29.640 --> 15:37.800
Let's go first into blueprints and UI and widget controller and let's make a new widget controller blueprint

15:37.800 --> 15:38.190
class.

15:38.190 --> 15:43.350
So Blueprint class, we're going to search for spell menu, Widget controller.

15:43.380 --> 15:48.330
Choose that, select it and we'll call this BP spell menu.

15:48.330 --> 15:49.500
Widget Controller.

15:52.830 --> 15:59.160
Now we have a spell menu widget controller and it does have an ability info data asset.

15:59.190 --> 16:00.480
We should set that.

16:00.510 --> 16:08.910
That way it has access to the ability info just like our other attribute menu widget controller has

16:08.910 --> 16:10.110
ability info.

16:10.140 --> 16:17.250
It just happens that now it's inheriting ability info from aura widget controller and it doesn't actually

16:17.250 --> 16:18.030
use it.

16:18.030 --> 16:21.270
But we could set it just in case we need to use it in the future.

16:21.360 --> 16:28.380
Overlay widget controller has already had its set, so when we moved it into the parent class, blueprint

16:28.380 --> 16:31.860
was smart enough to still have that set.

16:31.920 --> 16:34.770
So we have a blueprint for spell menu widget controller.

16:34.770 --> 16:40.530
We need to go to Aura HUD and set spell menu Widget Controller class to BP.

16:40.560 --> 16:41.190
Spell Menu.

16:41.190 --> 16:42.300
Widget Controller.

16:42.330 --> 16:49.620
Now it can be constructed, and that means we can have our spell menu set its own widget controller.

16:49.650 --> 16:57.370
Let's go into BP spell menu, go into the graph and we can have it set in as early as event construct.

16:58.520 --> 17:01.160
Let's just go ahead and add a sequence node.

17:02.480 --> 17:04.610
So we can organize things.

17:07.180 --> 17:12.070
So first we're binding to the on clicked for the close button.

17:13.900 --> 17:20.320
I'm going to make a comment and say Close button clicked and we'll move that out of the way.

17:24.720 --> 17:28.110
And after that, we're going to set our own widget controller.

17:28.110 --> 17:34.800
We're going to call the blueprint function library function, get spell menu, widget controller, and

17:34.800 --> 17:36.780
it requires a world context object.

17:36.810 --> 17:42.630
Now, this is the third time I've called one of these that needs a world context object, and I've been

17:42.630 --> 17:46.710
using self every single time for that world context object.

17:46.710 --> 17:51.870
And that is grinding my gears because look at some of these other nodes.

17:51.870 --> 17:53.010
Look at this function.

17:53.010 --> 17:56.190
It has an input parameter and look it says self.

17:56.190 --> 17:57.690
It's defaulting to self.

17:57.690 --> 17:59.730
We don't have to pass self into that one.

17:59.730 --> 18:04.710
Why do we have to keep passing self into our functions if it's always going to be self?

18:04.710 --> 18:07.350
I'd like it to default to self.

18:07.350 --> 18:13.920
So before we continue, I'm just going to really quickly close out and go back to Aura ability system

18:13.920 --> 18:19.560
library and make these functions default to the self for that input.

18:19.650 --> 18:20.850
Now how do we do that?

18:20.850 --> 18:25.570
Well, we can take a look at where we've done this before and we have done this before.

18:25.600 --> 18:33.340
We can go into our ability system folder, into ability tasks to target data under mouse.

18:33.370 --> 18:35.080
We did it here, didn't we?

18:35.110 --> 18:38.830
We added something to the meta specifiers.

18:38.830 --> 18:46.660
We have default to self and we set owning ability to default to self so we can take any of our input

18:46.660 --> 18:49.690
parameters and set them to default to self this way.

18:49.720 --> 18:57.700
So if we go into our aura ability system library for our world context objects, we can make those default

18:57.700 --> 18:58.360
to self.

18:58.360 --> 19:04.840
So what we do is we go to the U function macro, we add meta equals parentheses, and then we add our

19:04.840 --> 19:13.540
meta specifier and target data under mouse shows us it's just default to self equals and then we specify

19:13.540 --> 19:14.890
the input parameter.

19:15.070 --> 19:20.740
So I'm going to put default to self equals and we'll use world context object.

19:20.740 --> 19:27.280
And I'm going to add that to not only make widget controller params, which I don't plan on calling

19:27.280 --> 19:32.920
from Blueprint, we're calling it internally here, but hey, it's there if we need it and then get

19:32.920 --> 19:36.520
overlay widget controller can get it get attribute menu.

19:36.520 --> 19:40.750
Widget controller can get it get spell menu, widget controller can get it.

19:40.750 --> 19:47.440
And with that I'm going to relaunch the editor and use my nice blueprint pure function and not be bothered

19:47.440 --> 19:49.660
to have to get a self node.

19:50.750 --> 19:55.820
Okay, so let's get back into that blueprint where in spell menu in the graph.

19:55.820 --> 19:56.780
And look at this.

19:56.810 --> 20:01.460
Now it's defaulted to self so I don't have to right click type self.

20:01.880 --> 20:04.760
Get a reference to self and hook it in.

20:04.760 --> 20:06.500
No, we don't have to do any of that.

20:06.500 --> 20:15.950
It's already set to self and now that we have this, I'm going to call set widget controller and set

20:15.950 --> 20:18.050
my spell Menu's own widget controller.

20:18.050 --> 20:19.010
It's a big boy.

20:19.010 --> 20:20.810
It's doing it itself.

20:20.810 --> 20:26.180
And now we can make sure that this works by telling the spell menu.

20:26.180 --> 20:29.210
Widget Controller Hey, tell us what you got.

20:29.240 --> 20:33.680
Let me see what your widget controller's name is.

20:34.370 --> 20:35.900
Who is your widget controller?

20:35.900 --> 20:37.880
Let's get object name.

20:39.510 --> 20:40.820
We'll plug it in there.

20:40.830 --> 20:42.000
We'll print it out.

20:42.000 --> 20:46.020
And we should see this when we open the spell menu.

20:46.050 --> 20:47.610
I'm going to move this client out of the way.

20:47.610 --> 20:49.050
Open the spell menu there.

20:49.080 --> 20:55.140
There's my widget controller's name spell menu, Widget controller C zero.

20:55.140 --> 20:55.980
And it works.

20:55.980 --> 20:58.110
Let's see if it works on the client too.

20:58.140 --> 20:59.260
It does.

20:59.280 --> 21:03.270
We're successfully setting our spell menus, widget controller.

21:03.270 --> 21:09.750
And not only that, because of all the trouble we went through last video, our spell menu widget controller

21:09.750 --> 21:13.720
inherits some stuff from the Aura widget controller.

21:13.740 --> 21:19.050
It inherits the ability to broadcast some info about its abilities.

21:19.050 --> 21:20.190
It has the.

21:20.830 --> 21:25.420
Capability, I'll say, because ability is not their best word to use.

21:25.450 --> 21:33.790
It has the capability to broadcast ability info and that's going to be very handy for setting our equipped

21:33.790 --> 21:39.400
abilities row here so we can see the same info that we see down here.

21:39.400 --> 21:40.930
So we're going to do that next.

21:41.170 --> 21:42.760
Really exciting.

21:42.760 --> 21:45.610
I'll see you in the next video where we continue this.

21:45.640 --> 21:46.540
See you soon.
