Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #68 from MikalDev/master
Browse files Browse the repository at this point in the history
Add bbox, scale expressions
  • Loading branch information
MikalDev authored Nov 9, 2021
2 parents 9c04e12 + 0b3d864 commit b3e6038
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 27 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
Add-on based on **Mikal's** sample from this [thread](https://www.construct.net/en/forum/construct-3/general-discussion-7/spine-animation-js-template-145940)

## Downloads
[Current Add-on, Release 1.51.1](https://github.com/gritsenko/c3_spine_plugin/releases/download/1.51.1/Spine-v1.51.1.c3addon)
[Current Add-on, Release 1.53.0](https://github.com/gritsenko/c3_spine_plugin/releases/download/1.53.0/Spine-v1.53.0.c3addon)

[Previous Add-on Releases](https://github.com/gritsenko/c3_spine_plugin/releases)

Expand Down Expand Up @@ -127,6 +127,8 @@ Useful for Dragon Bones Spine JSON export and earlier Spine versions.
- Preview Spine render in editor (dependent on C3 editor SDK updates)

## Release notes
- 1.53.0 Add expressions for bbox and scale properties
- 1.52.0 Add customSkinOutfit script interface
- 1.51.1 Add icon, error handling for addCustomSkinOutfit
- 1.50.2 Fix worker mode support for C3
- 1.50.1 Fix slot color related to script add customskinoutfit
Expand Down
Binary file added dist/Spine-v1.52.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.53.0.c3addon
Binary file not shown.
40 changes: 40 additions & 0 deletions src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,46 @@
"type": "number"
}
]
},
{
"id": "bbox-offset-x",
"expressionName": "BboxOffsetX",
"scriptName": "BboxOffsetX",
"highlight": false,
"returnType": "number",
"params": []
},
{
"id": "bbox-offset-y",
"expressionName": "BboxOffsetY",
"scriptName": "BboxOffsetY",
"highlight": false,
"returnType": "number",
"params": []
},
{
"id": "bbox-size-x",
"expressionName": "BboxSizeX",
"scriptName": "BboxSizeX",
"highlight": false,
"returnType": "number",
"params": []
},
{
"id": "bbox-size-y",
"expressionName": "BboxSizeY",
"scriptName": "BboxSizeY",
"highlight": false,
"returnType": "number",
"params": []
},
{
"id": "skeleton-scale",
"expressionName": "SkeletonScale",
"scriptName": "SkeletonScale",
"highlight": false,
"returnType": "number",
"params": []
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "1.51.1",
"version": "1.53.0",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
24 changes: 1 addition & 23 deletions src/c3runtime/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,29 +135,7 @@

AddCustomSkin(skinName,addSkinName)
{
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
{
if (this.debug) console.warn('[Spine] AddCustomSkin, skeleton is not available',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
return;
}

const skeleton = this.skeletonInfo.skeleton;

if (this.customSkins[skinName])
{
let addSkin = skeleton.data.findSkin(addSkinName);
if (addSkin)
{
this.customSkins[skinName].addSkin(addSkin);
} else
{
if (this.debug) console.warn('[Spine] AddCustomSkin, add skin does not exist',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
}
} else
{
if (this.debug) console.warn('[Spine] AddCustomSkin, custom skin does not exist',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
}
this.SetRenderOnce(1.0, true, this.uid);
this._addCustomSkin(skinName, addSkinName);
},

SetCustomSkin(skinName)
Expand Down
15 changes: 15 additions & 0 deletions src/c3runtime/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,21 @@
},
CurrentValue(){
return this.currentValue;
},
BboxOffsetX(){
return this.bboxOffsetX;
},
BboxOffsetY(){
return this.bboxOffsetY;
},
BboxSizeX(){
return this.bboxSizeX;
},
BboxSizeY(){
return this.bboxSizeY;
},
SkeletonScale(){
return this.skeletonScale;
}
};
}
32 changes: 32 additions & 0 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,33 @@

return (track.animationEnd-track.animationStart);
}

_addCustomSkin(skinName,addSkinName)
{
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
{
if (this.debug) console.warn('[Spine] AddCustomSkin, skeleton is not available',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
return;
}

const skeleton = this.skeletonInfo.skeleton;

if (this.customSkins[skinName])
{
let addSkin = skeleton.data.findSkin(addSkinName);
if (addSkin)
{
this.customSkins[skinName].addSkin(addSkin);
} else
{
if (this.debug) console.warn('[Spine] AddCustomSkin, add skin does not exist',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
}
} else
{
if (this.debug) console.warn('[Spine] AddCustomSkin, custom skin does not exist',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
}
this.SetRenderOnce(1.0, true, this.uid);
}
};

// Script interface. Use a WeakMap to safely hide the internal implementation details from the
Expand Down Expand Up @@ -1234,6 +1261,11 @@
map.get(this)._applySlotColors();
}

addCustomSkin(skinName, addSkinName)
{
map.get(this)._addCustomSkin(skinName, addSkinName);
}

animationStart(trackIndex)
{
return map.get(this)._animationStart(trackIndex);
Expand Down
2 changes: 1 addition & 1 deletion src/c3runtime/spine-draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class SpineBatch {
// @ts-ignore
if (!globalThis.spineBatcher)
{
console.log('[Spine] SpineBatcher init, 1.51.1');
console.log('[Spine] SpineBatcher init, 1.53.0');
// @ts-ignore
globalThis.spineBatcher = new SpineBatch();
}
25 changes: 25 additions & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,31 @@
"translated-name": "CurrentKey",
"params": {
}
},
"bbox-offset-x": {
"description": "Bounding box offset x",
"translated-name": "BboxOffsetX",
"params": {}
},
"bbox-offset-y": {
"description": "Bounding box offset y",
"translated-name": "BboxOffsetY",
"params": {}
},
"bbox-size-x": {
"description": "Bounding box size x",
"translated-name": "BboxSizeX",
"params": {}
},
"bbox-size-y": {
"description": "Bounding box size y",
"translated-name": "BboxSizeY",
"params": {}
},
"skeleton-scale": {
"description": "Skeleton scale",
"translated-name": "SkeletonScale",
"params": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const C3 = self.C3;

const PLUGIN_ID = "Gritsenko_Spine";
const PLUGIN_VERSION = "1.51.1";
const PLUGIN_VERSION = "1.53.0";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand Down

0 comments on commit b3e6038

Please sign in to comment.