Skip to content

Commit

Permalink
v 0.2 Fix lastLineText visibility when dialogue begins with an option (
Browse files Browse the repository at this point in the history
…#78)

* check if lastSeenLine is null before trying to display it in OptionsListView.cs

* remove temporary option, update CHANGELOG.md
  • Loading branch information
dogboydog authored Jan 23, 2025
1 parent e34e599 commit dc5b955
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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#.
Expand Down
18 changes: 9 additions & 9 deletions addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private async void RunOptionsInternal(DialogueOption[] dialogueOptions, Action<i
}

// Update the last line, if one is configured
if (IsInstanceValid(lastLineText))
if (IsInstanceValid(lastLineText) && lastSeenLine != null)
{
var line = lastSeenLine.Text;
lastLineText.Visible = true;
Expand Down Expand Up @@ -195,6 +195,7 @@ async Task OptionViewWasSelectedInternal(DialogueOption selectedOption)
OnOptionSelected(selectedOption.DialogueOptionID);
}
}

// If the user is hiding unavailable options, select the first visible one.
optionViews.First(view => view.Visible).GrabFocus();
}
Expand All @@ -207,16 +208,15 @@ async Task OptionViewWasSelectedInternal(DialogueOption selectedOption)
/// <inheritdoc />
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 =>
Expand Down
6 changes: 3 additions & 3 deletions addons/YarnSpinner-Godot/Scenes/OptionView.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions addons/YarnSpinner-Godot/Scenes/RoundedOptionView.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")

Expand All @@ -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
Expand Down

0 comments on commit dc5b955

Please sign in to comment.