WEBVTT

00:07.290 --> 00:08.400
Welcome back.

00:08.400 --> 00:12.090
Now we have the ability to click on a slot and select it.

00:12.300 --> 00:18.390
But before we click on a slot and select it, our Play and delete buttons should be disabled.

00:18.390 --> 00:22.860
And only when we have a valid slot selected should we enable them.

00:22.860 --> 00:28.860
Now, when we have a valid slot selected, play and Delete should both be enabled, right?

00:28.860 --> 00:33.270
So a valid slot selected delegate is in order.

00:33.270 --> 00:38.340
We need to broadcast something to our main load screen widget.

00:38.550 --> 00:41.790
And then we can have these buttons be functional.

00:42.060 --> 00:48.990
Which means we'll need some kind of blueprint callable function for play button and delete button pressed.

00:49.380 --> 00:52.710
So that means we need a few things on the C plus plus side.

00:52.710 --> 00:59.700
If we go back to our load screen ViewModel mVVM load screen, we can start adding things to it.

00:59.970 --> 01:04.380
Now I don't need my load screen HUD, I'm going to close out of that.

01:05.090 --> 01:08.570
And back in mVVM load screen H.

01:08.570 --> 01:15.080
We can have a delegate to broadcast here for whenever we've selected a valid slot.

01:15.620 --> 01:20.270
And before we go and do that, let's take a look at where we're going to broadcast it.

01:20.270 --> 01:25.790
Well, when select slot button pressed is called, we know that we've just selected a slot.

01:25.790 --> 01:30.140
And we know that this will never be called if we haven't just selected a slot.

01:30.140 --> 01:30.740
Right.

01:30.740 --> 01:32.900
So we can broadcast here.

01:32.900 --> 01:39.410
When we've selected a slot, we can be certain that we've got a valid slot selected at this point.

01:39.650 --> 01:41.390
So that's where we're going to broadcast it.

01:41.390 --> 01:42.800
Let's make that delegate.

01:43.220 --> 01:43.550
Now.

01:43.550 --> 01:50.360
It's going to be basically the same as our load slot delegate f enable selected slot.

01:50.360 --> 01:57.470
So we'll just copy that delegate declaration and go back to our mVVM load screen.

01:57.470 --> 02:02.900
Paste it here and we'll call this F slot selected.

02:03.710 --> 02:07.280
And this will have a bool called be selected.

02:07.700 --> 02:13.940
Although the bull is not really all that necessary because this is really only going to be broadcast

02:13.940 --> 02:21.470
with true, as we can't select something unless we're on this menu, let's look at the menu itself.

02:21.470 --> 02:28.610
We can't ever select a slot if there is no slot here, because we'll never actually see this widget

02:28.610 --> 02:32.480
here unless there is a selected slot, unless it's taken.

02:34.760 --> 02:38.030
So arguably this could be zero parameters.

02:38.030 --> 02:39.800
We could remove that one param.

02:39.800 --> 02:42.290
And this can just be f slot selected.

02:42.290 --> 02:43.280
That's it.

02:43.670 --> 02:45.650
So why don't we just do that for now.

02:45.650 --> 02:47.360
We'll just have f slot selected.

02:47.360 --> 02:48.950
We'll put this right here.

02:49.250 --> 02:50.480
F slot selected.

02:50.480 --> 02:52.280
We'll call it slot selected.

02:53.050 --> 02:57.280
We'll give it a U property and we'll make it blueprint assignable.

02:57.610 --> 03:05.470
And as soon as we've selected a slot and select slot button pressed, we'll take our slot selected and

03:05.470 --> 03:06.670
broadcast it.

03:08.280 --> 03:12.090
Now we just need to bind to this in our load screen.

03:12.300 --> 03:16.500
Now in our load screen that's going to be the load screen widget itself.

03:17.270 --> 03:18.650
And UI.

03:20.060 --> 03:21.380
Load menu.

03:21.980 --> 03:23.570
LBP load screen.

03:23.900 --> 03:31.340
And in this widget event blueprint initialize widget is a good place to put it, as we know that this

03:31.340 --> 03:32.690
is going to be called.

03:32.690 --> 03:38.360
After we have a valid load screen view model, we can remind ourselves of that.

03:38.360 --> 03:41.240
Where are we calling that for the load screen?

03:41.270 --> 03:46.940
Well, we can go to Load screen HUD and see that we're calling it here after the load screen widget

03:46.940 --> 03:48.260
has been created.

03:48.680 --> 03:52.400
And this has all happened before the view model has been created.

03:52.550 --> 03:58.970
So as long as that view model exists before the load screen widget has been created, then when it has

03:58.970 --> 04:03.320
been constructed and finds its own view model, we know that it'll have a valid one.

04:03.320 --> 04:07.010
So after blueprint initialize widget is just fine.

04:07.010 --> 04:12.890
So in blueprint initialize widget, this is a perfectly fine place to bind to that delegate.

04:12.890 --> 04:15.020
But we have to compile in order to do that.

04:15.020 --> 04:18.770
So let's close the editor and we'll go ahead and recompile.

