Welcome back.
Now we have the ability to click on a slot and select it.
But before we click on a slot and select it, our Play and delete buttons should be disabled.
And only when we have a valid slot selected should we enable them.
Now, when we have a valid slot selected, play and Delete should both be enabled, right?
So a valid slot selected delegate is in order.
We need to broadcast something to our main load screen widget.
And then we can have these buttons be functional.
Which means we'll need some kind of blueprint callable function for play button and delete button pressed.
So that means we need a few things on the C plus plus side.
If we go back to our load screen ViewModel mVVM load screen, we can start adding things to it.
Now I don't need my load screen HUD, I'm going to close out of that.
And back in mVVM load screen H.
We can have a delegate to broadcast here for whenever we've selected a valid slot.
And before we go and do that, let's take a look at where we're going to broadcast it.
Well, when select slot button pressed is called, we know that we've just selected a slot.
And we know that this will never be called if we haven't just selected a slot.
Right.
So we can broadcast here.
When we've selected a slot, we can be certain that we've got a valid slot selected at this point.
So that's where we're going to broadcast it.
Let's make that delegate.
Now.
It's going to be basically the same as our load slot delegate f enable selected slot.
So we'll just copy that delegate declaration and go back to our mVVM load screen.
Paste it here and we'll call this F slot selected.
And this will have a bool called be selected.
Although the bull is not really all that necessary because this is really only going to be broadcast
with true, as we can't select something unless we're on this menu, let's look at the menu itself.
We can't ever select a slot if there is no slot here, because we'll never actually see this widget
here unless there is a selected slot, unless it's taken.
So arguably this could be zero parameters.
We could remove that one param.
And this can just be f slot selected.
That's it.
So why don't we just do that for now.
We'll just have f slot selected.
We'll put this right here.
F slot selected.
We'll call it slot selected.
We'll give it a U property and we'll make it blueprint assignable.
And as soon as we've selected a slot and select slot button pressed, we'll take our slot selected and
broadcast it.
Now we just need to bind to this in our load screen.
Now in our load screen that's going to be the load screen widget itself.
And UI.
Load menu.
LBP load screen.
And in this widget event blueprint initialize widget is a good place to put it, as we know that this
is going to be called.
After we have a valid load screen view model, we can remind ourselves of that.
Where are we calling that for the load screen?
Well, we can go to Load screen HUD and see that we're calling it here after the load screen widget
has been created.
And this has all happened before the view model has been created.
So as long as that view model exists before the load screen widget has been created, then when it has
been constructed and finds its own view model, we know that it'll have a valid one.
So after blueprint initialize widget is just fine.
So in blueprint initialize widget, this is a perfectly fine place to bind to that delegate.
But we have to compile in order to do that.
So let's close the editor and we'll go ahead and recompile.
We'll run in debug mode here.
All right.
So let's get these widgets open.
And right here in load screen after blueprint initialize widget.
Let's go ahead and organize this.
We'll add a sequence node.
And the first thing we can do is initialize those slots.
That's fine.
And the next thing we can do is we can assign an event to our new delegate.
We need to get BP load screen ViewModel.
And we can assign to slot selected.
And as soon as a slot is selected, that's when we can decide to enable.
Those buttons, the play and delete buttons, which we should make sure their variables they are and
they should be disabled by default.
We can do that right away.
We can do that in event construct or event Pre-construct.
Let's just go ahead and do it here in event construct.
We can get button, delete and button play from both of these.
We'll get the button widget.
And we'll call set is enabled on them.
And we'll make sure that false is passed in.
We'll do it for both.
And we'll go ahead and just collapse these to a function called disable play and delete buttons.
And if we wanted to, we could pass a boolean in there to enable both of them.
We might as well just do that.
So let's take this function.
We'll add an input of type boolean to it.
Called.
Should enable or just enable either one, and we can rename this to enable.
And just use should enable pass that into both.
And now we have a more versatile function that can also enable them, because as soon as a valid slot
is selected, we're going to want to do that.
Let's call it passing in.
True.
So now with that we can press play.
OOP.
Not in this level though.
Let's go back to maps.
Load menu.
Press play.
And now the play and delete buttons are disabled.
Oh, look at this.
I can click and possess the pawn and I can fly around.
That's not what I want.
We'll take care of that soon.
But these are disabled.
And once we've selected a slot, they become enabled.
And that's what we wanted.
Cool.
So that takes care of what I wanted to do in this video.
And that's just enabling those buttons when we've selected a slot.
But we can also make sure that we can't fly around and click in the viewport and possess that default
pawn.
And that's actually quite easy.
We can do that either in the level blueprint or when we spawn this widget.
I think a perfectly fine place to do it could be in our load screen widget blueprint.
An event construct, we can just call get player controller.
We can call set input mode UI only.
We can set the widget to focus to this widget that we're in.
Now we can get a reference to self.
And pass that in as the widget to focus, and we can take the player controller.
Set show mouse cursor to true.
And now we should only be able to interact with UI.
We can click around we can't possess.
We can select a slot and we can press play and delete.
Perfect.
Now we need those play and delete buttons to be functional, right.
So we'll do that next.
I'll see you soon.