WEBVTT

00:07.110 --> 00:08.100
Welcome back.

00:08.100 --> 00:11.670
Now we're saving the map name and we're loading it back in.

00:11.670 --> 00:15.000
But when we select the slot and press play nothing happens.

00:15.000 --> 00:17.100
So we need to take care of that.

00:17.100 --> 00:22.260
And I'd like to travel to that map based on whatever map name we have saved.

00:22.560 --> 00:24.300
So let's do that.

00:24.690 --> 00:30.690
In order to make this happen, we're going to go to our load menu and open Load Screen widget, because

00:30.690 --> 00:37.650
our play button now needs to do something and we can make our play button do something.

00:37.740 --> 00:43.140
As soon as we know that we have a valid view model and event blueprint initialize widget.

00:43.950 --> 00:49.950
Here's where we're taking our load screen view model and binding to event slot selected.

00:49.950 --> 00:56.670
I'd like to also make sure that when we click on play that we call a blueprint callable function here

00:56.670 --> 00:58.500
on load screen view model.

00:58.500 --> 01:05.520
So let's go back into the IDE and add a blueprint callable function to mVVM load screen.

01:05.760 --> 01:12.720
And when we call this function, we do need to pass in the slot at least by index, so that we can look

01:12.720 --> 01:16.800
up the saved level name associated with that slot.

01:16.800 --> 01:19.740
So we're going to make a new blueprint callable function.

01:20.070 --> 01:24.990
We can make it void and it can be play button pressed.

01:25.290 --> 01:28.290
And it can take in an INT 32 called slot.

01:28.950 --> 01:31.200
And it can be blueprint callable.

01:32.970 --> 01:35.520
So we can generate this definition.

01:35.940 --> 01:42.270
Now in play button pressed, I'd like to call a game mode function and just pass along the slot, because

01:42.270 --> 01:46.110
I'd like the game mode to handle traveling to another level.

01:46.110 --> 01:52.920
And in addition to that, I want to pass in the whole slot the you mVVM load slot so that the game mode

01:52.920 --> 01:59.580
can harvest any data from that slot that it needs, just in case it needs to keep track of which slot

01:59.610 --> 02:02.970
we're dealing with here once we travel to other levels.

02:03.420 --> 02:09.180
So the game mode itself is going to have a function we can call to travel to a given map.

02:09.480 --> 02:18.840
I'm going to call this void Travel to map, and it's going to take in a you mVVM load slot pointer called

02:18.840 --> 02:19.620
slot.

02:19.620 --> 02:26.580
So I'm going to go ahead and generate the definition and just make sure that I call this right here

02:26.580 --> 02:27.900
in load screen.

02:27.900 --> 02:30.330
I'm going to get the game mode.

02:30.750 --> 02:36.600
We'll just copy the line down here from Load Data where we're getting the game mode, and we're going

02:36.600 --> 02:45.750
to take or a game mode and call travel to map passing in the slots we can get load slots indexing slot

02:46.020 --> 02:48.840
and we can straight up pass that in okay.

02:48.840 --> 02:52.290
So now play button pressed is calling travel to map.

02:52.290 --> 02:54.270
Now what is travel to map going to do?

02:54.270 --> 02:57.840
Well we're passing in the slots or a game mode.

02:57.840 --> 03:04.680
Base knows that slot and knows that the slot has its own map name, and the game mode itself has maps

03:04.740 --> 03:11.430
a t map so it can perform a lookup and can take its maps map called maps.

03:11.760 --> 03:19.380
It can even use find checked if we want to find it with an assertion, and we can take the slot and

03:19.380 --> 03:23.640
get map name from it and pass that into maps.

03:23.670 --> 03:26.490
And that's going to return us the map.

03:26.670 --> 03:28.590
Now what do we do with the map?

03:28.590 --> 03:30.000
Well, we can travel to it.

03:30.000 --> 03:35.400
We can take that map and we can call a gameplay statics function to go to that map.

03:35.400 --> 03:41.760
Now that function is on gameplay statics and it's called open level by soft object pointer.

