Skip to content

Commit

Permalink
feat (outfit) add custom skin outfit skin tone support
Browse files Browse the repository at this point in the history
  • Loading branch information
MikalDev committed Nov 18, 2021
1 parent be1c779 commit 63132cb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
Binary file added dist/Spine-v1.55.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.54.0",
"version": "1.55.0",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
19 changes: 14 additions & 5 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,8 @@
this.SetRenderOnce(1.0, true, this.uid);
}

_addCustomSkinOutfit(skinName, addOutfit, slots, dependentSlotsSkin, dependentSlotsColor)
_addCustomSkinOutfit(skinName, addOutfit, slots, dependentSlotsSkin, dependentSlotsColor, dependentSlotsSkinColor)
{
console.log('[Spine], dependentSlotsColor', dependentSlotsColor)
const spine = globalThis.spine;
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
{
Expand Down Expand Up @@ -1044,6 +1043,17 @@
spine.Color.rgba8888ToColor(slotRef.darkColor, addOutfit[slotName].tintDarkColor);
}
}
// Dependent slots skin color
if (dependentSlotsSkinColor[slotName])
{
for(const dependentSlot of dependentSlotsSkinColor[slotName])
{
if (addOutfit[dependentSlot] && addOutfit[dependentSlot].skinName !== '0') continue;
const slotRef = skeleton.findSlot(dependentSlot)
spine.Color.rgba8888ToColor(slotRef.color, addOutfit[slotName].tintColor);
spine.Color.rgba8888ToColor(slotRef.darkColor, addOutfit[slotName].tintDarkColor);
}
}
} else
{
if (this.debug) console.warn('[Spine] AddCustomSkin, add skin does not exist',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
Expand All @@ -1063,7 +1073,6 @@
_hexToC3RGBAColorValue(s) {
if (s.length == 7) s = s + 'ff'
const result = this._swap32(parseInt(s.substr(1), 16))
console.log(s,result)
return result;
}

Expand Down Expand Up @@ -1264,9 +1273,9 @@
map.get(this)._deleteAnimation(trackIndex, mixDuration);
}

addCustomSkinOutfit(skinName, addOutfit, slots, dependentSlotsSkin, dependentSlotsColor)
addCustomSkinOutfit(skinName, addOutfit, slots, dependentSlotsSkin, dependentSlotsColor, dependentSlotsSkinColor)
{
map.get(this)._addCustomSkinOutfit(skinName, addOutfit, slots, dependentSlotsSkin, dependentSlotsColor);
map.get(this)._addCustomSkinOutfit(skinName, addOutfit, slots, dependentSlotsSkin, dependentSlotsColor, dependentSlotsSkinColor);
}

applySlotColors()
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.54.0');
console.log('[Spine] SpineBatcher init, 1.55.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.54.0";
const PLUGIN_VERSION = "1.55.0";
const PLUGIN_CATEGORY = "general";

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

0 comments on commit 63132cb

Please sign in to comment.