diff --git a/.github/workflows/continuous_build_check.yaml b/.github/workflows/continuous_build_check.yaml index 765f256..831218c 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.3", "4.2.0"] + godotVersion: ["4.1.4", "4.2.2"] targetFramework: ["net6.0", "net7.0"] name: Build runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 52b631c..fbf9c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ 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.6] 2024-05-08 +* Fix #53 where the first OptionView in an OptionsListView could not be interacted with if fadeTime was zero +* Update YarnSpinner core DLL files to [version 2.4.2](https://github.com/YarnSpinnerTool/YarnSpinner/releases/tag/v2.4.2) + * Updated dependency versions: + * Google.Protobuf: Moved from 3.15.0 to 3.25.2. + * Microsoft.Extensions.FileSystemGlobbing: Moved from 7.0.0 to 8.0.0 + * [Standard library functions (e.g. random, round_places, dice)](https://docs.yarnspinner.dev/getting-started/writing-in-yarn/functions#built-in-functions) have been removed from Yarn Spinner for Godot, since they have been added directly to the core Yarn Spinner library. +* Fix #55 where Yarn projects with no scripts added / compiled yet threw exceptions when locale related or 'export strings' were pressed + ## [0.2.5] 2024-04-28 * fix #50 - errors calling Stop if the runner was running a command like wait * fix #44 - show variable declarations in the yarn project inspector diff --git a/README.md b/README.md index 08ba54c..7015426 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To try these samples yourself, open this repository as a Godot project. Feel fre There is a [guide here](https://docs.yarnspinner.dev/beginners-guide/making-a-game/yarn-spinner-for-godot) on the basic installation and usage of the plugin. -See the [docs directory](./docs/Home.md) for more documentation. + Full documentation is available on the same site in [this section](https://docs.yarnspinner.dev/using-yarnspinner-with-godot/overview) ## Features diff --git a/Samples/VisualNovel/Scripts/VisualNovelManager.cs b/Samples/VisualNovel/Scripts/VisualNovelManager.cs index 1fa8ecb..3eb1358 100644 --- a/Samples/VisualNovel/Scripts/VisualNovelManager.cs +++ b/Samples/VisualNovel/Scripts/VisualNovelManager.cs @@ -62,7 +62,7 @@ public override void _Ready() public void StartDialogue(string locale) { TranslationServer.SetLocale(locale); - ((TextLineProvider) _dialogueRunner.lineProvider).textLanguageCode = locale; + ((TextLineProvider)_dialogueRunner.lineProvider).textLanguageCode = locale; _dialogueStartUi.Visible = false; _dialogueCanvas.Visible = true; _dialogueRunner.StartDialogue(_dialogueRunner.startNode); @@ -230,7 +230,7 @@ public async Task MoveSprite(string actorOrSpriteName, string screenPosX = "0.5" // calculate the sprite movement this frame, // trying to normalize it based on framerate var timeRatio = delta / moveTime; - var movement = new Vector2((float) timeRatio * distance.X, (float) timeRatio * distance.Y); + var movement = new Vector2((float)timeRatio * distance.X, (float)timeRatio * distance.Y); actor.Rect.Position += movement; elapsed += delta; await DefaultActions.Wait(delta); // wait a frame @@ -253,8 +253,8 @@ public async Task ShakeSprite(string actorOrSpriteName, float moveTime) Vector2 GetRandomDestination() { return initialPos + - new Vector2(DefaultActions.RandomRange(-40, 40), - DefaultActions.RandomRange(-40, 40)); + new Vector2(GD.RandRange(-40, 40), + GD.RandRange(-40, 40)); } var destination = GetRandomDestination(); @@ -270,7 +270,7 @@ Vector2 GetRandomDestination() iterationsSinceDestinationChange++; } - var distance = (destination - actor.Rect.Position) * (1f / delay)*16; + var distance = (destination - actor.Rect.Position) * (1f / delay) * 16; actor.Rect.Position += distance; await Task.Delay(delay); elapsed += delay; @@ -359,7 +359,7 @@ public async Task Fade(string fadeColorHex, float startAlpha = 0, float endAlpha while (elapsed < fadeTime && Mathf.Abs(endAlpha - newColor.A) > 0.001) { var timeRatio = elapsed / fadeTime; - newColor.A = (float) (startAlpha + timeRatio * colorDifference); + newColor.A = (float)(startAlpha + timeRatio * colorDifference); _colorOverlay.Color = newColor; elapsed += delay / 1000d; await Task.Delay(delay); diff --git a/YarnSpinner-Godot.csproj b/YarnSpinner-Godot.csproj index 92a2616..459d2d5 100644 --- a/YarnSpinner-Godot.csproj +++ b/YarnSpinner-Godot.csproj @@ -1,4 +1,4 @@ - + net6.0 true @@ -17,5 +17,11 @@ + + + + + + \ No newline at end of file diff --git a/addons/YarnSpinner-Godot/Editor/UI/LocaleDeleteButton.cs b/addons/YarnSpinner-Godot/Editor/UI/LocaleDeleteButton.cs index 0904696..07d771a 100644 --- a/addons/YarnSpinner-Godot/Editor/UI/LocaleDeleteButton.cs +++ b/addons/YarnSpinner-Godot/Editor/UI/LocaleDeleteButton.cs @@ -29,7 +29,7 @@ public partial class LocaleDeleteButton : Button /// public void OnPressed() { - if (!IsInstanceValid(Plugin)) + if (IsInstanceValid(Plugin)) { Plugin.RemoveLocale(LocaleCode); } diff --git a/addons/YarnSpinner-Godot/Editor/YarnCompileErrorsPropertyEditor.cs b/addons/YarnSpinner-Godot/Editor/YarnCompileErrorsPropertyEditor.cs index df0b23d..4b41f52 100644 --- a/addons/YarnSpinner-Godot/Editor/YarnCompileErrorsPropertyEditor.cs +++ b/addons/YarnSpinner-Godot/Editor/YarnCompileErrorsPropertyEditor.cs @@ -9,7 +9,7 @@ namespace YarnSpinnerGodot.Editor public partial class YarnCompileErrorsPropertyEditor : EditorProperty { // The main control for editing the property. - private Label _propertyControl = new Label(); + private Label _propertyControl; // An internal value of the property. private Array _currentValue; @@ -19,6 +19,7 @@ public partial class YarnCompileErrorsPropertyEditor : EditorProperty public YarnCompileErrorsPropertyEditor() { + _propertyControl = new Label(); Label = "Project Errors"; // Add the control as a direct child of EditorProperty node. AddChild(_propertyControl); diff --git a/addons/YarnSpinner-Godot/Editor/YarnEditorUtility.cs b/addons/YarnSpinner-Godot/Editor/YarnEditorUtility.cs index 25e1142..d17d0ee 100644 --- a/addons/YarnSpinner-Godot/Editor/YarnEditorUtility.cs +++ b/addons/YarnSpinner-Godot/Editor/YarnEditorUtility.cs @@ -1,8 +1,6 @@ #nullable disable #if TOOLS -using System.Collections.Generic; using Godot; -using Yarn.Compiler; using File = System.IO.File; using Path = System.IO.Path; diff --git a/addons/YarnSpinner-Godot/Editor/YarnImporter.cs b/addons/YarnSpinner-Godot/Editor/YarnImporter.cs index cd62ba1..a95a5e5 100644 --- a/addons/YarnSpinner-Godot/Editor/YarnImporter.cs +++ b/addons/YarnSpinner-Godot/Editor/YarnImporter.cs @@ -12,52 +12,27 @@ namespace YarnSpinnerGodot.Editor /// public partial class YarnImporter : EditorImportPlugin { - public override string[] _GetRecognizedExtensions() => new[] { "yarn" }; - public override string _GetImporterName() - { - return "yarnscript"; - } - - public override string _GetVisibleName() - { - return "Yarn Script"; - } + public override string _GetImporterName() => "yarnscript"; + public override string _GetVisibleName() => "Yarn Script"; public override string _GetSaveExtension() => "tres"; - public override string _GetResourceType() - { - var a = new Array(); - - return "Resource"; - } + public override string _GetResourceType() => "Resource"; - public override int _GetPresetCount() - { - return 0; - } + public override int _GetPresetCount() => 0; - public override float _GetPriority() - { - return 1.0f; - } + public override float _GetPriority() => 1.0f; - public override int _GetImportOrder() - { - return 0; - } + public override int _GetImportOrder() => 0; - public override Array _GetImportOptions(string path, int presetIndex) - { - return new Array(); - } + public override Array _GetImportOptions(string path, int presetIndex) => new(); public override Error _Import( string assetPath, diff --git a/addons/YarnSpinner-Godot/Editor/YarnMarkupPaletteInspectorPlugin.cs b/addons/YarnSpinner-Godot/Editor/YarnMarkupPaletteInspectorPlugin.cs index 8e50681..7d04946 100644 --- a/addons/YarnSpinner-Godot/Editor/YarnMarkupPaletteInspectorPlugin.cs +++ b/addons/YarnSpinner-Godot/Editor/YarnMarkupPaletteInspectorPlugin.cs @@ -14,10 +14,7 @@ namespace YarnSpinnerGodot.Editor [Tool] public partial class YarnMarkupPaletteInspectorPlugin : EditorInspectorPlugin { - public override bool _CanHandle(GodotObject obj) - { - return obj is MarkupPalette; - } + public override bool _CanHandle(GodotObject obj) => obj is MarkupPalette; public override bool _ParseProperty(GodotObject @object, Variant.Type type, string path, diff --git a/addons/YarnSpinner-Godot/Editor/YarnProjectEditorUtility.cs b/addons/YarnSpinner-Godot/Editor/YarnProjectEditorUtility.cs index 9eef53a..0174615 100644 --- a/addons/YarnSpinner-Godot/Editor/YarnProjectEditorUtility.cs +++ b/addons/YarnSpinner-Godot/Editor/YarnProjectEditorUtility.cs @@ -311,9 +311,10 @@ private static bool UpdateLocalizationFile(IEnumerable baseLoc if (modificationsNeeded == false) { if (generateTranslation) - { + { GenerateGodotTranslation(language, csvResourcePath); } + // No changes needed to be done to the translated string // table entries. Stop here. return false; @@ -381,7 +382,11 @@ public static void ClearJSONCache() public static void SaveYarnProject(YarnProject project) { // force the JSON serialization to update before saving - project.baseLocalization.stringTable = project.baseLocalization.stringTable; + if (GodotObject.IsInstanceValid(project.baseLocalization)) + { + project.baseLocalization.stringTable = project.baseLocalization.stringTable; + } + project.LineMetadata = project.LineMetadata; project.ListOfFunctions = project.ListOfFunctions; project.SerializedDeclarations = project.SerializedDeclarations; diff --git a/addons/YarnSpinner-Godot/Editor/YarnProjectInspectorPlugin.cs b/addons/YarnSpinner-Godot/Editor/YarnProjectInspectorPlugin.cs index 71550f7..ea2fbb8 100644 --- a/addons/YarnSpinner-Godot/Editor/YarnProjectInspectorPlugin.cs +++ b/addons/YarnSpinner-Godot/Editor/YarnProjectInspectorPlugin.cs @@ -62,7 +62,7 @@ public override bool _ParseProperty(GodotObject @object, Variant.Type type, { _project = project; // hide some properties that are not editable by the user - var hideProperties = new List + string[] hideProperties = { nameof(YarnProject.LastImportHadAnyStrings), nameof(YarnProject.LastImportHadImplicitStringIDs), @@ -254,6 +254,11 @@ public void CSVFileSelected(string savePath) private void LocaleAdded() { + if (string.IsNullOrEmpty(_localeTextEntry.Text)) + { + return; + } + _project.JSONProject.Localisation[_localeTextEntry.Text] = new Project.LocalizationInfo { @@ -455,7 +460,7 @@ public override void _ParseBegin(GodotObject @object) picker.AddChild(pickerButton); localeGrid.AddChild(picker); var deleteButton = new LocaleDeleteButton - {Text = "X", LocaleCode = locale.Key}; + {Text = "X", LocaleCode = locale.Key, Plugin = this}; deleteButton.Connect(BaseButton.SignalName.Pressed, new Callable(deleteButton, nameof(LocaleDeleteButton.OnPressed))); @@ -485,9 +490,20 @@ public override void _ParseBegin(GodotObject @object) baseLocaleRow.AddChild(changeBaseLocaleButton); AddCustomControl(baseLocaleRow); var writeBaseCSVButton = new Button(); + if (!IsInstanceValid(_project.baseLocalization)) + { + writeBaseCSVButton.Disabled = true; + AddCustomControl(new Label + { + AutowrapMode = TextServer.AutowrapMode.Word, + Text = + "No yarn scripts have been compiled into this project yet.\nYou can't export strings and metadata without compiled yarn script content." + }); + } + writeBaseCSVButton.Text = "Export Strings and Metadata as CSV"; writeBaseCSVButton.TooltipText = - "Write all of the lines in your Yarn Project to a CSV," + + "Write all of the lines in your Yarn Project to a CSV in your base language," + " including the metadata, line IDs, and the names of the nodes" + " in which each line appears."; writeBaseCSVButton.Connect(BaseButton.SignalName.Pressed, diff --git a/addons/YarnSpinner-Godot/Runtime/Commands/DefaultActions.cs b/addons/YarnSpinner-Godot/Runtime/Commands/DefaultActions.cs index 61735eb..f9756ae 100644 --- a/addons/YarnSpinner-Godot/Runtime/Commands/DefaultActions.cs +++ b/addons/YarnSpinner-Godot/Runtime/Commands/DefaultActions.cs @@ -9,6 +9,7 @@ namespace YarnSpinnerGodot public partial class DefaultActions : Godot.Node { #region Commands + /// /// Yarn Spinner defines two built-in commands: "wait", and "stop". /// Stop is defined inside the Virtual Machine (the compiler traps it @@ -18,111 +19,11 @@ public partial class DefaultActions : Godot.Node [YarnCommand("wait")] public static async Task Wait(double duration) { - var mainLoop = Engine.GetMainLoop(); - var sceneTree = mainLoop as SceneTree; + var sceneTree = (SceneTree)Engine.GetMainLoop(); var timer = sceneTree.CreateTimer((float)duration); - await mainLoop.ToSignal(timer, "timeout"); - } - #endregion - - #region Functions - [YarnFunction("random")] - public static float Random() - { - return RandomRange(0, 1); - } - - [YarnFunction("random_range")] - public static float RandomRange(float minInclusive, float maxInclusive) - { - return (float)GD.RandRange(minInclusive, maxInclusive); - } - - /// - /// Pick an integer in the given range. - /// - /// Dice range. - /// A number between [1, ]. - /// - [YarnFunction("dice")] - public static uint Dice(int sides) - { - return (uint)((GD.Randi() +1) % sides); - } - - [YarnFunction("round")] - public static int Round(float num) - { - return (int)RoundPlaces(num, 0); - } - - [YarnFunction("round_places")] - public static float RoundPlaces(float num, int places) - { - return (float)Math.Round(num, places); - } - - [YarnFunction("floor")] - public static int Floor(float num) - { - return Mathf.FloorToInt(num); + await sceneTree.ToSignal(timer, SceneTreeTimer.SignalName.Timeout); } - [YarnFunction("ceil")] - public static int Ceil(float num) - { - return Mathf.CeilToInt(num); - } - - /// - /// Increment if integer, otherwise go to next integer. - /// - [YarnFunction("inc")] - public static int Inc(float num) - { - if (Decimal(num) != 0) - { - return Mathf.CeilToInt(num); - } - return (int)num + 1; - } - - /// - /// Decrement if integer, otherwise go to previous integer. - /// - [YarnFunction("dec")] - public static int Dec(float num) - { - if (Decimal(num) != 0) - { - return Mathf.FloorToInt(num); - } - return (int)num - 1; - } - - /// - /// The decimal portion of the given number. - /// - /// Number to get the decimal portion of. - /// [0, 1) - [YarnFunction("decimal")] - public static float Decimal(float num) - { - return num - Int(num); - } - - /// - /// Truncates the number into an int. This is different to - /// because it rounds to zero rather than - /// negative . - /// - /// Number to truncate. - /// Truncated float value as int. - [YarnFunction("int")] - public static int Int(float num) - { - return (int)Math.Truncate(num); - } #endregion } -} +} \ No newline at end of file diff --git a/addons/YarnSpinner-Godot/Runtime/DLLs/Yarn.System.Text.Encodings.Web.dll b/addons/YarnSpinner-Godot/Runtime/DLLs/Yarn.System.Text.Encodings.Web.dll deleted file mode 100644 index 9297609..0000000 Binary files a/addons/YarnSpinner-Godot/Runtime/DLLs/Yarn.System.Text.Encodings.Web.dll and /dev/null differ diff --git a/addons/YarnSpinner-Godot/Runtime/DLLs/Yarn.System.Text.Json.dll b/addons/YarnSpinner-Godot/Runtime/DLLs/Yarn.System.Text.Json.dll deleted file mode 100644 index 5a22223..0000000 Binary files a/addons/YarnSpinner-Godot/Runtime/DLLs/Yarn.System.Text.Json.dll and /dev/null differ diff --git a/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.Compiler.dll b/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.Compiler.dll index 1f90289..a490be4 100644 Binary files a/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.Compiler.dll and b/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.Compiler.dll differ diff --git a/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.dll b/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.dll index d105f5b..cd0de86 100644 Binary files a/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.dll and b/addons/YarnSpinner-Godot/Runtime/DLLs/YarnSpinner.dll differ diff --git a/addons/YarnSpinner-Godot/Runtime/Views/OptionView.cs b/addons/YarnSpinner-Godot/Runtime/Views/OptionView.cs index 3161369..b089fce 100644 --- a/addons/YarnSpinner-Godot/Runtime/Views/OptionView.cs +++ b/addons/YarnSpinner-Godot/Runtime/Views/OptionView.cs @@ -11,9 +11,9 @@ public partial class OptionView : BaseButton public Action OnOptionSelected; public MarkupPalette palette; - DialogueOption _option; + private DialogueOption _option; - bool hasSubmittedOptionSelection = false; + private bool hasSubmittedOptionSelection = false; public DialogueOption Option { @@ -38,7 +38,7 @@ public DialogueOption Option } label.BbcodeEnabled = true; - if (palette != null) + if (IsInstanceValid(palette)) { label.Text = $"[center]{LineView.PaletteMarkedUpText(line, palette)}[/center]"; diff --git a/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs b/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs index 5ee79a4..25fa964 100644 --- a/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs +++ b/addons/YarnSpinner-Godot/Runtime/Views/OptionsListView.cs @@ -67,134 +67,139 @@ public void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished) public void RunOptions(DialogueOption[] dialogueOptions, Action onOptionSelected) { - viewControl.Visible = false; - // Hide all existing option views - foreach (var optionView in optionViews) - { - optionView.Visible = false; - } + RunOptionsInternal(dialogueOptions, onOptionSelected); + } - // If we don't already have enough option views, create more - while (dialogueOptions.Length > optionViews.Count) + private async void RunOptionsInternal(DialogueOption[] dialogueOptions, Action onOptionSelected) + { + try { - var optionView = CreateNewOptionView(); - optionView.Visible = false; - } + // prevent option views from being pressed by the same input that advanced the dialogue + // by waiting a frame + var mainTree = (SceneTree)Engine.GetMainLoop(); + await mainTree.ToSignal(mainTree, SceneTree.SignalName.ProcessFrame); + viewControl.Visible = false; + // Hide all existing option views + foreach (var optionView in optionViews) + { + optionView.Visible = false; + } - // Set up all of the option views - int optionViewsCreated = 0; + // If we don't already have enough option views, create more + while (dialogueOptions.Length > optionViews.Count) + { + var optionView = CreateNewOptionView(); + optionView.Visible = false; + } - for (int i = 0; i < dialogueOptions.Length; i++) - { - var optionView = optionViews[i]; - var option = dialogueOptions[i]; + // Set up all of the option views + int optionViewsCreated = 0; - if (option.IsAvailable == false && showUnavailableOptions == false) + for (int i = 0; i < dialogueOptions.Length; i++) { - // Don't show this option. - continue; - } + var optionView = optionViews[i]; + var option = dialogueOptions[i]; + + if (option.IsAvailable == false && showUnavailableOptions == false) + { + // Don't show this option. + continue; + } - optionView.Visible = true; + optionView.Visible = true; - optionView.palette = this.palette; - optionView.Option = option; + optionView.palette = this.palette; + optionView.Option = option; - // The first available option is selected by default - if (optionViewsCreated == 0) - { - optionView.GrabFocus(); - } + // The first available option is selected by default + if (optionViewsCreated == 0) + { + optionView.GrabFocus(); + } - optionViewsCreated += 1; - } + optionViewsCreated += 1; + } - // Update the last line, if one is configured - if (IsInstanceValid(lastLineText)) - { - var line = lastSeenLine.Text; - lastLineText.Visible = true; - if (IsInstanceValid(lastLineCharacterNameText)) + // Update the last line, if one is configured + if (IsInstanceValid(lastLineText)) { - if (string.IsNullOrWhiteSpace(lastSeenLine.CharacterName)) + var line = lastSeenLine.Text; + lastLineText.Visible = true; + if (IsInstanceValid(lastLineCharacterNameText)) + { + if (string.IsNullOrWhiteSpace(lastSeenLine.CharacterName)) + { + lastLineCharacterNameText.Visible = false; + } + else + { + line = lastSeenLine.TextWithoutCharacterName; + lastLineCharacterNameText.Visible = true; + lastLineCharacterNameText.Text = lastSeenLine.CharacterName; + } + } + + if (IsInstanceValid(palette)) { - lastLineCharacterNameText.Visible = false; + lastLineText.Text = LineView.PaletteMarkedUpText(line, palette); } else { - line = lastSeenLine.TextWithoutCharacterName; - lastLineCharacterNameText.Visible = true; - lastLineCharacterNameText.Text = lastSeenLine.CharacterName; + lastLineText.Text = line.Text; } } - if (palette != null) - { - lastLineText.Text = LineView.PaletteMarkedUpText(line, palette); - } - else - { - lastLineText.Text = line.Text; - } - } + // Note the delegate to call when an option is selected + OnOptionSelected = onOptionSelected; - // Note the delegate to call when an option is selected - OnOptionSelected = onOptionSelected; + // Fade it all in + await Effects.FadeAlpha(viewControl, 0, 1, fadeTime); - // Fade it all in - Effects.FadeAlpha(viewControl, 0, 1, fadeTime) - .ContinueWith(t => + /// + /// Creates and configures a new , and adds + /// it to . + /// + OptionView CreateNewOptionView() { - if (t.IsFaulted) - { - GD.PrintErr( - $"Error running {nameof(Effects.FadeAlpha)} on {nameof(OptionsListView)}: {t.Exception}"); - } - }); + var optionView = optionViewPrefab.Instantiate(); + boxContainer.AddChild(optionView); - /// - /// Creates and configures a new , and adds - /// it to . - /// - OptionView CreateNewOptionView() - { - var optionView = optionViewPrefab.Instantiate(); - boxContainer.AddChild(optionView); - - optionView.OnOptionSelected = OptionViewWasSelected; - optionViews.Add(optionView); + optionView.OnOptionSelected = OptionViewWasSelected; + optionViews.Add(optionView); - return optionView; - } + return optionView; + } - /// - /// Called by objects. - /// - void OptionViewWasSelected(DialogueOption option) - { - OptionViewWasSelectedInternal(option).ContinueWith(t => + /// + /// Called by objects. + /// + void OptionViewWasSelected(DialogueOption option) { - if (t.IsFaulted) + OptionViewWasSelectedInternal(option).ContinueWith(t => { GD.PrintErr( $"Error running {nameof(OptionViewWasSelected)} on {nameof(OptionsListView)}: {t.Exception}"); - } - }); + }, TaskContinuationOptions.OnlyOnFaulted); - async Task OptionViewWasSelectedInternal(DialogueOption selectedOption) - { - await Effects.FadeAlpha(viewControl, 1, 0, fadeTime); - viewControl.Visible = false; - if (lastLineText != null) + async Task OptionViewWasSelectedInternal(DialogueOption selectedOption) { - lastLineText.Visible = false; - } + await Effects.FadeAlpha(viewControl, 1, 0, fadeTime); + viewControl.Visible = false; + if (lastLineText != null) + { + lastLineText.Visible = false; + } - OnOptionSelected(selectedOption.DialogueOptionID); + OnOptionSelected(selectedOption.DialogueOptionID); + } } - } - optionViews[0].GrabFocus(); + optionViews[0].GrabFocus(); + } + catch (Exception e) + { + GD.PushError($"Error while running {nameof(OptionsListView)}.{nameof(RunOptionsInternal)}(): {e}"); + } } /// @@ -211,17 +216,19 @@ public void DialogueComplete() } viewControl.Visible = false; - Effects.FadeAlpha(viewControl, viewControl.Modulate.A, 0, fadeTime) + Effects.FadeAlpha(viewControl, viewControl.Modulate.A, 0, fadeTime) .ContinueWith(failedTask => - { - var errorMessage = ""; - if (failedTask.Exception != null) { - errorMessage = failedTask.Exception.ToString(); - } - GD.PushError($"Error while running {nameof(Effects.FadeAlpha)}: {errorMessage}"); - }, - TaskContinuationOptions.OnlyOnFaulted);; + var errorMessage = ""; + if (failedTask.Exception != null) + { + errorMessage = failedTask.Exception.ToString(); + } + + GD.PushError($"Error while running {nameof(Effects.FadeAlpha)}: {errorMessage}"); + }, + TaskContinuationOptions.OnlyOnFaulted); + ; } } } diff --git a/addons/YarnSpinner-Godot/YarnSpinner-Godot.props b/addons/YarnSpinner-Godot/YarnSpinner-Godot.props index 76fa7dd..97f9346 100644 --- a/addons/YarnSpinner-Godot/YarnSpinner-Godot.props +++ b/addons/YarnSpinner-Godot/YarnSpinner-Godot.props @@ -3,25 +3,19 @@ - + - + addons\YarnSpinner-Godot\Runtime\DLLs\YarnSpinner.dll addons\YarnSpinner-Godot\Runtime\DLLs\YarnSpinner.Compiler.dll - - addons\YarnSpinner-Godot\Runtime\DLLs\Yarn.System.Text.Json.dll - - - addons\YarnSpinner-Godot\Runtime\DLLs\Yarn.System.Text.Encodings.Web.dll - \ No newline at end of file diff --git a/addons/YarnSpinner-Godot/plugin.cfg b/addons/YarnSpinner-Godot/plugin.cfg index b8e34d9..4778611 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.5" +version="0.2.6" script="YarnSpinnerPlugin.cs"