mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Code review.
This commit is contained in:
parent
2a01da00df
commit
3ff5a9e943
@ -68,7 +68,7 @@ export class AssetLoader {
|
||||
|
||||
public async loadAtlasEditor (sid: number, instance: SDK.IWorldInstance, renderer: SDK.Gfx.IWebGLRenderer) {
|
||||
const projectFile = instance.GetProject().GetProjectFileBySID(sid);
|
||||
if (!projectFile) throw new Error(`Atlas file not found wit the given SID: ${sid}`);
|
||||
if (!projectFile) throw new Error(`Atlas file not found with the given SID: ${sid}`);
|
||||
|
||||
const blob = projectFile.GetBlob();
|
||||
const content = await blob.text();
|
||||
@ -91,7 +91,7 @@ export class AssetLoader {
|
||||
public async loadSpineTextureEditor (pageName: string, pma = false, instance: SDK.IWorldInstance) {
|
||||
const projectFile = instance.GetProject().GetProjectFileByExportPath(pageName);
|
||||
if (!projectFile) {
|
||||
throw new Error(`An error occured while loading the texture: ${pageName}`);
|
||||
throw new Error(`An error occurred while loading the texture: ${pageName}`);
|
||||
}
|
||||
|
||||
const content = projectFile.GetBlob();
|
||||
@ -207,9 +207,9 @@ export class AssetLoader {
|
||||
}
|
||||
|
||||
private async addToCache<T> (cache: ResourceCache<T>, cacheKey: string, promise: Promise<T>) {
|
||||
const cachEntry: CacheEntry<T> = { promise, refCount: 1 };
|
||||
cache.set(cacheKey, cachEntry);
|
||||
cachEntry.data = await promise;
|
||||
const cacheEntry: CacheEntry<T> = { promise, refCount: 1 };
|
||||
cache.set(cacheKey, cacheEntry);
|
||||
cacheEntry.data = await promise;
|
||||
}
|
||||
|
||||
private getFromCache<T> (cache: ResourceCache<T>, cacheKey: string) {
|
||||
@ -220,7 +220,7 @@ export class AssetLoader {
|
||||
return entry;
|
||||
}
|
||||
|
||||
static async createImageBitmapFromBlob (blob: Blob, pma: boolean): Promise<ImageBitmap | null> {
|
||||
static async createImageBitmapFromBlob (blob: Blob, pma: boolean): Promise<ImageBitmap> {
|
||||
try {
|
||||
return createImageBitmap(blob, { premultiplyAlpha: pma ? "none" : "premultiply" });
|
||||
} catch (e) {
|
||||
@ -230,5 +230,3 @@ export class AssetLoader {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,9 @@ export class C3Matrix {
|
||||
private tempPoint = new Vector2();
|
||||
|
||||
public update (x: number, y: number, angle: number, scaleX = 1, scaleY = 1) {
|
||||
if (this.prevX === x && this.prevY === y && this.prevAngle === angle && this.prevScaleX === scaleX && this.prevScaleY === scaleY) return false;
|
||||
if (this.prevX === x && this.prevY === y &&
|
||||
this.prevAngle === angle &&
|
||||
this.prevScaleX === scaleX && this.prevScaleY === scaleY) return false;
|
||||
this.prevX = x;
|
||||
this.prevY = y;
|
||||
this.prevAngle = angle;
|
||||
|
||||
@ -264,7 +264,7 @@ abstract class C3SkeletonRenderer<
|
||||
}
|
||||
|
||||
// clipping
|
||||
this.setColor(0.8, 0, 0, 1)
|
||||
this.setColor(0.8, 0, 0, 1);
|
||||
for (let i = 0, n = slots.length; i < n; i++) {
|
||||
const slot = slots[i];
|
||||
if (!slot.bone.active) continue;
|
||||
@ -388,8 +388,8 @@ export class C3RendererRuntime extends C3SkeletonRenderer<IRenderer, C3TextureRu
|
||||
this.renderer.setColorFillMode();
|
||||
}
|
||||
|
||||
protected setBlendMode (blenMode: BlendModeParameter = "normal"): void {
|
||||
this.renderer.setBlendMode(blenMode);
|
||||
protected setBlendMode (blendMode: BlendModeParameter = "normal"): void {
|
||||
this.renderer.setBlendMode(blendMode);
|
||||
}
|
||||
|
||||
protected poly (points: number[]): void {
|
||||
@ -433,8 +433,8 @@ export class C3RendererEditor extends C3SkeletonRenderer<SDK.Gfx.IWebGLRenderer,
|
||||
this.renderer.SetColorFillMode();
|
||||
}
|
||||
|
||||
protected setBlendMode (blenMode: BlendModeParameter = "normal"): void {
|
||||
this.renderer.SetBlendMode(blenMode);
|
||||
protected setBlendMode (blendMode: BlendModeParameter = "normal"): void {
|
||||
this.renderer.SetBlendMode(blendMode);
|
||||
}
|
||||
|
||||
protected poly (points: number[]): void {
|
||||
|
||||
@ -41,7 +41,7 @@ export class C3TextureEditor extends Texture {
|
||||
wrapY: toC3TextureWrap(page.vWrap),
|
||||
defaultSampling: toC3Filter(page.minFilter),
|
||||
mipMap: toC3MipMap(page.minFilter),
|
||||
}
|
||||
};
|
||||
this.texture = renderer.CreateDynamicTexture(image.width, image.height, options);
|
||||
this.renderer.UpdateTexture(image, this.texture, { premultiplyAlpha: !page.pma });
|
||||
}
|
||||
@ -72,12 +72,11 @@ export class C3TextureRuntime extends Texture {
|
||||
wrapY: toC3TextureWrap(page.vWrap),
|
||||
defaultSampling: toC3Filter(page.minFilter),
|
||||
mipMap: toC3MipMap(page.minFilter),
|
||||
}
|
||||
};
|
||||
this.texture = renderer.createDynamicTexture(image.width, image.height, options);
|
||||
this.renderer.updateTexture(image, this.texture, { premultiplyAlpha: !page.pma });
|
||||
}
|
||||
|
||||
|
||||
setFilters () {
|
||||
// cannot change filter after texture creation
|
||||
}
|
||||
|
||||
@ -203,7 +203,6 @@ function setupModalHandlers (overlay: HTMLDivElement, onCancel: () => void, extr
|
||||
|
||||
interface ModalButton<T> {
|
||||
text: string;
|
||||
color?: string;
|
||||
value?: T;
|
||||
style?: 'primary' | 'secondary';
|
||||
}
|
||||
@ -213,7 +212,6 @@ interface ModalOptions<T> {
|
||||
title: string;
|
||||
text: string;
|
||||
buttons: ModalButton<T>[];
|
||||
maxWidth?: number;
|
||||
}
|
||||
|
||||
export function showModal<T> (options: ModalOptions<T>): Promise<T | undefined> {
|
||||
@ -268,7 +266,6 @@ interface ListSelectionOptions {
|
||||
darkMode: boolean;
|
||||
title: string;
|
||||
items: string[];
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
}
|
||||
|
||||
@ -427,7 +424,6 @@ interface MultiListSelectionOptions {
|
||||
title: string;
|
||||
items: string[];
|
||||
selectedItems?: string[];
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
}
|
||||
|
||||
|
||||
@ -75,9 +75,7 @@ export class SetupPoseBoundsProvider implements SpineBoundsProvider {
|
||||
skeleton.setupPose();
|
||||
skeleton.updateWorldTransform(Physics.update);
|
||||
const bounds = skeleton.getBoundsRect(this.clipping ? new SkeletonClipping() : undefined);
|
||||
return bounds.width === Number.NEGATIVE_INFINITY
|
||||
? { x: 0, y: 0, width: 0, height: 0 }
|
||||
: bounds;
|
||||
return validateBounds(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +112,7 @@ export class SkinsAndAnimationBoundsProvider implements SpineBoundsProvider {
|
||||
const customSkin = new Skin("custom-skin");
|
||||
for (const skinName of this.skins) {
|
||||
const skin = data.findSkin(skinName);
|
||||
if (skin == null) continue;
|
||||
if (skin === null) continue;
|
||||
customSkin.addSkin(skin);
|
||||
}
|
||||
skeleton.setSkin(customSkin);
|
||||
@ -126,9 +124,7 @@ export class SkinsAndAnimationBoundsProvider implements SpineBoundsProvider {
|
||||
if (animation == null) {
|
||||
skeleton.updateWorldTransform(Physics.update);
|
||||
const bounds = skeleton.getBoundsRect(clipper);
|
||||
return bounds.width === Number.NEGATIVE_INFINITY
|
||||
? { x: 0, y: 0, width: 0, height: 0 }
|
||||
: bounds;
|
||||
return validateBounds(bounds);
|
||||
} else {
|
||||
let minX = Number.POSITIVE_INFINITY,
|
||||
minY = Number.POSITIVE_INFINITY,
|
||||
@ -156,9 +152,13 @@ export class SkinsAndAnimationBoundsProvider implements SpineBoundsProvider {
|
||||
width: maxX - minX,
|
||||
height: maxY - minY,
|
||||
};
|
||||
return bounds.width === Number.NEGATIVE_INFINITY
|
||||
? { x: 0, y: 0, width: 0, height: 0 }
|
||||
: bounds;
|
||||
return validateBounds(bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateBounds (bounds: Rectangle): Rectangle {
|
||||
return bounds.width === Number.NEGATIVE_INFINITY
|
||||
? { x: 0, y: 0, width: 0, height: 0 }
|
||||
: bounds;
|
||||
}
|
||||
@ -111,8 +111,9 @@
|
||||
"highlight": true,
|
||||
"params": [
|
||||
{
|
||||
"id": "track",
|
||||
"type": "number"
|
||||
"id": "track-index",
|
||||
"type": "number",
|
||||
"initial-value": 0
|
||||
},
|
||||
{
|
||||
"id": "animation",
|
||||
@ -130,8 +131,9 @@
|
||||
"highlight": true,
|
||||
"params": [
|
||||
{
|
||||
"id": "track",
|
||||
"type": "number"
|
||||
"id": "track-index",
|
||||
"type": "number",
|
||||
"initial-value": 0
|
||||
},
|
||||
{
|
||||
"id": "animation",
|
||||
@ -163,12 +165,14 @@
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "track",
|
||||
"type": "number"
|
||||
"id": "track-index",
|
||||
"type": "number",
|
||||
"initial-value": 0
|
||||
},
|
||||
{
|
||||
"id": "mix-duration",
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"initial-value": 0.25
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -178,12 +182,14 @@
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "track",
|
||||
"type": "number"
|
||||
"id": "track-index",
|
||||
"type": "number",
|
||||
"initial-value": 0
|
||||
},
|
||||
{
|
||||
"id": "mix-duration",
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"initial-value": 0.25
|
||||
},
|
||||
{
|
||||
"id": "delay",
|
||||
@ -260,17 +266,18 @@
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "units",
|
||||
"type": "combo",
|
||||
"items": ["seconds", "ratio"]
|
||||
"id": "track-index",
|
||||
"type": "number",
|
||||
"initial-value": 0
|
||||
},
|
||||
{
|
||||
"id": "time",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"id": "track",
|
||||
"type": "number"
|
||||
"id": "units",
|
||||
"type": "combo",
|
||||
"items": ["seconds", "ratio"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -483,18 +490,6 @@
|
||||
}
|
||||
],
|
||||
"expressions": [
|
||||
{
|
||||
"id": "double",
|
||||
"expressionName": "Double",
|
||||
"highlight": true,
|
||||
"returnType": "number",
|
||||
"params": [
|
||||
{
|
||||
"id": "number",
|
||||
"type": "number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "slot-attachment",
|
||||
"expressionName": "SlotAttachment",
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
|
||||
"is-c3-addon": true,
|
||||
"sdk-version": 2,
|
||||
"min-construct-version": "r459",
|
||||
"min-construct-version": "r470",
|
||||
"type": "plugin",
|
||||
"name": "Spine Construct3",
|
||||
"id": "EsotericSoftware_SpineConstruct3",
|
||||
"version": "1.0.0.1",
|
||||
"version": "4.3.0-beta",
|
||||
"author": "Esoteric Software",
|
||||
"website": "https://www.esotericsoftware.com",
|
||||
"documentation": "https://www.esotericsoftware.com",
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
|
||||
import type { SDKInstanceClass } from "./instance.ts";
|
||||
import type { SDKInstanceClass } from "./instance";
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
|
||||
C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
|
||||
{
|
||||
Alert (this: SDKInstanceClass) {
|
||||
alert(`Test`);
|
||||
},
|
||||
|
||||
SetSkin (this: SDKInstanceClass, skinList: string) {
|
||||
this.setSkin(skinList.split(","));
|
||||
},
|
||||
@ -61,7 +56,7 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
|
||||
this.setAnimationSpeed(speed);
|
||||
},
|
||||
|
||||
SetAnimationTime (this: SDKInstanceClass, units: 0 | 1, time: number, track: number) {
|
||||
SetAnimationTime (this: SDKInstanceClass, units: 0 | 1, track: number, time: number) {
|
||||
this.setAnimationTime(units, time, track);
|
||||
},
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
import type { SDKInstanceClass as SpineC3Instance } from "./instance.ts";
|
||||
import type { SDKInstanceClass as SpineC3Instance } from "./instance";
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
|
||||
import type { SDKInstanceClass as SpineC3Instance } from "./instance.ts";
|
||||
import type { SDKInstanceClass as SpineC3Instance } from "./instance";
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
|
||||
C3.Plugins.EsotericSoftware_SpineConstruct3.Exps =
|
||||
{
|
||||
Double (this: SpineC3Instance, num: number) {
|
||||
return num * 2;
|
||||
},
|
||||
|
||||
SlotAttachment (this: SpineC3Instance, slotName: string) {
|
||||
if (!this.skeleton) return "";
|
||||
const slot = this.skeleton.findSlot(slotName);
|
||||
@ -45,16 +40,15 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps =
|
||||
return this.getCurrentAnimation(trackIndex);
|
||||
},
|
||||
GetEventData (this: SpineC3Instance, field: "float" | "int" | "string" | "balance" | "volume" | "audiopath" | "event" | "track" | "animation") {
|
||||
if (field === "float") return this.triggeredEventData?.floatValue;
|
||||
if (field === "int") return this.triggeredEventData?.intValue;
|
||||
if (field === "string") return this.triggeredEventData?.stringValue;
|
||||
if (field === "balance") return this.triggeredEventData?.balance;
|
||||
if (field === "volume") return this.triggeredEventData?.volume;
|
||||
if (field === "audiopath") return this.triggeredEventData?.data.audioPath;
|
||||
if (field === "event") return this.triggeredEventData?.data.name;
|
||||
if (field === "animation") return this.triggeredEventData?.animation;
|
||||
if (field === "track") return this.triggeredEventData?.track;
|
||||
if (field === "float") return this.triggeredEventData?.floatValue ?? 0;
|
||||
if (field === "int") return this.triggeredEventData?.intValue ?? 0;
|
||||
if (field === "string") return this.triggeredEventData?.stringValue ?? "";
|
||||
if (field === "balance") return this.triggeredEventData?.balance ?? 0;
|
||||
if (field === "volume") return this.triggeredEventData?.volume ?? 0;
|
||||
if (field === "audiopath") return this.triggeredEventData?.data.audioPath ?? "";
|
||||
if (field === "event") return this.triggeredEventData?.data.name ?? 0;
|
||||
if (field === "animation") return this.triggeredEventData?.animation ?? 0;
|
||||
if (field === "track") return this.triggeredEventData?.track ?? -1;
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { AnimationState, AssetLoader, Bone, C3Matrix, C3RendererRuntime, Event, NumberArrayLike, RegionAttachment, Skeleton, Skin, Slot, SpineBoundsProvider, SpineBoundsProviderType, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
||||
import type { AnimationState, AssetLoader, Bone, C3Matrix, C3RendererRuntime, Event, NumberArrayLike, Skeleton, Skin, Slot, SpineBoundsProvider, SpineBoundsProviderType, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
const spine = globalThis.spine;
|
||||
@ -74,7 +74,6 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
|
||||
const properties = this._getInitProperties();
|
||||
if (properties) {
|
||||
console.log(properties);
|
||||
this.propAtlas = properties[0] as string;
|
||||
this.propSkel = properties[1] as string;
|
||||
this.propLoaderScale = properties[2] as number;
|
||||
@ -224,11 +223,11 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
if (!this.touchDown) return;
|
||||
this.touchX = event.clientX;
|
||||
this.touchY = event.clientY;
|
||||
}
|
||||
};
|
||||
|
||||
private dragHandleUp = (event: ConstructPointerEvent) => {
|
||||
if (event.button === 0) this.touchDown = false;
|
||||
}
|
||||
};
|
||||
|
||||
private dragHandleDispose () {
|
||||
this.runtime.removeEventListener("pointerdown", this.dragHandleDown);
|
||||
@ -317,8 +316,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
let hullLength = 8;
|
||||
|
||||
if (attachment instanceof spine.RegionAttachment) {
|
||||
const regionAttachment = <RegionAttachment>attachment;
|
||||
regionAttachment.computeWorldVertices(slot, vertices, 0, 2);
|
||||
attachment.computeWorldVertices(slot, vertices, 0, 2);
|
||||
} else if (attachment instanceof spine.MeshAttachment) {
|
||||
attachment.computeWorldVertices(this.skeleton as Skeleton, slot, 0, attachment.worldVerticesLength, vertices, 0, 2);
|
||||
hullLength = attachment.hullLength;
|
||||
@ -351,7 +349,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
|
||||
private isPointInPolygon (vertices: NumberArrayLike, hullLength: number, px: number, py: number) {
|
||||
if (hullLength < 6) {
|
||||
throw new Error("A polygon must have at least 3 vertices (6 numbers in the array). ");
|
||||
throw new Error("A polygon must have at least 3 vertices (6 numbers in the array).");
|
||||
}
|
||||
|
||||
let isInside = false;
|
||||
@ -489,7 +487,6 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
if (!skeleton) return;
|
||||
|
||||
let boundsProvider: SpineBoundsProvider;
|
||||
console.log(this.propBoundsProvider);
|
||||
if (this.propBoundsProvider === "animation-skin") {
|
||||
const { propSkin, propAnimation } = this;
|
||||
if ((propSkin && propSkin.length > 0) || propAnimation) {
|
||||
@ -549,7 +546,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
this.animationSpeed = speed;
|
||||
}
|
||||
|
||||
public setAnimationTime (units: 0 | 1, time: number, track: number) {
|
||||
public setAnimationTime (units: 0 | 1, track: number, time: number) {
|
||||
if (!this.state) return;
|
||||
|
||||
const trackEntry = this.state.tracks[track];
|
||||
@ -672,7 +669,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
||||
} else {
|
||||
const customSkin = new spine.Skin(skins.join(","));
|
||||
for (const s of skins) {
|
||||
const skin = skeleton.data.findSkin(s)
|
||||
const skin = skeleton.data.findSkin(s);
|
||||
if (!skin) throw new Error(`The given skin is not present in the skeleton data: ${s}`);
|
||||
customSkin.addSkin(skin);
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
|
||||
C3.Plugins.EsotericSoftware_SpineConstruct3 = class SpineC3 extends globalThis.ISDKPluginBase {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
import type { SDKInstanceClass } from "./instance.ts";
|
||||
import type { SDKInstanceClass } from "./instance";
|
||||
|
||||
const C3 = globalThis.C3;
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
// / <reference types="editor/sdk" />
|
||||
|
||||
import type { AnimationState, AssetLoader, C3Matrix, C3RendererEditor, Skeleton, SpineBoundsProvider, SpineBoundsProviderType, TextureAtlas, } from "@esotericsoftware/spine-construct3-lib";
|
||||
import type { SpineC3PluginType } from "./type";
|
||||
|
||||
@ -45,16 +43,16 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
*
|
||||
* In a Spine C3 GameObject:
|
||||
* - the original size is equivalent to spineBounds that is set selecting the BoundsProvider
|
||||
* - changing the C3 GameObject size from the editor will scale the skeleton by using skeleton.scaleX/Y
|
||||
* This information is stored into (PROP_SKELETON_OFFSET_SCALE_X and Y) and later passed to the runtime
|
||||
* - changing the C3 GameObject size from the editor will scale the skeleton by using a C3Matrix,
|
||||
* not the skeleton.scaleX/Y.
|
||||
* - the origin is position at the skeleton root
|
||||
*
|
||||
* positioningBounds allows to offset the position and the size of the C3 GameObject
|
||||
* with the one of the skeleton. When selected it allows to:
|
||||
* - move the C3 GameObjects position (visually the rectangle) keeping the skeleton still.
|
||||
* This is obtained by adding an offset to the GameObject position.
|
||||
* This information is stored into (PROP_SKELETON_OFFSET_SCALE_X and Y) and later passed to the runtime
|
||||
* - scale the C3 GameObjects keeping the skeleton.scaleX/Y as-is.
|
||||
* This information is stored into (PROP_BOUNDS_OFFSET_X and Y) and later passed to the runtime
|
||||
* - scale the C3 GameObjects keeping the skeleton.scaleX/Y as-is, and storing the scale offset in (PROP_SKELETON_OFFSET_SCALE_X and Y).
|
||||
*/
|
||||
private spineBounds = {
|
||||
x: 0, // determine the origin x (-x/width)
|
||||
@ -161,7 +159,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
}
|
||||
|
||||
if (id === PLUGIN_CLASS.PROP_BOUNDS_PROVIDER_MOVE) {
|
||||
value = value as boolean
|
||||
value = value as boolean;
|
||||
if (value) {
|
||||
this.positionModePrevX = this._inst.GetX();
|
||||
this.positionModePrevY = this._inst.GetY();
|
||||
@ -292,9 +290,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
message: this.lang('invalid-skins.message', [invalidSkins.join(", ")])
|
||||
});
|
||||
|
||||
const validSkins = split.filter(skinName => availableSkins.includes(skinName));
|
||||
console.log(validSkins);
|
||||
return validSkins.join(",");
|
||||
return split.filter(skinName => availableSkins.includes(skinName)).join(",");
|
||||
}
|
||||
|
||||
return split.join(",");
|
||||
@ -337,7 +333,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
} else {
|
||||
const customSkin = new spine.Skin(propValue);
|
||||
for (const s of skins) {
|
||||
const skin = skeleton.data.findSkin(s)
|
||||
const skin = skeleton.data.findSkin(s);
|
||||
if (!skin) return;
|
||||
customSkin.addSkin(skin);
|
||||
}
|
||||
@ -436,7 +432,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
if (this.getErrorsString()) {
|
||||
this.spineBoundsInit = false;
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
this.spineBoundsInit = true;
|
||||
|
||||
@ -457,7 +453,6 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
this.propOffsetAngle = 0;
|
||||
this.propScaleX = 1;
|
||||
this.propScaleY = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
private initBounds () {
|
||||
@ -499,13 +494,13 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
if (boundsType === "animation-skin" && (skins.length === 0 && !animation))
|
||||
errors.push("Animation/Skin bounds provider requires one between skin and animation to be set.");
|
||||
|
||||
if (Boolean(!animation || skeleton?.data.findAnimation(animation)) === false)
|
||||
if (animation && !skeleton?.data.findAnimation(animation))
|
||||
errors.push("Not existing animation");
|
||||
|
||||
if (skins.length > 0) {
|
||||
const missingSkins = skins.filter(skin => !skeleton?.data.findSkin(skin)).join(", ");
|
||||
if (missingSkins)
|
||||
errors.push("Not existing skin(s): ", missingSkins);
|
||||
errors.push(`Not existing skin(s): ${missingSkins}`);
|
||||
}
|
||||
|
||||
const { width, height } = spineBounds;
|
||||
@ -552,7 +547,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
}
|
||||
|
||||
private get propScaleX () {
|
||||
return this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON_OFFSET_SCALE_X) as number
|
||||
return this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON_OFFSET_SCALE_X) as number;
|
||||
}
|
||||
|
||||
private set propScaleX (value: number) {
|
||||
@ -560,7 +555,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
}
|
||||
|
||||
private get propScaleY () {
|
||||
return this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON_OFFSET_SCALE_Y) as number
|
||||
return this._inst.GetPropertyValue(PLUGIN_CLASS.PROP_SKELETON_OFFSET_SCALE_Y) as number;
|
||||
}
|
||||
|
||||
private set propScaleY (value: number) {
|
||||
@ -606,7 +601,6 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
if (spriteType) {
|
||||
const action = await spine.showModal({
|
||||
darkMode: false,
|
||||
maxWidth: 500,
|
||||
title: this.lang(`${type}.title`),
|
||||
text: this.lang(`${type}.message`, [collisionSpriteName]),
|
||||
buttons: [
|
||||
@ -616,7 +610,6 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
},
|
||||
{
|
||||
text: this.lang(`${type}.buttons.${1}`, [collisionSpriteName]),
|
||||
color: '#d9534f',
|
||||
value: 'delete'
|
||||
}
|
||||
]
|
||||
@ -702,7 +695,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
|
||||
let intlString = globalThis.lang(`${pluginContext}${stringKey}`);
|
||||
interpolate.forEach((toInterpolate, index) => {
|
||||
intlString = intlString.replace(`{${index}}`, `${toInterpolate}`);
|
||||
})
|
||||
});
|
||||
return intlString;
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
},
|
||||
"spine-bounds-provider-group": {
|
||||
"name": "Bounds provider",
|
||||
"desc": "Select the desired buound provider and fill the respective properties."
|
||||
"desc": "Select the desired bound provider and fill the respective properties."
|
||||
},
|
||||
"spine-bounds-provider": {
|
||||
"name": "Bounds provider",
|
||||
@ -169,11 +169,6 @@
|
||||
}
|
||||
},
|
||||
"actions": {
|
||||
"do-alert": {
|
||||
"list-name": "Do alert",
|
||||
"display-text": "Do alert",
|
||||
"description": "Do a dummy alert."
|
||||
},
|
||||
"set-skin": {
|
||||
"list-name": "Set skin",
|
||||
"display-text": "Set skin {0}",
|
||||
@ -201,7 +196,7 @@
|
||||
"display-text": "Set animation {1} on track {0} with loop {2}",
|
||||
"description": "Set animation",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "track",
|
||||
"desc": "track"
|
||||
},
|
||||
@ -220,7 +215,7 @@
|
||||
"display-text": "Add animation {1} on track {0} with loop {2} and delay {3}",
|
||||
"description": "Add animation",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "track",
|
||||
"desc": "track"
|
||||
},
|
||||
@ -253,7 +248,7 @@
|
||||
"display-text": "Set empty animation on track {0} with mix duration {1}",
|
||||
"description": "Set an empty animation on a specific track",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "Track",
|
||||
"desc": "Track index"
|
||||
},
|
||||
@ -268,7 +263,7 @@
|
||||
"display-text": "Add empty animation on track {0} with mix duration {1} and delay {2}",
|
||||
"description": "Add an empty animation to the animation queue on a specific track",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "Track",
|
||||
"desc": "Track index"
|
||||
},
|
||||
@ -347,9 +342,17 @@
|
||||
},
|
||||
"set-animation-time": {
|
||||
"list-name": "Set animation time",
|
||||
"display-text": "Set track {2} animation time to {1} ({0})",
|
||||
"display-text": "Set track {0} animation time to {1} ({2})",
|
||||
"description": "Set the current time of an animation on a track",
|
||||
"params": {
|
||||
"track-index": {
|
||||
"name": "Track",
|
||||
"desc": "Track index"
|
||||
},
|
||||
"time": {
|
||||
"name": "Time",
|
||||
"desc": "Time value (in seconds or as a ratio 0.0-1.0)"
|
||||
},
|
||||
"units": {
|
||||
"name": "Units",
|
||||
"desc": "Time units",
|
||||
@ -357,14 +360,6 @@
|
||||
"seconds": "Seconds (absolute time)",
|
||||
"ratio": "Ratio (0.0 to 1.0)"
|
||||
}
|
||||
},
|
||||
"time": {
|
||||
"name": "Time",
|
||||
"desc": "Time value (in seconds or as a ratio 0.0-1.0)"
|
||||
},
|
||||
"track": {
|
||||
"name": "Track",
|
||||
"desc": "Track index"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -593,16 +588,6 @@
|
||||
}
|
||||
},
|
||||
"expressions": {
|
||||
"double": {
|
||||
"description": "Double a number.",
|
||||
"translated-name": "Double",
|
||||
"params": {
|
||||
"number": {
|
||||
"name": "Number",
|
||||
"desc": "The number to double."
|
||||
}
|
||||
}
|
||||
},
|
||||
"slot-attachment": {
|
||||
"description": "Get the name of the attachment on a slot. Returns empty string if no attachment.",
|
||||
"translated-name": "SlotAttachment",
|
||||
|
||||
@ -169,11 +169,6 @@
|
||||
}
|
||||
},
|
||||
"actions": {
|
||||
"do-alert": {
|
||||
"list-name": "显示警告",
|
||||
"display-text": "显示警告",
|
||||
"description": "显示一个示例警告。"
|
||||
},
|
||||
"set-skin": {
|
||||
"list-name": "设置皮肤",
|
||||
"display-text": "设置皮肤 {0}",
|
||||
@ -201,7 +196,7 @@
|
||||
"display-text": "在轨道{0}上设置动画{1},循环{2}",
|
||||
"description": "设置动画",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "轨道",
|
||||
"desc": "轨道"
|
||||
},
|
||||
@ -220,7 +215,7 @@
|
||||
"display-text": "在轨道{0}上添加动画{1},循环{2},延迟{3}",
|
||||
"description": "添加动画",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "轨道",
|
||||
"desc": "轨道"
|
||||
},
|
||||
@ -253,7 +248,7 @@
|
||||
"display-text": "在轨道{0}上设置空动画,混合时长{1}",
|
||||
"description": "在特定轨道上设置空动画",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "轨道",
|
||||
"desc": "轨道索引"
|
||||
},
|
||||
@ -268,7 +263,7 @@
|
||||
"display-text": "在轨道{0}上添加空动画,混合时长{1},延迟{2}",
|
||||
"description": "将空动画添加到特定轨道的动画队列中",
|
||||
"params": {
|
||||
"track": {
|
||||
"track-index": {
|
||||
"name": "轨道",
|
||||
"desc": "轨道索引"
|
||||
},
|
||||
@ -347,9 +342,17 @@
|
||||
},
|
||||
"set-animation-time": {
|
||||
"list-name": "设置动画时间",
|
||||
"display-text": "将轨道{2}的动画时间设置为{1}({0})",
|
||||
"display-text": "将轨道{0}的动画时间设置为{1}({2})",
|
||||
"description": "设置轨道上动画的当前时间",
|
||||
"params": {
|
||||
"track-index": {
|
||||
"name": "轨道",
|
||||
"desc": "轨道索引"
|
||||
},
|
||||
"time": {
|
||||
"name": "时间",
|
||||
"desc": "时间值(秒或0.0-1.0的比例)"
|
||||
},
|
||||
"units": {
|
||||
"name": "单位",
|
||||
"desc": "时间单位",
|
||||
@ -357,14 +360,6 @@
|
||||
"seconds": "秒(绝对时间)",
|
||||
"ratio": "比例(0.0到1.0)"
|
||||
}
|
||||
},
|
||||
"time": {
|
||||
"name": "时间",
|
||||
"desc": "时间值(秒或0.0-1.0的比例)"
|
||||
},
|
||||
"track": {
|
||||
"name": "轨道",
|
||||
"desc": "轨道索引"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -593,16 +588,6 @@
|
||||
}
|
||||
},
|
||||
"expressions": {
|
||||
"double": {
|
||||
"description": "将数字翻倍。",
|
||||
"translated-name": "Double",
|
||||
"params": {
|
||||
"number": {
|
||||
"name": "数字",
|
||||
"desc": "要翻倍的数字。"
|
||||
}
|
||||
}
|
||||
},
|
||||
"slot-attachment": {
|
||||
"description": "获取插槽上的附件名称。如果没有附件则返回空字符串。",
|
||||
"translated-name": "SlotAttachment",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { SpineBoundsProviderType } from "@esotericsoftware/spine-construct3-lib";
|
||||
|
||||
import type { SDKEditorInstanceClass } from "./instance.ts";
|
||||
import type { SDKEditorInstanceClass } from "./instance";
|
||||
|
||||
const SDK = globalThis.SDK;
|
||||
|
||||
@ -70,7 +70,7 @@ const PLUGIN_CLASS = class SpineC3Plugin extends SDK.IPluginBase {
|
||||
this._info.AddFileDependency({
|
||||
filename: "c3runtime/spine-construct3-lib.js",
|
||||
type: "external-runtime-script"
|
||||
})
|
||||
});
|
||||
|
||||
SDK.Lang.PushContext(".properties");
|
||||
|
||||
@ -119,8 +119,6 @@ const PLUGIN_CLASS = class SpineC3Plugin extends SDK.IPluginBase {
|
||||
},
|
||||
callbackType: "for-each-instance"
|
||||
}),
|
||||
|
||||
|
||||
]);
|
||||
|
||||
SDK.Lang.PopContext(); // .properties
|
||||
@ -132,4 +130,3 @@ const PLUGIN_CLASS = class SpineC3Plugin extends SDK.IPluginBase {
|
||||
SDK.Plugins.EsotericSoftware_SpineConstruct3 = PLUGIN_CLASS;
|
||||
|
||||
PLUGIN_CLASS.Register(PLUGIN_ID, PLUGIN_CLASS);
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
const SDK = globalThis.SDK;
|
||||
|
||||
const PLUGIN_CLASS = SDK.Plugins.EsotericSoftware_SpineConstruct3;
|
||||
@ -21,7 +20,8 @@ export class SpineC3PluginType extends SDK.ITypeBase {
|
||||
this.spineLogo = iRenderer.CreateDynamicTexture(image.width, image.height);
|
||||
iRenderer.UpdateTexture(image, this.spineLogo);
|
||||
iLayoutView.Refresh();
|
||||
})
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user