04:19.680 --> 04:21.240
We'll run in debug mode here.

04:23.420 --> 04:23.960
All right.

04:23.960 --> 04:26.060
So let's get these widgets open.

04:26.420 --> 04:31.160
And right here in load screen after blueprint initialize widget.

04:31.550 --> 04:33.560
Let's go ahead and organize this.

04:33.560 --> 04:35.150
We'll add a sequence node.

04:35.480 --> 04:38.450
And the first thing we can do is initialize those slots.

04:38.450 --> 04:39.320
That's fine.

04:39.860 --> 04:46.040
And the next thing we can do is we can assign an event to our new delegate.

04:46.040 --> 04:49.460
We need to get BP load screen ViewModel.

04:51.600 --> 04:55.020
And we can assign to slot selected.

04:58.470 --> 05:04.650
And as soon as a slot is selected, that's when we can decide to enable.

05:05.510 --> 05:12.920
Those buttons, the play and delete buttons, which we should make sure their variables they are and

05:12.920 --> 05:15.050
they should be disabled by default.

05:15.050 --> 05:16.970
We can do that right away.

05:16.970 --> 05:21.650
We can do that in event construct or event Pre-construct.

05:22.220 --> 05:25.700
Let's just go ahead and do it here in event construct.

05:28.650 --> 05:33.750
We can get button, delete and button play from both of these.

05:33.780 --> 05:35.460
We'll get the button widget.

05:39.850 --> 05:42.130
And we'll call set is enabled on them.

05:45.420 --> 05:48.360
And we'll make sure that false is passed in.

05:49.140 --> 05:50.280
We'll do it for both.

05:53.290 --> 06:03.880
And we'll go ahead and just collapse these to a function called disable play and delete buttons.

06:05.890 --> 06:10.930
And if we wanted to, we could pass a boolean in there to enable both of them.

06:12.210 --> 06:13.980
We might as well just do that.

06:13.980 --> 06:15.540
So let's take this function.

06:15.540 --> 06:18.510
We'll add an input of type boolean to it.

06:20.070 --> 06:20.940
Called.

06:21.780 --> 06:28.770
Should enable or just enable either one, and we can rename this to enable.

06:32.950 --> 06:37.000
And just use should enable pass that into both.

06:37.180 --> 06:42.880
And now we have a more versatile function that can also enable them, because as soon as a valid slot

06:42.880 --> 06:44.710
is selected, we're going to want to do that.

06:44.710 --> 06:46.180
Let's call it passing in.

06:46.180 --> 06:46.720
True.

06:47.350 --> 06:50.260
So now with that we can press play.

06:51.370 --> 06:51.580
OOP.

06:51.580 --> 06:52.960
Not in this level though.

06:52.960 --> 06:54.400
Let's go back to maps.

06:54.400 --> 06:55.420
Load menu.

06:55.420 --> 06:56.530
Press play.

06:57.120 --> 07:00.390
And now the play and delete buttons are disabled.

07:00.390 --> 07:01.140
Oh, look at this.

07:01.140 --> 07:05.760
I can click and possess the pawn and I can fly around.

07:05.760 --> 07:07.080
That's not what I want.

07:07.080 --> 07:08.310
We'll take care of that soon.

07:08.310 --> 07:10.140
But these are disabled.

07:10.140 --> 07:13.470
And once we've selected a slot, they become enabled.

07:13.470 --> 07:14.700
And that's what we wanted.

07:16.020 --> 07:16.410
Cool.

07:16.410 --> 07:19.320
So that takes care of what I wanted to do in this video.

07:19.320 --> 07:23.430
And that's just enabling those buttons when we've selected a slot.

07:23.760 --> 07:30.060
But we can also make sure that we can't fly around and click in the viewport and possess that default

07:30.060 --> 07:30.840
pawn.

07:30.840 --> 07:33.000
And that's actually quite easy.

07:33.270 --> 07:39.300
We can do that either in the level blueprint or when we spawn this widget.

07:39.330 --> 07:44.970
I think a perfectly fine place to do it could be in our load screen widget blueprint.

07:46.540 --> 07:51.370
An event construct, we can just call get player controller.

07:52.430 --> 07:57.890
We can call set input mode UI only.

07:58.950 --> 08:02.040
We can set the widget to focus to this widget that we're in.

08:02.070 --> 08:04.320
Now we can get a reference to self.

08:05.500 --> 08:10.720
And pass that in as the widget to focus, and we can take the player controller.

08:11.050 --> 08:13.270
Set show mouse cursor to true.

08:15.370 --> 08:18.700
And now we should only be able to interact with UI.

08:19.280 --> 08:21.830
We can click around we can't possess.

08:22.340 --> 08:26.060
We can select a slot and we can press play and delete.

08:26.630 --> 08:27.470
Perfect.

08:27.910 --> 08:31.390
Now we need those play and delete buttons to be functional, right.

08:31.390 --> 08:33.100
So we'll do that next.

08:33.100 --> 08:34.180
I'll see you soon.