03:41.880 --> 03:45.510
Now it requires a world context object.

03:45.510 --> 03:47.910
We can pass in the slot itself for that.

03:47.910 --> 03:49.380
That's totally fine.

03:49.380 --> 03:56.100
And for the T soft object pointer, well, we can look up in our maps using that map name.

03:56.100 --> 03:58.440
In other words, we can use this value here.

03:58.440 --> 04:00.000
We can just pass that in.

04:00.120 --> 04:02.430
But the cool thing here is we have the slot.

04:02.430 --> 04:08.580
So that means we can get any information from it such as the slot name, the slot index and so on.

04:08.580 --> 04:11.640
We can make a const f string called slot name.

04:11.790 --> 04:15.240
We can get slot load slot name.

04:15.240 --> 04:19.230
We can also make a const int 32 slot index.

04:19.410 --> 04:22.350
And we can get slot slot index.

04:22.350 --> 04:25.890
So we have access to this stuff in case we need it later.

04:25.890 --> 04:27.810
I'm just going to keep it right there for now.

04:28.110 --> 04:30.420
So this is doing nothing but right here.

04:30.420 --> 04:35.310
This is where we should be traveling to this particular map.

04:35.310 --> 04:43.470
Now we can check that by making sure that our load screen play button pressed is being called.

04:43.470 --> 04:46.740
We're going to have to call that from our load screen widget.

04:46.740 --> 04:49.710
So let's compile and launch and make that happen.

04:52.150 --> 04:52.750
Okay.

04:52.750 --> 05:00.910
So we can open up our widgets and we need WB load screen here and right here in blueprint initialize

05:00.910 --> 05:01.600
widget.

05:01.600 --> 05:05.410
When we know that our view model is valid, we're going to take it.

05:05.410 --> 05:09.520
And we're going to call a blueprint callable function play button pressed.

05:10.060 --> 05:12.970
But only when we've clicked the play button.

05:12.970 --> 05:16.480
So that means we need to get that play button out here.

05:16.480 --> 05:19.390
Button play and get the button from it.

05:22.100 --> 05:24.620
And we can assign onclicked.

05:26.290 --> 05:29.020
We'll hook that in and on clicked.

05:29.020 --> 05:31.150
We're going to call play button pressed.

05:37.950 --> 05:41.970
And how are we going to get our selected slot?

05:42.000 --> 05:45.780
Actually, we don't really have that here in the widget, do we?

05:45.780 --> 05:51.720
But we have it in the view model so we can get that selected slot from there.

05:51.720 --> 05:58.110
So we should actually go back and remove this slot from the input and just get it right here and play

05:58.110 --> 05:58.710
button press.

05:58.710 --> 06:00.120
Let's just do that real quick.

06:00.390 --> 06:03.930
So in play button pressed we don't need the slot passed in.

06:03.930 --> 06:07.770
That was actually incorrect on my behalf.

06:07.770 --> 06:10.560
We already know the selected slot.

06:10.800 --> 06:13.710
That's because we have our selected slot.

06:15.050 --> 06:18.260
Right here and we can just make sure it's valid.

06:23.450 --> 06:24.560
If it is.

06:25.280 --> 06:32.510
Then we'll travel to the map using our selected slot, and from that selected slot we're going to get

06:32.510 --> 06:33.350
our slot index.

06:33.350 --> 06:34.730
We're going to pass that in.

06:34.970 --> 06:36.800
So we're traveling to the map.

06:36.800 --> 06:38.810
In fact we don't need to perform a lookup.

06:38.810 --> 06:41.510
In load slots we have the selected slot.

06:42.750 --> 06:45.720
So we just need to travel to the map using the selected slot.

06:45.750 --> 06:46.710
How silly of me.

06:46.740 --> 06:49.200
And with that, let's test this out.

06:52.580 --> 06:54.980
All right, so back in the editor.

06:55.640 --> 07:02.150
In our Wbhp load screen, we see that when we click the play button, we're calling play button pressed.

