WEBVTT

00:06.810 --> 00:07.980
Welcome back.

00:07.980 --> 00:11.160
Now things are looking good in the spell menu hood.

00:11.460 --> 00:17.580
If we click on a spell globe, we can see the descriptions and everything, but it'd be kind of nice

00:17.580 --> 00:20.490
if we could deselect by clicking on it again.

00:20.490 --> 00:24.990
So if it's already selected and we click on it, we should deselect it.

00:24.990 --> 00:26.130
That would be nice.

00:26.130 --> 00:33.090
And then we can just broadcast something to clear out the descriptions and set that selected ability

00:33.090 --> 00:36.030
in the widget controller to none.

00:36.030 --> 00:36.560
Right?

00:36.570 --> 00:45.120
So let's make a function on the widget controller class for Deselecting one of our spell globes.

00:45.120 --> 00:52.860
So I'm going to go to public UI widget controller, spell menu, widget controller and we'll make a

00:52.860 --> 00:54.720
function that's blueprint callable.

00:54.720 --> 01:01.740
For this, it'll be void and we'll call this Globe Deselect.

01:01.830 --> 01:07.900
It'll take a const gameplay tag reference called ability tag.

01:08.560 --> 01:10.900
And what should we do?

01:10.930 --> 01:22.390
We should first of all set our selected ability so we can say selected ability equals for a gameplay

01:22.390 --> 01:25.690
tags get dot abilities.

01:25.720 --> 01:26.500
None.

01:27.550 --> 01:29.860
And we can set the status to locked as well.

01:29.860 --> 01:36.130
And it's actually selected ability, ability and the status for selected ability.

01:36.610 --> 01:46.960
So selected ability status can be for a gameplay tags dot get dot ability status locked.

01:48.230 --> 01:53.360
Now, we don't really need to know which Globe has deselected itself, do we?

01:53.660 --> 01:56.210
All we need to do is just clear things out.

01:56.210 --> 01:58.670
So I'm going to remove that input parameter.

01:58.700 --> 02:00.590
We actually don't need to know.

02:02.660 --> 02:07.640
So Globe Deselect is just going to set the selected ability to none.

02:08.000 --> 02:13.220
And then we can broadcast spell globe selected delegate.

02:14.660 --> 02:24.020
Only we can pass in false for both booleans to disable both buttons and the two description strings

02:24.020 --> 02:25.700
can be the empty string.

02:25.820 --> 02:31.760
F string loop autocomplete sometimes can get out of hand.

02:31.940 --> 02:33.020
F string.

02:34.600 --> 02:36.010
And F string.

02:37.540 --> 02:42.730
So with this, we should see those buttons be disabled.

02:42.730 --> 02:43.960
Let's give this a try.

02:44.380 --> 02:45.820
Oh, before we give it a try.

02:45.850 --> 02:52.060
This has to be blueprint callable, so I'm going to hit cancel there and make this a blueprint callable

02:52.060 --> 02:55.690
function like so.

02:56.020 --> 02:57.460
And we can test this.

02:57.460 --> 03:01.420
Now, there's something we have to do when we select a globe.

03:01.420 --> 03:04.690
The globe itself needs to know if it's already selected.

03:04.690 --> 03:10.660
So a globe should have a boolean so it knows if it's selected already or not.

03:13.130 --> 03:13.520
Okay.

03:13.520 --> 03:22.060
So what we need to do is go into our spell globe button and right here, as soon as we're clicking,

03:22.070 --> 03:26.240
what we need to do is check to see if we're already selected.

03:26.240 --> 03:28.190
Well, that means we need a boolean.

03:28.190 --> 03:37.370
So let's add a variable called selected and selected is going to be set whenever we actually select

03:37.370 --> 03:44.840
that should be in the select function because that's when we actually show our selection circle texture.

03:44.840 --> 03:48.110
So we'll set it here to true.

03:50.340 --> 03:53.430
When selected and when deselected.

03:53.430 --> 03:57.510
Whenever deselect gets called, we'll set it back to false.

04:00.230 --> 04:02.840
So we'll set it to false right here.

04:04.090 --> 04:11.200
Now when we are clicking on a spell globe, we should check to see if we're already selected.

04:11.200 --> 04:12.430
If we are.

04:12.670 --> 04:14.740
If selected is true.

04:14.950 --> 04:20.680
Well, if that's the case, we're going to do something entirely different, and only if selected is

04:20.680 --> 04:24.410
false are we going to go through what we were doing before.

04:24.430 --> 04:26.770
But if selected is already true.

04:26.860 --> 04:31.330
Well, what I'd like to do is first of all deselect.

04:31.330 --> 04:39.730
So we're going to call deselect, it'll set render opacity to zero and set selected back to false so

04:39.730 --> 04:41.950
we can call deselect here.

04:43.620 --> 04:53.010
But we can also get the widget controller and call the new blueprint callable function globe Deselect.

04:54.980 --> 05:02.690
And this will handle things on the plus side, such as setting the current selected ability to none

05:02.690 --> 05:10.850
and broadcasting the delegate that our spell menu needs to receive to disable its buttons and empty

05:10.850 --> 05:12.860
out the description strings.

05:12.890 --> 05:13.940
Let's try it.

05:13.970 --> 05:14.980
We click.

05:14.990 --> 05:16.160
We click again.

05:16.160 --> 05:17.030
We click.

05:17.030 --> 05:18.200
We click again.

05:20.000 --> 05:20.840
It works.

