From ffe4ad8538ee818697768e4ce97a66f15397c076 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sat, 6 Aug 2022 18:59:27 +0200 Subject: [PATCH 1/2] [godot] Fix compilation for 3.x, update to 3.5-stable --- .github/workflows/spine-godot.yml | 4 ++-- spine-godot/README.md | 16 ++++++++-------- spine-godot/spine_godot/SpineSprite.cpp | 9 +++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/spine-godot.yml b/.github/workflows/spine-godot.yml index 20b742243..09cb42a2e 100644 --- a/.github/workflows/spine-godot.yml +++ b/.github/workflows/spine-godot.yml @@ -13,8 +13,8 @@ env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true EM_VERSION: 3.1.10 - GODOT_TAG: 3.4.4-stable - GODOT_VERSION: 3.4.4.stable + GODOT_TAG: 3.5-stable + GODOT_VERSION: 3.5.stable jobs: diff --git a/spine-godot/README.md b/spine-godot/README.md index 4a987cbf5..2ce420e41 100644 --- a/spine-godot/README.md +++ b/spine-godot/README.md @@ -22,18 +22,18 @@ spine-godot supports all Spine features, except two-color tinting and the screen ## Setup -spine-godot works with the latest stable Godot 3.4 release. It requires compilation of Godot, as spine-godot is implemented as a module. +spine-godot works with the latest stable Godot 3.5 release. It requires compilation of Godot, as spine-godot is implemented as a module. > *NOTE:* spine-godot also compiles and works against Godot 4.x. However, we currently can not guarantee stability, as Godot 4.x is still heavily in flux. ### Pre-built Godot editor and export template binaries -We provide prebuilt Godot editor and export template binaries for Godot 3.4.4-stable: +We provide prebuilt Godot editor and export template binaries for Godot 3.5-stable: -* [Godot Editor Windows](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.4.4-stable/godot-editor-windows.zip) -* [Godot Editor Linux](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.4.4-stable/godot-editor-linux.zip) -* [Godot Editor macOS](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.4.4-stable/godot-editor-macos.zip) -* [Godot export templates for Windows, Linux, macOS, Web, Android, iOS](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.4.4-stable/spine-godot-templates-4.1-3.4.4-stable.tpz) +* [Godot Editor Windows](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.5-stable/godot-editor-windows.zip) +* [Godot Editor Linux](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.5-stable/godot-editor-linux.zip) +* [Godot Editor macOS](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.5-stable/godot-editor-macos.zip) +* [Godot export templates for Windows, Linux, macOS, Web, Android, iOS](https://spine-godot.s3.eu-central-1.amazonaws.com/4.1/3.5-stable/spine-godot-templates-4.1-3.5-stable.tpz) ### Building the Godot editor and export templates locally @@ -59,7 +59,7 @@ To build the export template for a specific platform, run the following in a Bas ``` cd spine-godot -./build/setup.sh 3.4.4-stable false +./build/setup.sh 3.5-stable false ./build/build-templates.sh windows ``` @@ -79,7 +79,7 @@ This repository contains a GitHub workflow in `.github/workflows/spine-godot.yml The resulting binaries will be attached as artifacts to a sucessful workflow run. ## Example -Sample projects for both Godot 3.4.x and Godot 4.x are provided in the `example/` and `example-v4/` folders respectively. They illustrate all spine-godot functionality and can be opened and exported with the pre-built or custom build Godot editor and export template binaries. +Sample projects for both Godot 3.5.x and Godot 4.x are provided in the `example/` and `example-v4/` folders respectively. They illustrate all spine-godot functionality and can be opened and exported with the pre-built or custom build Godot editor and export template binaries. diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index 40ccc5a03..d79fefa15 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -831,12 +831,21 @@ void SpineSprite::draw() { auto global_scale = get_global_scale(); draw_set_transform(mouse_position + Vector2(20, 0), -get_global_rotation(), Vector2(inverse_zoom * (1 / global_scale.x), inverse_zoom * (1 / global_scale.y))); +#if VERSION_MAJOR > 3 float line_height = default_font->get_height(Font::DEFAULT_FONT_SIZE) + default_font->get_descent(Font::DEFAULT_FONT_SIZE); +#else + float line_height = default_font->get_height() + default_font->get_descent(); +#endif float rect_width = 0; for (int i = 0; i < hover_text_lines.size(); i++) { rect_width = MAX(rect_width, default_font->get_string_size(hover_text_lines[i]).x); } + +#if VERSION_MAJOR > 3 Rect2 background_rect(0, -default_font->get_height(Font::DEFAULT_FONT_SIZE) - 5, rect_width + 20, line_height * hover_text_lines.size() + 10); +#else +Rect2 background_rect(0, -default_font->get_height() - 5, rect_width + 20, line_height * hover_text_lines.size() + 10); +#endif if (hover_text_lines.size() > 0) draw_rect(background_rect, Color(0, 0, 0, 0.8)); for (int i = 0; i < hover_text_lines.size(); i++) { #if VERSION_MAJOR > 3 From 62f0c6decaf65723fd9631d83cfe9ce5e0b4d715 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sat, 6 Aug 2022 19:26:08 +0200 Subject: [PATCH 2/2] [godot] Fixes for latest Godot 4.0, closes #2133, fix setters. --- spine-godot/example-v4/project.godot | 2 +- spine-godot/spine_godot/SpineAnimationTrack.cpp | 4 ++-- spine-godot/spine_godot/SpineAnimationTrack.h | 4 ++-- spine-godot/spine_godot/SpineAtlasResource.cpp | 4 ++++ spine-godot/spine_godot/SpineAtlasResource.h | 4 ++++ spine-godot/spine_godot/SpineEditorPlugin.cpp | 14 +++++++++++++- .../spine_godot/SpineSkeletonFileResource.cpp | 4 ++++ .../spine_godot/SpineSkeletonFileResource.h | 4 ++++ spine-godot/spine_godot/SpineSprite.cpp | 2 +- 9 files changed, 35 insertions(+), 7 deletions(-) diff --git a/spine-godot/example-v4/project.godot b/spine-godot/example-v4/project.godot index e989f7857..e6cb6f038 100644 --- a/spine-godot/example-v4/project.godot +++ b/spine-godot/example-v4/project.godot @@ -12,9 +12,9 @@ config_version=5 config/name="spine-godot-examples" run/main_scene="res://examples/08-animation-player/animation-player.tscn" +config/features=PackedStringArray("4.0") run/low_processor_mode=true config/icon="res://icon.png" -config/features=PackedStringArray("4.0") [global] diff --git a/spine-godot/spine_godot/SpineAnimationTrack.cpp b/spine-godot/spine_godot/SpineAnimationTrack.cpp index b99237af7..ec188768f 100644 --- a/spine-godot/spine_godot/SpineAnimationTrack.cpp +++ b/spine-godot/spine_godot/SpineAnimationTrack.cpp @@ -487,7 +487,7 @@ float SpineAnimationTrack::get_alpha() { return alpha; } -void SpineAnimationTrack::set_attachment_threshold(bool _attachment_threshold) { +void SpineAnimationTrack::set_attachment_threshold(float _attachment_threshold) { attachment_threshold = _attachment_threshold; } @@ -495,7 +495,7 @@ float SpineAnimationTrack::get_attachment_threshold() { return attachment_threshold; } -void SpineAnimationTrack::set_draw_order_threshold(bool _draw_order_threshold) { +void SpineAnimationTrack::set_draw_order_threshold(float _draw_order_threshold) { draw_order_threshold = _draw_order_threshold; } diff --git a/spine-godot/spine_godot/SpineAnimationTrack.h b/spine-godot/spine_godot/SpineAnimationTrack.h index 2cce79256..67f79d255 100644 --- a/spine-godot/spine_godot/SpineAnimationTrack.h +++ b/spine-godot/spine_godot/SpineAnimationTrack.h @@ -113,11 +113,11 @@ public: float get_alpha(); - void set_attachment_threshold(bool _attachment_threshold); + void set_attachment_threshold(float _attachment_threshold); float get_attachment_threshold(); - void set_draw_order_threshold(bool _draw_order_threshold); + void set_draw_order_threshold(float _draw_order_threshold); float get_draw_order_threshold(); diff --git a/spine-godot/spine_godot/SpineAtlasResource.cpp b/spine-godot/spine_godot/SpineAtlasResource.cpp index 1fd685786..5665c0306 100644 --- a/spine-godot/spine_godot/SpineAtlasResource.cpp +++ b/spine-godot/spine_godot/SpineAtlasResource.cpp @@ -254,7 +254,11 @@ bool SpineAtlasResourceFormatLoader::handles_type(const String &type) const { return type == "SpineAtlasResource" || ClassDB::is_parent_class(type, "SpineAtlasResource"); } +#if VERSION_MAJOR > 3 +Error SpineAtlasResourceFormatSaver::save(const RES &resource, const String &path, uint32_t flags) { +#else Error SpineAtlasResourceFormatSaver::save(const String &path, const RES &resource, uint32_t flags) { +#endif Ref res = resource; return res->save_to_file(path); } diff --git a/spine-godot/spine_godot/SpineAtlasResource.h b/spine-godot/spine_godot/SpineAtlasResource.h index 2de2b54e0..3ae6344ce 100644 --- a/spine-godot/spine_godot/SpineAtlasResource.h +++ b/spine-godot/spine_godot/SpineAtlasResource.h @@ -97,7 +97,11 @@ class SpineAtlasResourceFormatSaver : public ResourceFormatSaver { GDCLASS(SpineAtlasResourceFormatSaver, ResourceFormatSaver) public: +#if VERSION_MAJOR > 3 + Error save(const RES &resource, const String &path, uint32_t flags) override; +#else Error save(const String &path, const RES &resource, uint32_t flags) override; +#endif void get_recognized_extensions(const RES &resource, List *extensions) const override; diff --git a/spine-godot/spine_godot/SpineEditorPlugin.cpp b/spine-godot/spine_godot/SpineEditorPlugin.cpp index eb6841b7d..e367b37f2 100644 --- a/spine-godot/spine_godot/SpineEditorPlugin.cpp +++ b/spine-godot/spine_godot/SpineEditorPlugin.cpp @@ -42,7 +42,11 @@ Error SpineAtlasResourceImportPlugin::import(const String &source_file, const St atlas->load_from_atlas_file(source_file); String file_name = vformat("%s.%s", save_path, get_save_extension()); +#if VERSION_MAJOR > 3 + auto error = ResourceSaver::save(atlas, file_name); +#else auto error = ResourceSaver::save(file_name, atlas); +#endif return error; } @@ -70,7 +74,11 @@ Error SpineJsonResourceImportPlugin::import(const String &source_file, const Str skeleton_file_res->load_from_file(source_file); String file_name = vformat("%s.%s", save_path, get_save_extension()); +#if VERSION_MAJOR > 3 + auto error = ResourceSaver::save(skeleton_file_res, file_name); +#else auto error = ResourceSaver::save(file_name, skeleton_file_res); +#endif return error; } @@ -83,7 +91,11 @@ Error SpineBinaryResourceImportPlugin::import(const String &source_file, const S skeleton_file_res->load_from_file(source_file); String file_name = vformat("%s.%s", save_path, get_save_extension()); +#if VERSION_MAJOR > 3 + auto error = ResourceSaver::save(skeleton_file_res, file_name); +#else auto error = ResourceSaver::save(file_name, skeleton_file_res); +#endif return error; } @@ -205,7 +217,7 @@ void SpineEditorPropertyAnimationMixes::update_property() { hbox->add_child(delete_button); delete_button->set_text("Remove"); #if VERSION_MAJOR > 3 - delete_button->connect("pressed", callable_mp(this, &SpineEditorPropertyAnimationMixes::delete_mix), varray(i)); + delete_button->connect("pressed", callable_mp(this, &SpineEditorPropertyAnimationMixes::delete_mix), i); #else delete_button->connect("pressed", this, "delete_mix", varray(i)); #endif diff --git a/spine-godot/spine_godot/SpineSkeletonFileResource.cpp b/spine-godot/spine_godot/SpineSkeletonFileResource.cpp index 1c617fc81..ad5395eb1 100644 --- a/spine-godot/spine_godot/SpineSkeletonFileResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonFileResource.cpp @@ -94,7 +94,11 @@ bool SpineSkeletonFileResourceFormatLoader::handles_type(const String &type) con return type == "SpineSkeletonFileResource" || ClassDB::is_parent_class(type, "SpineSkeletonFileResource"); } +#if VERSION_MAJOR > 3 +Error SpineSkeletonFileResourceFormatSaver::save(const RES &resource, const String &path, uint32_t flags) { +#else Error SpineSkeletonFileResourceFormatSaver::save(const String &path, const RES &resource, uint32_t flags) { +#endif Ref res = resource; Error error = res->save_to_file(path); return error; diff --git a/spine-godot/spine_godot/SpineSkeletonFileResource.h b/spine-godot/spine_godot/SpineSkeletonFileResource.h index d8b6d68c2..e67da4c76 100644 --- a/spine-godot/spine_godot/SpineSkeletonFileResource.h +++ b/spine-godot/spine_godot/SpineSkeletonFileResource.h @@ -75,7 +75,11 @@ class SpineSkeletonFileResourceFormatSaver : public ResourceFormatSaver { GDCLASS(SpineSkeletonFileResourceFormatSaver, ResourceFormatSaver); public: +#if VERSION_MAJOR > 3 + Error save(const RES &resource, const String &path, uint32_t flags) override; +#else Error save(const String &path, const RES &resource, uint32_t flags) override; +#endif void get_recognized_extensions(const RES &resource, List *p_extensions) const override; diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index d79fefa15..86b07560f 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -844,7 +844,7 @@ void SpineSprite::draw() { #if VERSION_MAJOR > 3 Rect2 background_rect(0, -default_font->get_height(Font::DEFAULT_FONT_SIZE) - 5, rect_width + 20, line_height * hover_text_lines.size() + 10); #else -Rect2 background_rect(0, -default_font->get_height() - 5, rect_width + 20, line_height * hover_text_lines.size() + 10); + Rect2 background_rect(0, -default_font->get_height() - 5, rect_width + 20, line_height * hover_text_lines.size() + 10); #endif if (hover_text_lines.size() > 0) draw_rect(background_rect, Color(0, 0, 0, 0.8)); for (int i = 0; i < hover_text_lines.size(); i++) {