WEBVTT

00:07.090 --> 00:08.080
Welcome back.

00:08.080 --> 00:17.560
Now if we load up our menu here, as you can see I have three slots saved just from playing around entering

00:17.560 --> 00:21.100
in a name no name and saving.

00:21.100 --> 00:28.090
We have these slots saved and as we've seen we can go in and delete any of these from our save games.

00:28.090 --> 00:33.940
I can delete the third one there and it won't show up anymore because it no longer exists.

00:34.300 --> 00:40.510
But as soon as we do enter something in here, now we have a select slot button.

00:40.510 --> 00:41.620
This one's up a little bit.

00:41.620 --> 00:47.620
It's raised because with no text there, well it sort of collapses that text box there.

00:47.620 --> 00:52.390
But either way we have a select slot button which is not implemented.

00:52.390 --> 00:54.940
And we want to be able to select a slot.

00:55.660 --> 01:02.560
Now, what that means is as soon as we have a slot selected, we should remember that somehow, somewhere.

01:02.560 --> 01:07.660
And that should affect what happens if we press our play or delete buttons.

01:07.660 --> 01:11.590
So we need a way to know which slot is selected.

01:11.590 --> 01:18.520
First of all, and as soon as we do select a slot, if any of the other two are selected, we need to

01:18.520 --> 01:19.780
update those as well.

01:19.780 --> 01:22.540
If we select a slot, how are we going to know it's selected?

01:23.020 --> 01:26.500
Well, a good way is to disable the button, right?

01:26.500 --> 01:33.880
So we need a way to first of all disable the button and then respond to knowing which slot is selected.

01:34.210 --> 01:36.460
Now if we go into our widgets.

01:37.630 --> 01:43.750
And UI load menu and take a look at the take in widget.

01:44.710 --> 01:47.920
Our select slot button if we go to the graph.

01:48.460 --> 01:55.750
Has its onClick event and it's calling select slot button pressed, letting the mVVM load screen view

01:55.750 --> 01:58.780
model know which button has been pressed.

01:58.810 --> 02:02.470
Another thing we can do is we can disable the button itself.

02:02.620 --> 02:06.250
We can take our select slot button.

02:07.120 --> 02:11.080
And with its button we can call set is enabled.

02:15.320 --> 02:19.370
And we can set it to not enabled, we can disable the button.

02:19.370 --> 02:23.330
Now all that's going to do is if we click on it, it'll be disabled.

02:23.330 --> 02:25.820
If we click on any of them, they'll all be disabled.

02:25.820 --> 02:33.290
And when that happens, we should probably go and enable all the other buttons if they are disabled

02:33.290 --> 02:33.920
already.

02:33.920 --> 02:37.130
So that very basic task we can handle.

02:37.130 --> 02:44.180
We know that our load screen view model is going to know which button was just selected, and it can

02:44.180 --> 02:47.570
set the others to be enabled.

02:47.960 --> 02:54.170
So how is it going to do that if it doesn't know anything about the actual widget blueprints themselves?

02:54.170 --> 02:58.970
Well, it has a reference to the other view models, the load screen view models.

02:58.970 --> 03:06.170
Those load screen view models are capable of broadcasting data, and we can easily broadcast data up

03:06.170 --> 03:07.520
to their widgets.

03:07.760 --> 03:13.340
For example, if we go to our load slot view model, we've already made a delegate to broadcast the

03:13.340 --> 03:14.870
widget switcher index.

03:14.870 --> 03:21.620
We can make another one to broadcast whether or not to enable the select slot button, right.

03:21.620 --> 03:28.370
So we can make a new delegate called F enable select slot button.

03:29.090 --> 03:34.550
And this can broadcast a boolean and it can be called be enable.

03:34.550 --> 03:38.210
So we can have a blueprint assignable delegate here.

03:39.650 --> 03:43.700
And we can call it enable select slot button.

03:43.910 --> 03:46.190
And it can be of course blueprint assignable.

03:46.190 --> 03:46.580
Right.

03:46.580 --> 03:49.550
And we can broadcast a value for this.

03:49.940 --> 03:54.680
So we need to bind to this in our load slot taken.

03:54.680 --> 03:56.720
And we're going to have to compile to do that.

03:56.720 --> 04:03.080
But before we go about doing that we can also realize that as soon as select slot button pressed is

04:03.080 --> 04:07.430
called, we can then tell those slots to broadcast that delegate.

04:07.910 --> 04:14.480
So here in our load screen ViewModel and select slot button pressed, the first thing we can do is we

04:14.480 --> 04:22.820
can access our load slots, and we can broadcast that delegate with a boolean based on which slot there

04:22.820 --> 04:23.570
is.

04:23.570 --> 04:25.430
So we can loop through those slots.

04:25.430 --> 04:28.850
Here's a loop in load data where we're doing just that.

04:28.850 --> 04:30.380
We can copy that.

04:30.970 --> 04:37.780
And we can have a for loop here where we're looping over each of our load slots, and we can even tell

04:37.810 --> 04:40.540
each of the load slots to broadcast that delegate.

