Welcome back.
Now we're saving our attributes, which is great, but our load screen menu doesn't show the correct
level.
Well, we never actually bound this to anything.
We're going to need to bind it, which means we need a way to access that level.
Right.
So we're going to head back into C plus.
Plus I'm going to close all tabs and let's go into public UI view model and get my load slot view model
here.
The load slot view model is going to want to know the player level.
That's because we want it to be a field notify, just like player name and map name.
And this can be an integer.
So I'm going to copy map name with its u property and paste it.
But this is going to be an int 32.
And we'll call this player level.
Now it needs a getter and setter.
So we're going to make a void set player level which takes in an INT 32 called in level.
And we're going to generate the definition and use the field notify broadcast macro.
So you e MVVM set property value.
We're going to use player level and broadcast in level like so.
And then we can get a getter up here.
So we're going to have an INT 32 returning function.
Get player level const return player level.
Okay, great.
Well, this means we're going to need to actually set this.
So where are we going to do that.
Well let's go into our load screen view model.
And when do we need to set this?
Well, when we load data and when we save data, we now have to save our level along with our player
name.
Let's start with saving data.
So we first save data when new slot button pressed is called we call set map name.
We call set player name.
Now we can also call set player level.
So we're going to take load slots here of slot and call set player level.
And this is for a new slot.
So player level can be set to one here.
Basically what its default value already was.
Nothing really changes.
Now when we call load data we need to load that player level.
This happens at the very beginning and this is where we set our load slot, player name, slot status,
map name.
And we can set the load slots level as well.
So we're going to take load slot dot value.
And we're going to call set player level.
Very important that we call the setter.
We're going to get it from the save object.
That's going to be player level.
So now we're actually updating it.
The last thing to do is to bind our widget's level text to that field notify.
So I'm going to close the editor and launch backup.
So back in the editor looks like I'm done with these two widgets.
I need to get my load slot taken.
And it's this widget here the little text.
It's called text underscore level value I need this bound I need to check is variable.
First I'm going to compile and then open my view bindings.
And we're going to add a new one.
We're going to click add widget.
We're going to select text Level value.
We're going to select its text.
That's what we want to bind.
We want one way to widget.
And we're going to need a conversion function.
We need two text from integer.
So we're going to choose two text parentheses integer.
Select that and here's the value we see always sign.
If we check that it's going to have negatives.
We don't care about negatives.
We're going to leave that unchecked.
The minimum number of integral digits is going to be one and the maximum 324.
That's totally fine.
But we do need to bind the value here.
So if we click right here, bind this argument to a property.
Now we can click on this choose load Slot View model and pick Player Level and hit select.
And we're going to uncheck Use Grouping.
Now due to the lack of documentation and the newness of this technology, it isn't clear to me what
use grouping is.
I just know that this doesn't work without it.
So we're going to uncheck that.
And with that we can press play.
And we see level four.
Now I can make a new game.
Enter a name select the slot press play and level up.
Now I'm level four.
I can save the game.
And exit and come back.
And now it's level four.
Now the only problem is if we never actually save the game and load back in.
So if I create a new slot here and select it and play, and I never actually save anything and I exit
and come back, now it's zero.
Now this is actually a pretty easy fix.
We don't have to go out of our way to make sure that that's a one.
If we've never saved it, it should always be a one unless we've saved it.
Right.
So let's go to the game folder open load screen save game.
And we'll just set this to a default value of one.
We'll always have a player level of one unless we've actually saved the game.
So pretty easy fix for that little edge case there.
And with that we'll open the load menu.
And it says one.
Perfect okay I'm going to delete that slot.
I'm going to delete this slot.
And I'll go ahead and delete that slot.
And we're ready to start thinking about how to save our abilities.
And we'll do that next.
I'll see you soon.