WEBVTT

00:07.120 --> 00:08.140
Welcome back.

00:08.140 --> 00:10.570
So we've made an are you sure widget.

00:10.570 --> 00:12.010
So we can select a slot.

00:12.010 --> 00:13.180
We can hit delete.

00:13.180 --> 00:15.130
And we have the ability to back out.

00:15.130 --> 00:16.210
We can cancel.

00:16.210 --> 00:20.140
And then we can hit delete again and it pops up again.

00:20.440 --> 00:22.960
So this gives us a nice early exit.

00:22.960 --> 00:26.260
But once we actually hit delete we want something to happen.

00:26.260 --> 00:26.800
Right.

00:26.950 --> 00:30.640
So we need something to happen in response to clicking on delete.

00:31.090 --> 00:36.730
Now are you sure needs to bind something to that delete button.

00:37.840 --> 00:40.900
I'm going to delete event tick and get it out of the way.

00:40.900 --> 00:43.540
And we're going to get that button delete.

00:44.130 --> 00:46.830
We're going to get its button widget.

00:47.410 --> 00:50.140
And we're going to assign to Onclicked.

00:51.250 --> 00:53.020
And we need to do something.

00:53.020 --> 00:53.440
Now.

00:53.440 --> 01:01.570
We could try to get that load screen view model and call a blueprint callable function on it to delete

01:01.570 --> 01:02.200
something.

01:02.200 --> 01:08.470
I don't want to do that, because this is kind of a generic widget that could be used as an rusher for

01:08.470 --> 01:13.750
anything, especially if we make that message a variable that we can set anywhere.

01:13.900 --> 01:20.200
So for that reason, I'm just going to broadcast a generic delegate, just like we did for our cancel

01:20.200 --> 01:21.070
button clicked.

01:21.070 --> 01:23.110
We're going to have another event dispatcher.

01:23.110 --> 01:27.250
Let's add one and this will be our delete button clicked.

01:28.450 --> 01:33.490
And we can simply broadcast that before calling remove from parent.

01:33.490 --> 01:36.310
So let's broadcast delete button clicked.

01:36.310 --> 01:40.510
We'll call that and we'll call remove from parent after that.

01:40.510 --> 01:44.230
And that is going to remove this widget.

01:44.230 --> 01:48.580
But also inform whoever subscribes to this delete button.

01:48.580 --> 01:51.670
Clicked delegate that the delete button has been clicked.

01:51.670 --> 01:55.480
And our load screen widget is going to subscribe to that.

01:56.120 --> 02:02.150
So it's going to subscribe to another delegate on the rusher widget.

02:02.660 --> 02:10.370
So let's take that rusher widget and let's assign something to delete button clicked.

02:12.830 --> 02:16.370
So when the delete button has been clicked, we're going to do something.

02:16.370 --> 02:18.860
Well, the delete button has been clicked.

02:18.860 --> 02:28.010
So what we can do is we need to actually delete that slot because we're deleting the selected slot.

02:28.040 --> 02:33.470
Now we don't know anything about what slot has been selected from the C plus plus side.

02:33.470 --> 02:40.040
In our load screen view model, we need to know as soon as we've selected a slot which slot is currently

02:40.040 --> 02:40.760
selected.

02:40.760 --> 02:43.340
So that's something we should keep track of.

02:43.870 --> 02:46.150
And as soon as we click on delete.

02:46.150 --> 02:49.510
And not this one, but this one here, the real delete.

02:49.510 --> 02:54.430
Well, we need to tell the ViewModel hey, something has been deleted, right?

02:54.430 --> 02:59.110
So if we click on delete here, we do want that widget to go away.

02:59.110 --> 03:03.910
And perhaps we still want these two buttons Play and delete to be disabled.

03:03.910 --> 03:07.900
Because at this point the selected slot should no longer exist.

03:07.900 --> 03:10.150
So we really shouldn't have a selected slot.

03:10.150 --> 03:14.590
But the ViewModel needs to have the concept of a selected slot.

03:14.590 --> 03:21.070
So what we need to do is every time we select a slot, we need to tell the ViewModel, hey, remember

03:21.070 --> 03:23.410
which slot is selected, right?

03:23.410 --> 03:24.730
So a couple of things.

