WEBVTT

00:06.880 --> 00:08.170
Welcome back.

00:08.410 --> 00:15.610
Now we're saving our attributes, which is great, but our load screen menu doesn't show the correct

00:15.610 --> 00:16.210
level.

00:16.240 --> 00:18.940
Well, we never actually bound this to anything.

00:18.940 --> 00:24.820
We're going to need to bind it, which means we need a way to access that level.

00:24.850 --> 00:25.360
Right.

00:25.360 --> 00:28.540
So we're going to head back into C plus.

00:28.540 --> 00:38.560
Plus I'm going to close all tabs and let's go into public UI view model and get my load slot view model

00:38.560 --> 00:39.190
here.

00:39.760 --> 00:43.990
The load slot view model is going to want to know the player level.

00:43.990 --> 00:49.480
That's because we want it to be a field notify, just like player name and map name.

00:49.570 --> 00:51.820
And this can be an integer.

00:51.820 --> 00:55.960
So I'm going to copy map name with its u property and paste it.

00:55.960 --> 00:58.600
But this is going to be an int 32.

00:59.380 --> 01:01.900
And we'll call this player level.

01:03.010 --> 01:05.380
Now it needs a getter and setter.

01:05.380 --> 01:13.480
So we're going to make a void set player level which takes in an INT 32 called in level.

01:13.480 --> 01:20.680
And we're going to generate the definition and use the field notify broadcast macro.

01:20.680 --> 01:24.550
So you e MVVM set property value.

01:24.580 --> 01:32.620
We're going to use player level and broadcast in level like so.

01:32.620 --> 01:34.930
And then we can get a getter up here.

01:34.930 --> 01:37.780
So we're going to have an INT 32 returning function.

01:38.980 --> 01:45.700
Get player level const return player level.

01:47.680 --> 01:49.000
Okay, great.

01:49.000 --> 01:53.230
Well, this means we're going to need to actually set this.

01:53.230 --> 01:55.390
So where are we going to do that.

01:55.420 --> 01:59.290
Well let's go into our load screen view model.

02:00.760 --> 02:03.310
And when do we need to set this?

02:03.340 --> 02:10.540
Well, when we load data and when we save data, we now have to save our level along with our player

02:10.540 --> 02:11.050
name.

02:11.050 --> 02:12.760
Let's start with saving data.

02:12.760 --> 02:19.120
So we first save data when new slot button pressed is called we call set map name.

02:19.120 --> 02:20.770
We call set player name.

02:20.950 --> 02:24.010
Now we can also call set player level.

02:24.010 --> 02:29.050
So we're going to take load slots here of slot and call set player level.

02:29.050 --> 02:30.970
And this is for a new slot.

02:30.970 --> 02:33.490
So player level can be set to one here.

02:33.490 --> 02:36.340
Basically what its default value already was.

02:36.340 --> 02:38.110
Nothing really changes.

02:38.110 --> 02:42.010
Now when we call load data we need to load that player level.

02:42.010 --> 02:49.390
This happens at the very beginning and this is where we set our load slot, player name, slot status,

02:49.390 --> 02:50.350
map name.

02:50.350 --> 02:53.050
And we can set the load slots level as well.

02:53.050 --> 02:55.690
So we're going to take load slot dot value.

02:55.690 --> 02:58.000
And we're going to call set player level.

02:58.000 --> 03:00.100
Very important that we call the setter.

03:00.100 --> 03:02.290
We're going to get it from the save object.

03:02.500 --> 03:04.660
That's going to be player level.

03:04.660 --> 03:06.940
So now we're actually updating it.

03:06.940 --> 03:13.210
The last thing to do is to bind our widget's level text to that field notify.

03:13.210 --> 03:17.410
So I'm going to close the editor and launch backup.

03:17.410 --> 03:20.890
So back in the editor looks like I'm done with these two widgets.

03:20.890 --> 03:25.540
I need to get my load slot taken.

