Welcome back.
Now we have a few new widgets right.
We have load slot taken load slot, vacant load slot, enter name.
And tying it all together we have our load menu which has three widgets which are widget switchers.
And each of these widget switchers has all three widgets inside of it.
Now this is just the widget switcher widget type that's built into the engine, but we're going to actually
want our own custom widget switcher type.
That way it can have its own concept of which particular slot it belongs to.
So then if we click on say, a button like select slot, for example, and we'd like to play that slot,
then that widget switcher will know what slot it is.
So we're going to create a special widget switcher of our own.
So let's go into the blueprints UI load menu and we'll make a special new widget blueprint here.
Now I'm just going to choose User Widget and it's going to be Wbhp load slot underscore widget switcher.
And here we can have our own class for our widget switcher.
And the first thing we're going to add is a widget switcher.
We'll change it from full screen to desired, and we'll just add the three types of widgets we need
vacant enter name and taken.
So we're going to find WB load.
And we're going to take load slot vacant and drag it on.
And here we see it.
Now we're going to take enter Name and drag that onto the widget switcher.
And we're going to take our taken and drag that onto the widget switcher.
And now we have a class designated for this that we can use.
And now that we have this special widget switcher, we can go back to our load menu and start to replace
each of these with our special type of widget switcher.
Now the easiest way to do this is to take all three widget switchers and just delete them.
And we can bring in our new load slot widget switcher.
So we're going to bring in three of these.
I'm going to bring one in onto the canvas panel first.
And select it.
There it is up there.
I'm going to bring it down though, and anchor it to the center.
I'm going to set its size x to 256, size Y to 300.
Now it looks blank.
But if we go back to our load slot widget switcher and compile it.
Then it won't be blank looking here.
Now I have its anchor set to the middle.
I'm going to set its alignment to 0.5 for x and y and its position x and y just to zero, and then move
the position over.
And I believe I had 250 -250 for the X there.
That might be a little bit too close, maybe -300.
So I have this widget switcher I'm going to copy it.
Control C click on the canvas panel control V and this one.
Can get position y of zero, position x of zero, and then I'll copy it again.
Control C canvas panel control v.
And this one can get a position y of zero and a position x of 300 okay.
So we've replaced those widget switchers with our custom widget switcher, which is going to make things
a lot easier for us to control each one as a whole.
And then each one can have its own view model.
I'm going to call this first one switcher underscore zero.
I'm going to call the next one switcher underscore one and the next one switcher underscore two.
So they'll be designated those indices.
Now for our load menu map.
If we go to it in Maps and open load menu we can save all first.
We can press play and see these widgets because we're adding them to the viewport in the level blueprint.
If we open the level blueprint, we can see that we're doing that here.
Now I'm actually going to remove this logic because it was a good way to get things working and showing
on the screen.
But now we're going to have a little bit more fine tuned control in the C plus plus domain.
So I'm going to go ahead and remove that from our level blueprint.
And now if we press play we don't see anything.
The reason for that is I'm going to have our own full on game mode and HUD for the load screen.
And the HUD is going to have its own C plus plus class that will construct the widget and show it,
add it to the viewport and set its view model.
So that way we can create its view model in C plus plus and control the timing of things so that when
the time comes for that widget to have its own view model, we'll know for sure that that view model
has been constructed.
So we need a few classes.
We need to construct that view model and we'll see how.
But we also need a game mode for the load screen map and a HUD for the load screen map.
So we're going to create several new classes right now.
I'm going to go to C plus plus classes, Aura Public and go into game where we have our aura game mode
base, and I'm going to make a new game mode.
Now.
The game mode itself doesn't have to be a new C plus plus class.
It can just be based on aura game mode base.
I can right click and make a blueprint based on it and stick it in blueprints slash game and call this
BP underscore or a load screen game mode.
I can even take the aura out to make it a little bit shorter.
Load screen game mode.
We can create this blueprint class.
Now that we have it, I'm going to close that content browser, and here in the load menu map, I'll
go to World Settings and set the game mode to BP Load screen Game mode.
And now we can control what HUD gets spawned.
And the HUD can control things like the widgets, as that's the proper separation of concerns.
So now that we have a game mode assigned, we can save all and we can create that HUD class that we
need to assign here for the load screen as well as a view model class.
So let's go to C plus plus classes.
Where we were here, and we'll go into UI, we'll go into HUD and we'll make a new class for the load
screen HUD.
Now this can be just a new a HUD.
It doesn't have to be based on your HUD.
It's going to be completely different.
And we can find the HUD class here.
Click next.
And right here in UI slash HUD I'm going to have a load screen HUD class.
I'm going to create the class I'm going to click no I don't want to recompile.
I want to create another class before closing the editor down.
I want to make a ViewModel.
Now if I'm going to make a ViewModel, I have to enable the mVVM plugin.
So I have to go to Edit Plugins.
And if I search for ViewModel, here's the UMG ViewModel.
It's in beta.
If we check it, we get a warning saying this is in the beta version.
Epic recommends using caution when shipping projects with beta plugins.
So we're going to click yes and we need to restart.
So we're going to restart now.
And now that we've restarted, we can make a new class based on the view model that we've been talking
about.
So I'm going to go ahead and right here in Aura Public UI, I'll make a new C plus plus class and search
all classes for MV M.
That stands for Model View ViewModel mVVM View Model Base.
That's the class we need to use.
So we'll select this class mVVM view model base.
And we're going to rename this.
And this is going to be the view model for our load screen widget.
So I'd like to prefix each of these with VM.
You could prefix them with mVVM if you like.
Sure.
Why not.
And let's make this one load screen.
And in the UI folder I'd like to put it in the view model subfolder.
So we're going to have a new view model folder and a new mVVM load screen.
I'm going to create this class.
And I'm almost done and ready to close the editor, but I'd like to create yet one more class.
And that's because if we're doing all this stuff in C plus plus, it would be wise to have a C plus
plus class backing our widgets when using the ViewModel system, much like we have a C plus plus class
backing our widgets for the widget controller system we have or a user widget, right?
Well, I'd like a C plus plus class backing our load screen widgets.
So I'm going to make a new C plus plus class.
And this will be a user widget.
So similar to our user widget only it's just user widget.
And we're going to put this inside of UI slash widgets along with the other widgets.
And this is going to be our load screen widget.
So we'll just have a C plus plus class behind our load screen widgets.
And we could parent those user widgets to this class.
So we're going to create that class and we can finally close our editor down.
Now back here in our IDE, we can start opening these new things we made.
So we kind of made a lot of things.
We first made a new game mode.
Well we didn't make a C plus plus class.
We made that just a blueprint based on aura game mode base.
So we don't have anything new to open up here for that.
But we did make a new HUD class.
We went to UI HUD and added a load screen HUD so we can get that header and cpp file open here.
We also created a new view model and there's our new view model folder.
We have mVVM load screen and we have the dot h and cpp files for that.
So we need to figure out how to tie that together.
And we finally made a load screen user widget and UI slash widget called load screen widget.
So we have that new class as well.
We can get the header and cpp files open for that.
And we know that our game mode load screen, game mode, the new one is now going to want to use our
load screen HUD, which means we should make a load screen HUD blueprint and set that in our game mode
blueprint.
And then we can go about doing things with our load screen, HUD, creating widgets, creating view
models, and learning how those work, all that great stuff.
We'll do that next.
But first, let's just compile and launch our engine and create our load screen HUD blueprint and set
that in the game mode.
So back in the editor, I'm going to go into my maps folder.
An open load menu.
Here we have our BP load screen game mode.
Now it has its own HUD class.
But we need to set what that is so we can open BP load screen game mode and find the HUD class.
We can set that.
We do need a blueprint based on our C plus plus class.
So let's go to blueprints UI, HUD, and right next to aura HUD, we'll make a new blueprint class based
on load screen HUD.
Here it is.
And we'll call this BP load screen HUD.
Now.
There's nothing to set in here.
It's just a HUD blueprint.
Nothing really special about it yet.
Not yet, but we'll go to our load screen game mode and set its HUD class to be load screen HUD.
And now whenever we go into this load menu map, well, we know that the load screen HUD is active and
it's Beginplay has already been called and all that great stuff.
We're ready to start doing things in that load screen HUD such as creating widgets, add them to the
viewport, set variables, tie things together and the like.
So we'll do that next.
Great job on creating all those classes and I'll see you soon.