04:40.540 --> 04:44.560
We can take that load slot and we have to get value from it.

04:44.560 --> 04:46.600
That gives us the load slot.

04:47.050 --> 04:54.250
We can access that enable select slot button delegate and we can broadcast.

04:55.030 --> 05:03.340
Now as long as they bind some event to this delegate in those widgets, then they can respond by enabling

05:03.340 --> 05:04.630
or disabling the button.

05:04.630 --> 05:10.120
But if we just selected a button with this slot, the slot that's passed in, we only want to disable

05:10.120 --> 05:11.950
that one and enable the others.

05:11.950 --> 05:17.950
So what we can do is we can check the key here and see if it's equal to that slot.

05:17.950 --> 05:31.420
So we can say if load slot dot key is equal to slot in that case then this is the button that we should

05:31.420 --> 05:32.170
disable.

05:32.170 --> 05:37.300
So really if we go back into blueprint we don't really even have to disable anything here as long as

05:37.300 --> 05:38.530
we bind to a delegate.

05:38.530 --> 05:44.350
Because that delegate can be broadcast and we can respond to it and disable the button there, we can

05:44.350 --> 05:47.200
simply get our load slot dot value.

05:48.620 --> 05:53.420
And broadcast, and we want to disable the button so we can pass false in here.

05:54.090 --> 05:56.040
Now for all the others.

05:56.040 --> 06:00.930
In other words, there's an else case here we can broadcast true to enable those buttons.

06:00.930 --> 06:05.460
So what we'll do is paste this line and change this from false to true.

06:05.460 --> 06:11.370
And now all we need to do is make sure that those widgets bind to enable select slot button.

06:12.650 --> 06:16.280
So we can save all here and close the editor.

06:17.100 --> 06:22.200
And we can compile and relaunch and bind to enable select slot button.

06:22.200 --> 06:23.280
Let's try that.

06:24.830 --> 06:28.850
So back here in the editor, here's our load slot taken.

06:29.270 --> 06:36.770
We can have this widget bind a callback as soon as we know that it has a valid load slot view model.

06:36.800 --> 06:41.780
Now in event blueprint initialize widget we know that it does.

06:42.200 --> 06:49.010
Because if we remind ourselves by going back to our widget switcher and our widget switcher and initialize

06:49.010 --> 06:49.820
slot.

06:50.180 --> 06:53.540
Here's where it's finding the load screen view model.

06:53.540 --> 06:59.300
It's finding the specific load slot view model based on the slot index.

06:59.300 --> 07:05.450
It's setting its own member variable, and then it's going through each of its three children and setting

07:05.450 --> 07:12.260
each of their BP load slot view models to the load slot view model here, because those view models

07:12.260 --> 07:19.010
are set to be assigned manually, and only after assigning that view model does it call blueprint initialize

07:19.010 --> 07:19.430
widget.

07:19.430 --> 07:23.360
So we know that in blueprint initialize widget those view models are set.

07:23.360 --> 07:28.790
It's a lot like widget controller is set in the system we created using MVC.

07:28.970 --> 07:35.690
So because of that, we know that it's safe to bind to our load slot view model.

07:35.690 --> 07:45.050
If we search for BP load slot view model we can get that get BP load slot view model and we can drag

07:45.050 --> 07:49.250
off of it and assign enable select slot button.

07:49.250 --> 07:53.330
Now we're going to hook this up straight from the other bind.

07:53.330 --> 07:55.970
Not the event but the bind.

07:56.570 --> 07:59.420
As this is only fired off when clicking the button.

07:59.420 --> 08:03.590
This is as soon as that ViewModel is valid.

08:04.760 --> 08:12.440
And as soon as we get the broadcast here, we can take our button, the select slot button.

08:13.580 --> 08:20.870
Grab that, get the button from it and call set is enabled.

08:22.670 --> 08:25.910
And we'll pass in the boolean enable.

08:27.570 --> 08:28.980
Now let's test this out.

08:28.980 --> 08:30.930
We'll go back to our maps.

08:30.960 --> 08:32.340
Go to load menu.

08:32.370 --> 08:34.560
We'll save all press play.

08:34.560 --> 08:38.400
And if we select a slot it becomes disabled.

08:38.400 --> 08:40.860
Now because of that delegate broadcast.

08:40.860 --> 08:44.580
And if we select another slot, all the others become enabled.

08:45.700 --> 08:49.270
Now it's clear which one is selected, at least visually.

08:49.270 --> 08:53.530
But we also need to know which one is selected in code.

08:53.950 --> 08:59.770
We should have some load slot designated as the selected slot, and we're going to handle that next.

08:59.770 --> 09:01.000
We'll do that in the next video.

09:01.000 --> 09:06.310
For now we know that we can affect the other widgets whenever we select one of them.

09:06.610 --> 09:07.480
Pretty cool.

09:07.960 --> 09:08.590
Great job.

09:08.590 --> 09:11.080
We'll continue with this in the next video.

09:11.110 --> 09:12.190
I'll see you soon.
