diff --git a/data/emulator.js b/data/emulator.js index 5fbcfb0..c99eafb 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -248,6 +248,7 @@ class EmulatorJS { this.muted = false; this.paused = true; this.listeners = []; + this.missingLang = []; this.setElements(element); this.setColor(this.config.color || ""); this.config.alignStartButton = (typeof this.config.alignStartButton === "string") ? this.config.alignStartButton : "bottom"; @@ -452,13 +453,13 @@ class EmulatorJS { this.elements.parent.appendChild(this.textElem); } localization(text, log) { - if (!isNaN(text)) return text; + if (typeof text === "undefined") return; + text = text.toString(); if (text.includes("EmulatorJS v")) return text; if (this.config.langJson) { if (typeof log === "undefined") log = true; if (!this.config.langJson[text] && log) { - if(!window.EJS_missingLang) window.EJS_missingLang = []; - window.EJS_missingLang.push(text); + if (!this.missingLang.includes(text)) this.missingLang.push(text); console.log("Translation not found for '"+text+"'. Language set to '"+this.config.language+"'"); } return this.config.langJson[text] || text; @@ -2245,18 +2246,24 @@ class EmulatorJS { textBox2.value = ""; textBox1.value = ""; if (this.controls[i][k] && this.controls[i][k].value !== undefined) { - textBox2.value = this.controls[i][k].value; + let value = this.controls[i][k].value.toString(); + if (value === " ") value = "space"; + textBox2.value = value; } - if (this.controls[i][k] && this.controls[i][k].value2 !== undefined) { - textBox1.value = this.controls[i][k].value2; + if (this.controls[i][k] && this.controls[i][k].value2 !== undefined && this.controls[i][k].value2 !== "") { + let value2 = this.controls[i][k].value2.toString().split(":"); + textBox1.value = this.localization(value2[0]) + ":" + this.localization(value2[1]); } }) if (this.controls[i][k] && this.controls[i][k].value) { - textBox2.value = this.controls[i][k].value; + let value = this.controls[i][k].value.toString(); + if (value === " ") value = "space"; + textBox2.value = value; } if (this.controls[i][k] && this.controls[i][k].value2) { - textBox1.value = "button " + this.controls[i][k].value2; + let value2 = this.controls[i][k].value2.toString().split(":"); + textBox1.value = this.localization("button") + " " + this.localization(value2[0]) + ":" + this.localization(value2[1]); } textBoxes.appendChild(textBox1Parent); @@ -2758,6 +2765,11 @@ class EmulatorJS { ]; info.push(...speedControlButtons); } + for (let i=0; ithis.options.threshold){var r,l={};for(r in this.direction)this.direction.hasOwnProperty(r)&&(l[r]=this.direction[r]);var c={};for(r in this.direction={x:n,y:i,angle:t},e.direction=this.direction,l)l[r]===this.direction[r]&&(c[r]=!0);if(c.x&&c.y&&c.angle)return e;c.x&&c.y||this.trigger("plain",e),c.x||this.trigger("plain:"+n,e),c.y||this.trigger("plain:"+i,e),c.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var x=w;function E(e,t){this.nipples=[],this.idles=[],this.actives=[],this.ids=[],this.pressureIntervals={},this.manager=e,this.id=E.id,E.id+=1,this.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},this.config(t),"static"!==this.options.mode&&"semi"!==this.options.mode||(this.options.multitouch=!1),this.options.multitouch||(this.options.maxNumberOfNipples=1);e=getComputedStyle(this.options.zone.parentElement);return e&&"flex"===e.display&&(this.parentIsFlex=!0),this.updateBox(),this.prepareNipples(),this.bindings(),this.begin(),this.nipples}E.prototype=new m,(E.constructor=E).id=0,E.prototype.prepareNipples=function(){var i=this.nipples;i.on=this.on.bind(this),i.off=this.off.bind(this),i.options=this.options,i.destroy=this.destroy.bind(this),i.ids=this.ids,i.id=this.id,i.processOnMove=this.processOnMove.bind(this),i.processOnEnd=this.processOnEnd.bind(this),i.get=function(e){if(void 0===e)return i[0];for(var t=0,n=i.length;t