03:25.810 --> 03:29.890
And it's this widget here the little text.

03:29.890 --> 03:35.920
It's called text underscore level value I need this bound I need to check is variable.

03:35.920 --> 03:40.960
First I'm going to compile and then open my view bindings.

03:40.960 --> 03:42.670
And we're going to add a new one.

03:42.670 --> 03:44.380
We're going to click add widget.

03:44.470 --> 03:48.670
We're going to select text Level value.

03:49.810 --> 03:52.630
We're going to select its text.

03:52.630 --> 03:54.340
That's what we want to bind.

03:54.340 --> 03:56.590
We want one way to widget.

03:56.590 --> 03:59.710
And we're going to need a conversion function.

03:59.710 --> 04:02.290
We need two text from integer.

04:02.380 --> 04:05.680
So we're going to choose two text parentheses integer.

04:05.680 --> 04:10.930
Select that and here's the value we see always sign.

04:10.930 --> 04:13.480
If we check that it's going to have negatives.

04:13.480 --> 04:14.800
We don't care about negatives.

04:14.800 --> 04:16.510
We're going to leave that unchecked.

04:16.510 --> 04:22.780
The minimum number of integral digits is going to be one and the maximum 324.

04:22.810 --> 04:24.400
That's totally fine.

04:24.850 --> 04:27.580
But we do need to bind the value here.

04:28.210 --> 04:32.020
So if we click right here, bind this argument to a property.

04:32.050 --> 04:40.000
Now we can click on this choose load Slot View model and pick Player Level and hit select.

04:40.120 --> 04:43.420
And we're going to uncheck Use Grouping.

04:43.810 --> 04:49.750
Now due to the lack of documentation and the newness of this technology, it isn't clear to me what

04:49.750 --> 04:50.650
use grouping is.

04:50.650 --> 04:53.110
I just know that this doesn't work without it.

04:53.110 --> 04:54.610
So we're going to uncheck that.

04:54.610 --> 04:56.380
And with that we can press play.

04:56.380 --> 04:57.970
And we see level four.

04:57.970 --> 04:59.710
Now I can make a new game.

04:59.710 --> 05:04.810
Enter a name select the slot press play and level up.

05:07.130 --> 05:08.690
Now I'm level four.

05:08.720 --> 05:10.490
I can save the game.

05:11.260 --> 05:13.090
And exit and come back.

05:13.090 --> 05:14.680
And now it's level four.

05:14.680 --> 05:20.410
Now the only problem is if we never actually save the game and load back in.

05:20.410 --> 05:30.190
So if I create a new slot here and select it and play, and I never actually save anything and I exit

05:30.190 --> 05:32.440
and come back, now it's zero.

05:32.440 --> 05:35.140
Now this is actually a pretty easy fix.

05:35.140 --> 05:38.620
We don't have to go out of our way to make sure that that's a one.

05:38.620 --> 05:42.610
If we've never saved it, it should always be a one unless we've saved it.

05:42.610 --> 05:43.000
Right.

05:43.000 --> 05:46.930
So let's go to the game folder open load screen save game.

05:46.930 --> 05:49.780
And we'll just set this to a default value of one.

05:50.080 --> 05:54.850
We'll always have a player level of one unless we've actually saved the game.

05:54.850 --> 05:59.170
So pretty easy fix for that little edge case there.

05:59.170 --> 06:01.690
And with that we'll open the load menu.

06:01.690 --> 06:03.010
And it says one.

06:03.010 --> 06:06.610
Perfect okay I'm going to delete that slot.

06:06.610 --> 06:08.320
I'm going to delete this slot.

06:08.320 --> 06:11.020
And I'll go ahead and delete that slot.

06:11.020 --> 06:16.450
And we're ready to start thinking about how to save our abilities.

06:16.450 --> 06:18.100
And we'll do that next.

06:18.190 --> 06:19.390
I'll see you soon.
