mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
e8e0c29aa7
@ -122,6 +122,8 @@ void SpineAtlasResource::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_path"), "", "get_source_path");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_path"), "", "get_source_path");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures"), "", "get_textures");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures"), "", "get_textures");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "normal_maps"), "", "get_normal_maps");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "normal_maps"), "", "get_normal_maps");
|
||||||
|
|
||||||
|
ADD_SIGNAL(MethodInfo("skeleton_atlas_changed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineAtlasResource::SpineAtlasResource() : atlas(nullptr), texture_loader(nullptr), normal_map_prefix("n") {
|
SpineAtlasResource::SpineAtlasResource() : atlas(nullptr), texture_loader(nullptr), normal_map_prefix("n") {
|
||||||
@ -230,6 +232,27 @@ Error SpineAtlasResource::save_to_file(const String &path) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error SpineAtlasResource::copy_from(const Ref<Resource> &p_resource) {
|
||||||
|
auto error = Resource::copy_from(p_resource);
|
||||||
|
if (error != OK) return error;
|
||||||
|
|
||||||
|
const Ref<SpineAtlasResource> &spineAtlas = static_cast<const Ref<SpineAtlasResource> &>(p_resource);
|
||||||
|
this->clear();
|
||||||
|
this->atlas = spineAtlas->atlas;
|
||||||
|
spineAtlas->atlas = nullptr;
|
||||||
|
this->texture_loader = spineAtlas->texture_loader;
|
||||||
|
spineAtlas->texture_loader = nullptr;
|
||||||
|
|
||||||
|
this->source_path = spineAtlas->source_path;
|
||||||
|
this->atlas_data = spineAtlas->atlas_data;
|
||||||
|
this->normal_map_prefix = spineAtlas->normal_map_prefix;
|
||||||
|
this->textures = spineAtlas->textures;
|
||||||
|
this->normal_maps = spineAtlas->normal_maps;
|
||||||
|
emit_signal(SNAME("skeleton_file_changed"));
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
RES SpineAtlasResourceFormatLoader::load(const String &path, const String &original_path, Error *error, bool use_sub_threads, float *progress, CacheMode cache_mode) {
|
RES SpineAtlasResourceFormatLoader::load(const String &path, const String &original_path, Error *error, bool use_sub_threads, float *progress, CacheMode cache_mode) {
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -69,6 +69,8 @@ public:
|
|||||||
|
|
||||||
Error save_to_file(const String &path);// .spatlas
|
Error save_to_file(const String &path);// .spatlas
|
||||||
|
|
||||||
|
virtual Error copy_from(const Ref<Resource> &p_resource);
|
||||||
|
|
||||||
String get_source_path();
|
String get_source_path();
|
||||||
|
|
||||||
Array get_textures();
|
Array get_textures();
|
||||||
|
|||||||
@ -115,6 +115,7 @@ void SpineSkeletonDataResource::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_images_path"), &SpineSkeletonDataResource::get_images_path);
|
ClassDB::bind_method(D_METHOD("get_images_path"), &SpineSkeletonDataResource::get_images_path);
|
||||||
ClassDB::bind_method(D_METHOD("get_audio_path"), &SpineSkeletonDataResource::get_audio_path);
|
ClassDB::bind_method(D_METHOD("get_audio_path"), &SpineSkeletonDataResource::get_audio_path);
|
||||||
ClassDB::bind_method(D_METHOD("get_fps"), &SpineSkeletonDataResource::get_fps);
|
ClassDB::bind_method(D_METHOD("get_fps"), &SpineSkeletonDataResource::get_fps);
|
||||||
|
ClassDB::bind_method(D_METHOD("update_skeleton_data"), &SpineSkeletonDataResource::update_skeleton_data);
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("skeleton_data_changed"));
|
ADD_SIGNAL(MethodInfo("skeleton_data_changed"));
|
||||||
ADD_SIGNAL(MethodInfo("_internal_spine_objects_invalidated"));
|
ADD_SIGNAL(MethodInfo("_internal_spine_objects_invalidated"));
|
||||||
@ -190,6 +191,15 @@ bool SpineSkeletonDataResource::is_skeleton_data_loaded() const {
|
|||||||
|
|
||||||
void SpineSkeletonDataResource::set_atlas_res(const Ref<SpineAtlasResource> &atlas) {
|
void SpineSkeletonDataResource::set_atlas_res(const Ref<SpineAtlasResource> &atlas) {
|
||||||
atlas_res = atlas;
|
atlas_res = atlas;
|
||||||
|
if (atlas_res.is_valid()) {
|
||||||
|
#if VERSION_MAJOR > 3
|
||||||
|
if (!atlas_res->is_connected(SNAME("skeleton_atlas_changed"), callable_mp(this, &SpineSkeletonDataResource::update_skeleton_data)))
|
||||||
|
atlas_res->connect(SNAME("skeleton_atlas_changed"), callable_mp(this, &SpineSkeletonDataResource::update_skeleton_data));
|
||||||
|
#else
|
||||||
|
if (!atlas_res->is_connected(SNAME("skeleton_atlas_changed"), this, SNAME("update_skeleton_data")))
|
||||||
|
atlas_res->connect(SNAME("skeleton_atlas_changed"), this, SNAME("update_skeleton_data"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
update_skeleton_data();
|
update_skeleton_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +209,15 @@ Ref<SpineAtlasResource> SpineSkeletonDataResource::get_atlas_res() {
|
|||||||
|
|
||||||
void SpineSkeletonDataResource::set_skeleton_file_res(const Ref<SpineSkeletonFileResource> &skeleton_file) {
|
void SpineSkeletonDataResource::set_skeleton_file_res(const Ref<SpineSkeletonFileResource> &skeleton_file) {
|
||||||
skeleton_file_res = skeleton_file;
|
skeleton_file_res = skeleton_file;
|
||||||
|
if (skeleton_file_res.is_valid()) {
|
||||||
|
#if VERSION_MAJOR > 3
|
||||||
|
if (!skeleton_file_res->is_connected(SNAME("skeleton_file_changed"), callable_mp(this, &SpineSkeletonDataResource::update_skeleton_data)))
|
||||||
|
skeleton_file_res->connect(SNAME("skeleton_file_changed"), callable_mp(this, &SpineSkeletonDataResource::update_skeleton_data));
|
||||||
|
#else
|
||||||
|
if (!skeleton_file_res->is_connected(SNAME("skeleton_file_changed"), this, SNAME("update_skeleton_data")))
|
||||||
|
skeleton_file_res->connect(SNAME("skeleton_file_changed"), this, SNAME("update_skeleton_data"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
update_skeleton_data();
|
update_skeleton_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,8 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "SpineSkeletonFileResource.h"
|
#include "SpineSkeletonFileResource.h"
|
||||||
|
#include "core/error/error_list.h"
|
||||||
|
#include "core/error/error_macros.h"
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
#include "core/io/file_access.h"
|
#include "core/io/file_access.h"
|
||||||
#else
|
#else
|
||||||
@ -85,6 +87,7 @@ static char *readString(BinaryInput *input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineSkeletonFileResource::_bind_methods() {
|
void SpineSkeletonFileResource::_bind_methods() {
|
||||||
|
ADD_SIGNAL(MethodInfo("skeleton_file_changed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkVersion(const char *version) {
|
static bool checkVersion(const char *version) {
|
||||||
@ -157,6 +160,16 @@ Error SpineSkeletonFileResource::save_to_file(const String &path) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error SpineSkeletonFileResource::copy_from(const Ref<Resource> &p_resource) {
|
||||||
|
auto error = Resource::copy_from(p_resource);
|
||||||
|
if (error != OK) return error;
|
||||||
|
const Ref<SpineSkeletonFileResource> &spineFile = static_cast<const Ref<SpineSkeletonFileResource> &>(p_resource);
|
||||||
|
this->json = spineFile->json;
|
||||||
|
this->binary = spineFile->binary;
|
||||||
|
emit_signal(SNAME("skeleton_file_changed"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
RES SpineSkeletonFileResourceFormatLoader::load(const String &path, const String &original_path, Error *error, bool use_sub_threads, float *progress, CacheMode cache_mode) {
|
RES SpineSkeletonFileResourceFormatLoader::load(const String &path, const String &original_path, Error *error, bool use_sub_threads, float *progress, CacheMode cache_mode) {
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -52,6 +52,8 @@ public:
|
|||||||
Error load_from_file(const String &path);
|
Error load_from_file(const String &path);
|
||||||
|
|
||||||
Error save_to_file(const String &path);
|
Error save_to_file(const String &path);
|
||||||
|
|
||||||
|
virtual Error copy_from(const Ref<Resource> &p_resource);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpineSkeletonFileResourceFormatLoader : public ResourceFormatLoader {
|
class SpineSkeletonFileResourceFormatLoader : public ResourceFormatLoader {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user