From 63d175a8d7a59e7e374c13cba8903eb0e3f30025 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 22 May 2017 20:38:00 +0200 Subject: [PATCH] texture and number --- src/game-lib-d3-image-factory.js | 5 +++-- src/game-lib-d3-texture.js | 11 +++++++++-- src/game-lib-gui.js | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/game-lib-d3-image-factory.js b/src/game-lib-d3-image-factory.js index 464df9a..450fb32 100644 --- a/src/game-lib-d3-image-factory.js +++ b/src/game-lib-d3-image-factory.js @@ -75,7 +75,8 @@ GameLib.D3.ImageFactory.prototype.updateInstance = function() { * @constructor */ GameLib.D3.ImageFactory.prototype.loadImage = function( - imagePath + imagePath, + force ) { imagePath = imagePath.replace(new RegExp('\/*'), '/'); @@ -85,7 +86,7 @@ GameLib.D3.ImageFactory.prototype.loadImage = function( throw new Error('Bad URL : ' + imagePath); } - if (this.promiseList[imagePath]) { + if (!force && this.promiseList[imagePath]) { return this.promiseList[imagePath]; } diff --git a/src/game-lib-d3-texture.js b/src/game-lib-d3-texture.js index e09d0e1..37d05c5 100644 --- a/src/game-lib-d3-texture.js +++ b/src/game-lib-d3-texture.js @@ -78,15 +78,19 @@ GameLib.D3.Texture.prototype.constructor = GameLib.D3.Texture; /** * Loads a texture from the image factory, it could already have downloaded, and then it updates the instance + * @param force boolean to force a reload */ -GameLib.D3.Texture.prototype.loadTexture = function() { +GameLib.D3.Texture.prototype.loadTexture = function(force, onComplete) { - this.imageData = this.imageFactory.loadImage(this.imagePath); + this.imageData = this.imageFactory.loadImage(this.imagePath, force); this.imageData.then( function (imageInstance){ this.imageInstance = imageInstance; this.instance = this.createInstance(); + if (onComplete) { + onComplete(); + } // this.parentObjects.map( // function(parentObject){ // if (parentObject instanceof GameLib.D3.Material && parentObject.updateInstance) { @@ -97,6 +101,9 @@ GameLib.D3.Texture.prototype.loadTexture = function() { }.bind(this), function onRejected(message) { console.warn(message); + if (onComplete) { + onComplete(message); + } } ); }; diff --git a/src/game-lib-gui.js b/src/game-lib-gui.js index 1f2262f..2c4b549 100644 --- a/src/game-lib-gui.js +++ b/src/game-lib-gui.js @@ -672,6 +672,8 @@ GameLib.GUI.prototype.buildControl = function(folder, object, property) { function (value) { if (object[property] instanceof GameLib.Color) { object[property].fromHex(value); + } else if (typeof this.initialValue === 'number') { + object[property] = Number(value); } else { object[property] = value; }