ソースを参照

feat (loadTextureAtlas) add option to use file alias (#2019)

For Construct 3, in preview mode, the texture file names are changed to blobs with completely different filenames. So, loadTextureAtalas will not work because the file names don't match the page.name.  When Construct 3 is not in preview mode, the normal file names will match the page.name.

To get around this issue, added an optional parameter to loadTextureAtlas, fileAlias, this will allow the Construct 3 plug-in to create a fileAlias object which maps between page.name and the C3 project file names, whether they are aliased or not. If this is not needed, the function performs as it did before.

Co-authored-by: MikalDev <[email protected]>
MikalDev 3 年 前
コミット
b1d396cf55
2 ファイル変更16 行追加15 行削除
  1. 13 13
      spine-ts/package-lock.json
  2. 3 2
      spine-ts/spine-core/src/AssetManagerBase.ts

+ 13 - 13
spine-ts/package-lock.json

@@ -7949,41 +7949,41 @@
     },
     },
     "spine-canvas": {
     "spine-canvas": {
       "name": "@esotericsoftware/spine-canvas",
       "name": "@esotericsoftware/spine-canvas",
-      "version": "4.0.16",
+      "version": "4.0.17",
       "license": "LicenseRef-LICENSE",
       "license": "LicenseRef-LICENSE",
       "dependencies": {
       "dependencies": {
-        "@esotericsoftware/spine-core": "^4.0.15"
+        "@esotericsoftware/spine-core": "^4.0.17"
       }
       }
     },
     },
     "spine-core": {
     "spine-core": {
       "name": "@esotericsoftware/spine-core",
       "name": "@esotericsoftware/spine-core",
-      "version": "4.0.16",
+      "version": "4.0.17",
       "license": "LicenseRef-LICENSE"
       "license": "LicenseRef-LICENSE"
     },
     },
     "spine-player": {
     "spine-player": {
       "name": "@esotericsoftware/spine-player",
       "name": "@esotericsoftware/spine-player",
-      "version": "4.0.16",
+      "version": "4.0.17",
       "license": "LicenseRef-LICENSE",
       "license": "LicenseRef-LICENSE",
       "dependencies": {
       "dependencies": {
-        "@esotericsoftware/spine-webgl": "^4.0.15"
+        "@esotericsoftware/spine-webgl": "^4.0.17"
       }
       }
     },
     },
     "spine-threejs": {
     "spine-threejs": {
       "name": "@esotericsoftware/spine-threejs",
       "name": "@esotericsoftware/spine-threejs",
-      "version": "4.0.16",
+      "version": "4.0.17",
       "license": "LicenseRef-LICENSE",
       "license": "LicenseRef-LICENSE",
       "dependencies": {
       "dependencies": {
-        "@esotericsoftware/spine-core": "^4.0.15",
+        "@esotericsoftware/spine-core": "^4.0.17",
         "@types/three": "^0.133.1",
         "@types/three": "^0.133.1",
         "three": "^0.133.1"
         "three": "^0.133.1"
       }
       }
     },
     },
     "spine-webgl": {
     "spine-webgl": {
       "name": "@esotericsoftware/spine-webgl",
       "name": "@esotericsoftware/spine-webgl",
-      "version": "4.0.16",
+      "version": "4.0.17",
       "license": "LicenseRef-LICENSE",
       "license": "LicenseRef-LICENSE",
       "dependencies": {
       "dependencies": {
-        "@esotericsoftware/spine-core": "^4.0.16"
+        "@esotericsoftware/spine-core": "^4.0.17"
       }
       }
     }
     }
   },
   },
@@ -7991,7 +7991,7 @@
     "@esotericsoftware/spine-canvas": {
     "@esotericsoftware/spine-canvas": {
       "version": "file:spine-canvas",
       "version": "file:spine-canvas",
       "requires": {
       "requires": {
-        "@esotericsoftware/spine-core": "^4.0.15"
+        "@esotericsoftware/spine-core": "^4.0.17"
       }
       }
     },
     },
     "@esotericsoftware/spine-core": {
     "@esotericsoftware/spine-core": {
@@ -8000,13 +8000,13 @@
     "@esotericsoftware/spine-player": {
     "@esotericsoftware/spine-player": {
       "version": "file:spine-player",
       "version": "file:spine-player",
       "requires": {
       "requires": {
-        "@esotericsoftware/spine-webgl": "^4.0.15"
+        "@esotericsoftware/spine-webgl": "^4.0.17"
       }
       }
     },
     },
     "@esotericsoftware/spine-threejs": {
     "@esotericsoftware/spine-threejs": {
       "version": "file:spine-threejs",
       "version": "file:spine-threejs",
       "requires": {
       "requires": {
-        "@esotericsoftware/spine-core": "^4.0.15",
+        "@esotericsoftware/spine-core": "^4.0.17",
         "@types/three": "^0.133.1",
         "@types/three": "^0.133.1",
         "three": "^0.133.1"
         "three": "^0.133.1"
       }
       }
@@ -8014,7 +8014,7 @@
     "@esotericsoftware/spine-webgl": {
     "@esotericsoftware/spine-webgl": {
       "version": "file:spine-webgl",
       "version": "file:spine-webgl",
       "requires": {
       "requires": {
-        "@esotericsoftware/spine-core": "^4.0.16"
+        "@esotericsoftware/spine-core": "^4.0.17"
       }
       }
     },
     },
     "@types/offscreencanvas": {
     "@types/offscreencanvas": {

+ 3 - 2
spine-ts/spine-core/src/AssetManagerBase.ts

@@ -138,7 +138,8 @@ export class AssetManagerBase implements Disposable {
 
 
 	loadTextureAtlas (path: string,
 	loadTextureAtlas (path: string,
 		success: (path: string, atlas: TextureAtlas) => void = null,
 		success: (path: string, atlas: TextureAtlas) => void = null,
-		error: (path: string, message: string) => void = null
+		error: (path: string, message: string) => void = null,
+		fileAlias: {[keyword:string] : string} = null
 	) {
 	) {
 		let index = path.lastIndexOf("/");
 		let index = path.lastIndexOf("/");
 		let parent = index >= 0 ? path.substring(0, index + 1) : "";
 		let parent = index >= 0 ? path.substring(0, index + 1) : "";
@@ -149,7 +150,7 @@ export class AssetManagerBase implements Disposable {
 				let atlas = new TextureAtlas(atlasText);
 				let atlas = new TextureAtlas(atlasText);
 				let toLoad = atlas.pages.length, abort = false;
 				let toLoad = atlas.pages.length, abort = false;
 				for (let page of atlas.pages) {
 				for (let page of atlas.pages) {
-					this.loadTexture(parent + page.name,
+					this.loadTexture(fileAlias == null ? parent + page.name : fileAlias[page.name],
 						(imagePath: string, texture: Texture) => {
 						(imagePath: string, texture: Texture) => {
 							if (!abort) {
 							if (!abort) {
 								page.setTexture(texture);
 								page.setTexture(texture);