03:24.730 --> 03:28.990
We need our load screen widget to call a blueprint callable function.

03:28.990 --> 03:34.150
On the load screen view model a delete button clicked or delete button pressed.

03:34.150 --> 03:34.570
Right.

03:34.570 --> 03:37.510
So let's go ahead and close out.

03:37.510 --> 03:41.650
Save everything here and go to our load screen ViewModel.

03:41.650 --> 03:43.870
That's mVVM load screen.

03:44.850 --> 03:48.990
And we're going to need a delete button pressed function.

03:48.990 --> 03:53.370
And it's going to need to know which slot is selected.

03:53.370 --> 04:01.830
So two things we're going to first of all create that blueprint callable function void delete button

04:01.830 --> 04:02.760
pressed.

04:02.970 --> 04:09.090
And I'm not going to pass anything into it from the widget because our load screen widget doesn't really

04:09.090 --> 04:11.160
know what is selected.

04:11.160 --> 04:13.830
It just knows that the delete button has been pressed.

04:13.830 --> 04:15.810
So this will be blueprint callable.

04:15.810 --> 04:17.760
Let's generate a definition.

04:17.760 --> 04:20.220
And what do we want to do?

04:20.220 --> 04:23.490
Well, we need to know which slot is currently selected.

04:23.490 --> 04:29.670
Well that means when we select a slot with select slot button pressed we need to know which slot we're

04:29.670 --> 04:30.450
selecting.

04:30.750 --> 04:31.980
So we should save this.

04:31.980 --> 04:38.310
We should at least save the slot index or save the actual pointer to the slot the load slot.

04:38.310 --> 04:44.130
Either one of those is fine, but we need a selected slot to save.

04:44.650 --> 04:46.450
This can be a private variable.

04:46.450 --> 04:51.370
It can be a um VM load slot pointer or it could be an integer.

04:51.370 --> 04:52.330
It doesn't matter.

04:52.330 --> 04:55.210
I'm just going to store a pointer to the load slot.

04:55.210 --> 04:57.700
And we're going to call this selected slot.

04:58.960 --> 05:01.360
And it's going to get a U property.

05:02.570 --> 05:07.970
And our selected slot is going to be set as soon as we've called select slot button pressed.

05:07.970 --> 05:12.080
So right here we're going to say selected slot equals.

05:12.700 --> 05:16.750
And it's going to be the slot with this particular slot index.

05:16.750 --> 05:18.970
It's going to be load slots.

05:20.120 --> 05:21.230
Of slot.

05:22.590 --> 05:27.900
So now we have the selected slot stored in this selected slot pointer.

05:27.900 --> 05:34.440
And now when the delete button is actually pressed now we can decide how to delete that slot.

05:34.440 --> 05:37.500
And then of course update the widget switcher as well.

05:37.860 --> 05:41.310
So how are we going to delete a slot.

05:41.550 --> 05:44.010
We need to delete that slot from memory.

05:44.040 --> 05:46.320
We've already seen how we can do that.

05:46.320 --> 05:48.330
If we look at our A game mode base.

05:48.600 --> 05:55.740
If we go to save slot data, we've seen that we can call delete game in slot, and it's a good idea

05:55.740 --> 05:57.960
to check if that slot exists first.

05:57.960 --> 06:03.870
This is something we can create a function for on the game mode, so that we don't have to handle deleting

06:03.870 --> 06:05.580
slots from a ViewModel.

06:05.580 --> 06:09.780
We can let the very important game mode handle that for us.

06:10.140 --> 06:16.200
So this right here could be refactored into a nice game mode function delete slot.

06:16.200 --> 06:17.010
Let's do that.

06:17.010 --> 06:20.610
Let's make an aura game mode base function called delete slot.

06:20.910 --> 06:22.080
It can be void.

06:22.080 --> 06:27.960
We'll call it delete slot, and it can take in the slot name and the slot index.

06:27.960 --> 06:29.910
We'll pass those both in here.

06:30.120 --> 06:35.940
Alternatively, we could even just pass in a mVVM load slot if we wanted to do that.

06:35.940 --> 06:42.930
But I'm going to pass in the slot name and the slot index, and we'll just have this delete slot function.

06:42.930 --> 06:46.170
We'll generate the definition and it's going to do this.

