From dc5b955028480004fa39cd1ee70c8c8b7316c1bd Mon Sep 17 00:00:00 2001 From: dogboydog Date: Thu, 23 Jan 2025 00:31:21 -0500 Subject: [PATCH] v 0.2 Fix lastLineText visibility when dialogue begins with an option (#78) * check if lastSeenLine is null before trying to display it in OptionsListView.cs * remove temporary option, update CHANGELOG.md --- CHANGELOG.md | 4 ++++ .../Runtime/Views/OptionsListView.cs | 18 +++++++-------- .../YarnSpinner-Godot/Scenes/OptionView.tscn | 6 ++--- .../Scenes/RoundedOptionView.tscn | 22 +++++++++---------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 103be53..dcc04a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.2.15] 2025-1-23 + +* Fixed an issue where an exception could be raised if OptionsListView has lastLineText set, and dialogue begins with an option. + ## [0.2.14] 2024-11-02 * GDScript: Add GDScriptViewAdapter, a C# Script which allows you to write custom dialogue views in GDScript. See GDScriptViewAdapter.cs for more details. * GDScript: Add new method AddCommandHandlerCallable to DialogueRunner, allowing commands to be registered from GDScript. GDScript command handlers that use asynchronous `await` functionality are also supported as blocking YarnSpinner commands, similar to using `async Task` commands in C#. diff --git a/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs b/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs index b987098..38721bf 100644 --- a/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs +++ b/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs @@ -122,7 +122,7 @@ private async void RunOptionsInternal(DialogueOption[] dialogueOptions, Action view.Visible).GrabFocus(); } @@ -207,16 +208,15 @@ async Task OptionViewWasSelectedInternal(DialogueOption selectedOption) /// public void DialogueComplete() { - // do we still have a line lying around? - if (viewControl.Visible) + lastSeenLine = null; + OnOptionSelected = null; + if (IsInstanceValid(lastLineText)) { - lastSeenLine = null; - OnOptionSelected = null; - if (lastLineText != null) - { - lastLineText.Visible = false; - } + lastLineText.Visible = false; + } + if (viewControl.Visible) + { viewControl.Visible = false; Effects.FadeAlpha(viewControl, viewControl.Modulate.A, 0, fadeTime) .ContinueWith(failedTask => diff --git a/addons/YarnSpinner-Godot/Scenes/OptionView.tscn b/addons/YarnSpinner-Godot/Scenes/OptionView.tscn index b831b56..52d2619 100644 --- a/addons/YarnSpinner-Godot/Scenes/OptionView.tscn +++ b/addons/YarnSpinner-Godot/Scenes/OptionView.tscn @@ -32,11 +32,11 @@ alignment = 1 layout_mode = 2 size_flags_vertical = 6 mouse_filter = 2 -theme_override_font_sizes/normal_font_size = 24 -theme_override_font_sizes/bold_font_size = 24 -theme_override_font_sizes/italics_font_size = 24 theme_override_font_sizes/bold_italics_font_size = 24 +theme_override_font_sizes/italics_font_size = 24 theme_override_font_sizes/mono_font_size = 24 +theme_override_font_sizes/normal_font_size = 24 +theme_override_font_sizes/bold_font_size = 24 bbcode_enabled = true text = "[center]Option View[/center]" fit_content = true diff --git a/addons/YarnSpinner-Godot/Scenes/RoundedOptionView.tscn b/addons/YarnSpinner-Godot/Scenes/RoundedOptionView.tscn index e9423aa..7dfe3ba 100644 --- a/addons/YarnSpinner-Godot/Scenes/RoundedOptionView.tscn +++ b/addons/YarnSpinner-Godot/Scenes/RoundedOptionView.tscn @@ -2,7 +2,7 @@ [ext_resource type="StyleBox" uid="uid://itxqi5xpilu6" path="res://addons/YarnSpinner-Godot/Scenes/RoundedViewStylebox.tres" id="1_brfok"] [ext_resource type="Script" path="res://addons/YarnSpinner-Godot/Runtime/Views/OptionView.cs" id="1_uv0oc"] -[ext_resource type="StyleBox" uid="uid://cqadffkf802cr" path="res://addons/YarnSpinner-Godot/Scenes/RoundedViewFocusedStylebox.tres" id="2_tuu8c"] +[ext_resource type="StyleBox" uid="uid://cqadffkf802cr" path="res://addons/YarnSpinner-Godot/Scenes/RoundedViewFocusedStyleBox.tres" id="2_tuu8c"] [node name="OptionView" type="Button" node_paths=PackedStringArray("label")] anchors_preset = 7 @@ -19,11 +19,11 @@ grow_vertical = 0 size_flags_horizontal = 3 size_flags_vertical = 3 theme_override_font_sizes/font_size = 36 -theme_override_styles/normal = ExtResource("1_brfok") +theme_override_styles/focus = ExtResource("2_tuu8c") +theme_override_styles/disabled = ExtResource("1_brfok") theme_override_styles/hover = ExtResource("1_brfok") theme_override_styles/pressed = ExtResource("1_brfok") -theme_override_styles/disabled = ExtResource("1_brfok") -theme_override_styles/focus = ExtResource("2_tuu8c") +theme_override_styles/normal = ExtResource("1_brfok") script = ExtResource("1_uv0oc") label = NodePath("VBoxContainer/RichTextLabel") @@ -41,19 +41,19 @@ alignment = 1 layout_mode = 2 size_flags_vertical = 6 mouse_filter = 2 +theme_override_colors/table_border = Color(0, 0, 0, 1) +theme_override_colors/table_even_row_bg = Color(0, 0, 0, 1) +theme_override_colors/table_odd_row_bg = Color(0, 0, 0, 1) theme_override_colors/default_color = Color(0, 0, 0, 1) theme_override_colors/font_selected_color = Color(0, 0, 0, 1) theme_override_colors/selection_color = Color(0, 0, 0, 1) -theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) theme_override_colors/font_outline_color = Color(0, 0, 0, 1) -theme_override_colors/table_odd_row_bg = Color(0, 0, 0, 1) -theme_override_colors/table_even_row_bg = Color(0, 0, 0, 1) -theme_override_colors/table_border = Color(0, 0, 0, 1) -theme_override_font_sizes/normal_font_size = 24 -theme_override_font_sizes/bold_font_size = 24 -theme_override_font_sizes/italics_font_size = 24 +theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) theme_override_font_sizes/bold_italics_font_size = 24 +theme_override_font_sizes/italics_font_size = 24 theme_override_font_sizes/mono_font_size = 24 +theme_override_font_sizes/normal_font_size = 24 +theme_override_font_sizes/bold_font_size = 24 bbcode_enabled = true text = "[center]Option View[/center]" fit_content = true