07:02.180 --> 07:05.330
Now we need to go into our load screen menu.

07:05.900 --> 07:07.580
Our load menu that is.

07:07.580 --> 07:14.600
And just to make sure things are all reset, I'm going to delete everything and I'm going to create

07:14.600 --> 07:16.850
a new slot with my name.

07:18.900 --> 07:24.210
We see that first dungeon is the map, and if I select the slot and press play.

07:25.160 --> 07:25.760
Look at that.

07:25.760 --> 07:29.510
I'm now in the first dungeon, so it works.

07:30.450 --> 07:31.470
Excellent.

07:31.970 --> 07:33.470
So this is great.

07:33.470 --> 07:41.360
Our menu is now working and as long as our game mode has all the maps in it, then whatever map that

07:41.360 --> 07:46.910
we use, as long as we're saving one that exists in our game mode and it knows about it, then when

07:46.910 --> 07:51.410
we select the slot and press play, we'll always travel to that level.

07:51.860 --> 07:57.800
So in a sense, our load screen system is almost complete.

07:57.800 --> 08:00.890
I mean, we're not showing the actual level of the player.

08:00.890 --> 08:03.260
We're not saving the player's level.

08:03.440 --> 08:09.800
We're not saving anything related to the progress of the player other than what map they might currently

08:09.800 --> 08:10.580
be in.

08:10.580 --> 08:13.880
But then again, if we travel to a new map, we're not saving that either.

08:13.880 --> 08:20.300
So there are a few things we still need to save, but our menu system is looking pretty nice.

08:20.900 --> 08:23.210
There's only one little issue and that's that.

08:23.210 --> 08:25.580
We have text wrapping for our map name.

08:25.580 --> 08:32.030
So when our map name is really long it's going to push that select slot button down a little bit.

08:32.030 --> 08:39.440
And we can see that problem if we go to our load screen game mode and change the name of First Dungeon

08:39.440 --> 08:47.480
to really, really, really long, long, long dungeon name.

08:48.780 --> 08:50.550
If we do that and press play.

08:50.550 --> 08:53.280
Well, now we've just introduced a bug, right?

08:53.280 --> 08:59.700
Because First Dungeon isn't in our map, so we can't really travel to that, but we can create a new

08:59.700 --> 09:00.450
slot.

09:00.810 --> 09:04.410
And now we have really, really, really, really long, long, long dungeon name.

09:04.770 --> 09:06.180
It actually doesn't wrap.

09:06.210 --> 09:07.260
That's good to know.

09:07.260 --> 09:08.730
It's not wrapping over.

09:08.730 --> 09:12.390
It's just taking up as much room as it needs.

09:12.390 --> 09:16.530
And we can see on this very end one, it goes all the way out to there.

09:16.530 --> 09:18.600
So we could do something about that.

09:18.600 --> 09:24.360
It's kind of a Polish issue, but it's also kind of important because our dungeon names might be a little

09:24.360 --> 09:25.500
bit longer.

09:25.860 --> 09:28.560
So we may wish to fix that.

09:28.950 --> 09:33.720
If we go to load slot taken, we are in a wrap box.

09:33.720 --> 09:39.180
And of course that's going to make things push each other down like that.

09:39.570 --> 09:46.980
If you always want that select slot at the bottom at the same spot every time we could change the wrap

09:46.980 --> 09:51.300
box, we could right click on it, replace it with a vertical box.

09:52.020 --> 09:55.830
And rename it, of course, because it's not a rat box anymore.

09:59.400 --> 10:04.110
And the vertical box, as we see, is not containing that button.

10:04.760 --> 10:11.780
So the button itself, which is set to fill, could be set to bottom align vertically, but it needs

10:11.780 --> 10:12.770
more room.

10:13.160 --> 10:16.700
So our spacers might be a little bit too large.

10:16.700 --> 10:18.950
We can bring them down a bit.

10:20.890 --> 10:22.600
And we see that level.

10:23.260 --> 10:26.740
And the level number are not together.

