Skip to content

Commit

Permalink
version 0.2.6 - update yarnspinner core to 2.4.2, fix fadeTime issue …
Browse files Browse the repository at this point in the history
…in optionsListView, fix empty yarn project inspector bugs (#56)
  • Loading branch information
dogboydog authored May 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0d06943 commit b9a8fc3
Showing 21 changed files with 181 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous_build_check.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

12 changes: 6 additions & 6 deletions Samples/VisualNovel/Scripts/VisualNovelManager.cs
Original file line number Diff line number Diff line change
@@ -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);
8 changes: 7 additions & 1 deletion YarnSpinner-Godot.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.2.1">
<Project Sdk="Godot.NET.Sdk/4.2.2">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
@@ -17,5 +17,11 @@
<!-- For SQL variable storage sample -->
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
</ItemGroup>
<ItemGroup>
<Content Include="todotest\NodeCompleteTest.yarn.import" />
<Content Include="todotest\test.tscn" />
<Content Include="todotest\test.yarnproject" />
<Content Include="todotest\test.yarnproject.import" />
</ItemGroup>
<Import Project="addons\YarnSpinner-Godot\YarnSpinner-Godot.props" />
</Project>
2 changes: 1 addition & 1 deletion addons/YarnSpinner-Godot/Editor/UI/LocaleDeleteButton.cs
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ public partial class LocaleDeleteButton : Button
/// </summary>
public void OnPressed()
{
if (!IsInstanceValid(Plugin))
if (IsInstanceValid(Plugin))
{
Plugin.RemoveLocale(LocaleCode);
}
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 0 additions & 2 deletions addons/YarnSpinner-Godot/Editor/YarnEditorUtility.cs
Original file line number Diff line number Diff line change
@@ -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;

39 changes: 7 additions & 32 deletions addons/YarnSpinner-Godot/Editor/YarnImporter.cs
Original file line number Diff line number Diff line change
@@ -12,52 +12,27 @@ namespace YarnSpinnerGodot.Editor
/// </summary>
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<Dictionary> _GetImportOptions(string path, int presetIndex)
{
return new Array<Dictionary>();
}
public override Array<Dictionary> _GetImportOptions(string path, int presetIndex) => new();

public override Error _Import(
string assetPath,
Original file line number Diff line number Diff line change
@@ -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,
9 changes: 7 additions & 2 deletions addons/YarnSpinner-Godot/Editor/YarnProjectEditorUtility.cs
Original file line number Diff line number Diff line change
@@ -311,9 +311,10 @@ private static bool UpdateLocalizationFile(IEnumerable<StringTableEntry> 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;
22 changes: 19 additions & 3 deletions addons/YarnSpinner-Godot/Editor/YarnProjectInspectorPlugin.cs
Original file line number Diff line number Diff line change
@@ -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>
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,
Loading

0 comments on commit b9a8fc3

Please sign in to comment.