Kaynağa Gözat

Merged master manually

badlogic 8 yıl önce
ebeveyn
işleme
6a4a667458

+ 2 - 0
spine-ts/README.md

@@ -179,7 +179,9 @@ new spine.SpineWidget("my-widget", {
 The configuration object has the following fields:
 
   * `json`: required, path to the `.json` file, absolute or relative, e.g. "assets/animation.json"
+  * `jsonContent`: optional, string or JSON object holding the content of a skeleton `.json` file. Overrides `json` if given.
   * `atlas`: required, path to the `.atlas` file, absolute or relative, e.g. "assets/animation.atlas"
+  * `atlasContent`: optional, string holding the content of a file. Overrides `atlasContent` if given.
   * `animation`: required, the name of the animation to play back
   * `imagesPath`: optional, the location of images on the server to load atlas pages from. If omitted, atlas `.png` page files are loaded relative to the `.atlas` file.
   * `atlasPages`: optional, the list of atlas page images, e.g. `atlasPages: ["assets/page1.png", "assets/page2.png"]` when using code, or `data-atlas-pages="assets/page1.png,assets/page2.png"` on case of HTML instantiation. Use this if you have a multi-page atlas. If ommited, only one atlas page image is loaded based on the atlas file name, replacing `.atlas` with `.png`.

+ 2 - 0
spine-ts/build/spine-all.d.ts

@@ -1620,7 +1620,9 @@ declare module spine {
 	}
 	class SpineWidgetConfig {
 		json: string;
+		jsonContent: any;
 		atlas: string;
+		atlasContent: string;
 		animation: string;
 		imagesPath: string;
 		atlasPages: string[];

+ 12 - 8
spine-ts/build/spine-all.js

@@ -8448,8 +8448,10 @@ var spine;
 			this.debugRenderer = new spine.webgl.SkeletonDebugRenderer(gl);
 			this.shapes = new spine.webgl.ShapeRenderer(gl);
 			var assets = this.assetManager = new spine.webgl.AssetManager(gl);
-			assets.loadText(config.atlas);
-			assets.loadText(config.json);
+			if (!config.atlasContent)
+				assets.loadText(config.atlas);
+			if (!config.jsonContent)
+				assets.loadText(config.json);
 			if (config.atlasPages == null) {
 				assets.loadTexture(config.atlas.replace(".atlas", ".png"));
 			}
@@ -8461,10 +8463,10 @@ var spine;
 			requestAnimationFrame(function () { _this.load(); });
 		}
 		SpineWidget.prototype.validateConfig = function (config) {
-			if (!config.atlas)
-				throw new Error("Please specify config.atlas");
-			if (!config.json)
-				throw new Error("Please specify config.json");
+			if (!config.atlas && !config.atlasContent)
+				throw new Error("Please specify config.atlas or config.atlasContent");
+			if (!config.json && !config.jsonContent)
+				throw new Error("Please specify config.json or config.jsonContent");
 			if (!config.animation)
 				throw new Error("Please specify config.animationName");
 			if (!config.scale)
@@ -8511,14 +8513,16 @@ var spine;
 					else
 						throw new Error("Failed to load assets: " + JSON.stringify(assetManager.getErrors()));
 				}
-				var atlas = new spine.TextureAtlas(this.assetManager.get(this.config.atlas), function (path) {
+				var atlasContent = config.atlasContent === undefined ? this.assetManager.get(this.config.atlas) : config.atlasContent;
+				var atlas = new spine.TextureAtlas(atlasContent, function (path) {
 					var texture = assetManager.get(imagesPath + path);
 					return texture;
 				});
 				var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
 				var skeletonJson = new spine.SkeletonJson(atlasLoader);
 				skeletonJson.scale = config.scale;
-				var skeletonData = skeletonJson.readSkeletonData(assetManager.get(config.json));
+				var jsonContent = config.jsonContent === undefined ? assetManager.get(config.json) : config.jsonContent;
+				var skeletonData = skeletonJson.readSkeletonData(jsonContent);
 				var skeleton = this.skeleton = new spine.Skeleton(skeletonData);
 				var bounds = this.bounds;
 				skeleton.setSkinByName(config.skin);

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 2 - 0
spine-ts/build/spine-widget.d.ts

@@ -1541,7 +1541,9 @@ declare module spine {
 	}
 	class SpineWidgetConfig {
 		json: string;
+		jsonContent: any;
 		atlas: string;
+		atlasContent: string;
 		animation: string;
 		imagesPath: string;
 		atlasPages: string[];

+ 12 - 8
spine-ts/build/spine-widget.js

@@ -7916,8 +7916,10 @@ var spine;
 			this.debugRenderer = new spine.webgl.SkeletonDebugRenderer(gl);
 			this.shapes = new spine.webgl.ShapeRenderer(gl);
 			var assets = this.assetManager = new spine.webgl.AssetManager(gl);
-			assets.loadText(config.atlas);
-			assets.loadText(config.json);
+			if (!config.atlasContent)
+				assets.loadText(config.atlas);
+			if (!config.jsonContent)
+				assets.loadText(config.json);
 			if (config.atlasPages == null) {
 				assets.loadTexture(config.atlas.replace(".atlas", ".png"));
 			}
@@ -7929,10 +7931,10 @@ var spine;
 			requestAnimationFrame(function () { _this.load(); });
 		}
 		SpineWidget.prototype.validateConfig = function (config) {
-			if (!config.atlas)
-				throw new Error("Please specify config.atlas");
-			if (!config.json)
-				throw new Error("Please specify config.json");
+			if (!config.atlas && !config.atlasContent)
+				throw new Error("Please specify config.atlas or config.atlasContent");
+			if (!config.json && !config.jsonContent)
+				throw new Error("Please specify config.json or config.jsonContent");
 			if (!config.animation)
 				throw new Error("Please specify config.animationName");
 			if (!config.scale)
@@ -7979,14 +7981,16 @@ var spine;
 					else
 						throw new Error("Failed to load assets: " + JSON.stringify(assetManager.getErrors()));
 				}
-				var atlas = new spine.TextureAtlas(this.assetManager.get(this.config.atlas), function (path) {
+				var atlasContent = config.atlasContent === undefined ? this.assetManager.get(this.config.atlas) : config.atlasContent;
+				var atlas = new spine.TextureAtlas(atlasContent, function (path) {
 					var texture = assetManager.get(imagesPath + path);
 					return texture;
 				});
 				var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
 				var skeletonJson = new spine.SkeletonJson(atlasLoader);
 				skeletonJson.scale = config.scale;
-				var skeletonData = skeletonJson.readSkeletonData(assetManager.get(config.json));
+				var jsonContent = config.jsonContent === undefined ? assetManager.get(config.json) : config.jsonContent;
+				var skeletonData = skeletonJson.readSkeletonData(jsonContent);
 				var skeleton = this.skeleton = new spine.Skeleton(skeletonData);
 				var bounds = this.bounds;
 				skeleton.setSkinByName(config.skin);

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
spine-ts/build/spine-widget.js.map


+ 10 - 6
spine-ts/widget/src/Widget.ts

@@ -78,8 +78,8 @@ module spine {
 			this.shapes = new spine.webgl.ShapeRenderer(gl);
 
 			let assets = this.assetManager = new spine.webgl.AssetManager(gl);
-			assets.loadText(config.atlas);
-			assets.loadText(config.json);
+			if (!config.atlasContent) assets.loadText(config.atlas);
+			if (!config.jsonContent) assets.loadText(config.json);
 			if (config.atlasPages == null) {
 				assets.loadTexture(config.atlas.replace(".atlas", ".png"));
 			} else {
@@ -91,8 +91,8 @@ module spine {
 		}
 
 		private validateConfig (config: SpineWidgetConfig) {
-			if (!config.atlas) throw new Error("Please specify config.atlas");
-			if (!config.json) throw new Error("Please specify config.json");
+			if (!config.atlas && !config.atlasContent) throw new Error("Please specify config.atlas or config.atlasContent");
+			if (!config.json && !config.jsonContent) throw new Error("Please specify config.json or config.jsonContent");
 			if (!config.animation) throw new Error("Please specify config.animationName");
 
 			if (!config.scale) config.scale = 1.0;
@@ -127,7 +127,8 @@ module spine {
 					else throw new Error("Failed to load assets: " + JSON.stringify(assetManager.getErrors()));
 				}
 
-				let atlas = new spine.TextureAtlas(this.assetManager.get(this.config.atlas) as string, (path: string) => {
+				let atlasContent = config.atlasContent === undefined ? this.assetManager.get(this.config.atlas) as string : config.atlasContent;
+				let atlas = new spine.TextureAtlas(atlasContent, (path: string) => {
 					let texture = assetManager.get(imagesPath + path) as spine.webgl.GLTexture;
 					return texture;
 				});
@@ -137,7 +138,8 @@ module spine {
 
 				// Set the scale to apply during parsing, parse the file, and create a new skeleton.
 				skeletonJson.scale = config.scale;
-				var skeletonData = skeletonJson.readSkeletonData(assetManager.get(config.json) as string);
+				let jsonContent = config.jsonContent === undefined ? assetManager.get(config.json) as string : config.jsonContent;
+				var skeletonData = skeletonJson.readSkeletonData(jsonContent);
 				var skeleton = this.skeleton = new spine.Skeleton(skeletonData);
 				var bounds = this.bounds;
 				skeleton.setSkinByName(config.skin);
@@ -307,7 +309,9 @@ module spine {
 
 	export class SpineWidgetConfig {
 		json: string;
+		jsonContent: any;
 		atlas: string;
+		atlasContent: string;
 		animation: string;
 		imagesPath: string;
 		atlasPages: string[];

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor