Skip to content

Commit

Permalink
feat (skin) add addCustomSkin scrip interface
Browse files Browse the repository at this point in the history
  • Loading branch information
MikalDev committed Nov 5, 2021
1 parent bdc97c3 commit 1acc1b1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
Binary file added dist/Spine-v1.52.0.c3addon
Binary file not shown.
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.52.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
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.52.0');
// @ts-ignore
globalThis.spineBatcher = new SpineBatch();
}
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.52.0";
const PLUGIN_CATEGORY = "general";

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

0 comments on commit 1acc1b1

Please sign in to comment.