Skip to content

Commit 4361921

Browse files
committed
check if lastSeenLine is null before trying to display it in OptionsListView.cs
1 parent e34e599 commit 4361921

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

Samples/Space/Dialogue/Intro.yarn

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ title: SpaceIntro
33
tags:
44
---
55
<<declare $sampleName to "Space">>
6+
-> Test
67
Welcome to the {$sampleName} Sample! Try talking to Sally and the Ship. #line:03f451b
78
===

addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private async void RunOptionsInternal(DialogueOption[] dialogueOptions, Action<i
122122
}
123123

124124
// Update the last line, if one is configured
125-
if (IsInstanceValid(lastLineText))
125+
if (IsInstanceValid(lastLineText) && lastSeenLine != null)
126126
{
127127
var line = lastSeenLine.Text;
128128
lastLineText.Visible = true;
@@ -195,6 +195,7 @@ async Task OptionViewWasSelectedInternal(DialogueOption selectedOption)
195195
OnOptionSelected(selectedOption.DialogueOptionID);
196196
}
197197
}
198+
198199
// If the user is hiding unavailable options, select the first visible one.
199200
optionViews.First(view => view.Visible).GrabFocus();
200201
}
@@ -207,16 +208,15 @@ async Task OptionViewWasSelectedInternal(DialogueOption selectedOption)
207208
/// <inheritdoc />
208209
public void DialogueComplete()
209210
{
210-
// do we still have a line lying around?
211-
if (viewControl.Visible)
211+
lastSeenLine = null;
212+
OnOptionSelected = null;
213+
if (IsInstanceValid(lastLineText))
212214
{
213-
lastSeenLine = null;
214-
OnOptionSelected = null;
215-
if (lastLineText != null)
216-
{
217-
lastLineText.Visible = false;
218-
}
215+
lastLineText.Visible = false;
216+
}
219217

218+
if (viewControl.Visible)
219+
{
220220
viewControl.Visible = false;
221221
Effects.FadeAlpha(viewControl, viewControl.Modulate.A, 0, fadeTime)
222222
.ContinueWith(failedTask =>

addons/YarnSpinner-Godot/Scenes/OptionView.tscn

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ alignment = 1
3232
layout_mode = 2
3333
size_flags_vertical = 6
3434
mouse_filter = 2
35-
theme_override_font_sizes/normal_font_size = 24
36-
theme_override_font_sizes/bold_font_size = 24
37-
theme_override_font_sizes/italics_font_size = 24
3835
theme_override_font_sizes/bold_italics_font_size = 24
36+
theme_override_font_sizes/italics_font_size = 24
3937
theme_override_font_sizes/mono_font_size = 24
38+
theme_override_font_sizes/normal_font_size = 24
39+
theme_override_font_sizes/bold_font_size = 24
4040
bbcode_enabled = true
4141
text = "[center]Option View[/center]"
4242
fit_content = true

addons/YarnSpinner-Godot/Scenes/RoundedOptionView.tscn

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[ext_resource type="StyleBox" uid="uid://itxqi5xpilu6" path="res://addons/YarnSpinner-Godot/Scenes/RoundedViewStylebox.tres" id="1_brfok"]
44
[ext_resource type="Script" path="res://addons/YarnSpinner-Godot/Runtime/Views/OptionView.cs" id="1_uv0oc"]
5-
[ext_resource type="StyleBox" uid="uid://cqadffkf802cr" path="res://addons/YarnSpinner-Godot/Scenes/RoundedViewFocusedStylebox.tres" id="2_tuu8c"]
5+
[ext_resource type="StyleBox" uid="uid://cqadffkf802cr" path="res://addons/YarnSpinner-Godot/Scenes/RoundedViewFocusedStyleBox.tres" id="2_tuu8c"]
66

77
[node name="OptionView" type="Button" node_paths=PackedStringArray("label")]
88
anchors_preset = 7
@@ -19,11 +19,11 @@ grow_vertical = 0
1919
size_flags_horizontal = 3
2020
size_flags_vertical = 3
2121
theme_override_font_sizes/font_size = 36
22-
theme_override_styles/normal = ExtResource("1_brfok")
22+
theme_override_styles/focus = ExtResource("2_tuu8c")
23+
theme_override_styles/disabled = ExtResource("1_brfok")
2324
theme_override_styles/hover = ExtResource("1_brfok")
2425
theme_override_styles/pressed = ExtResource("1_brfok")
25-
theme_override_styles/disabled = ExtResource("1_brfok")
26-
theme_override_styles/focus = ExtResource("2_tuu8c")
26+
theme_override_styles/normal = ExtResource("1_brfok")
2727
script = ExtResource("1_uv0oc")
2828
label = NodePath("VBoxContainer/RichTextLabel")
2929

@@ -41,19 +41,19 @@ alignment = 1
4141
layout_mode = 2
4242
size_flags_vertical = 6
4343
mouse_filter = 2
44+
theme_override_colors/table_border = Color(0, 0, 0, 1)
45+
theme_override_colors/table_even_row_bg = Color(0, 0, 0, 1)
46+
theme_override_colors/table_odd_row_bg = Color(0, 0, 0, 1)
4447
theme_override_colors/default_color = Color(0, 0, 0, 1)
4548
theme_override_colors/font_selected_color = Color(0, 0, 0, 1)
4649
theme_override_colors/selection_color = Color(0, 0, 0, 1)
47-
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
4850
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
49-
theme_override_colors/table_odd_row_bg = Color(0, 0, 0, 1)
50-
theme_override_colors/table_even_row_bg = Color(0, 0, 0, 1)
51-
theme_override_colors/table_border = Color(0, 0, 0, 1)
52-
theme_override_font_sizes/normal_font_size = 24
53-
theme_override_font_sizes/bold_font_size = 24
54-
theme_override_font_sizes/italics_font_size = 24
51+
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
5552
theme_override_font_sizes/bold_italics_font_size = 24
53+
theme_override_font_sizes/italics_font_size = 24
5654
theme_override_font_sizes/mono_font_size = 24
55+
theme_override_font_sizes/normal_font_size = 24
56+
theme_override_font_sizes/bold_font_size = 24
5757
bbcode_enabled = true
5858
text = "[center]Option View[/center]"
5959
fit_content = true

0 commit comments

Comments
 (0)