From 233f39a1f26eef4b8b0254630449a98974f90eb5 Mon Sep 17 00:00:00 2001 From: Anton Bystrov Date: Thu, 13 Jun 2019 15:56:22 +0300 Subject: [PATCH] v1.0.0 Migrate to Phaser 3.17. ComponentClip extends Phaser Container. --- dist/phaser-ui-comps-with-underscore.min.js | 2 +- dist/phaser-ui-comps.min.js | 2 +- package-lock.json | 343 +++++++++++--------- package.json | 4 +- src/clip/ComponentClip.js | 287 ++-------------- src/components/UIComponentPrototype.js | 2 +- src/components/UIContainer.js | 35 +- src/plugin/Plugin.js | 10 +- 8 files changed, 232 insertions(+), 453 deletions(-) diff --git a/dist/phaser-ui-comps-with-underscore.min.js b/dist/phaser-ui-comps-with-underscore.min.js index bab22ea..7a1e901 100644 --- a/dist/phaser-ui-comps-with-underscore.min.js +++ b/dist/phaser-ui-comps-with-underscore.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("phaser")):"function"==typeof define&&define.amd?define(["phaser"],e):"object"==typeof exports?exports.PhaserComps=e(require("phaser")):t.PhaserComps=e(t.Phaser)}(window,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n=0&&e<=j};d.each=d.forEach=function(t,e,n){var r,i;if(e=b(e,n),x(t))for(r=0,i=t.length;r=3;return function(e,n,r,i){var o=!x(e)&&d.keys(e),u=(o||e).length,a=t>0?0:u-1;for(i||(r=e[o?o[a]:a],a+=t);a>=0&&a=0},d.invoke=O(function(t,e,n){var r,i;return d.isFunction(e)?i=e:d.isArray(e)&&(r=e.slice(0,-1),e=e[e.length-1]),d.map(t,function(t){var o=i;if(!o){if(r&&r.length&&(t=P(t,r)),null==t)return;o=t[e]}return null==o?o:o.apply(t,n)})}),d.pluck=function(t,e){return d.map(t,d.property(e))},d.where=function(t,e){return d.filter(t,d.matcher(e))},d.findWhere=function(t,e){return d.find(t,d.matcher(e))},d.max=function(t,e,n){var r,i,o=-1/0,u=-1/0;if(null==e||"number"==typeof e&&"object"!=typeof t[0]&&null!=t)for(var a=0,l=(t=x(t)?t:d.values(t)).length;ao&&(o=r);else e=m(e,n),d.each(t,function(t,n,r){((i=e(t,n,r))>u||i===-1/0&&o===-1/0)&&(o=t,u=i)});return o},d.min=function(t,e,n){var r,i,o=1/0,u=1/0;if(null==e||"number"==typeof e&&"object"!=typeof t[0]&&null!=t)for(var a=0,l=(t=x(t)?t:d.values(t)).length;ar||void 0===n)return 1;if(n0?0:i-1;o>=0&&o0?u=o>=0?o:Math.max(o+a,u):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return r[o=n(r,i)]===i?o:-1;if(i!=i)return(o=e(c.call(r,u,a),d.isNaN))>=0?o+u:-1;for(o=t>0?u:a-1;o>=0&&oe?(r&&(clearTimeout(r),r=null),a=s,u=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(l,c)),u};return s.cancel=function(){clearTimeout(r),a=0,r=i=o=null},s},d.debounce=function(t,e,n){var r,i,o=function(e,n){r=null,n&&(i=t.apply(e,n))},u=O(function(u){if(r&&clearTimeout(r),n){var a=!r;r=setTimeout(o,e),a&&(i=t.apply(this,u))}else r=d.delay(o,e,this,u);return i});return u.cancel=function(){clearTimeout(r),r=null},u},d.wrap=function(t,e){return d.partial(e,t)},d.negate=function(t){return function(){return!t.apply(this,arguments)}},d.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,r=t[e].apply(this,arguments);n--;)r=t[n].call(this,r);return r}},d.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},d.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},d.once=d.partial(d.before,2),d.restArguments=O;var V=!{toString:null}.propertyIsEnumerable("toString"),D=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],N=function(t,e){var n=D.length,r=t.constructor,i=d.isFunction(r)&&r.prototype||a,o="constructor";for(w(t,o)&&!d.contains(e,o)&&e.push(o);n--;)(o=D[n])in t&&t[o]!==i[o]&&!d.contains(e,o)&&e.push(o)};d.keys=function(t){if(!d.isObject(t))return[];if(_)return _(t);var e=[];for(var n in t)w(t,n)&&e.push(n);return V&&N(t,e),e},d.allKeys=function(t){if(!d.isObject(t))return[];var e=[];for(var n in t)e.push(n);return V&&N(t,e),e},d.values=function(t){for(var e=d.keys(t),n=e.length,r=Array(n),i=0;i1&&(r=b(r,e[1])),e=d.allKeys(t)):(r=U,e=A(e,!1,!1),t=Object(t));for(var i=0,o=e.length;i1&&(n=e[1])):(e=d.map(A(e,!1,!1),String),r=function(t,n){return!d.contains(e,n)}),d.pick(t,r,n)}),d.defaults=X(d.allKeys,!0),d.create=function(t,e){var n=k(t);return e&&d.extendOwn(n,e),n},d.clone=function(t){return d.isObject(t)?d.isArray(t)?t.slice():d.extend({},t):t},d.tap=function(t,e){return e(t),t},d.isMatch=function(t,e){var n=d.keys(e),r=n.length;if(null==t)return!r;for(var i=Object(t),o=0;o":">",'"':""","'":"'","`":"`"},Z=d.invert(K),q=function(t){var e=function(e){return t[e]},n="(?:"+d.keys(t).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(i,e):t}};d.escape=q(K),d.unescape=q(Z),d.result=function(t,e,n){d.isArray(e)||(e=[e]);var r=e.length;if(!r)return d.isFunction(n)?n.call(t):n;for(var i=0;i/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var z=/(.)^/,G={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},W=/\\|'|\r|\n|\u2028|\u2029/g,$=function(t){return"\\"+G[t]};d.template=function(t,e,n){!e&&n&&(e=n),e=d.defaults({},e,d.templateSettings);var r,i=RegExp([(e.escape||z).source,(e.interpolate||z).source,(e.evaluate||z).source].join("|")+"|$","g"),o=0,u="__p+='";t.replace(i,function(e,n,r,i,a){return u+=t.slice(o,a).replace(W,$),o=a+e.length,n?u+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?u+="'+\n((__t=("+r+"))==null?'':__t)+\n'":i&&(u+="';\n"+i+"\n__p+='"),e}),u+="';\n",e.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{r=new Function(e.variable||"obj","_",u)}catch(t){throw t.source=u,t}var a=function(t){return r.call(this,t,d)},l=e.variable||"obj";return a.source="function("+l+"){\n"+u+"}",a},d.chain=function(t){var e=d(t);return e._chain=!0,e};var J=function(t,e){return t._chain?d(e).chain():e};d.mixin=function(t){return d.each(d.functions(t),function(e){var n=d[e]=t[e];d.prototype[e]=function(){var t=[this._wrapped];return s.apply(t,arguments),J(this,n.apply(d,t))}}),d},d.mixin(d),d.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=u[t];d.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],J(this,n)}}),d.each(["concat","join","slice"],function(t){var e=u[t];d.prototype[t]=function(){return J(this,e.apply(this._wrapped,arguments))}}),d.prototype.value=function(){return this._wrapped},d.prototype.valueOf=d.prototype.toJSON=d.prototype.value,d.prototype.toString=function(){return String(this._wrapped)},void 0===(r=function(){return d}.apply(e,[]))||(n.exports=r)}()}).call(this,n(5),n(12)(t))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;nthis._dragBounds.maxX&&(i=this._dragBounds.maxX),othis._dragBounds.maxY&&(o=this._dragBounds.maxY),this.emit("event_drag",i,o)}}},{key:"_setupInteractive",value:function(t){r(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_setupInteractive",this).call(this,t),this._dragZone=t,t.scene.input.setDraggable(t,!0),t.scene.input.on("dragstart",this._onDragStart,this),t.scene.input.on("drag",this._onDrag,this)}},{key:"_removeInteractive",value:function(t){r(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_removeInteractive",this).call(this,t),this._dragZone=null,t.scene.input.setDraggable(t,!1),t.scene.input.removeListener("dragstart",this._onDragStart),t.scene.input.removeListener("drag",this._onDrag)}}]),e}();e.default=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function t(e,n,r){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,n);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,r)}if("value"in i)return i.value;var u=i.get;return void 0!==u?u.call(r):void 0},i=function(){function t(t,e){for(var n=0;n1&&(e=1),e!==this._value&&(this._value=e,this._updateThumbFromValue())}}]),e}();e.default=c},function(t,e,n){t.exports=n(11)},function(t,e,n){"use strict";(function(e){var r=a(n(6)),i=a(n(13)),o=a(n(18)),u=a(n(1));function a(t){return t&&t.__esModule?t:{default:t}}var l={ComponentClip:r.default,UIComponents:i.default,Plugin:o.default,UIManager:u.default};t.exports=l,e.PhaserComps=l}).call(this,n(5))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=p(n(3)),i=p(n(14)),o=p(n(0)),u=p(n(7)),a=p(n(8)),l=p(n(9)),s=p(n(15)),c=p(n(16)),f=p(n(17));function p(t){return t&&t.__esModule?t:{default:t}}var h={UIComponentPrototype:o.default,UIButton:r.default,UIButtonSelect:u.default,UIButtonRadio:i.default,UIButtonDraggable:a.default,UIScrollBar:l.default,UIScrollPanel:s.default,UIProgressBar:c.default,UIContainer:f.default};e.default=h},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,i=function(){function t(t,e){for(var n=0;na.stepValue&&this._value=0&&e<=j};d.each=d.forEach=function(t,e,n){var r,i;if(e=b(e,n),x(t))for(r=0,i=t.length;r=3;return function(e,n,r,i){var o=!x(e)&&d.keys(e),u=(o||e).length,a=t>0?0:u-1;for(i||(r=e[o?o[a]:a],a+=t);a>=0&&a=0},d.invoke=O(function(t,e,n){var r,i;return d.isFunction(e)?i=e:d.isArray(e)&&(r=e.slice(0,-1),e=e[e.length-1]),d.map(t,function(t){var o=i;if(!o){if(r&&r.length&&(t=P(t,r)),null==t)return;o=t[e]}return null==o?o:o.apply(t,n)})}),d.pluck=function(t,e){return d.map(t,d.property(e))},d.where=function(t,e){return d.filter(t,d.matcher(e))},d.findWhere=function(t,e){return d.find(t,d.matcher(e))},d.max=function(t,e,n){var r,i,o=-1/0,u=-1/0;if(null==e||"number"==typeof e&&"object"!=typeof t[0]&&null!=t)for(var a=0,l=(t=x(t)?t:d.values(t)).length;ao&&(o=r);else e=m(e,n),d.each(t,function(t,n,r){((i=e(t,n,r))>u||i===-1/0&&o===-1/0)&&(o=t,u=i)});return o},d.min=function(t,e,n){var r,i,o=1/0,u=1/0;if(null==e||"number"==typeof e&&"object"!=typeof t[0]&&null!=t)for(var a=0,l=(t=x(t)?t:d.values(t)).length;ar||void 0===n)return 1;if(n0?0:i-1;o>=0&&o0?u=o>=0?o:Math.max(o+a,u):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return r[o=n(r,i)]===i?o:-1;if(i!=i)return(o=e(c.call(r,u,a),d.isNaN))>=0?o+u:-1;for(o=t>0?u:a-1;o>=0&&oe?(r&&(clearTimeout(r),r=null),a=s,u=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(l,c)),u};return s.cancel=function(){clearTimeout(r),a=0,r=i=o=null},s},d.debounce=function(t,e,n){var r,i,o=function(e,n){r=null,n&&(i=t.apply(e,n))},u=O(function(u){if(r&&clearTimeout(r),n){var a=!r;r=setTimeout(o,e),a&&(i=t.apply(this,u))}else r=d.delay(o,e,this,u);return i});return u.cancel=function(){clearTimeout(r),r=null},u},d.wrap=function(t,e){return d.partial(e,t)},d.negate=function(t){return function(){return!t.apply(this,arguments)}},d.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,r=t[e].apply(this,arguments);n--;)r=t[n].call(this,r);return r}},d.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},d.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},d.once=d.partial(d.before,2),d.restArguments=O;var D=!{toString:null}.propertyIsEnumerable("toString"),V=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],N=function(t,e){var n=V.length,r=t.constructor,i=d.isFunction(r)&&r.prototype||a,o="constructor";for(C(t,o)&&!d.contains(e,o)&&e.push(o);n--;)(o=V[n])in t&&t[o]!==i[o]&&!d.contains(e,o)&&e.push(o)};d.keys=function(t){if(!d.isObject(t))return[];if(_)return _(t);var e=[];for(var n in t)C(t,n)&&e.push(n);return D&&N(t,e),e},d.allKeys=function(t){if(!d.isObject(t))return[];var e=[];for(var n in t)e.push(n);return D&&N(t,e),e},d.values=function(t){for(var e=d.keys(t),n=e.length,r=Array(n),i=0;i1&&(r=b(r,e[1])),e=d.allKeys(t)):(r=L,e=M(e,!1,!1),t=Object(t));for(var i=0,o=e.length;i1&&(n=e[1])):(e=d.map(M(e,!1,!1),String),r=function(t,n){return!d.contains(e,n)}),d.pick(t,r,n)}),d.defaults=U(d.allKeys,!0),d.create=function(t,e){var n=k(t);return e&&d.extendOwn(n,e),n},d.clone=function(t){return d.isObject(t)?d.isArray(t)?t.slice():d.extend({},t):t},d.tap=function(t,e){return e(t),t},d.isMatch=function(t,e){var n=d.keys(e),r=n.length;if(null==t)return!r;for(var i=Object(t),o=0;o":">",'"':""","'":"'","`":"`"},Z=d.invert(Y),q=function(t){var e=function(e){return t[e]},n="(?:"+d.keys(t).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(i,e):t}};d.escape=q(Y),d.unescape=q(Z),d.result=function(t,e,n){d.isArray(e)||(e=[e]);var r=e.length;if(!r)return d.isFunction(n)?n.call(t):n;for(var i=0;i/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var z=/(.)^/,G={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},W=/\\|'|\r|\n|\u2028|\u2029/g,$=function(t){return"\\"+G[t]};d.template=function(t,e,n){!e&&n&&(e=n),e=d.defaults({},e,d.templateSettings);var r,i=RegExp([(e.escape||z).source,(e.interpolate||z).source,(e.evaluate||z).source].join("|")+"|$","g"),o=0,u="__p+='";t.replace(i,function(e,n,r,i,a){return u+=t.slice(o,a).replace(W,$),o=a+e.length,n?u+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?u+="'+\n((__t=("+r+"))==null?'':__t)+\n'":i&&(u+="';\n"+i+"\n__p+='"),e}),u+="';\n",e.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{r=new Function(e.variable||"obj","_",u)}catch(t){throw t.source=u,t}var a=function(t){return r.call(this,t,d)},l=e.variable||"obj";return a.source="function("+l+"){\n"+u+"}",a},d.chain=function(t){var e=d(t);return e._chain=!0,e};var J=function(t,e){return t._chain?d(e).chain():e};d.mixin=function(t){return d.each(d.functions(t),function(e){var n=d[e]=t[e];d.prototype[e]=function(){var t=[this._wrapped];return s.apply(t,arguments),J(this,n.apply(d,t))}}),d},d.mixin(d),d.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=u[t];d.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],J(this,n)}}),d.each(["concat","join","slice"],function(t){var e=u[t];d.prototype[t]=function(){return J(this,e.apply(this._wrapped,arguments))}}),d.prototype.value=function(){return this._wrapped},d.prototype.valueOf=d.prototype.toJSON=d.prototype.value,d.prototype.toString=function(){return String(this._wrapped)},void 0===(r=function(){return d}.apply(e,[]))||(n.exports=r)}()}).call(this,n(5),n(12)(t))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;nthis._dragBounds.maxX&&(i=this._dragBounds.maxX),othis._dragBounds.maxY&&(o=this._dragBounds.maxY),this.emit("event_drag",i,o)}}},{key:"_setupInteractive",value:function(t){r(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_setupInteractive",this).call(this,t),this._dragZone=t,t.scene.input.setDraggable(t,!0),t.scene.input.on("dragstart",this._onDragStart,this),t.scene.input.on("drag",this._onDrag,this)}},{key:"_removeInteractive",value:function(t){r(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_removeInteractive",this).call(this,t),this._dragZone=null,t.scene.input.setDraggable(t,!1),t.scene.input.removeListener("dragstart",this._onDragStart),t.scene.input.removeListener("drag",this._onDrag)}}]),e}();e.default=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function t(e,n,r){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,n);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,r)}if("value"in i)return i.value;var u=i.get;return void 0!==u?u.call(r):void 0},i=function(){function t(t,e){for(var n=0;n1&&(e=1),e!==this._value&&(this._value=e,this._updateThumbFromValue())}}]),e}();e.default=c},function(t,e,n){t.exports=n(11)},function(t,e,n){"use strict";(function(e){var r=a(n(6)),i=a(n(13)),o=a(n(18)),u=a(n(1));function a(t){return t&&t.__esModule?t:{default:t}}var l={ComponentClip:r.default,UIComponents:i.default,Plugin:o.default,UIManager:u.default};t.exports=l,e.PhaserComps=l}).call(this,n(5))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=p(n(3)),i=p(n(14)),o=p(n(0)),u=p(n(7)),a=p(n(8)),l=p(n(9)),s=p(n(15)),c=p(n(16)),f=p(n(17));function p(t){return t&&t.__esModule?t:{default:t}}var h={UIComponentPrototype:o.default,UIButton:r.default,UIButtonSelect:u.default,UIButtonRadio:i.default,UIButtonDraggable:a.default,UIScrollBar:l.default,UIScrollPanel:s.default,UIProgressBar:c.default,UIContainer:f.default};e.default=h},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,i=function(){function t(t,e){for(var n=0;na.stepValue&&this._valuethis._dragBounds.maxX&&(r=this._dragBounds.maxX),othis._dragBounds.maxY&&(o=this._dragBounds.maxY),this.emit("event_drag",r,o)}}},{key:"_setupInteractive",value:function(t){i(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_setupInteractive",this).call(this,t),this._dragZone=t,t.scene.input.setDraggable(t,!0),t.scene.input.on("dragstart",this._onDragStart,this),t.scene.input.on("drag",this._onDrag,this)}},{key:"_removeInteractive",value:function(t){i(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_removeInteractive",this).call(this,t),this._dragZone=null,t.scene.input.setDraggable(t,!1),t.scene.input.removeListener("dragstart",this._onDragStart),t.scene.input.removeListener("drag",this._onDrag)}}]),e}();e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function t(e,n,i){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,n);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,i)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(i):void 0},r=function(){function t(t,e){for(var n=0;n1&&(e=1),e!==this._value&&(this._value=e,this._updateThumbFromValue())}}]),e}();e.default=c},function(t,e,n){t.exports=n(10)},function(t,e,n){"use strict";(function(e){var i=s(n(5)),r=s(n(12)),o=s(n(17)),a=s(n(1));function s(t){return t&&t.__esModule?t:{default:t}}var u={ComponentClip:i.default,UIComponents:r.default,Plugin:o.default,UIManager:a.default};t.exports=u,e.PhaserComps=u}).call(this,n(11))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=f(n(3)),r=f(n(13)),o=f(n(0)),a=f(n(6)),s=f(n(7)),u=f(n(8)),l=f(n(14)),c=f(n(15)),h=f(n(16));function f(t){return t&&t.__esModule?t:{default:t}}var p={UIComponentPrototype:o.default,UIButton:i.default,UIButtonSelect:a.default,UIButtonRadio:r.default,UIButtonDraggable:s.default,UIScrollBar:u.default,UIScrollPanel:l.default,UIProgressBar:c.default,UIContainer:h.default};e.default=p},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i,r=function(){function t(t,e){for(var n=0;ns.stepValue&&this._valuethis._dragBounds.maxX&&(r=this._dragBounds.maxX),othis._dragBounds.maxY&&(o=this._dragBounds.maxY),this.emit("event_drag",r,o)}}},{key:"_setupInteractive",value:function(e){i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_setupInteractive",this).call(this,e),this._dragZone=e,e.scene.input.setDraggable(e,!0),e.scene.input.on("dragstart",this._onDragStart,this),e.scene.input.on("drag",this._onDrag,this)}},{key:"_removeInteractive",value:function(e){i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_removeInteractive",this).call(this,e),this._dragZone=null,e.scene.input.setDraggable(e,!1),e.scene.input.removeListener("dragstart",this._onDragStart),e.scene.input.removeListener("drag",this._onDrag)}}]),t}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,i)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(i):void 0},r=function(){function e(e,t){for(var n=0;n1&&(t=1),t!==this._value&&(this._value=t,this._updateThumbFromValue())}}]),t}();t.default=c},function(e,t,n){e.exports=n(10)},function(e,t,n){"use strict";(function(t){var i=u(n(5)),r=u(n(12)),o=u(n(17)),a=u(n(1));function u(e){return e&&e.__esModule?e:{default:e}}var s={ComponentClip:i.default,UIComponents:r.default,Plugin:o.default,UIManager:a.default};e.exports=s,t.PhaserComps=s}).call(this,n(11))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=f(n(3)),r=f(n(13)),o=f(n(0)),a=f(n(6)),u=f(n(7)),s=f(n(8)),l=f(n(14)),c=f(n(15)),p=f(n(16));function f(e){return e&&e.__esModule?e:{default:e}}var h={UIComponentPrototype:o.default,UIButton:i.default,UIButtonSelect:a.default,UIButtonRadio:r.default,UIButtonDraggable:u.default,UIScrollBar:s.default,UIScrollPanel:l.default,UIProgressBar:c.default,UIContainer:p.default};t.default=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,r=function(){function e(e,t){for(var n=0;nu.stepValue&&this._value} textures Array of texture names, where component should find its texture frames - * @param {Boolean} [isChildComponent = false] used internally to build child component clips recursively */ -export default class ComponentClip { - constructor(scene, config, textures, isChildComponent) { - this.scene = scene; - - this.childrenList = []; - - this._groupConfig = { - x: 0, - y: 0, - scaleX: 1, - scaleY: 1, - angle: 0, - alpha: 1, - visible: true - }; - - this._x = 0; - this._y = 0; - this._scaleX = 1; - this._scaleY = 1; - this._angle = 0; - this._angle = 0; - this._alpha = 1; - this._visible = true; - - - this._isChildComponent = isChildComponent || false; - if (this._isChildComponent) { - this._container = scene.add.container(0, 0); - this.childrenList.push(this._container); - } +export default class ComponentClip extends Phaser.GameObjects.Container { + constructor(scene, config, textures) { + super(scene, 0, 0); + this.childComponentClips = []; + /** * component config object * @type {Object} @@ -170,169 +112,6 @@ export default class ComponentClip { this._parseConfig(); } - get groupX() { - return this._groupConfig.x; - } - - set groupX(val) { - if (this._groupConfig.x === val) { - return; - } - let delta = val - this._groupConfig.x; - this._groupConfig.x = val; - this.x += delta; - } - - get groupY() { - return this._groupConfig.y; - } - - set groupY(val) { - if (this._groupConfig.y === val) { - return; - } - let delta = val - this._groupConfig.y; - this._groupConfig.y = val; - this.y += delta; - } - - get groupScaleX() { - return this._groupConfig.scaleX; - } - - set groupScaleX(val) { - if (this._groupConfig.scaleX === val) { - return; - } - let delta = val / this._groupConfig.scaleX; - this._groupConfig.scaleX = val; - this.scaleX *= delta; - } - - get groupScaleY() { - return this._groupConfig.scaleY; - } - - set groupScaleY(val) { - if (this._groupConfig.scaleY === val) { - return; - } - let delta = val / this._groupConfig.scaleY; - this._groupConfig.scaleY = val; - this.scaleY *= delta; - } - - get groupAlpha() { - return this._groupConfig.alpha; - } - - set groupAlpha(val) { - if (this._groupConfig.alpha === val) { - return; - } - let delta = val / this._groupConfig.alpha; - this._groupConfig.alpha = val; - this.alpha *= delta; - } - - get groupVisible() { - return this._groupConfig.visible; - } - - set groupVisible(val) { - if (this._groupConfig.visible === val) { - return; - } - this._groupConfig.visible = val; - this._stateManager.setupState(); - } - - - get x() { - return this._x; - } - - set x(val) { - let delta = val - this.x; - Phaser.Actions.IncX(this.childrenList, delta); - this._x = val; - } - - get y() { - return this._y; - } - - set y(val) { - let delta = val - this.y; - Phaser.Actions.IncY(this.childrenList, delta); - this._y = val; - } - - get visible() { - return this._visible; - } - - set visible(val) { - if (this._visible === val) { - return; - } - this._visible = val; - Phaser.Actions.SetVisible(this.childrenList, val); - } - - get alpha() { - return this._alpha; - } - - set alpha(val) { - if (this._alpha === val) { - return; - } - this._alpha = val; - Phaser.Actions.SetAlpha(this.childrenList, val); - } - - get scaleX() { - return this._scaleX; - } - - set scaleX(val) { - if (this._scaleX === val) { - return; - } - this._scaleX = val; - Phaser.Actions.SetScaleX(this.childrenList, val); - } - - get scaleY() { - return this._scaleY; - } - - set scaleY(val) { - if (this._scaleY === val) { - return; - } - this._scaleY = val; - Phaser.Actions.SetScaleY(this.childrenList, val); - } - - get angle() { - return this._angle; - } - - set angle(val) { - if (this._angle === val) { - return; - } - Phaser.Actions.PropertyValueSet(this.childrenList, "angle", val); - } - - setMask(mask) { - _.each(this.childrenList, (child) => { - child.setMask(mask); - }, this); - } - /** * @public * @method PhaserComps.ComponentClip#getStateConfig @@ -370,7 +149,7 @@ export default class ComponentClip { /** * @public - * @method PhaserComps.ComponentClip#applyChildParamsapplyChildParams + * @method PhaserComps.ComponentClip#applyChildParams * @description * Apply child params * @param {String} childId @@ -380,7 +159,7 @@ export default class ComponentClip { if (!this._childrenById.hasOwnProperty(childId)) { return; } - ComponentClip._setupCommonParams(this._childrenById[childId], params, this._groupConfig); + ComponentClip._setupCommonParams(this._childrenById[childId], params); } /** @@ -412,7 +191,7 @@ export default class ComponentClip { * @description destroy all child GameObjects and child clips recursively */ destroy() { - _.each(this.childrenList, child => { + _.each(this.childComponentClips, child => { child.destroy(); }, this); } @@ -464,9 +243,9 @@ export default class ComponentClip { */ _createChildFromConfig(config) { let child = null; - let childView = null; let childId = config.childId; let childKey = config.key; + let addAsChild = true; if (config.type === TYPE_IMAGE) { child = this._createImageFromConfig(config); } else if (config.type === TYPE_TEXT) { @@ -474,35 +253,30 @@ export default class ComponentClip { } else if (config.type === TYPE_TILE_SPRITE) { child = this._createTileSpriteFromConfig(config); } else if (config.type === TYPE_COMPONENT) { - child = new ComponentClip(this.scene, config, this._textures, true); + child = new ComponentClip(this.scene, config, this._textures); ComponentClip._setupCommonParams(child, config); - childView = child._container; } else if (config.type === TYPE_ZONE) { child = this._createHitZoneFromConfig(config); } else if (config.type === TYPE_POLYGON) { child = this._createPolygonFromConfig(config); + if (config.hasOwnProperty("masking")) { + let mask = child.createGeometryMask(); + _.each(config.masking, (maskedChildId) => { + let maskedChild = this._childrenById[maskedChildId]; + maskedChild.setMask(mask); + }, this); + addAsChild = false; + } } if (child === null) { //console.warn("unknown component type", config.type, config); return; } - if (childView === null) { - childView = child; - } //ComponentView._setupCommonParams(child, config); this._childrenById[childId] = child; - if (config.hasOwnProperty("masking")) { - // TODO check if the shape - let mask = child.createGeometryMask(); - _.each(config.masking, (maskedChildId) => { - let maskedChild = this._childrenById[maskedChildId]; - maskedChild.setMask(mask); - }, this); - } - if (this._isChildComponent) { - this._container.add(childView); - } else { - this.childrenList.push(child); + this.childComponentClips.push(child); + if (addAsChild) { + this.add(child); } this._stateManager.addComponent(child, childId, childKey); } @@ -615,24 +389,15 @@ export default class ComponentClip { * @description setup common game object params from jsfl-generated config * @param {*} component * @param {Object} config - * @param {Object} [groupConfig] * @ignore */ - static _setupCommonParams(component, config, groupConfig) { + static _setupCommonParams(component, config) { let x = config.x || 0; let y = config.y || 0; let scaleX = config.scaleX || 1; let scaleY = config.scaleY || 1; let angle = config.angle || 0; let alpha = config.hasOwnProperty("alpha") ? config.alpha : 1; - if (groupConfig) { - x += groupConfig.x; - y += groupConfig.y; - scaleX *= groupConfig.scaleX; - scaleY *= groupConfig.scaleY; - angle += groupConfig.angle; - alpha *= groupConfig.alpha; - } component.x = x; component.y = y; component.scaleX = scaleX; @@ -839,8 +604,8 @@ class StateManager { _.each(idsToShow, (id) => { let component = this._components[id]; - component.visible = this._clip._groupConfig.visible; // && true; - ComponentClip._setupCommonParams(component, this._currentState.config[id], this._clip._groupConfig); + component.visible = true; + ComponentClip._setupCommonParams(component, this._currentState.config[id]); }, this); } } \ No newline at end of file diff --git a/src/components/UIComponentPrototype.js b/src/components/UIComponentPrototype.js index c1f1335..b7e2205 100644 --- a/src/components/UIComponentPrototype.js +++ b/src/components/UIComponentPrototype.js @@ -1,4 +1,4 @@ -import Phaser from "phaser"; +import "phaser"; import UIManager from "../manager/UIManager"; const _EVENT_STATE = "event_state"; diff --git a/src/components/UIContainer.js b/src/components/UIContainer.js index 8abedb0..6931d74 100644 --- a/src/components/UIContainer.js +++ b/src/components/UIContainer.js @@ -1,5 +1,5 @@ import UIComponentPrototype from "./UIComponentPrototype"; -import Phaser from 'phaser'; +import 'phaser'; import _ from 'underscore'; /** @@ -28,13 +28,6 @@ export default class UIContainer extends UIComponentPrototype { * @private */ this._children = []; - - /** - * Current active Phaser container instance - * @type {Phaser.GameObjects.Container} - * @private - */ - this._containerClip = null; } /** @@ -52,10 +45,11 @@ export default class UIContainer extends UIComponentPrototype { this._children.push(child); // add to container instance, or hide - if (this._containerClip) { + if (this._clip) { + child._clip.visible = true; this._addUIComponentToContainerClip(child); } else { - child._clip.groupVisible = false; + child._clip.visible = false; } return child; } @@ -75,7 +69,7 @@ export default class UIContainer extends UIComponentPrototype { } this._children.splice(index, 1); - if (this._containerClip) { + if (this._clip) { this._removeUIComponentFromContainerClip(child); } return child; @@ -87,10 +81,8 @@ export default class UIContainer extends UIComponentPrototype { * @private */ _addUIComponentToContainerClip(child) { - _.each(child._clip.childrenList, clipChild => { - this._containerClip.add(clipChild); - }, this); - child._clip.groupVisible = true; + this._clip.add(child._clip); + child._clip.visible = true; } /** @@ -100,16 +92,13 @@ export default class UIContainer extends UIComponentPrototype { * @private */ _removeUIComponentFromContainerClip(child, destroyChild) { - _.each(child._clip.childrenList, clipChild => { - this._containerClip.remove(clipChild, destroyChild); - }, this); - child._clip.groupVisible = false; + this._clip.remove(child._clip, destroyChild); + child._clip.visible = false; } onClipAppend(clip) { super.onClipAppend(clip); - this._containerClip = clip._container; - if (this._containerClip) { + if (clip) { _.each(this._children, child => { this._addUIComponentToContainerClip(child); }, this); @@ -119,7 +108,7 @@ export default class UIContainer extends UIComponentPrototype { onClipRemove(clip) { super.onClipRemove(clip); // hide and remove children from current container - if (this._containerClip) { + if (clip) { _.each(this._children, child => { this._removeUIComponentFromContainerClip(child); }, this); @@ -129,7 +118,7 @@ export default class UIContainer extends UIComponentPrototype { destroy() { // remove and destroy children _.each(this._children, child => { - if (this._containerClip) { // TODO check if needed + if (this._clip) { // TODO check if needed this._removeUIComponentFromContainerClip(child); } child.destroy(); diff --git a/src/plugin/Plugin.js b/src/plugin/Plugin.js index 1368b56..6207c58 100644 --- a/src/plugin/Plugin.js +++ b/src/plugin/Plugin.js @@ -1,4 +1,4 @@ -import Phaser from "phaser"; +import "phaser"; import ComponentClip from "../clip/ComponentClip"; /** @@ -41,10 +41,16 @@ import ComponentClip from "../clip/ComponentClip"; export default class Plugin extends Phaser.Plugins.BasePlugin { constructor(mgr) { super(mgr); - mgr.registerGameObject("ui_component", this.addComponent, this.addComponent); + mgr.registerGameObject("ui_component", this.addComponent, this.makeComponent); } addComponent(config, textures) { + let clip = new ComponentClip(this.scene, config, textures); + this.scene.add.existing(clip); + return clip; + } + + makeComponent(config, textures) { return new ComponentClip(this.scene, config, textures); } }