diff --git a/.github/workflows/continuous_build_check.yaml b/.github/workflows/continuous_build_check.yaml index 831218c..dbe7518 100644 --- a/.github/workflows/continuous_build_check.yaml +++ b/.github/workflows/continuous_build_check.yaml @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - godotVersion: ["4.1.4", "4.2.2"] + godotVersion: ["4.1.4", "4.2.2", "4.3.0"] targetFramework: ["net6.0", "net7.0"] name: Build runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index e1881fb..866cfa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ 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.11] 2024-09-13 +* Fix an issue where the OptionsListView did not fade in properly and instead suddenly appeared at the end of the fade time. (Fix #62) +* `Effects.Fade` now uses a Godot Tween. +* Grab focus of the first visible option in OptionsListView.cs, rather than the first option which may be hidden due to being unavailable. + ## [0.2.10] 2024-07-11 * Update System.Text.Json to 8.0.4 based on CVE-2024-30105 https://github.com/advisories/GHSA-hh2w-p6rv-4g7w * Fix references to `RoundedViewStylebox.tres` that were in the wrong case in resource files, which could cause an issue on case-sensitive platforms. diff --git a/Samples/SQLiteVariableStorage/SQLSample.tscn b/Samples/SQLiteVariableStorage/SQLSample.tscn index 13e8367..84907fb 100644 --- a/Samples/SQLiteVariableStorage/SQLSample.tscn +++ b/Samples/SQLiteVariableStorage/SQLSample.tscn @@ -15,6 +15,13 @@ variableStorage = NodePath("../SQLVariableStorage") startNode = "SqlSample" startAutomatically = true +[node name="LineView" parent="RoundedYarnSpinnerCanvasLayer" index="2"] +useFadeEffect = true +fadeInTime = 1.0 + +[node name="OptionsListView" parent="RoundedYarnSpinnerCanvasLayer" index="3"] +fadeTime = 2.0 + [node name="ColorRect" type="ColorRect" parent="RoundedYarnSpinnerCanvasLayer"] z_index = -6 z_as_relative = false diff --git a/addons/YarnSpinner-Godot/Runtime/Views/Effects.cs b/addons/YarnSpinner-Godot/Runtime/Views/Effects.cs index 6348f00..a300641 100644 --- a/addons/YarnSpinner-Godot/Runtime/Views/Effects.cs +++ b/addons/YarnSpinner-Godot/Runtime/Views/Effects.cs @@ -94,21 +94,25 @@ public static async Task FadeAlpha(Control control, float from, float to, float color.A = from; control.Modulate = color; - var timeElapsed = 0d; + var destinationColor = color; + destinationColor.A = to; - while (timeElapsed < fadeTime) + var tween = control.CreateTween(); + tween.TweenProperty(control, "modulate", destinationColor, fadeTime); + while (tween.IsRunning()) { - if (stopToken?.WasInterrupted ?? false) + if (!GodotObject.IsInstanceValid(control)) { + // the control was deleted from the scene return; } - var fraction = timeElapsed / fadeTime; - timeElapsed += mainTree.Root.GetProcessDeltaTime(); + if (stopToken?.WasInterrupted ?? false) + { + tween.Kill(); + return; + } - float a = Mathf.Lerp(from, to, (float) fraction); - color.A = a; - control.Modulate = color; await DefaultActions.Wait(mainTree.Root.GetProcessDeltaTime()); } @@ -122,7 +126,7 @@ public static async Task FadeAlpha(Control control, float from, float to, float stopToken?.Complete(); } - public static async Task Typewriter(RichTextLabel text, float lettersPerSecond, + public static async Task Typewriter(RichTextLabel text, float lettersPerSecond, Action onCharacterTyped, TaskInterruptToken stopToken = null) { await PausableTypewriter( @@ -231,7 +235,7 @@ public static async Task PausableTypewriter(RichTextLabel text, float lettersPer // the requested speed. var deltaTime = mainTree.Root.GetProcessDeltaTime(); var accumulator = deltaTime; - + while (GodotObject.IsInstanceValid(text) && text.VisibleRatio < 1) { if (!GodotObject.IsInstanceValid(text)) @@ -259,6 +263,7 @@ public static async Task PausableTypewriter(RichTextLabel text, float lettersPer { return; } + onPauseEnded?.Invoke(); // need to reset the accumulator @@ -289,6 +294,7 @@ public static async Task PausableTypewriter(RichTextLabel text, float lettersPer { return; } + // We either finished displaying everything, or were // interrupted. Either way, display everything now. text.VisibleRatio = 1; diff --git a/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs b/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs index 25fa964..ceb5a1e 100644 --- a/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs +++ b/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs @@ -1,6 +1,7 @@ #nullable disable using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Godot; @@ -76,7 +77,7 @@ private async void RunOptionsInternal(DialogueOption[] dialogueOptions, Action view.Visible).GrabFocus(); } catch (Exception e) { diff --git a/addons/YarnSpinner-Godot/plugin.cfg b/addons/YarnSpinner-Godot/plugin.cfg index 4417090..9d21908 100644 --- a/addons/YarnSpinner-Godot/plugin.cfg +++ b/addons/YarnSpinner-Godot/plugin.cfg @@ -3,5 +3,5 @@ name="YarnSpinner-Godot" description="Yarn language based dialogue system plugin for Godot" author="dogboydog" -version="0.2.10" +version="0.2.11" script="YarnSpinnerPlugin.cs"