06:47.540 --> 06:53.450
So we'll copy those lines there, check to see if it exists, and then we'll use the slot name.

06:54.240 --> 06:55.860
And the slot index.

06:57.450 --> 06:58.920
To delete the slot.

06:58.950 --> 07:02.370
We can even have a boolean that returns the success or failure.

07:02.370 --> 07:04.710
But for now, I'm fine with this.

07:04.710 --> 07:09.330
Now this could be a static function as we're only calling a static functions in it.

07:09.330 --> 07:11.790
So let's go ahead and make that static.

07:12.720 --> 07:19.320
So that makes things even easier because now we can just call the static function directly here in load

07:19.320 --> 07:20.160
screen.

07:20.310 --> 07:21.420
Our view model.

07:21.660 --> 07:26.640
So what we can do is say a or a game mode base delete slot.

07:28.020 --> 07:29.940
But we need to know what slot.

07:29.940 --> 07:30.480
Right?

07:30.480 --> 07:32.880
So we have to get that slot.

07:32.880 --> 07:37.710
Well we know it's our selected slot and this could be null at any point in time.

07:37.710 --> 07:40.710
So we're going to say if selected slot.

07:46.110 --> 07:48.030
We'll wrap it in an is valid.

07:48.880 --> 07:55.540
And then we can call our or a game mode based static function delete slot passing in selected slot,

07:56.350 --> 08:01.930
and we'll get its slot name, the load slot name, and the index.

08:01.930 --> 08:05.530
So selected slot slot index.

08:06.960 --> 08:08.580
Now we get red squiggles.

08:08.580 --> 08:13.020
Says cannot convert f string to parameter type int 32.

08:13.140 --> 08:13.590
Uh oh.

08:13.590 --> 08:15.000
That doesn't sound good.

08:15.000 --> 08:16.680
Let's go back and look.

08:17.190 --> 08:23.070
Delete slot does take an INT 32 called slot index and an f string called slot name.

08:23.100 --> 08:25.800
So the function signature is correct.

08:26.590 --> 08:30.850
Slot index looks like it's an F string.

08:31.210 --> 08:32.230
Interesting.

08:32.230 --> 08:34.630
Let's go to mVVM load slot.

08:35.510 --> 08:36.890
And take a look at that slot.

08:36.890 --> 08:38.690
Index is an F string.

08:38.690 --> 08:40.910
This should be an int 32 shouldn't it?

08:41.610 --> 08:43.650
And we should be setting this slot index.

08:43.650 --> 08:46.020
Let's make sure that we're actually setting that.

08:46.020 --> 08:52.050
It should be set really as soon as we create it up here, as soon as we set our load slot name, we

08:52.050 --> 08:54.360
should also set that index as well.

08:54.420 --> 08:56.790
Otherwise it won't have any meaning.

08:56.790 --> 08:57.840
So let's do it.

08:57.840 --> 09:00.660
Load slot underscore zero.

09:01.020 --> 09:03.180
We're going to take its slot index.

09:03.180 --> 09:04.500
And we can set that.

09:04.500 --> 09:06.990
It's going to be zero for slot zero.

09:07.760 --> 09:09.770
And we'll set it for one and two as well.

09:09.770 --> 09:15.410
So load slot one can be set to one and load slot two.

09:17.090 --> 09:18.290
Can be set to two.

09:18.800 --> 09:20.810
Now they're identifiable.

09:20.810 --> 09:28.910
And then when delete button is pressed, we can now call delete slot and pass in that slot index.

09:29.480 --> 09:31.220
Now that's great.

09:31.220 --> 09:37.130
We're actually deleting the slot, but how are we going to update our HUD?

09:37.160 --> 09:41.120
Well, for one that slot has a status right?

09:41.120 --> 09:48.320
We have selected slot and we have a slot status not a slot index a slot status.

09:48.710 --> 09:53.180
Now that it's going to have its slot deleted, it can be vacant.

09:54.130 --> 10:01.900
We can set that to vacant, and we can tell it to go ahead and broadcast its delegate using the function

10:02.920 --> 10:04.150
initialize slot.

10:04.180 --> 10:06.190
Now it's going to be updated.

10:06.490 --> 10:09.220
So this should effectively delete that slot.

10:09.250 --> 10:10.510
Let's test that out.

