Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement spine extension #5927

Merged
merged 90 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
de2adbc
first not tested commit with spine extension and atlas resource
Jul 21, 2023
dae9cbf
Merge branch 'master' into spine-extension
Jul 21, 2023
65f370f
implement base spine functionality, properties panel and object editor
Aug 11, 2023
db3a94a
Merge branch 'master' into spine-extension
Aug 11, 2023
93903c6
add isAnimationComplete condition and isUpdatable expression, conditi…
Aug 14, 2023
086e49f
fix extension configuration
Aug 14, 2023
476eea8
make spine creation synchrounous in SpineRuntimeObject
Aug 17, 2023
6ecd04e
use regex to get atlas image path
Aug 17, 2023
88cda55
fix spine extension issues
Aug 18, 2023
9ed5fbc
clean up code
Aug 22, 2023
2d20907
Merge branch 'master' into spine-extension
Aug 22, 2023
01c2afc
solve flow test errors
Aug 22, 2023
95f5474
apply format
Aug 22, 2023
e36a050
ignore pixi-spine during check-types
Aug 31, 2023
3477f58
format and style code, fix some test
Aug 31, 2023
2313fe9
remove console logs, solve typos
Aug 31, 2023
4ac52de
remove pixi deps
Sep 19, 2023
3628be7
Merge branch 'master' into spine-extension
Oct 11, 2023
a6895fc
update pixi-spine to 4.x.x
Nov 3, 2023
5b33a7f
Merge branch 'master' into spine-extension
Nov 14, 2023
bd60956
copy pixi-spine.js from node_modules on postinstall
Nov 14, 2023
25cdc63
cover errors on spine loading with incompatible files
Nov 14, 2023
a982540
remove pixi-spine import in global d.ts files, remove animations ui i…
Nov 15, 2023
b466d4d
run format
Nov 15, 2023
55fcf45
fix flow issues
Nov 15, 2023
56e940a
fix react warnings
Nov 15, 2023
fc941b0
run format and flow
Nov 15, 2023
71333b7
update spine configuration page
Nov 15, 2023
ee70d96
update typings and docs
Nov 15, 2023
75da727
remove dev console.logs
Nov 15, 2023
a7c5c1a
use PixiFiltersTools from gdjs namespace, use correct onDestroy method
Nov 16, 2023
e7c69e9
format runtime code, update install-spine script
Nov 20, 2023
fc28b76
Merge branch 'master' into spine-extension
Nov 20, 2023
63e9893
update spine extenstion
Nov 22, 2023
1520bbb
add badAnimation SpineObjectConfiguration
Nov 22, 2023
cccb1b9
solve typo
Nov 22, 2023
135100a
comment sourcemap back in runtime pixi.js
Nov 22, 2023
b69b83f
update install-spine script with shelljs and error logs
Nov 22, 2023
8f37308
create SpineResource, restore JsonManager, update spine extension
Nov 23, 2023
fee9627
Merge branch 'master' into spine-extension
Nov 24, 2023
34172bf
update install-spine script
f0nar Nov 27, 2023
4f65ee6
add try/catch block to install-spine
f0nar Nov 27, 2023
7c9fefd
Remove unused logger in SpineAtlasManager
malec-palec Nov 27, 2023
5be0906
Add missing `jsonmanger` dependency in tests
malec-palec Nov 27, 2023
506487d
lock pixi-spine version
Nov 28, 2023
d8f580d
remove pixi-simple-gesture dependency
Nov 28, 2023
550b358
apply format
Nov 28, 2023
8b948ae
use spine root bone centration
Nov 28, 2023
f42cd38
add mixing parameter for animations
Nov 28, 2023
ee780f8
use correct spine help page path
f0nar Dec 5, 2023
dc35f5d
fix formatting issue
f0nar Dec 5, 2023
0bd9044
Merge branch 'master' into spine-extension
Dec 8, 2023
4b9e780
use embedded resources mechanis for spine loading
Dec 11, 2023
b279cec
Merge branch 'spine-extension' of github.com-f0nar:f0nar/GDevelop int…
Dec 11, 2023
109fc71
recursively expose embedded resources
Dec 12, 2023
298268f
use scaled initial width/height
Dec 12, 2023
2f58de6
add explanation comment for TextureAtlas issue, format code
Dec 21, 2023
b34c136
use custom clamp instead of PixiFiltersTools
Dec 13, 2023
969daf3
lock pixi.js-legacy
Dec 13, 2023
ed6193f
fix typos
Dec 13, 2023
4f68cc8
stop imitate spine behavior if spine skeleton is not loaded
Dec 13, 2023
7bf1a81
update spine atlas manager
Dec 13, 2023
c5f78e4
stop spine skeleton loading at every render call
Dec 13, 2023
138804a
apply format
f0nar Dec 21, 2023
6a14a9e
Merge branch 'master' into spine-extension
f0nar Dec 21, 2023
2e38c51
Improve various error handling
4ian Dec 23, 2023
1d17ff5
Add a table showing embedded resources in the resource editor
4ian Dec 23, 2023
804918e
Improve some wordings
4ian Dec 23, 2023
6727d01
Properly factor property fields between Spine and 3D model editors
4ian Dec 23, 2023
9bbbef9
Refactor some logic out of React components and fix animations cleare…
4ian Dec 23, 2023
e08f8a1
clear and format code
f0nar Dec 23, 2023
7bf0848
Add display of the loading error of a Spine in the Spine editor
4ian Dec 24, 2023
a541138
Robustify against crashes when loading a Spine in the editor
4ian Dec 24, 2023
a974c74
stop destroy children textures on spine destroy
f0nar Dec 28, 2023
6e6b13d
implement reloading for spine resources
f0nar Jan 5, 2024
962a1ea
make up code
f0nar Jan 5, 2024
db85cde
make up code
f0nar Jan 5, 2024
7201ce7
Slight refactoring and support for multiple embedder resources reloading
4ian Jan 7, 2024
25241a9
Simplify a bit error reporting + indicate this is experimental feature
4ian Jan 7, 2024
aa03f27
format code
f0nar Jan 8, 2024
0a4e337
Add icon for Spine based object
4ian Jan 9, 2024
1f295f4
Update the description
4ian Jan 9, 2024
93bc488
implement geDrawableX/Y methods for spine runtime object to correctly…
f0nar Jan 10, 2024
234cbb0
Add capabilities for size, scale, flip, opacity and effects.
D8H Jan 15, 2024
a12bcab
Add capability for animation.
D8H Jan 15, 2024
f1d80a2
Add a warning about the license.
D8H Jan 16, 2024
5c6e285
Remove the opacity property.
D8H Jan 16, 2024
35cf1cf
Fix default size update on hot-reload.
D8H Jan 16, 2024
c6d96ad
Update the hit-boxes while the animation plays.
D8H Jan 16, 2024
15442f0
Remove deprecated actions.
D8H Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
metadata.GetType() == "tilesetResource" ||
metadata.GetType() == "videoResource" ||
metadata.GetType() == "model3DResource" ||
metadata.GetType() == "atlasResource" ||
metadata.GetType() == "spineResource" ||
// Deprecated, old parameter names:
metadata.GetType() == "password" || metadata.GetType() == "musicfile" ||
metadata.GetType() == "soundfile" || metadata.GetType() == "police") {
Expand Down
4 changes: 3 additions & 1 deletion Core/GDCore/Extensions/Metadata/ValueTypeMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ class GD_CORE_API ValueTypeMetadata {
parameterType == "jsonResource" ||
parameterType == "tilemapResource" ||
parameterType == "tilesetResource" ||
parameterType == "model3DResource";
parameterType == "model3DResource" ||
parameterType == "atlasResource" ||
parameterType == "spineResource";
}
return false;
}
Expand Down
27 changes: 27 additions & 0 deletions Core/GDCore/IDE/Project/ArbitraryResourceWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ void ArbitraryResourceWorker::ExposeModel3D(gd::String& resourceName){
// do.
};

