WEBVTT

00:07.030 --> 00:08.200
Welcome back.

00:08.650 --> 00:15.790
Now we know that we need a few classes to get our UI system started, so I'm going to go into C plus

00:15.790 --> 00:21.220
plus classes aura public, and we'll make a new C plus plus class here.

00:21.310 --> 00:25.720
And I'm going to choose all classes and search for user widget.

00:25.720 --> 00:32.950
I'd like to have my own base user widget C plus plus class and I'm going to use this class for my user

00:32.950 --> 00:34.720
widgets in this project.

00:34.750 --> 00:38.970
That way they're all compatible and share the same base functionality.

00:38.980 --> 00:41.080
So I'm going to choose user widget.

00:41.110 --> 00:48.580
Go to next and I'll place this in a folder called UI slash Widgets.

00:48.880 --> 00:56.020
That way I can have all UI related stuff in UI and my aura user widget in widgets.

00:56.020 --> 01:02.110
In fact, I'll just say widget to keep with the convention that I'm using throughout the course without

01:02.110 --> 01:06.820
the s at the end we have a player folder, a character folder and so on.

01:06.820 --> 01:12.470
We're going to have a widget folder and this will be called Aura User Widget.

01:12.500 --> 01:15.370
This will be our specific user widget.

01:15.380 --> 01:17.060
I'm going to create the class.

01:17.660 --> 01:21.950
And I'm also going to create the widget controller class.

01:21.950 --> 01:28.520
So I'm going to right click New Cplusplus class and my widget controller is just going to be a simple

01:28.520 --> 01:29.450
object.

01:29.450 --> 01:39.440
So we'll have a U object and I'm going to click next, put this in the UI folder slash widget controller

01:39.440 --> 01:48.320
folder, and this will be called my Aura Widget Controller class so we can make widget controllers and

01:48.320 --> 01:49.970
base them off of this class.

01:49.970 --> 01:54.830
And this will be designed to be the controller for all widgets in our system.

01:54.830 --> 01:58.850
So I'm going to click Create Class and close the editor.

01:58.850 --> 02:06.440
And here in writer, I should be seeing the UI folder popping up in both public and private.

02:06.830 --> 02:08.060
And there it is.

02:08.060 --> 02:16.610
It took a second, but now I have UI and in UI we have widget inside of which we have aura user, widget

02:16.610 --> 02:21.150
and widget controller which contains aura widget controller.

02:21.270 --> 02:27.750
So now that we have these two classes, we can start making them compatible with one another.

02:27.750 --> 02:33.690
Now my Aura user widget class, this will be our base class for widgets.

02:33.690 --> 02:39.000
I want this class to have a member variable for its widget controller.

02:39.000 --> 02:43.800
I would like our widgets to have the concept of a controller.

02:44.260 --> 02:48.250
So any given widget is going to have its controller set.

02:48.250 --> 02:56.380
And when the widget controller broadcasts data, our widgets will receive that data and respond to it.

02:56.380 --> 03:03.340
So our dependencies will be one way from or a user widget to or a widget controller.

03:03.370 --> 03:09.910
The widget controller isn't going to know what widgets it's associated with, but the widgets themselves

03:09.910 --> 03:12.100
will know what their controller is.

03:12.100 --> 03:19.900
So we're going to make a public section, and here in the public section I'm going to have a T object

03:19.900 --> 03:20.740
pointer.

03:22.560 --> 03:26.430
And the type for this will simply be you object.

03:27.120 --> 03:29.760
So it's going to be very generic.

03:29.790 --> 03:35.640
The way we're setting this up, the widget controller could literally be any object that makes it a

03:35.640 --> 03:37.080
little bit more versatile.

03:37.260 --> 03:41.040
And we're going to call this pointer simply widget controller.

03:41.250 --> 03:49.290
Now, widget controller is going to need to be accessed from blueprints as all of our user widget classes

03:49.290 --> 03:56.490
are going to be widget blueprints that use this C plus plus class as their base and widget controller

03:56.490 --> 03:59.940
should be a new property with access in blueprints.

03:59.940 --> 04:06.390
We're going to make it blueprint read only so that we can only access but not set it directly.

04:06.720 --> 04:14.030
Now, most of what our user widgets are responsible for is the visuals for the widgets.

04:14.040 --> 04:21.460
Basically, they're responsible for what the widgets look like on the screen when they receive data.

04:21.700 --> 04:29.470
And whenever we set our widget controller for a given user widget, we're going to want to initialize

04:29.470 --> 04:30.250
the visuals.

04:30.250 --> 04:34.020
We're going to want to do something visually in response.

04:34.030 --> 04:40.180
In other words, as soon as the widget controller is set, we now know that we can get whatever data

04:40.180 --> 04:42.170
we want from that widget controller.

04:42.190 --> 04:48.880
So we're going to want a sort of begin play like function that we can call as soon as the widget controller

04:48.880 --> 04:49.900
is set.

04:50.170 --> 04:52.810
So I'm going to make a protected function.

04:52.810 --> 04:58.750
I'll make a protected section and make a void function called widget controller set.

04:59.350 --> 05:02.680
And I want this to be a blueprint implementable event.

05:02.680 --> 05:08.230
So I'll give it a new function macro with blueprint implementable event.

05:08.680 --> 05:14.830
So this way, whenever we set the widget controller for a given widget, we'll also call this function

05:14.830 --> 05:16.510
widget controller set.

05:16.510 --> 05:22.810
And as soon as that happens, anything we want in the blueprint that we would like to do in response

05:22.810 --> 05:26.740
to the widget controller set, we'll do that in the blueprint.

05:27.430 --> 05:34.150
So that means we should associate setting the widget controller with calling widget controller set.