10:10.510 --> 10:13.000
We'll go ahead and run in debug mode.

10:14.430 --> 10:15.000
All right.

10:15.000 --> 10:19.470
So we're going to go ahead and open up those widgets we had open.

10:19.470 --> 10:24.210
We can go into the load menu map.

10:24.600 --> 10:28.440
Now we also need to make sure that our delete button here when it's pressed.

10:29.350 --> 10:33.190
That our load screen widget knows about it.

10:33.190 --> 10:36.160
So here in our load screen widget we know about it.

10:36.160 --> 10:40.150
But we also want to call that blueprint callable function we created.

10:40.150 --> 10:44.710
That's on BP load screen ViewModel.

10:46.430 --> 10:48.620
And what's that function called?

10:48.620 --> 10:50.720
It's called delete button pressed.

10:51.050 --> 10:54.470
Let's call that delete button pressed.

10:55.690 --> 10:56.620
There we go.

10:56.650 --> 10:58.150
Let's just see what happens.

10:58.180 --> 11:01.810
See if we've forgotten about anything that we haven't taken into account.

11:01.810 --> 11:04.420
We'll select a slot, we'll hit delete.

11:04.420 --> 11:06.280
And instead of hitting cancel.

11:06.890 --> 11:09.800
We'll hit the delete button and there we go.

11:09.800 --> 11:14.750
Now this is great because now we can press plus and we can enter a new name.

11:14.750 --> 11:16.010
Let's call it John.

11:16.820 --> 11:18.230
Click on new slot.

11:18.230 --> 11:20.030
And now we have a new slot.

11:20.640 --> 11:23.400
Now, just a couple issues that we're going to clean up.

11:23.400 --> 11:31.500
Before we wrap up, let's go ahead and delete those slots and press play and click on New Game.

11:31.710 --> 11:37.800
And the first issue that we need to take care of is as soon as we enter a name, let's say Joe.

11:38.280 --> 11:43.920
Then this editable text block here is going to retain Joe.

11:44.400 --> 11:49.860
So even though we click on new slot, we're switching to a different widget that says Joe.

11:49.890 --> 11:55.470
That old widget with the editable text still has Joe, and we'll know that as soon as we select the

11:55.470 --> 12:00.510
slot, delete it, confirm that deletion, and click on plus for a new game.

12:00.510 --> 12:01.950
Joe is still there.

12:01.950 --> 12:07.440
That's in that editable text, so we need to clear that out as soon as we leave this widget.

12:07.770 --> 12:08.820
Well, that's pretty easy.

12:08.820 --> 12:11.190
As soon as we click on new slot we can do that.

12:11.190 --> 12:18.510
So if we go into our enter name widget and click on new slot, we'll go into our graph as soon as this

12:18.510 --> 12:19.170
is clicked.

12:19.170 --> 12:23.490
Well we know that we're calling a blueprint callable function new slot button pressed.

12:23.490 --> 12:28.380
This will inevitably end up in our widget switcher switching to a different widget.

12:28.380 --> 12:34.500
So since we're leaving this widget behind, we can take its editable text and we can set the text on

12:34.500 --> 12:34.740
it.

12:34.740 --> 12:37.350
We can call set text the function.

12:39.680 --> 12:41.690
And we can set it to an empty string.

12:42.810 --> 12:46.950
Now, if we press play and press new, I'll go to this one here.

12:46.950 --> 12:51.990
We'll enter some text, make a new slot, we'll select that slot and delete that slot.

12:52.230 --> 12:59.010
And if we click plus then it's empty again because we cleared it as soon as we clicked on new slot.

12:59.460 --> 13:05.790
Now here's another issue I clicked on new slot and select slot is now disabled.

13:05.790 --> 13:12.210
That's because we disabled it and then switched away from that widget and never set that back to enabled.

13:12.210 --> 13:14.160
Now that's a problem.

13:14.160 --> 13:19.920
If we don't have any other slots, let's say we click on this one, create a new slot and select that

13:19.920 --> 13:21.720
slot and then come back.

13:21.720 --> 13:28.230
We can now select this one because only when we select another slot are the select slot buttons for

13:28.230 --> 13:30.630
the other widgets enabled again.

13:30.870 --> 13:32.400
So that's a problem.

