Welcome back.
Now we're saving the map name and we're loading it back in.
But when we select the slot and press play nothing happens.
So we need to take care of that.
And I'd like to travel to that map based on whatever map name we have saved.
So let's do that.
In order to make this happen, we're going to go to our load menu and open Load Screen widget, because
our play button now needs to do something and we can make our play button do something.
As soon as we know that we have a valid view model and event blueprint initialize widget.
Here's where we're taking our load screen view model and binding to event slot selected.
I'd like to also make sure that when we click on play that we call a blueprint callable function here
on load screen view model.
So let's go back into the IDE and add a blueprint callable function to mVVM load screen.
And when we call this function, we do need to pass in the slot at least by index, so that we can look
up the saved level name associated with that slot.
So we're going to make a new blueprint callable function.
We can make it void and it can be play button pressed.
And it can take in an INT 32 called slot.
And it can be blueprint callable.
So we can generate this definition.
Now in play button pressed, I'd like to call a game mode function and just pass along the slot, because
I'd like the game mode to handle traveling to another level.
And in addition to that, I want to pass in the whole slot the you mVVM load slot so that the game mode
can harvest any data from that slot that it needs, just in case it needs to keep track of which slot
we're dealing with here once we travel to other levels.
So the game mode itself is going to have a function we can call to travel to a given map.
I'm going to call this void Travel to map, and it's going to take in a you mVVM load slot pointer called
slot.
So I'm going to go ahead and generate the definition and just make sure that I call this right here
in load screen.
I'm going to get the game mode.
We'll just copy the line down here from Load Data where we're getting the game mode, and we're going
to take or a game mode and call travel to map passing in the slots we can get load slots indexing slot
and we can straight up pass that in okay.
So now play button pressed is calling travel to map.
Now what is travel to map going to do?
Well we're passing in the slots or a game mode.
Base knows that slot and knows that the slot has its own map name, and the game mode itself has maps
a t map so it can perform a lookup and can take its maps map called maps.
It can even use find checked if we want to find it with an assertion, and we can take the slot and
get map name from it and pass that into maps.
And that's going to return us the map.
Now what do we do with the map?
Well, we can travel to it.
We can take that map and we can call a gameplay statics function to go to that map.
Now that function is on gameplay statics and it's called open level by soft object pointer.
Now it requires a world context object.
We can pass in the slot itself for that.
That's totally fine.
And for the T soft object pointer, well, we can look up in our maps using that map name.
In other words, we can use this value here.
We can just pass that in.
But the cool thing here is we have the slot.
So that means we can get any information from it such as the slot name, the slot index and so on.
We can make a const f string called slot name.
We can get slot load slot name.
We can also make a const int 32 slot index.
And we can get slot slot index.
So we have access to this stuff in case we need it later.
I'm just going to keep it right there for now.
So this is doing nothing but right here.
This is where we should be traveling to this particular map.
Now we can check that by making sure that our load screen play button pressed is being called.
We're going to have to call that from our load screen widget.
So let's compile and launch and make that happen.
Okay.
So we can open up our widgets and we need WB load screen here and right here in blueprint initialize
widget.
When we know that our view model is valid, we're going to take it.
And we're going to call a blueprint callable function play button pressed.
But only when we've clicked the play button.
So that means we need to get that play button out here.
Button play and get the button from it.
And we can assign onclicked.
We'll hook that in and on clicked.
We're going to call play button pressed.
And how are we going to get our selected slot?
Actually, we don't really have that here in the widget, do we?
But we have it in the view model so we can get that selected slot from there.
So we should actually go back and remove this slot from the input and just get it right here and play
button press.
Let's just do that real quick.
So in play button pressed we don't need the slot passed in.
That was actually incorrect on my behalf.
We already know the selected slot.
That's because we have our selected slot.
Right here and we can just make sure it's valid.
If it is.
Then we'll travel to the map using our selected slot, and from that selected slot we're going to get
our slot index.
We're going to pass that in.
So we're traveling to the map.
In fact we don't need to perform a lookup.
In load slots we have the selected slot.
So we just need to travel to the map using the selected slot.
How silly of me.
And with that, let's test this out.
All right, so back in the editor.
In our Wbhp load screen, we see that when we click the play button, we're calling play button pressed.
Now we need to go into our load screen menu.
Our load menu that is.
And just to make sure things are all reset, I'm going to delete everything and I'm going to create
a new slot with my name.
We see that first dungeon is the map, and if I select the slot and press play.
Look at that.
I'm now in the first dungeon, so it works.
Excellent.
So this is great.
Our menu is now working and as long as our game mode has all the maps in it, then whatever map that
we use, as long as we're saving one that exists in our game mode and it knows about it, then when
we select the slot and press play, we'll always travel to that level.
So in a sense, our load screen system is almost complete.
I mean, we're not showing the actual level of the player.
We're not saving the player's level.
We're not saving anything related to the progress of the player other than what map they might currently
be in.
But then again, if we travel to a new map, we're not saving that either.
So there are a few things we still need to save, but our menu system is looking pretty nice.
There's only one little issue and that's that.
We have text wrapping for our map name.
So when our map name is really long it's going to push that select slot button down a little bit.
And we can see that problem if we go to our load screen game mode and change the name of First Dungeon
to really, really, really long, long, long dungeon name.
If we do that and press play.
Well, now we've just introduced a bug, right?
Because First Dungeon isn't in our map, so we can't really travel to that, but we can create a new
slot.
And now we have really, really, really, really long, long, long dungeon name.
It actually doesn't wrap.
That's good to know.
It's not wrapping over.
It's just taking up as much room as it needs.
And we can see on this very end one, it goes all the way out to there.
So we could do something about that.
It's kind of a Polish issue, but it's also kind of important because our dungeon names might be a little
bit longer.
So we may wish to fix that.
If we go to load slot taken, we are in a wrap box.
And of course that's going to make things push each other down like that.
If you always want that select slot at the bottom at the same spot every time we could change the wrap
box, we could right click on it, replace it with a vertical box.
And rename it, of course, because it's not a rat box anymore.
And the vertical box, as we see, is not containing that button.
So the button itself, which is set to fill, could be set to bottom align vertically, but it needs
more room.
So our spacers might be a little bit too large.
We can bring them down a bit.
And we see that level.
And the level number are not together.
Here, we can group those in their own horizontal box by wrapping them with a horizontal box.
Now they're together.
Of course, that one has to be after level so we can rearrange that there.
And we can take this box and if we want it to stick down to the bottom there, we can select fill.
Now that bottom aligned vertically will work.
We don't have to have it stretched horizontally.
We can set this to center and it won't be stretched out so much.
And we can get rid of this spacer here if we take this spacer and delete it.
Now this map here with dungeon one should be able to just occupy space without pushing that select slot
button down.
And of course these two, if we want them on the same line, we could wrap them in a horizontal box.
Like that.
And then dungeon one can be set to wrap.
So auto wrap text, we can check that checkbox.
And let's just see by saving all and pressing play, okay?
It's not wrapping and we can take it and select fill.
And now it's wrapping.
Okay.
So that's great.
Now it just happens to be able to push that button down and squeeze it a little bit.
But as long as we don't have to ridiculously long of a dungeon name, we should be okay.
We could change this to really, really long dungeon name.
And.
We can take a slot, delete it, create a new slot.
And now really, really long dungeon name is reasonably long, but it's not going to squeeze that select
slot button down.
And if it's really really really long I'm just going to make it as long as I can with some spaces in
here.
And delete a slot.
Make a new one.
It's going to push that button all the way down.
So that's something to be aware of.
And of course, if you do plan on longer dungeon names, I'm going to set this back to dungeon.
I'm going to set it back to First dungeon.
Then if you want a very long dungeon name, you can start making these fonts a little bit smaller,
but I'm okay with it.
I think this is going to work.
I'm going to actually delete these slots from the saved folder because I can't actually select that
slot.
So going to save games, deleting those.
Now I can create new slots.
They look great.
I can select the slot.
I can press play and travel to the dungeon.
Perfect.
Okay.
I'm going to go ahead and delete that slot.
And with that.
We now have a menu system, it's now time to start saving our actual attributes, abilities, our level,
and all that great stuff.
And we'll do that next.
I'll see you soon.