void ArbitraryResourceWorker::ExposeAtlas(gd::String& resourceName){
// Nothing to do by default - each child class can define here the action to
// do.
};

void ArbitraryResourceWorker::ExposeSpine(gd::String& resourceName){
// Nothing to do by default - each child class can define here the action to
// do.
};

void ArbitraryResourceWorker::ExposeVideo(gd::String& videoName){
// Nothing to do by default - each child class can define here the action to
// do.
Expand Down Expand Up @@ -120,6 +130,7 @@ void ArbitraryResourceWorker::ExposeEmbeddeds(gd::String& resourceName) {

gd::String potentiallyUpdatedTargetResourceName = targetResourceName;
ExposeResourceWithType(targetResource.GetKind(), potentiallyUpdatedTargetResourceName);
ExposeEmbeddeds(potentiallyUpdatedTargetResourceName);

if (potentiallyUpdatedTargetResourceName != targetResourceName) {
// The resource name was renamed. Also update the mapping.
Expand Down Expand Up @@ -176,6 +187,14 @@ void ArbitraryResourceWorker::ExposeResourceWithType(
ExposeVideo(resourceName);
return;
}
if (resourceType == "atlas") {
ExposeAtlas(resourceName);
return;
}
if (resourceType == "spine") {
ExposeSpine(resourceName);
return;
}
gd::LogError("Unexpected resource type: " + resourceType + " for: " + resourceName);
return;
}
Expand Down Expand Up @@ -244,6 +263,14 @@ bool ResourceWorkerInEventsWorker::DoVisitInstruction(gd::Instruction& instructi
gd::String updatedParameterValue = parameterValue;
worker.ExposeModel3D(updatedParameterValue);
instruction.SetParameter(parameterIndex, updatedParameterValue);
} else if (parameterMetadata.GetType() == "atlasResource") {
gd::String updatedParameterValue = parameterValue;
worker.ExposeAtlas(updatedParameterValue);
instruction.SetParameter(parameterIndex, updatedParameterValue);
} else if (parameterMetadata.GetType() == "spineResource") {
gd::String updatedParameterValue = parameterValue;
worker.ExposeSpine(updatedParameterValue);
instruction.SetParameter(parameterIndex, updatedParameterValue);
}
});