13:32.400 --> 13:34.980
Whoops I accidentally clicked on quit.

13:34.980 --> 13:36.210
Let's go back to play.

13:36.210 --> 13:37.890
That's a problem right?

13:37.890 --> 13:41.190
We need to actually enable this button again.

13:41.190 --> 13:43.320
And when do we enable the button.

13:43.320 --> 13:48.570
Well if I press plus here and create a new slot right.

13:48.570 --> 13:55.470
And select it and delete it and click on delete right now as soon as I hit delete would be a great time

13:55.470 --> 13:57.180
to re-enable that button.

13:57.180 --> 14:03.360
So in other words, in the delete button pressed for this slot, we might as well go ahead and re-enable

14:03.360 --> 14:11.190
that select slot button, because then next time we come back to it, when we create a new slot again,

14:11.190 --> 14:13.380
it'll be enabled again.

14:13.380 --> 14:16.560
So let's make sure that that happens when we delete a slot.

14:16.560 --> 14:23.040
I'm going to go ahead and close down the editor and we'll go into our load screen view model into delete

14:23.040 --> 14:24.030
button pressed.

14:24.030 --> 14:25.770
Here's a good place to do it.

14:26.010 --> 14:30.600
And our load slots have that delegate enable select slot button.

14:30.600 --> 14:35.850
We can broadcast that delegate right here for this given slot.

14:36.180 --> 14:39.870
So as we're deleting the slots we can go ahead and enable it.

14:39.870 --> 14:42.990
Select slot button for the next time we get back to that widget.

14:42.990 --> 14:45.150
So we're going to take our selected slot.

14:45.360 --> 14:52.140
We'll get its enable select slot button delegate and we'll broadcast true.

14:54.920 --> 15:00.110
So that should enable that button and we won't see that button get enabled as we're switching away from

15:00.110 --> 15:00.560
that widget.

15:00.560 --> 15:04.610
But next time we get to it we'll be actually able to select it.

15:05.060 --> 15:06.680
So let's test this out.

15:07.280 --> 15:13.460
So back in the editor let's go into maps load menu press play.

15:13.490 --> 15:16.340
Now all of these have slots in them.

15:16.880 --> 15:21.800
So I'm going to go ahead and just delete those slots and our save game folder.

15:23.150 --> 15:24.080
Press play.

15:24.080 --> 15:25.550
Now we're starting anew.

15:25.550 --> 15:32.180
Now I'm going to click plus here and enter a name Stephen and click New Slot.

15:32.180 --> 15:38.840
Now we have a slot I'm going to select that slot and hit delete and confirm that deletion and click

15:38.840 --> 15:39.740
plus again.

15:39.740 --> 15:41.120
Now I can enter a name.

15:41.120 --> 15:44.630
Again I'm just going to enter S click on new slot.

15:44.630 --> 15:50.210
And now I see that I can select that slot and I can play delete quit whatever.

15:50.480 --> 15:54.470
Now so far we can't play but we can delete that slot.

15:54.470 --> 15:57.590
We can cancel deletion, we can confirm deletion.

15:57.590 --> 16:01.250
And now we know that that slot will be deleted.

16:01.250 --> 16:04.160
And we can even check our save games.

16:04.160 --> 16:08.300
That slot actually gets deleted from here if we create a new slot.

16:09.200 --> 16:10.970
It comes back to our savegames.

16:10.970 --> 16:17.150
If we select it and delete it and confirm it's gone from our Savegames pretty nice right?

16:17.240 --> 16:21.560
Okay, so we're now able to delete slots, which is great.

16:21.560 --> 16:23.120
That's an important feature.

16:23.480 --> 16:26.330
But now it's time to actually play the game.

16:26.330 --> 16:29.930
Which means well, we need some kind of level to go to.

16:29.930 --> 16:32.720
Once we have a valid slot, we select it.

16:32.720 --> 16:34.010
We click on play.

16:34.010 --> 16:35.000
What are we going to do?

16:35.000 --> 16:39.560
In that case, we're going to want to travel to a dungeon or a level of some kind.

16:39.560 --> 16:42.890
And we need a default level to go to first.

16:42.890 --> 16:46.940
And so we'll take care of doing that in the next video.

16:47.180 --> 16:48.170
I'll see you soon.