05:34.150 --> 05:37.230
These should be tied closely together.

05:37.240 --> 05:41.050
So what we'll do is we'll make a function to set the widget controller.

05:41.050 --> 05:47.020
I'll put this right at the top of the public section and it's going to be a void function.

05:47.020 --> 05:55.180
It'll be called set widget controller, and it's going to take an input of type you object and we'll

05:55.180 --> 05:59.650
call this in widget controller like so.

05:59.650 --> 06:02.020
And I'd like to be able to call this from blueprints.

06:02.020 --> 06:09.130
So I'll make it a new function with blueprint callable so we can set the widget controller from Blueprint

06:09.130 --> 06:10.030
if we want.

06:10.030 --> 06:14.020
And I'll generate the definition and the definition will be simple.

06:14.050 --> 06:23.980
All we want to do is set widget controller to in widget controller, but we also want to call widget

06:23.980 --> 06:26.980
controller set.

06:27.720 --> 06:30.300
Now this is a blueprint, implementable event.

06:30.300 --> 06:36.900
So if we set the widget controller, we should do so with the setter and that way this will be kicked

06:36.900 --> 06:43.110
off and we're safe to assume that when we implement widget controller set in any blueprint, we know

06:43.140 --> 06:47.130
our widget controller will be set as it was just set.

06:47.730 --> 06:49.140
Okay, perfect.

06:49.170 --> 06:56.940
Now, or a widget controller is going to be responsible for getting any data from the system, from

06:56.940 --> 06:59.460
the model in this architecture.

06:59.460 --> 07:06.660
That means our ability system component, our attribute set, our character, anything that really matters

07:06.660 --> 07:08.130
relating to our data.

07:08.160 --> 07:15.780
The widget controller will be responsible for getting that data and broadcasting it over to any widgets

07:15.780 --> 07:17.910
that have their controller set to it.

07:18.180 --> 07:26.250
So what I'd like our widget controller to have is a set of variables from which it's going to get any

07:26.250 --> 07:28.210
information, any data.

07:28.740 --> 07:34.950
And for the purposes of this game project, I'm interested in four main classes.

07:35.340 --> 07:37.650
I'm interested in the ability system component.

07:37.650 --> 07:44.070
Obviously I'm interested in the attribute set and I'm also interested in the player state and the player

07:44.070 --> 07:44.970
controller.

07:45.640 --> 07:46.930
Throughout the game.

07:46.930 --> 07:51.370
Our widget controller may need to have access to the four of those.

07:51.550 --> 07:55.720
So that's how our dependencies will be set up for our widget controllers.

07:55.720 --> 07:57.730
We're going to have those four variables.

07:58.330 --> 08:01.030
So I'd like to make a protected section.

08:02.730 --> 08:09.390
Since any child classes of or a widget controller are going to want to access these to get data from

08:09.390 --> 08:13.170
them or to subscribe to delegates broadcast by them.

08:13.170 --> 08:17.010
And those four objects are going to be the player controller.

08:17.010 --> 08:25.440
So we'll make a T object pointer of type A player controller and we'll call this player controller and

08:25.440 --> 08:35.370
this gets a new property and I'm going to give this a blueprint read only with a category of widget

08:35.370 --> 08:36.240
controller.

08:38.210 --> 08:41.990
So the widget controller is going to have a player controller variable.

08:42.020 --> 08:44.630
It's also going to have a player state variable.

08:44.630 --> 08:50.630
So I'm going to make a T object pointer of type A player state as we will have important information

08:50.630 --> 08:53.720
on the player state that will need to know about in the HUD.

08:53.750 --> 08:55.880
So we're going to call this one player state.

08:56.330 --> 09:01.610
This one also gets a new property with the same specifiers and category.

09:01.880 --> 09:06.830
Now, in addition to that, we need the ability system component and the attribute set.

09:06.830 --> 09:11.690
So we'll make a T object pointer of type U ability system component.

09:13.130 --> 09:15.920
And we'll add a forward declaration for that.

09:15.920 --> 09:19.010
And this will be called ability system component.

09:19.550 --> 09:24.230
And we'll also have a T object pointer of type attribute set.

09:24.260 --> 09:28.130
We'll add a forward declaration for that and call it attribute set.

09:28.130 --> 09:34.700
And just like the others, we need U property and we'll make this blueprint read only.

09:35.030 --> 09:36.950
Category Widget Controller.

09:36.950 --> 09:43.880
And now the widget controller has four main variables and these are the variables that it's going to

09:43.880 --> 09:48.470
get the data from in order to broadcast to our widgets.

09:48.830 --> 09:52.110
So now that we have these, we need to set them up.

09:52.130 --> 09:52.670
Right.

09:52.670 --> 09:53.930
We've just created classes.

09:53.930 --> 09:57.950
We've never actually created any instances of these classes.

09:57.950 --> 10:03.680
And in our game we're going to want a widget controller to control certain widgets.

10:03.680 --> 10:09.650
For example, we may want an overlay that shows health bars and things like that, but we may also want

10:09.680 --> 10:14.760
other widgets like menus attribute menus, spell menus, things like that.

10:14.940 --> 10:19.680
And each of these is going to need a widget controller that can broadcast data to it.

10:19.680 --> 10:22.020
So we'll set that system up next.

10:22.430 --> 10:23.330
For now.

10:23.330 --> 10:24.610
This is looking good.

10:24.620 --> 10:32.210
We should compile our code, make sure we don't have any typos, make sure everything compiles and we

10:32.210 --> 10:33.230
see that it does.

10:33.260 --> 10:34.160
Perfect.

10:34.250 --> 10:37.260
So we'll continue with this in the next video.

10:37.280 --> 10:38.450
I'll see you soon.
