mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
0d443644c5
@ -1031,6 +1031,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
{
|
{
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name,
|
||||||
path, sequence);
|
path, sequence);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spRegionAttachment *region = SUB_CAST(spRegionAttachment, attachment);
|
spRegionAttachment *region = SUB_CAST(spRegionAttachment, attachment);
|
||||||
region->path = path;
|
region->path = path;
|
||||||
region->rotation = rotation;
|
region->rotation = rotation;
|
||||||
@ -1051,6 +1053,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
int vertexCount = readVarint(input, 1);
|
int vertexCount = readVarint(input, 1);
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spVertexAttachment *vertexAttachment = SUB_CAST(spVertexAttachment, attachment);
|
spVertexAttachment *vertexAttachment = SUB_CAST(spVertexAttachment, attachment);
|
||||||
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
||||||
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
||||||
@ -1102,6 +1106,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
|
|
||||||
{
|
{
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
mesh->path = path;
|
mesh->path = path;
|
||||||
spColor_setFromColor(&mesh->color, &color);
|
spColor_setFromColor(&mesh->color, &color);
|
||||||
@ -1151,6 +1157,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
|
|
||||||
{
|
{
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
mesh->path = path;
|
mesh->path = path;
|
||||||
spColor_setFromColor(&mesh->color, &color);
|
spColor_setFromColor(&mesh->color, &color);
|
||||||
@ -1164,6 +1172,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
case SP_ATTACHMENT_PATH: {
|
case SP_ATTACHMENT_PATH: {
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spPathAttachment *path = SUB_CAST(spPathAttachment, attachment);
|
spPathAttachment *path = SUB_CAST(spPathAttachment, attachment);
|
||||||
spVertexAttachment *vertexAttachment = SUPER(path);
|
spVertexAttachment *vertexAttachment = SUPER(path);
|
||||||
int vertexCount = 0;
|
int vertexCount = 0;
|
||||||
@ -1187,6 +1197,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
case SP_ATTACHMENT_POINT: {
|
case SP_ATTACHMENT_POINT: {
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spPointAttachment *point = SUB_CAST(spPointAttachment, attachment);
|
spPointAttachment *point = SUB_CAST(spPointAttachment, attachment);
|
||||||
point->rotation = readFloat(input);
|
point->rotation = readFloat(input);
|
||||||
point->x = readFloat(input) * self->scale;
|
point->x = readFloat(input) * self->scale;
|
||||||
@ -1203,6 +1215,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
int vertexCount = readVarint(input, 1);
|
int vertexCount = readVarint(input, 1);
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
spClippingAttachment *clip = SUB_CAST(spClippingAttachment, attachment);
|
spClippingAttachment *clip = SUB_CAST(spClippingAttachment, attachment);
|
||||||
spVertexAttachment *vertexAttachment = SUPER(clip);
|
spVertexAttachment *vertexAttachment = SUPER(clip);
|
||||||
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
||||||
@ -1253,7 +1267,9 @@ spSkin *spSkeletonBinary_readSkin(spSkeletonBinary *self, _dataInput *input, int
|
|||||||
const char *name = readStringRef(input, skeletonData);
|
const char *name = readStringRef(input, skeletonData);
|
||||||
spAttachment *attachment = spSkeletonBinary_readAttachment(self, input, skin, slotIndex, name, skeletonData,
|
spAttachment *attachment = spSkeletonBinary_readAttachment(self, input, skin, slotIndex, name, skeletonData,
|
||||||
nonessential);
|
nonessential);
|
||||||
if (attachment) spSkin_setAttachment(skin, slotIndex, name, attachment);
|
if (!attachment)
|
||||||
|
return NULL;
|
||||||
|
spSkin_setAttachment(skin, slotIndex, name, attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return skin;
|
return skin;
|
||||||
@ -1508,6 +1524,11 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
|
|||||||
|
|
||||||
/* Default skin. */
|
/* Default skin. */
|
||||||
skeletonData->defaultSkin = spSkeletonBinary_readSkin(self, input, -1, skeletonData, nonessential);
|
skeletonData->defaultSkin = spSkeletonBinary_readSkin(self, input, -1, skeletonData, nonessential);
|
||||||
|
if (self->attachmentLoader->error1) {
|
||||||
|
spSkeletonData_dispose(skeletonData);
|
||||||
|
_spSkeletonBinary_setError(self, self->attachmentLoader->error1, self->attachmentLoader->error2);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
skeletonData->skinsCount = readVarint(input, 1);
|
skeletonData->skinsCount = readVarint(input, 1);
|
||||||
|
|
||||||
if (skeletonData->defaultSkin)
|
if (skeletonData->defaultSkin)
|
||||||
@ -1520,7 +1541,13 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
|
|||||||
|
|
||||||
/* Skins. */
|
/* Skins. */
|
||||||
for (i = skeletonData->defaultSkin ? 1 : 0; i < skeletonData->skinsCount; ++i) {
|
for (i = skeletonData->defaultSkin ? 1 : 0; i < skeletonData->skinsCount; ++i) {
|
||||||
skeletonData->skins[i] = spSkeletonBinary_readSkin(self, input, 0, skeletonData, nonessential);
|
spSkin *skin = spSkeletonBinary_readSkin(self, input, 0, skeletonData, nonessential);
|
||||||
|
if (self->attachmentLoader->error1) {
|
||||||
|
spSkeletonData_dispose(skeletonData);
|
||||||
|
_spSkeletonBinary_setError(self, self->attachmentLoader->error1, self->attachmentLoader->error2);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
skeletonData->skins[i] = skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Linked meshes. */
|
/* Linked meshes. */
|
||||||
@ -1575,6 +1602,7 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
|
|||||||
if (!animation) {
|
if (!animation) {
|
||||||
FREE(input);
|
FREE(input);
|
||||||
spSkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
|
_spSkeletonBinary_setError(self, "Animation corrupted: ", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
skeletonData->animations[i] = animation;
|
skeletonData->animations[i] = animation;
|
||||||
|
|||||||
@ -984,8 +984,8 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
|
|||||||
|
|
||||||
skeleton = Json_getItem(root, "skeleton");
|
skeleton = Json_getItem(root, "skeleton");
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
MALLOC_STR(skeletonData->hash, Json_getString(skeleton, "hash", 0));
|
MALLOC_STR(skeletonData->hash, Json_getString(skeleton, "hash", "0"));
|
||||||
MALLOC_STR(skeletonData->version, Json_getString(skeleton, "spine", 0));
|
MALLOC_STR(skeletonData->version, Json_getString(skeleton, "spine", "0"));
|
||||||
if (!string_starts_with(skeletonData->version, SPINE_VERSION_STRING)) {
|
if (!string_starts_with(skeletonData->version, SPINE_VERSION_STRING)) {
|
||||||
char errorMsg[255];
|
char errorMsg[255];
|
||||||
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->version, SPINE_VERSION_STRING);
|
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->version, SPINE_VERSION_STRING);
|
||||||
|
|||||||
@ -11,21 +11,21 @@ import { SpineGameObjectConfig, SpinePlugin } from "./SpinePlugin";
|
|||||||
import { SpineGameObject, SpineGameObjectBoundsProvider } from "./SpineGameObject";
|
import { SpineGameObject, SpineGameObjectBoundsProvider } from "./SpineGameObject";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace Phaser.Loader {
|
namespace Phaser.Loader {
|
||||||
export interface LoaderPlugin {
|
export interface LoaderPlugin {
|
||||||
spineJson(key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
spineJson (key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||||
spineBinary(key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
spineBinary (key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||||
spineAtlas(key: string, url: string, premultipliedAlpha?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
spineAtlas (key: string, url: string, premultipliedAlpha?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Phaser.GameObjects {
|
namespace Phaser.GameObjects {
|
||||||
export interface GameObjectFactory {
|
export interface GameObjectFactory {
|
||||||
spine(x: number, y: number, dataKey: string, atlasKey: string, boundsProvider?: SpineGameObjectBoundsProvider): SpineGameObject;
|
spine (x: number, y: number, dataKey: string, atlasKey: string, boundsProvider?: SpineGameObjectBoundsProvider): SpineGameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GameObjectCreator {
|
export interface GameObjectCreator {
|
||||||
spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
|
spine (config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user