05:20.840 --> 05:23.260
And if we click on one, then click another.

05:23.270 --> 05:24.770
It works as expected.

05:24.770 --> 05:28.160
It's only if we click on one that's already currently selected.

05:28.280 --> 05:29.840
Pretty nice.

05:30.350 --> 05:31.070
Now.

05:31.070 --> 05:34.550
It should make a sound when we deselect it.

05:34.550 --> 05:36.710
So we'll just play a sound right here.

05:36.800 --> 05:41.960
And that sound doesn't necessarily have to be the same sound that we've been using.

05:42.110 --> 05:44.870
So let's do a play sound.

05:46.220 --> 05:54.770
To D And why don't we just take a look at the sounds we have content, assets, sounds, UI.

05:59.100 --> 06:00.360
We have a cancel.

06:03.600 --> 06:06.300
Let's try one of these cancels and see how it sounds.

06:10.040 --> 06:10.940
So listening.

06:10.940 --> 06:11.720
Close.

06:16.490 --> 06:17.360
That one's okay.

06:17.360 --> 06:19.670
Let's try a different cancel.

06:32.300 --> 06:33.230
Okay.

06:37.820 --> 06:39.290
I'm going to try the third one.

06:56.040 --> 06:58.350
Those sound pretty good, but I'm going to try.

07:05.760 --> 07:07.590
I'm going to try one of the hover sounds.

07:13.410 --> 07:14.700
Yeah, I like that.

07:19.890 --> 07:20.580
Perfect.

07:20.610 --> 07:22.080
Now we can deselect.

07:23.570 --> 07:26.990
And I can just test my other stuff.

07:28.700 --> 07:33.000
So I'm going to go ahead and upgrade this one and deselect it.

07:33.020 --> 07:33.740
Look at that.

07:33.740 --> 07:34.700
Cool.

07:39.850 --> 07:40.630
Excellent.

07:41.650 --> 07:47.680
Okay, so there's an edge case I want to check, and that's when I level up with nothing selected.

07:47.800 --> 07:49.870
Let's go ahead and just level up.

07:53.530 --> 07:54.100
All right.

07:54.100 --> 07:59.580
So just as I suspected, we get this spell locked into level one.

07:59.590 --> 08:04.870
Now, as soon as we level up with nothing selected, we shouldn't really see anything.

08:04.990 --> 08:08.800
So I'm going to want to find out why we see that.

08:09.750 --> 08:17.760
Now we get a spell description whenever spell points change and when the ability status changes and

08:17.760 --> 08:21.330
both of those get the description from the ability system component.

08:21.360 --> 08:30.210
So if we go to the aura ability system component into get descriptions by ability tag, then when we

08:30.210 --> 08:34.620
don't have anything selected, the ability tag should be abilities none.

08:35.250 --> 08:41.610
And what we're doing is we're checking if the ability info has that tag and we're checking the level

08:41.610 --> 08:45.950
requirement for a real ability that exists in ability info.

08:45.960 --> 08:53.190
But if it's abilities none or an invalid tag, then our description should be an empty string.

08:53.280 --> 08:55.200
So I'd like to check.

08:55.200 --> 09:04.620
I'd like to say first of all, if ability tag is valid and we'll just have a not as valid here and we'll

09:04.620 --> 09:17.670
have an Or and say or ability tag dot matches tag we'll say matches tag exact abilities none so or ability

09:17.670 --> 09:21.990
tags get abilities none.

09:22.860 --> 09:28.650
And either of those cases we have a non valid tag or the tag is abilities.

09:28.680 --> 09:29.400
None.

09:29.460 --> 09:37.150
In that case I'm going to set out description to the empty string so equals just f string.

09:38.120 --> 09:40.610
And then we'll have an else case.

09:40.610 --> 09:45.890
And in the else case, we'll set out description to get locked.

09:45.890 --> 09:46.580
Description.

09:46.580 --> 09:51.890
So we'll have the lock description if it's a valid tag, if it's not a valid tag, we're not going to

09:51.890 --> 09:59.330
show anything because there's no point in showing the level requirement in a message if there's no valid

09:59.360 --> 10:06.140
tag there and there won't be a valid tag if we deselect because our spell menu widget controller now

10:06.140 --> 10:12.020
has a globe deselect which will set that ability to abilities none.

10:12.290 --> 10:15.950
So with that we should be able to test this out.

10:17.560 --> 10:21.430
And we'll go ahead and press play.

10:21.790 --> 10:23.440
We'll level up.

10:30.250 --> 10:30.850
All right.

10:30.850 --> 10:32.710
And we don't see anything there.

10:32.830 --> 10:39.630
And I'm going to also test if I've already selected something and deselected.

10:39.640 --> 10:41.230
Let's level up again.

10:43.430 --> 10:44.900
And we don't see anything.

10:44.900 --> 10:48.620
It's not until we have something selected that we see something.

10:49.010 --> 10:56.660
And don't worry about this ability showing the lower ipsum that is the default description right in

10:56.660 --> 10:58.160
or a gameplay ability.

10:58.160 --> 11:04.160
And that's just there to tell us that this ability doesn't have a valid description.

11:04.160 --> 11:10.250
And then these don't have any valid gameplay ability tags set to them, so we shouldn't see anything

11:10.250 --> 11:10.910
for them.

11:11.780 --> 11:12.780
Perfect.

11:12.800 --> 11:14.670
So that concludes this video.

11:14.690 --> 11:16.820
I'll see you in the next one.