Expand Down
10 changes: 10 additions & 0 deletions Core/GDCore/IDE/Project/ArbitraryResourceWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ class GD_CORE_API ArbitraryResourceWorker {
* \brief Expose a 3D model, which is always a reference to a "model3D" resource.
*/
virtual void ExposeModel3D(gd::String &resourceName);

/**
* \brief Expose an atlas, which is always a reference to a "atlas" resource.
*/
virtual void ExposeAtlas(gd::String &resourceName);

/**
* \brief Expose an spine, which is always a reference to a "spine" resource.
*/
virtual void ExposeSpine(gd::String &resourceName);

/**
* \brief Expose a video, which is always a reference to a "video" resource.
Expand Down
6 changes: 6 additions & 0 deletions Core/GDCore/IDE/Project/ObjectsUsingResourceCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class GD_CORE_API ResourceNameMatcher : public ArbitraryResourceWorker {
virtual void ExposeModel3D(gd::String& otherResourceName) override {
MatchResourceName(otherResourceName);
};
virtual void ExposeAtlas(gd::String& otherResourceName) override {
MatchResourceName(otherResourceName);
};
virtual void ExposeSpine(gd::String& otherResourceName) override {
MatchResourceName(otherResourceName);
};

void MatchResourceName(gd::String& otherResourceName) {
if (otherResourceName == resourceName) matchesResourceName = true;
Expand Down
12 changes: 12 additions & 0 deletions Core/GDCore/IDE/Project/ResourcesInUseHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
std::set<gd::String>& GetAllVideos() { return GetAll("video"); };
std::set<gd::String>& GetAllBitmapFonts() { return GetAll("bitmapFont"); };
std::set<gd::String>& GetAll3DModels() { return GetAll("model3D"); };
std::set<gd::String>& GetAllAtlases() { return GetAll("atlas"); };
std::set<gd::String>& GetAllSpines() { return GetAll("spine"); };
std::set<gd::String>& GetAll(const gd::String& resourceType) {
if (resourceType == "image") return allImages;
if (resourceType == "audio") return allAudios;
Expand All @@ -57,6 +59,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
if (resourceType == "video") return allVideos;
if (resourceType == "bitmapFont") return allBitmapFonts;
if (resourceType == "model3D") return allModel3Ds;
if (resourceType == "atlas") return allAtlases;
if (resourceType == "spine") return allSpines;

return emptyResources;
};
Expand Down Expand Up @@ -91,6 +95,12 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
virtual void ExposeModel3D(gd::String& resourceName) override {
allModel3Ds.insert(resourceName);
};
virtual void ExposeAtlas(gd::String& resourceName) override {
allAtlases.insert(resourceName);
};
virtual void ExposeSpine(gd::String& resourceName) override {
allSpines.insert(resourceName);
};

protected:
std::set<gd::String> allImages;
Expand All @@ -102,6 +112,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
std::set<gd::String> allVideos;
std::set<gd::String> allBitmapFonts;
std::set<gd::String> allModel3Ds;
std::set<gd::String> allAtlases;
std::set<gd::String> allSpines;
std::set<gd::String> emptyResources;
};

Expand Down
6 changes: 6 additions & 0 deletions Core/GDCore/IDE/Project/ResourcesRenamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class ResourcesRenamer : public gd::ArbitraryResourceWorker {
virtual void ExposeModel3D(gd::String& resourceName) override {
RenameIfNeeded(resourceName);
};
virtual void ExposeAtlas(gd::String& resourceName) override {
RenameIfNeeded(resourceName);
};
virtual void ExposeSpine(gd::String& resourceName) override {
RenameIfNeeded(resourceName);
};

private:
void RenameIfNeeded(gd::String& resourceName) {
Expand Down
6 changes: 6 additions & 0 deletions Core/GDCore/IDE/Project/SceneResourcesFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ class SceneResourcesFinder : private gd::ArbitraryResourceWorker {
void ExposeModel3D(gd::String &resourceName) override {
AddUsedResource(resourceName);
};
void ExposeAtlas(gd::String &resourceName) override {
AddUsedResource(resourceName);
};
void ExposeSpine(gd::String &resourceName) override {
AddUsedResource(resourceName);
};

std::set<gd::String> resourceNames;
};
Expand Down
4 changes: 4 additions & 0 deletions Core/GDCore/Project/CustomObjectConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ void CustomObjectConfiguration::ExposeResources(gd::ArbitraryResourceWorker& wor
worker.ExposeBitmapFont(newPropertyValue);
} else if (resourceType == "model3D") {
worker.ExposeModel3D(newPropertyValue);
} else if (resourceType == "atlas") {
worker.ExposeAtlas(newPropertyValue);
} else if (resourceType == "spine") {
worker.ExposeSpine(newPropertyValue);
}

if (newPropertyValue != oldPropertyValue) {
Expand Down
18 changes: 18 additions & 0 deletions Core/GDCore/Project/ResourcesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ std::shared_ptr<Resource> ResourcesManager::CreateResource(
return std::make_shared<BitmapFontResource>();
else if (kind == "model3D")
return std::make_shared<Model3DResource>();
else if (kind == "atlas")
return std::make_shared<AtlasResource>();
else if (kind == "spine")
return std::make_shared<SpineResource>();

std::cout << "Bad resource created (type: " << kind << ")" << std::endl;
return std::make_shared<Resource>();
Expand Down Expand Up @@ -756,6 +760,20 @@ void Model3DResource::SerializeTo(SerializerElement& element) const {
element.SetAttribute("file", GetFile());
}

void AtlasResource::SetFile(const gd::String& newFile) {
file = NormalizePathSeparator(newFile);
}

void AtlasResource::UnserializeFrom(const SerializerElement& element) {
SetUserAdded(element.GetBoolAttribute("userAdded"));
SetFile(element.GetStringAttribute("file"));
}

void AtlasResource::SerializeTo(SerializerElement& element) const {
element.SetAttribute("userAdded", IsUserAdded());
element.SetAttribute("file", GetFile());
}

ResourceFolder::ResourceFolder(const ResourceFolder& other) { Init(other); }

ResourceFolder& ResourceFolder::operator=(const ResourceFolder& other) {
Expand Down
41 changes: 41 additions & 0 deletions Core/GDCore/Project/ResourcesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,21 @@ class GD_CORE_API JsonResource : public Resource {
gd::String file;
};

/**
* \brief Describe a spine json file used by a project.
*
* \see Resource
* \ingroup ResourcesManagement
*/
class GD_CORE_API SpineResource : public JsonResource {
public:
SpineResource() : JsonResource() { SetKind("spine"); };
virtual ~SpineResource(){};
virtual SpineResource* Clone() const override {
return new SpineResource(*this);
}
};

/**
* \brief Describe a tilemap file used by a project.
*
Expand Down Expand Up @@ -507,6 +522,32 @@ class GD_CORE_API Model3DResource : public Resource {
gd::String file;
};

/**
* \brief Describe an atlas file used by a project.
*
* \see Resource
* \ingroup ResourcesManagement
*/
class GD_CORE_API AtlasResource : public Resource {
public:
AtlasResource() : Resource() { SetKind("atlas"); };
virtual ~AtlasResource(){};
virtual AtlasResource* Clone() const override {
return new AtlasResource(*this);
}

virtual const gd::String& GetFile() const override { return file; };
virtual void SetFile(const gd::String& newFile) override;

virtual bool UseFile() const override { return true; }
void SerializeTo(SerializerElement& element) const override;

void UnserializeFrom(const SerializerElement& element) override;

private:
gd::String file;
};

/**
* \brief Inventory all resources used by a project
*
Expand Down
1 change: 1 addition & 0 deletions Extensions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Spine/pixi-spine
1 change: 1 addition & 0 deletions Extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(
TextEntryObject
TextObject
TiledSpriteObject
Spine
TopDownMovementBehavior)

# Automatically add all listed extensions
Expand Down
20 changes: 20 additions & 0 deletions Extensions/Spine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0015 NEW)

project(SpineObject)
gd_add_extension_includes()

#Defines
###
gd_add_extension_definitions(SpineObject)

#The targets
###
include_directories(.)
file(GLOB source_files *.cpp *.h)
gd_add_clang_utils(SpineObject "${source_files}")
gd_add_extension_target(SpineObject "${source_files}")

#Linker files for the IDE extension
###
gd_extension_link_libraries(SpineObject)
Loading