From 3ff5a9e94319e4db730bdef6e488f86419a5430d Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Fri, 30 Jan 2026 15:10:12 +0100 Subject: [PATCH] Code review. --- .../spine-construct3-lib/src/AssetLoader.ts | 14 +++--- .../spine-construct3-lib/src/C3Matrix.ts | 4 +- .../src/C3SkeletonRenderer.ts | 10 ++-- .../spine-construct3-lib/src/C3Texture.ts | 5 +- .../spine-construct3-lib/src/CustomUI.ts | 4 -- .../src/SpineBoundsProvider.ts | 20 ++++---- spine-ts/spine-construct3/src/aces.json | 49 +++++++++---------- spine-ts/spine-construct3/src/addon.json | 4 +- .../spine-construct3/src/c3runtime/actions.ts | 9 +--- .../src/c3runtime/conditions.ts | 3 +- .../src/c3runtime/expressions.ts | 26 ++++------ .../src/c3runtime/instance.ts | 17 +++---- .../spine-construct3/src/c3runtime/plugin.ts | 1 - .../spine-construct3/src/c3runtime/type.ts | 3 +- spine-ts/spine-construct3/src/instance.ts | 33 +++++-------- spine-ts/spine-construct3/src/lang/en-US.json | 43 ++++++---------- spine-ts/spine-construct3/src/lang/zh-CN.json | 41 +++++----------- spine-ts/spine-construct3/src/plugin.ts | 7 +-- spine-ts/spine-construct3/src/type.ts | 4 +- 19 files changed, 115 insertions(+), 182 deletions(-) diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts index 7ec2e309f..7ecd5c49d 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/AssetLoader.ts @@ -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 (cache: ResourceCache, cacheKey: string, promise: Promise) { - const cachEntry: CacheEntry = { promise, refCount: 1 }; - cache.set(cacheKey, cachEntry); - cachEntry.data = await promise; + const cacheEntry: CacheEntry = { promise, refCount: 1 }; + cache.set(cacheKey, cacheEntry); + cacheEntry.data = await promise; } private getFromCache (cache: ResourceCache, cacheKey: string) { @@ -220,7 +220,7 @@ export class AssetLoader { return entry; } - static async createImageBitmapFromBlob (blob: Blob, pma: boolean): Promise { + static async createImageBitmapFromBlob (blob: Blob, pma: boolean): Promise { try { return createImageBitmap(blob, { premultiplyAlpha: pma ? "none" : "premultiply" }); } catch (e) { @@ -230,5 +230,3 @@ export class AssetLoader { } } - - diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts index 44f8dd695..d2bf72687 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/C3Matrix.ts @@ -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; diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts index 28219ef5c..4653db076 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/C3SkeletonRenderer.ts @@ -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 void, extr interface ModalButton { text: string; - color?: string; value?: T; style?: 'primary' | 'secondary'; } @@ -213,7 +212,6 @@ interface ModalOptions { title: string; text: string; buttons: ModalButton[]; - maxWidth?: number; } export function showModal (options: ModalOptions): Promise { @@ -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; } diff --git a/spine-ts/spine-construct3/spine-construct3-lib/src/SpineBoundsProvider.ts b/spine-ts/spine-construct3/spine-construct3-lib/src/SpineBoundsProvider.ts index cacaaf108..324590552 100644 --- a/spine-ts/spine-construct3/spine-construct3-lib/src/SpineBoundsProvider.ts +++ b/spine-ts/spine-construct3/spine-construct3-lib/src/SpineBoundsProvider.ts @@ -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; } \ No newline at end of file diff --git a/spine-ts/spine-construct3/src/aces.json b/spine-ts/spine-construct3/src/aces.json index c12853c70..df37fb5bb 100644 --- a/spine-ts/spine-construct3/src/aces.json +++ b/spine-ts/spine-construct3/src/aces.json @@ -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", diff --git a/spine-ts/spine-construct3/src/addon.json b/spine-ts/spine-construct3/src/addon.json index 55ea603d6..f86857679 100644 --- a/spine-ts/spine-construct3/src/addon.json +++ b/spine-ts/spine-construct3/src/addon.json @@ -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", diff --git a/spine-ts/spine-construct3/src/c3runtime/actions.ts b/spine-ts/spine-construct3/src/c3runtime/actions.ts index 420990dfb..7b4e3debc 100644 --- a/spine-ts/spine-construct3/src/c3runtime/actions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/actions.ts @@ -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); }, diff --git a/spine-ts/spine-construct3/src/c3runtime/conditions.ts b/spine-ts/spine-construct3/src/c3runtime/conditions.ts index db2410b24..c77b4526a 100644 --- a/spine-ts/spine-construct3/src/c3runtime/conditions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/conditions.ts @@ -1,5 +1,4 @@ - -import type { SDKInstanceClass as SpineC3Instance } from "./instance.ts"; +import type { SDKInstanceClass as SpineC3Instance } from "./instance"; const C3 = globalThis.C3; diff --git a/spine-ts/spine-construct3/src/c3runtime/expressions.ts b/spine-ts/spine-construct3/src/c3runtime/expressions.ts index e743fa48e..882e990f5 100644 --- a/spine-ts/spine-construct3/src/c3runtime/expressions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/expressions.ts @@ -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 ""; } }; - diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index 210c11e3e..9e873db00 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -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 = 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); } diff --git a/spine-ts/spine-construct3/src/c3runtime/plugin.ts b/spine-ts/spine-construct3/src/c3runtime/plugin.ts index 3b0b74a04..7aec61472 100644 --- a/spine-ts/spine-construct3/src/c3runtime/plugin.ts +++ b/spine-ts/spine-construct3/src/c3runtime/plugin.ts @@ -1,4 +1,3 @@ - const C3 = globalThis.C3; C3.Plugins.EsotericSoftware_SpineConstruct3 = class SpineC3 extends globalThis.ISDKPluginBase { diff --git a/spine-ts/spine-construct3/src/c3runtime/type.ts b/spine-ts/spine-construct3/src/c3runtime/type.ts index 418ce3104..348771b52 100644 --- a/spine-ts/spine-construct3/src/c3runtime/type.ts +++ b/spine-ts/spine-construct3/src/c3runtime/type.ts @@ -1,5 +1,4 @@ - -import type { SDKInstanceClass } from "./instance.ts"; +import type { SDKInstanceClass } from "./instance"; const C3 = globalThis.C3; diff --git a/spine-ts/spine-construct3/src/instance.ts b/spine-ts/spine-construct3/src/instance.ts index 5eb5ff28a..0d41fbb1b 100644 --- a/spine-ts/spine-construct3/src/instance.ts +++ b/spine-ts/spine-construct3/src/instance.ts @@ -1,5 +1,3 @@ -// / - 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; } diff --git a/spine-ts/spine-construct3/src/lang/en-US.json b/spine-ts/spine-construct3/src/lang/en-US.json index 7ecb2cae8..56c5d0163 100644 --- a/spine-ts/spine-construct3/src/lang/en-US.json +++ b/spine-ts/spine-construct3/src/lang/en-US.json @@ -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", diff --git a/spine-ts/spine-construct3/src/lang/zh-CN.json b/spine-ts/spine-construct3/src/lang/zh-CN.json index e8a169d56..c689aac27 100644 --- a/spine-ts/spine-construct3/src/lang/zh-CN.json +++ b/spine-ts/spine-construct3/src/lang/zh-CN.json @@ -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", diff --git a/spine-ts/spine-construct3/src/plugin.ts b/spine-ts/spine-construct3/src/plugin.ts index de3ac30fc..7520052d7 100644 --- a/spine-ts/spine-construct3/src/plugin.ts +++ b/spine-ts/spine-construct3/src/plugin.ts @@ -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); - diff --git a/spine-ts/spine-construct3/src/type.ts b/spine-ts/spine-construct3/src/type.ts index 82f71e376..f2003a892 100644 --- a/spine-ts/spine-construct3/src/type.ts +++ b/spine-ts/spine-construct3/src/type.ts @@ -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; } };