10:26.740 --> 10:34.120
Here, we can group those in their own horizontal box by wrapping them with a horizontal box.

10:35.510 --> 10:37.040
Now they're together.

10:37.430 --> 10:42.290
Of course, that one has to be after level so we can rearrange that there.

10:43.040 --> 10:48.590
And we can take this box and if we want it to stick down to the bottom there, we can select fill.

10:48.590 --> 10:51.890
Now that bottom aligned vertically will work.

10:51.890 --> 10:54.500
We don't have to have it stretched horizontally.

10:54.500 --> 10:59.090
We can set this to center and it won't be stretched out so much.

10:59.090 --> 11:03.590
And we can get rid of this spacer here if we take this spacer and delete it.

11:03.620 --> 11:11.810
Now this map here with dungeon one should be able to just occupy space without pushing that select slot

11:11.810 --> 11:13.070
button down.

11:13.070 --> 11:18.950
And of course these two, if we want them on the same line, we could wrap them in a horizontal box.

11:19.520 --> 11:20.660
Like that.

11:21.860 --> 11:25.220
And then dungeon one can be set to wrap.

11:26.590 --> 11:29.770
So auto wrap text, we can check that checkbox.

11:30.400 --> 11:34.990
And let's just see by saving all and pressing play, okay?

11:34.990 --> 11:38.800
It's not wrapping and we can take it and select fill.

11:41.130 --> 11:42.840
And now it's wrapping.

11:42.840 --> 11:43.500
Okay.

11:43.590 --> 11:45.690
So that's great.

11:46.050 --> 11:51.960
Now it just happens to be able to push that button down and squeeze it a little bit.

11:51.960 --> 11:56.940
But as long as we don't have to ridiculously long of a dungeon name, we should be okay.

11:56.940 --> 12:03.090
We could change this to really, really long dungeon name.

12:03.530 --> 12:04.370
And.

12:07.710 --> 12:11.820
We can take a slot, delete it, create a new slot.

12:12.240 --> 12:18.720
And now really, really long dungeon name is reasonably long, but it's not going to squeeze that select

12:18.720 --> 12:19.920
slot button down.

12:20.400 --> 12:27.450
And if it's really really really long I'm just going to make it as long as I can with some spaces in

12:27.450 --> 12:28.050
here.

12:32.010 --> 12:33.900
And delete a slot.

12:34.470 --> 12:35.700
Make a new one.

12:36.870 --> 12:39.390
It's going to push that button all the way down.

12:39.390 --> 12:41.970
So that's something to be aware of.

12:41.970 --> 12:47.550
And of course, if you do plan on longer dungeon names, I'm going to set this back to dungeon.

12:49.300 --> 12:51.220
I'm going to set it back to First dungeon.

12:54.020 --> 12:59.150
Then if you want a very long dungeon name, you can start making these fonts a little bit smaller,

12:59.150 --> 13:00.530
but I'm okay with it.

13:00.530 --> 13:02.390
I think this is going to work.

13:02.780 --> 13:10.130
I'm going to actually delete these slots from the saved folder because I can't actually select that

13:10.130 --> 13:10.850
slot.

13:11.470 --> 13:14.650
So going to save games, deleting those.

13:15.150 --> 13:17.160
Now I can create new slots.

13:17.820 --> 13:19.140
They look great.

13:19.500 --> 13:20.610
I can select the slot.

13:20.610 --> 13:23.550
I can press play and travel to the dungeon.

13:24.200 --> 13:25.160
Perfect.

13:25.460 --> 13:26.060
Okay.

13:26.060 --> 13:27.860
I'm going to go ahead and delete that slot.

13:28.530 --> 13:29.700
And with that.

13:30.500 --> 13:37.880
We now have a menu system, it's now time to start saving our actual attributes, abilities, our level,

13:37.880 --> 13:39.470
and all that great stuff.

13:39.470 --> 13:40.670
And we'll do that next.

13:41.060 --> 13:41.960
I'll see you soon.
