gdcore-tools 2.0.0-gd-v5.5.236-autobuild → 2.0.0-gd-v5.5.237-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
- package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
- package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
- package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +5 -4
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +67 -0
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +48 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/JsExtension.js +26 -0
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
- package/dist/Runtime/events-tools/inputtools.js +1 -1
- package/dist/Runtime/events-tools/inputtools.js.map +2 -2
- package/dist/Runtime/runtimeobject.js +1 -1
- package/dist/Runtime/runtimeobject.js.map +2 -2
- package/dist/Runtime/types/project-data.d.ts +4 -0
- package/dist/lib/libGD.wasm +0 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(a){const f={text:"text",email:"email",password:"password",number:"number","telephone number":"tel",url:"url",search:"search"},o=(h,t)=>"rgba("+h[0]+","+h[1]+","+h[2]+","+t/255+")";class r{constructor(t,e){this._input=null;this._form=null;this._object=t,this._instanceContainer=e,this._runtimeGame=this._instanceContainer.getGame(),this._createElement()}_createElement(){if(this._input)throw new Error("Tried to recreate an input while it already exists.");this._form=document.createElement("form");const t=this._object.getInputType()==="text area";this._input=document.createElement(t?"textarea":"input"),this._form.style.border="0px",this._form.style.borderRadius="0px",this._form.style.backgroundColor="transparent",this._form.style.position="absolute",this._form.style.pointerEvents="auto",this._form.style.display="none",this._form.style.boxSizing="border-box",this._form.style.textAlign=this._object.getTextAlign(),this._input.autocomplete="off",this._input.style.backgroundColor="white",this._input.style.outline="none",this._input.style.resize="none",this._input.style.border="1px solid black",this._input.style.boxSizing="border-box",this._input.style.borderRadius="0px",this._input.style.width="100%",this._input.style.height="100%",this._input.maxLength=this._object.getMaxLength(),this._input.style.padding=`${this._object.getPaddingY().toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`,this._form.appendChild(this._input),this._input.addEventListener("input",()=>{!this._input||this._object.onRendererInputValueChanged(this._input.value)}),this._input.addEventListener("touchstart",()=>{!this._input||document.activeElement!==this._input&&this._input.focus()}),this._form.addEventListener("submit",e=>{e.preventDefault(),this._object.onRendererFormSubmitted()}),this.updateString(),this.updateFont(),this.updatePlaceholder(),this.updateOpacity(),this.updateInputType(),this.updateTextColor(),this.updateFillColorAndOpacity(),this.updateBorderColorAndOpacity(),this.updateBorderWidth(),this.updateDisabled(),this.updateReadOnly(),this.updateTextAlign(),this.updateMaxLength(),this.updatePadding(),this._runtimeGame.getRenderer().getDomElementContainer().appendChild(this._form)}_destroyElement(){this._form&&(this._form.remove(),this._form=null),this._input&&(this._input.remove(),this._input=null)}onScenePaused(){this._destroyElement()}onSceneResumed(){this._input||this._createElement()}onDestroy(){this._destroyElement()}updatePreRender(){if(!this._input||!this._form)return;if(this._object.isHidden()){this._form.style.display="none";return}{let n=this._instanceContainer,s=this._object,b=!0;do{if(!n.getLayer(s.getLayer()).isVisible()||!s.isVisible()){this._form.style.display="none";return}n instanceof a.CustomRuntimeObjectInstanceContainer?(s=n.getOwner(),n=s.getInstanceContainer()):b=!1}while(b)}const t=a.staticArray(r.prototype.updatePreRender),e=this._instanceContainer.getGame(),i=e.getRenderer(),u=this._instanceContainer.getLayer(this._object.getLayer()),p=u.convertInverseCoords(this._object.x,this._object.y,0,t),
|
|
1
|
+
var gdjs;(function(a){const f={text:"text",email:"email",password:"password",number:"number","telephone number":"tel",url:"url",search:"search"},o=(h,t)=>"rgba("+h[0]+","+h[1]+","+h[2]+","+t/255+")";class r{constructor(t,e){this._input=null;this._form=null;this._object=t,this._instanceContainer=e,this._runtimeGame=this._instanceContainer.getGame(),this._createElement()}_createElement(){if(this._input)throw new Error("Tried to recreate an input while it already exists.");this._form=document.createElement("form");const t=this._object.getInputType()==="text area";this._input=document.createElement(t?"textarea":"input"),this._form.style.border="0px",this._form.style.borderRadius="0px",this._form.style.backgroundColor="transparent",this._form.style.position="absolute",this._form.style.pointerEvents="auto",this._form.style.display="none",this._form.style.boxSizing="border-box",this._form.style.textAlign=this._object.getTextAlign(),this._input.autocomplete="off",this._input.style.backgroundColor="white",this._input.style.outline="none",this._input.style.resize="none",this._input.style.border="1px solid black",this._input.style.boxSizing="border-box",this._input.style.borderRadius="0px",this._input.style.width="100%",this._input.style.height="100%",this._input.maxLength=this._object.getMaxLength(),this._input.style.padding=`${this._object.getPaddingY().toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`,this._form.appendChild(this._input),this._input.addEventListener("input",()=>{!this._input||this._object.onRendererInputValueChanged(this._input.value)}),this._input.addEventListener("touchstart",()=>{!this._input||document.activeElement!==this._input&&this._input.focus()}),this._form.addEventListener("submit",e=>{e.preventDefault(),this._object.onRendererFormSubmitted()}),this.updateString(),this.updateFont(),this.updatePlaceholder(),this.updateOpacity(),this.updateInputType(),this.updateTextColor(),this.updateFillColorAndOpacity(),this.updateBorderColorAndOpacity(),this.updateBorderWidth(),this.updateDisabled(),this.updateReadOnly(),this.updateSpellCheck(),this.updateTextAlign(),this.updateMaxLength(),this.updatePadding(),this._runtimeGame.getRenderer().getDomElementContainer().appendChild(this._form)}_destroyElement(){this._form&&(this._form.remove(),this._form=null),this._input&&(this._input.remove(),this._input=null)}onScenePaused(){this._destroyElement()}onSceneResumed(){this._input||this._createElement()}onDestroy(){this._destroyElement()}updatePreRender(){if(!this._input||!this._form)return;if(this._object.isHidden()){this._form.style.display="none";return}{let n=this._instanceContainer,s=this._object,b=!0;do{if(!n.getLayer(s.getLayer()).isVisible()||!s.isVisible()){this._form.style.display="none";return}n instanceof a.CustomRuntimeObjectInstanceContainer?(s=n.getOwner(),n=s.getInstanceContainer()):b=!1}while(b)}const t=a.staticArray(r.prototype.updatePreRender),e=this._instanceContainer.getGame(),i=e.getRenderer(),u=this._instanceContainer.getLayer(this._object.getLayer()),p=u.convertInverseCoords(this._object.x,this._object.y,0,t),l=p[0],d=p[1],c=u.convertInverseCoords(this._object.x+this._object.getWidth(),this._object.y+this._object.getHeight(),0,t),_=c[0],m=c[1];if(_<0||m<0||l>e.getGameResolutionWidth()||d>e.getGameResolutionHeight()){this._form.style.display="none";return}t[0]=l,t[1]=d,i.convertCanvasToDomElementContainerCoords(t,t);const g=t[0],y=t[1];t[0]=_,t[1]=m,i.convertCanvasToDomElementContainerCoords(t,t);const x=t[0],j=t[1],C=x-g,T=j-y;this._form.style.left=g+"px",this._form.style.top=y+"px",this._form.style.width=C+"px",this._form.style.height=T+"px",this._form.style.transform="rotate3d(0,0,1,"+this._object.getAngle()%360+"deg)",this._form.style.textAlign=this._object.getTextAlign(),this._input.style.padding=`${this._object.getPaddingY().toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`,this._input.style.fontSize=this._object.getFontSize()*i.getCanvasToDomElementContainerHeightScale()+"px",this._form.style.display="initial"}updateString(){!this._input||(this._input.value=this._object.getString())}updatePlaceholder(){!this._input||(this._input.placeholder=this._object.getPlaceholder())}updateFont(){!this._input||(this._input.style.fontFamily=this._instanceContainer.getGame().getFontManager().getFontFamily(this._object.getFontResourceName()))}updateOpacity(){!this._form||(this._form.style.opacity=(this._object.getOpacity()/255).toFixed(3))}updateInputType(){if(!this._input)return;const t=this._input instanceof HTMLTextAreaElement,e=this._object.getInputType()==="text area";t!==e&&(this._destroyElement(),this._createElement());const i=f[this._object.getInputType()]||"text";this._input.setAttribute("type",i)}updateTextColor(){!this._input||(this._input.style.color=o(this._object._getRawTextColor(),255))}updateFillColorAndOpacity(){!this._input||(this._input.style.backgroundColor=o(this._object._getRawFillColor(),this._object.getFillOpacity()))}updateBorderColorAndOpacity(){!this._input||(this._input.style.borderColor=o(this._object._getRawBorderColor(),this._object.getBorderOpacity()))}updateBorderWidth(){!this._input||(this._input.style.borderWidth=this._object.getBorderWidth()+"px")}updateDisabled(){!this._input||(this._input.disabled=this._object.isDisabled())}updateReadOnly(){!this._input||(this._input.readOnly=this._object.isReadOnly())}updateSpellCheck(){!this._input||(this._input.spellcheck=this._object.isSpellCheckEnabled())}updateMaxLength(){const t=this._input;if(!!t){if(this._object.getMaxLength()<=0){t.removeAttribute("maxLength");return}t.maxLength=this._object.getMaxLength()}}updatePadding(){!this._input||(this._input.style.padding=`${this._object.getPaddingY().toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`)}updateTextAlign(){if(!this._input)return;const t=this._object.getTextAlign();this._input.style.textAlign=t}isFocused(){return this._input===document.activeElement}focus(){!this._input||this._input.focus()}}a.TextInputRuntimeObjectRenderer=r})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=textinputruntimeobject-pixi-renderer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TextInput/textinputruntimeobject-pixi-renderer.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n const userFriendlyToHtmlInputTypes = {\n text: 'text',\n email: 'email',\n password: 'password',\n number: 'number',\n 'telephone number': 'tel',\n url: 'url',\n search: 'search',\n };\n\n const formatRgbAndOpacityToCssRgba = (\n rgbColor: [float, float, float],\n opacity: float\n ) => {\n return (\n 'rgba(' +\n rgbColor[0] +\n ',' +\n rgbColor[1] +\n ',' +\n rgbColor[2] +\n ',' +\n opacity / 255 +\n ')'\n );\n };\n\n class TextInputRuntimeObjectPixiRenderer {\n private _object: gdjs.TextInputRuntimeObject;\n private _input: HTMLInputElement | HTMLTextAreaElement | null = null;\n private _instanceContainer: gdjs.RuntimeInstanceContainer;\n private _runtimeGame: gdjs.RuntimeGame;\n private _form: HTMLFormElement | null = null;\n\n constructor(\n runtimeObject: gdjs.TextInputRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n this._instanceContainer = instanceContainer;\n this._runtimeGame = this._instanceContainer.getGame();\n\n this._createElement();\n }\n\n _createElement() {\n if (!!this._input)\n throw new Error('Tried to recreate an input while it already exists.');\n\n this._form = document.createElement('form');\n\n const isTextArea = this._object.getInputType() === 'text area';\n this._input = document.createElement(isTextArea ? 'textarea' : 'input');\n\n this._form.style.border = '0px';\n this._form.style.borderRadius = '0px';\n this._form.style.backgroundColor = 'transparent';\n this._form.style.position = 'absolute';\n this._form.style.pointerEvents = 'auto'; // Element can be clicked/touched.\n this._form.style.display = 'none'; // Hide while object is being set up.\n this._form.style.boxSizing = 'border-box';\n this._form.style.textAlign = this._object.getTextAlign();\n\n this._input.autocomplete = 'off';\n this._input.style.backgroundColor = 'white';\n this._input.style.outline = 'none'; // Remove any style added by the browser to highlight the focused field in a form (:focus & :focus-visible modifiers).\n this._input.style.resize = 'none'; // Prevent user from resizing the input when it's a text area.\n this._input.style.border = '1px solid black';\n this._input.style.boxSizing = 'border-box';\n this._input.style.borderRadius = '0px'; // Remove any style added by the browser (Safari adds some radius for instance).\n this._input.style.width = '100%';\n this._input.style.height = '100%';\n this._input.maxLength = this._object.getMaxLength();\n this._input.style.padding = `${this._object\n .getPaddingY()\n .toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`;\n\n this._form.appendChild(this._input);\n\n this._input.addEventListener('input', () => {\n if (!this._input) return;\n\n this._object.onRendererInputValueChanged(this._input.value);\n });\n this._input.addEventListener('touchstart', () => {\n if (!this._input) return;\n\n // Focus directly when touching the input on touchscreens.\n if (document.activeElement !== this._input) this._input.focus();\n });\n\n this._form.addEventListener('submit', (event) => {\n event.preventDefault();\n this._object.onRendererFormSubmitted();\n });\n\n this.updateString();\n this.updateFont();\n this.updatePlaceholder();\n this.updateOpacity();\n this.updateInputType();\n this.updateTextColor();\n this.updateFillColorAndOpacity();\n this.updateBorderColorAndOpacity();\n this.updateBorderWidth();\n this.updateDisabled();\n this.updateReadOnly();\n this.updateTextAlign();\n this.updateMaxLength();\n this.updatePadding();\n\n this._runtimeGame\n .getRenderer()\n .getDomElementContainer()!\n .appendChild(this._form);\n }\n\n _destroyElement() {\n if (this._form) {\n this._form.remove();\n this._form = null;\n }\n if (this._input) {\n this._input.remove();\n this._input = null;\n }\n }\n\n onScenePaused() {\n // This is the only renderer that uses a DOM element. PixiJS renderers\n // usually don't need to know if a scene is paused/resumed,\n // because their renderers are then not used (not part of the other scene graphs).\n // For this object, we need to remove the DOM element whenever it must\n // be not rendered.\n this._destroyElement();\n }\n\n onSceneResumed() {\n // The input must have been destroyed when the scene was paused,\n // in case it still exists, skip recreation.\n if (!this._input) this._createElement();\n }\n\n onDestroy() {\n this._destroyElement();\n }\n\n updatePreRender() {\n if (!this._input || !this._form) return;\n // Hide the input entirely if the object is hidden.\n // Because this object is rendered as a DOM element (and not part of the PixiJS\n // scene graph), we have to do this manually.\n if (this._object.isHidden()) {\n this._form.style.display = 'none';\n return;\n }\n\n // Hide the input entirely if the layer is not visible.\n // Because this object is rendered as a DOM element (and not part of the PixiJS\n // scene graph), we have to do this manually.\n {\n let instanceContainer = this._instanceContainer;\n let object: gdjs.RuntimeObject = this._object;\n let hasParent = true;\n do {\n const layer = instanceContainer.getLayer(object.getLayer());\n if (!layer.isVisible() || !object.isVisible()) {\n this._form.style.display = 'none';\n return;\n }\n // TODO Declare an interface to move up in the object tree.\n if (\n instanceContainer instanceof\n gdjs.CustomRuntimeObjectInstanceContainer\n ) {\n object = instanceContainer.getOwner();\n instanceContainer = object.getInstanceContainer();\n } else {\n hasParent = false;\n }\n } while (hasParent);\n }\n\n const workingPoint: FloatPoint = gdjs.staticArray(\n TextInputRuntimeObjectPixiRenderer.prototype.updatePreRender\n ) as FloatPoint;\n\n const runtimeGame = this._instanceContainer.getGame();\n const runtimeGameRenderer = runtimeGame.getRenderer();\n const layer = this._instanceContainer.getLayer(this._object.getLayer());\n const topLeftCanvasCoordinates = layer.convertInverseCoords(\n this._object.x,\n this._object.y,\n 0,\n workingPoint\n );\n const canvasLeft = topLeftCanvasCoordinates[0];\n const canvasTop = topLeftCanvasCoordinates[1];\n\n const bottomRightCanvasCoordinates = layer.convertInverseCoords(\n this._object.x + this._object.getWidth(),\n this._object.y + this._object.getHeight(),\n 0,\n workingPoint\n );\n const canvasRight = bottomRightCanvasCoordinates[0];\n const canvasBottom = bottomRightCanvasCoordinates[1];\n\n // Hide the input entirely if not visible at all.\n const isOutsideCanvas =\n canvasRight < 0 ||\n canvasBottom < 0 ||\n canvasLeft > runtimeGame.getGameResolutionWidth() ||\n canvasTop > runtimeGame.getGameResolutionHeight();\n if (isOutsideCanvas) {\n this._form.style.display = 'none';\n return;\n }\n\n // Position the input on the container on top of the canvas.\n workingPoint[0] = canvasLeft;\n workingPoint[1] = canvasTop;\n runtimeGameRenderer.convertCanvasToDomElementContainerCoords(\n workingPoint,\n workingPoint\n );\n const pageLeft = workingPoint[0];\n const pageTop = workingPoint[1];\n\n workingPoint[0] = canvasRight;\n workingPoint[1] = canvasBottom;\n runtimeGameRenderer.convertCanvasToDomElementContainerCoords(\n workingPoint,\n workingPoint\n );\n const pageRight = workingPoint[0];\n const pageBottom = workingPoint[1];\n\n const widthInContainer = pageRight - pageLeft;\n const heightInContainer = pageBottom - pageTop;\n\n this._form.style.left = pageLeft + 'px';\n this._form.style.top = pageTop + 'px';\n this._form.style.width = widthInContainer + 'px';\n this._form.style.height = heightInContainer + 'px';\n this._form.style.transform =\n 'rotate3d(0,0,1,' + (this._object.getAngle() % 360) + 'deg)';\n this._form.style.textAlign = this._object.getTextAlign();\n\n this._input.style.padding = `${this._object\n .getPaddingY()\n .toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`;\n\n // Automatically adjust the font size to follow the game scale.\n this._input.style.fontSize =\n this._object.getFontSize() *\n runtimeGameRenderer.getCanvasToDomElementContainerHeightScale() +\n 'px';\n\n // Display after the object is positioned.\n this._form.style.display = 'initial';\n }\n\n updateString() {\n if (!this._input) return;\n this._input.value = this._object.getString();\n }\n\n updatePlaceholder() {\n if (!this._input) return;\n this._input.placeholder = this._object.getPlaceholder();\n }\n\n updateFont() {\n if (!this._input) return;\n this._input.style.fontFamily = this._instanceContainer\n .getGame()\n .getFontManager()\n .getFontFamily(this._object.getFontResourceName());\n }\n\n updateOpacity() {\n if (!this._form) return;\n this._form.style.opacity = (this._object.getOpacity() / 255).toFixed(3);\n }\n\n updateInputType() {\n if (!this._input) return;\n\n const isTextArea = this._input instanceof HTMLTextAreaElement;\n const shouldBeTextArea = this._object.getInputType() === 'text area';\n if (isTextArea !== shouldBeTextArea) {\n this._destroyElement();\n this._createElement();\n }\n\n const newType =\n userFriendlyToHtmlInputTypes[this._object.getInputType()] || 'text';\n this._input.setAttribute('type', newType);\n }\n\n updateTextColor() {\n if (!this._input) return;\n\n this._input.style.color = formatRgbAndOpacityToCssRgba(\n this._object._getRawTextColor(),\n 255\n );\n }\n\n updateFillColorAndOpacity() {\n if (!this._input) return;\n\n this._input.style.backgroundColor = formatRgbAndOpacityToCssRgba(\n this._object._getRawFillColor(),\n this._object.getFillOpacity()\n );\n }\n\n updateBorderColorAndOpacity() {\n if (!this._input) return;\n\n this._input.style.borderColor = formatRgbAndOpacityToCssRgba(\n this._object._getRawBorderColor(),\n this._object.getBorderOpacity()\n );\n }\n updateBorderWidth() {\n if (!this._input) return;\n\n this._input.style.borderWidth = this._object.getBorderWidth() + 'px';\n }\n updateDisabled() {\n if (!this._input) return;\n\n this._input.disabled = this._object.isDisabled();\n }\n updateReadOnly() {\n if (!this._input) return;\n\n this._input.readOnly = this._object.isReadOnly();\n }\n\n updateMaxLength() {\n const input = this._input;\n if (!input) return;\n if (this._object.getMaxLength() <= 0) {\n input.removeAttribute('maxLength');\n return;\n }\n input.maxLength = this._object.getMaxLength();\n }\n\n updatePadding() {\n if (!this._input) return;\n\n this._input.style.padding = `${this._object\n .getPaddingY()\n .toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`;\n }\n\n updateTextAlign() {\n if (!this._input) return;\n\n const newTextAlign = this._object.getTextAlign();\n this._input.style.textAlign = newTextAlign;\n }\n\n isFocused() {\n return this._input === document.activeElement;\n }\n\n focus() {\n if (!this._input) return;\n\n this._input.focus();\n }\n }\n export const TextInputRuntimeObjectRenderer =\n TextInputRuntimeObjectPixiRenderer;\n export type TextInputRuntimeObjectRenderer =\n TextInputRuntimeObjectPixiRenderer;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAA+B,CACnC,KAAM,OACN,MAAO,QACP,SAAU,WACV,OAAQ,SACR,mBAAoB,MACpB,IAAK,MACL,OAAQ,UAGJ,EAA+B,CACnC,EACA,IAGE,QACA,EAAS,GACT,IACA,EAAS,GACT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Y,EAGhC,WAAY,CACV,MAAO,MAAK,SAAW,SAAS,cAGlC,OAAQ,CACN,AAAI,CAAC,KAAK,QAEV,KAAK,OAAO,SAGT,AAAM,iCACX,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n const userFriendlyToHtmlInputTypes = {\n text: 'text',\n email: 'email',\n password: 'password',\n number: 'number',\n 'telephone number': 'tel',\n url: 'url',\n search: 'search',\n };\n\n const formatRgbAndOpacityToCssRgba = (\n rgbColor: [float, float, float],\n opacity: float\n ) => {\n return (\n 'rgba(' +\n rgbColor[0] +\n ',' +\n rgbColor[1] +\n ',' +\n rgbColor[2] +\n ',' +\n opacity / 255 +\n ')'\n );\n };\n\n class TextInputRuntimeObjectPixiRenderer {\n private _object: gdjs.TextInputRuntimeObject;\n private _input: HTMLInputElement | HTMLTextAreaElement | null = null;\n private _instanceContainer: gdjs.RuntimeInstanceContainer;\n private _runtimeGame: gdjs.RuntimeGame;\n private _form: HTMLFormElement | null = null;\n\n constructor(\n runtimeObject: gdjs.TextInputRuntimeObject,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n this._object = runtimeObject;\n this._instanceContainer = instanceContainer;\n this._runtimeGame = this._instanceContainer.getGame();\n\n this._createElement();\n }\n\n _createElement() {\n if (!!this._input)\n throw new Error('Tried to recreate an input while it already exists.');\n\n this._form = document.createElement('form');\n\n const isTextArea = this._object.getInputType() === 'text area';\n this._input = document.createElement(isTextArea ? 'textarea' : 'input');\n\n this._form.style.border = '0px';\n this._form.style.borderRadius = '0px';\n this._form.style.backgroundColor = 'transparent';\n this._form.style.position = 'absolute';\n this._form.style.pointerEvents = 'auto'; // Element can be clicked/touched.\n this._form.style.display = 'none'; // Hide while object is being set up.\n this._form.style.boxSizing = 'border-box';\n this._form.style.textAlign = this._object.getTextAlign();\n\n this._input.autocomplete = 'off';\n this._input.style.backgroundColor = 'white';\n this._input.style.outline = 'none'; // Remove any style added by the browser to highlight the focused field in a form (:focus & :focus-visible modifiers).\n this._input.style.resize = 'none'; // Prevent user from resizing the input when it's a text area.\n this._input.style.border = '1px solid black';\n this._input.style.boxSizing = 'border-box';\n this._input.style.borderRadius = '0px'; // Remove any style added by the browser (Safari adds some radius for instance).\n this._input.style.width = '100%';\n this._input.style.height = '100%';\n this._input.maxLength = this._object.getMaxLength();\n this._input.style.padding = `${this._object\n .getPaddingY()\n .toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`;\n\n this._form.appendChild(this._input);\n\n this._input.addEventListener('input', () => {\n if (!this._input) return;\n\n this._object.onRendererInputValueChanged(this._input.value);\n });\n this._input.addEventListener('touchstart', () => {\n if (!this._input) return;\n\n // Focus directly when touching the input on touchscreens.\n if (document.activeElement !== this._input) this._input.focus();\n });\n\n this._form.addEventListener('submit', (event) => {\n event.preventDefault();\n this._object.onRendererFormSubmitted();\n });\n\n this.updateString();\n this.updateFont();\n this.updatePlaceholder();\n this.updateOpacity();\n this.updateInputType();\n this.updateTextColor();\n this.updateFillColorAndOpacity();\n this.updateBorderColorAndOpacity();\n this.updateBorderWidth();\n this.updateDisabled();\n this.updateReadOnly();\n this.updateSpellCheck();\n this.updateTextAlign();\n this.updateMaxLength();\n this.updatePadding();\n\n this._runtimeGame\n .getRenderer()\n .getDomElementContainer()!\n .appendChild(this._form);\n }\n\n _destroyElement() {\n if (this._form) {\n this._form.remove();\n this._form = null;\n }\n if (this._input) {\n this._input.remove();\n this._input = null;\n }\n }\n\n onScenePaused() {\n // This is the only renderer that uses a DOM element. PixiJS renderers\n // usually don't need to know if a scene is paused/resumed,\n // because their renderers are then not used (not part of the other scene graphs).\n // For this object, we need to remove the DOM element whenever it must\n // be not rendered.\n this._destroyElement();\n }\n\n onSceneResumed() {\n // The input must have been destroyed when the scene was paused,\n // in case it still exists, skip recreation.\n if (!this._input) this._createElement();\n }\n\n onDestroy() {\n this._destroyElement();\n }\n\n updatePreRender() {\n if (!this._input || !this._form) return;\n // Hide the input entirely if the object is hidden.\n // Because this object is rendered as a DOM element (and not part of the PixiJS\n // scene graph), we have to do this manually.\n if (this._object.isHidden()) {\n this._form.style.display = 'none';\n return;\n }\n\n // Hide the input entirely if the layer is not visible.\n // Because this object is rendered as a DOM element (and not part of the PixiJS\n // scene graph), we have to do this manually.\n {\n let instanceContainer = this._instanceContainer;\n let object: gdjs.RuntimeObject = this._object;\n let hasParent = true;\n do {\n const layer = instanceContainer.getLayer(object.getLayer());\n if (!layer.isVisible() || !object.isVisible()) {\n this._form.style.display = 'none';\n return;\n }\n // TODO Declare an interface to move up in the object tree.\n if (\n instanceContainer instanceof\n gdjs.CustomRuntimeObjectInstanceContainer\n ) {\n object = instanceContainer.getOwner();\n instanceContainer = object.getInstanceContainer();\n } else {\n hasParent = false;\n }\n } while (hasParent);\n }\n\n const workingPoint: FloatPoint = gdjs.staticArray(\n TextInputRuntimeObjectPixiRenderer.prototype.updatePreRender\n ) as FloatPoint;\n\n const runtimeGame = this._instanceContainer.getGame();\n const runtimeGameRenderer = runtimeGame.getRenderer();\n const layer = this._instanceContainer.getLayer(this._object.getLayer());\n const topLeftCanvasCoordinates = layer.convertInverseCoords(\n this._object.x,\n this._object.y,\n 0,\n workingPoint\n );\n const canvasLeft = topLeftCanvasCoordinates[0];\n const canvasTop = topLeftCanvasCoordinates[1];\n\n const bottomRightCanvasCoordinates = layer.convertInverseCoords(\n this._object.x + this._object.getWidth(),\n this._object.y + this._object.getHeight(),\n 0,\n workingPoint\n );\n const canvasRight = bottomRightCanvasCoordinates[0];\n const canvasBottom = bottomRightCanvasCoordinates[1];\n\n // Hide the input entirely if not visible at all.\n const isOutsideCanvas =\n canvasRight < 0 ||\n canvasBottom < 0 ||\n canvasLeft > runtimeGame.getGameResolutionWidth() ||\n canvasTop > runtimeGame.getGameResolutionHeight();\n if (isOutsideCanvas) {\n this._form.style.display = 'none';\n return;\n }\n\n // Position the input on the container on top of the canvas.\n workingPoint[0] = canvasLeft;\n workingPoint[1] = canvasTop;\n runtimeGameRenderer.convertCanvasToDomElementContainerCoords(\n workingPoint,\n workingPoint\n );\n const pageLeft = workingPoint[0];\n const pageTop = workingPoint[1];\n\n workingPoint[0] = canvasRight;\n workingPoint[1] = canvasBottom;\n runtimeGameRenderer.convertCanvasToDomElementContainerCoords(\n workingPoint,\n workingPoint\n );\n const pageRight = workingPoint[0];\n const pageBottom = workingPoint[1];\n\n const widthInContainer = pageRight - pageLeft;\n const heightInContainer = pageBottom - pageTop;\n\n this._form.style.left = pageLeft + 'px';\n this._form.style.top = pageTop + 'px';\n this._form.style.width = widthInContainer + 'px';\n this._form.style.height = heightInContainer + 'px';\n this._form.style.transform =\n 'rotate3d(0,0,1,' + (this._object.getAngle() % 360) + 'deg)';\n this._form.style.textAlign = this._object.getTextAlign();\n\n this._input.style.padding = `${this._object\n .getPaddingY()\n .toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`;\n\n // Automatically adjust the font size to follow the game scale.\n this._input.style.fontSize =\n this._object.getFontSize() *\n runtimeGameRenderer.getCanvasToDomElementContainerHeightScale() +\n 'px';\n\n // Display after the object is positioned.\n this._form.style.display = 'initial';\n }\n\n updateString() {\n if (!this._input) return;\n this._input.value = this._object.getString();\n }\n\n updatePlaceholder() {\n if (!this._input) return;\n this._input.placeholder = this._object.getPlaceholder();\n }\n\n updateFont() {\n if (!this._input) return;\n this._input.style.fontFamily = this._instanceContainer\n .getGame()\n .getFontManager()\n .getFontFamily(this._object.getFontResourceName());\n }\n\n updateOpacity() {\n if (!this._form) return;\n this._form.style.opacity = (this._object.getOpacity() / 255).toFixed(3);\n }\n\n updateInputType() {\n if (!this._input) return;\n\n const isTextArea = this._input instanceof HTMLTextAreaElement;\n const shouldBeTextArea = this._object.getInputType() === 'text area';\n if (isTextArea !== shouldBeTextArea) {\n this._destroyElement();\n this._createElement();\n }\n\n const newType =\n userFriendlyToHtmlInputTypes[this._object.getInputType()] || 'text';\n this._input.setAttribute('type', newType);\n }\n\n updateTextColor() {\n if (!this._input) return;\n\n this._input.style.color = formatRgbAndOpacityToCssRgba(\n this._object._getRawTextColor(),\n 255\n );\n }\n\n updateFillColorAndOpacity() {\n if (!this._input) return;\n\n this._input.style.backgroundColor = formatRgbAndOpacityToCssRgba(\n this._object._getRawFillColor(),\n this._object.getFillOpacity()\n );\n }\n\n updateBorderColorAndOpacity() {\n if (!this._input) return;\n\n this._input.style.borderColor = formatRgbAndOpacityToCssRgba(\n this._object._getRawBorderColor(),\n this._object.getBorderOpacity()\n );\n }\n updateBorderWidth() {\n if (!this._input) return;\n\n this._input.style.borderWidth = this._object.getBorderWidth() + 'px';\n }\n updateDisabled() {\n if (!this._input) return;\n\n this._input.disabled = this._object.isDisabled();\n }\n updateReadOnly() {\n if (!this._input) return;\n\n this._input.readOnly = this._object.isReadOnly();\n }\n\n updateSpellCheck() {\n if (!this._input) return;\n\n this._input.spellcheck = this._object.isSpellCheckEnabled();\n }\n\n updateMaxLength() {\n const input = this._input;\n if (!input) return;\n if (this._object.getMaxLength() <= 0) {\n input.removeAttribute('maxLength');\n return;\n }\n input.maxLength = this._object.getMaxLength();\n }\n\n updatePadding() {\n if (!this._input) return;\n\n this._input.style.padding = `${this._object\n .getPaddingY()\n .toFixed(2)}px ${this._object.getPaddingX().toFixed(2)}px`;\n }\n\n updateTextAlign() {\n if (!this._input) return;\n\n const newTextAlign = this._object.getTextAlign();\n this._input.style.textAlign = newTextAlign;\n }\n\n isFocused() {\n return this._input === document.activeElement;\n }\n\n focus() {\n if (!this._input) return;\n\n this._input.focus();\n }\n }\n export const TextInputRuntimeObjectRenderer =\n TextInputRuntimeObjectPixiRenderer;\n export type TextInputRuntimeObjectRenderer =\n TextInputRuntimeObjectPixiRenderer;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAA+B,CACnC,KAAM,OACN,MAAO,QACP,SAAU,WACV,OAAQ,SACR,mBAAoB,MACpB,IAAK,MACL,OAAQ,UAGJ,EAA+B,CACnC,EACA,IAGE,QACA,EAAS,GACT,IACA,EAAS,GACT,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AChB,GAAI,CAAC,KAAK,OAAQ,OAElB,KAAM,GAAe,KAAK,QAAQ,eAClC,KAAK,OAAO,MAAM,UAAY,EAGhC,WAAY,CACV,MAAO,MAAK,SAAW,SAAS,cAGlC,OAAQ,CACN,AAAI,CAAC,KAAK,QAEV,KAAK,OAAO,SAGT,AAAM,iCACX,IAnYM",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){const
|
|
1
|
+
var gdjs;(function(i){const d=["text","email","password","number","telephone number","url","search","text area"],l=["left","center","right"],n=r=>{const e=r.toLowerCase();return d.includes(e)?r:"text"},o=r=>{if(!r)return"left";const e=r.toLowerCase();return l.includes(e)?r:"left"},h=300,p=30,s=(r,e,t)=>Math.max(0,Math.min(e/2-t,r));class u extends i.RuntimeObject{constructor(e,t){super(e,t);this.opacity=255;this._width=h;this._height=p;this._string=t.content.initialValue,this._placeholder=t.content.placeholder,this._fontResourceName=t.content.fontResourceName,this._fontSize=t.content.fontSize||20,this._inputType=n(t.content.inputType),this._textColor=i.rgbOrHexToRGBColor(t.content.textColor),this._fillColor=i.rgbOrHexToRGBColor(t.content.fillColor),this._fillOpacity=t.content.fillOpacity,this._borderColor=i.rgbOrHexToRGBColor(t.content.borderColor),this._borderOpacity=t.content.borderOpacity,this._borderWidth=t.content.borderWidth,this._disabled=t.content.disabled,this._readOnly=t.content.readOnly,this._spellCheck=t.content.spellCheck!==void 0?t.content.spellCheck:!1,this._textAlign=o(t.content.textAlign),this._maxLength=t.content.maxLength||0,this._paddingX=t.content.paddingX!==void 0?t.content.paddingX:2,this._paddingY=t.content.paddingY!==void 0?t.content.paddingY:1,this._isSubmitted=!1,this._renderer=new i.TextInputRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return null}updateFromObjectData(e,t){return e.content.initialValue!==t.content.initialValue&&this._string===e.content.initialValue&&this.setString(t.content.initialValue),e.content.placeholder!==t.content.placeholder&&this.setPlaceholder(t.content.placeholder),e.content.fontResourceName!==t.content.fontResourceName&&this.setFontResourceName(t.content.fontResourceName),e.content.fontSize!==t.content.fontSize&&this.setFontSize(t.content.fontSize),e.content.inputType!==t.content.inputType&&this.setInputType(t.content.inputType),e.content.textColor!==t.content.textColor&&this.setTextColor(t.content.textColor),e.content.fillColor!==t.content.fillColor&&this.setFillColor(t.content.fillColor),e.content.fillOpacity!==t.content.fillOpacity&&this.setFillOpacity(t.content.fillOpacity),e.content.borderColor!==t.content.borderColor&&this.setBorderColor(t.content.borderColor),e.content.borderOpacity!==t.content.borderOpacity&&this.setBorderOpacity(t.content.borderOpacity),e.content.borderWidth!==t.content.borderWidth&&this.setBorderWidth(t.content.borderWidth),e.content.disabled!==t.content.disabled&&this.setDisabled(t.content.disabled),e.content.readOnly!==t.content.readOnly&&this.setReadOnly(t.content.readOnly),t.content.spellCheck!==void 0&&e.content.spellCheck!==t.content.spellCheck&&this.setSpellCheck(t.content.spellCheck),t.content.maxLength!==void 0&&e.content.maxLength!==t.content.maxLength&&this.setMaxLength(t.content.maxLength),t.content.textAlign&&e.content.textAlign!==t.content.textAlign&&(this._textAlign=t.content.textAlign),t.content.paddingX!==void 0&&e.content.paddingX!==t.content.paddingX&&this.setPaddingX(t.content.paddingX),t.content.paddingY!==void 0&&e.content.paddingY!==t.content.paddingY&&this.setPaddingY(t.content.paddingY),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),opa:this.getOpacity(),txt:this.getText(),frn:this.getFontResourceName(),fs:this.getFontSize(),place:this.getPlaceholder(),it:this.getInputType(),tc:this.getTextColor(),fc:this.getFillColor(),fo:this.getFillOpacity(),bc:this.getBorderColor(),bo:this.getBorderOpacity(),bw:this.getBorderWidth(),dis:this.isDisabled(),ro:this.isReadOnly(),sc:this.isSpellCheckEnabled()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.opa!==void 0&&this.setOpacity(e.opa),e.txt!==void 0&&this.setText(e.txt),e.frn!==void 0&&this.setFontResourceName(e.frn),e.fs!==void 0&&this.setFontSize(e.fs),e.place!==void 0&&this.setPlaceholder(e.place),e.it!==void 0&&this.setInputType(e.it),e.tc!==void 0&&this.setTextColor(e.tc),e.fc!==void 0&&this.setFillColor(e.fc),e.fo!==void 0&&this.setFillOpacity(e.fo),e.bc!==void 0&&this.setBorderColor(e.bc),e.bo!==void 0&&this.setBorderOpacity(e.bo),e.bw!==void 0&&this.setBorderWidth(e.bw),e.dis!==void 0&&this.setDisabled(e.dis),e.ro!==void 0&&this.setReadOnly(e.ro),e.sc!==void 0&&this.setSpellCheck(e.sc)}updatePreRender(e){this._isSubmitted=!1,this._renderer.updatePreRender()}extraInitializationFromInitialInstance(e){for(const t of e.stringProperties)t.name==="initialValue"?this.setString(t.value):t.name==="placeholder"&&this.setPlaceholder(t.value);e.customSize&&(this.setWidth(e.width),this.setHeight(e.height),this._renderer.updatePadding()),e.opacity!==void 0&&this.setOpacity(e.opacity)}onScenePaused(e){this._renderer.onScenePaused()}onSceneResumed(e){this._renderer.onSceneResumed()}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}setOpacity(e){this.opacity=Math.max(0,Math.min(255,e)),this._renderer.updateOpacity()}getOpacity(){return this.opacity}setSize(e,t){this.setWidth(e),this.setHeight(t)}setWidth(e){this._width=e,this._renderer.updatePadding()}setHeight(e){this._height=e,this._renderer.updatePadding()}getWidth(){return this._width}getHeight(){return this._height}getString(){return this.getText()}setString(e){this.setText(e)}getText(){return this._string}setText(e){e!==this._string&&(this._string=e,this._renderer.updateString())}onRendererInputValueChanged(e){this._string=e}onRendererFormSubmitted(){this._isSubmitted=!0}getFontResourceName(){return this._fontResourceName}setFontResourceName(e){this._fontResourceName!==e&&(this._fontResourceName=e,this._renderer.updateFont())}getFontSize(){return this._fontSize}setFontSize(e){this._fontSize=e}getPlaceholder(){return this._placeholder}setPlaceholder(e){e!==this._placeholder&&(this._placeholder=e,this._renderer.updatePlaceholder())}getInputType(){return this._inputType}setInputType(e){const t=e.toLowerCase();t!==this._inputType&&(this._inputType=n(t),this._renderer.updateInputType())}setTextColor(e){this._textColor=i.rgbOrHexToRGBColor(e),this._renderer.updateTextColor()}getTextColor(){return this._textColor[0]+";"+this._textColor[1]+";"+this._textColor[2]}_getRawTextColor(){return this._textColor}setFillColor(e){this._fillColor=i.rgbOrHexToRGBColor(e),this._renderer.updateFillColorAndOpacity()}getFillColor(){return this._fillColor[0]+";"+this._fillColor[1]+";"+this._fillColor[2]}_getRawFillColor(){return this._fillColor}setFillOpacity(e){this._fillOpacity=Math.max(0,Math.min(255,e)),this._renderer.updateFillColorAndOpacity()}getFillOpacity(){return this._fillOpacity}setBorderColor(e){this._borderColor=i.rgbOrHexToRGBColor(e),this._renderer.updateBorderColorAndOpacity()}getBorderColor(){return this._borderColor[0]+";"+this._borderColor[1]+";"+this._borderColor[2]}_getRawBorderColor(){return this._borderColor}setBorderOpacity(e){this._borderOpacity=Math.max(0,Math.min(255,e)),this._renderer.updateBorderColorAndOpacity()}getBorderOpacity(){return this._borderOpacity}setBorderWidth(e){this._borderWidth=Math.max(0,e),this._renderer.updateBorderWidth()}getBorderWidth(){return this._borderWidth}setDisabled(e){this._disabled=e,this._renderer.updateDisabled()}isDisabled(){return this._disabled}setReadOnly(e){this._readOnly=e,this._renderer.updateReadOnly()}isReadOnly(){return this._readOnly}setSpellCheck(e){this._spellCheck=e,this._renderer.updateSpellCheck()}isSpellCheckEnabled(){return this._spellCheck}isFocused(){return this._renderer.isFocused()}isSubmitted(){return this._isSubmitted}getMaxLength(){return this._maxLength}setMaxLength(e){this._maxLength!==e&&(this._maxLength=e,this._renderer.updateMaxLength())}getPaddingX(){return s(this._paddingX,this._width,this._borderWidth)}setPaddingX(e){if(this._paddingX!==e){if(e<0){this._paddingX=0;return}this._paddingX=e,this._renderer.updatePadding()}}getPaddingY(){return s(this._paddingY,this._height,this._borderWidth)}setPaddingY(e){if(this._paddingY!==e){if(e<0){this._paddingY=0;return}this._paddingY=e,this._renderer.updatePadding()}}getTextAlign(){return this._textAlign}setTextAlign(e){const t=o(e);t!==this._textAlign&&(this._textAlign=t,this._renderer.updateTextAlign())}focus(){this.isFocused()||this.getInstanceContainer().getGame().getInputManager().clearAllPressedKeys(),this._renderer.focus()}}i.TextInputRuntimeObject=u,i.registerObject("TextInput::TextInputObject",i.TextInputRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=textinputruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TextInput/textinputruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n const supportedInputTypes = [\n 'text',\n 'email',\n 'password',\n 'number',\n 'telephone number',\n 'url',\n 'search',\n 'text area',\n ] as const;\n const supportedTextAlign = ['left', 'center', 'right'] as const;\n\n type SupportedInputType = (typeof supportedInputTypes)[number];\n type SupportedTextAlign = (typeof supportedTextAlign)[number];\n const parseInputType = (potentialInputType: string): SupportedInputType => {\n const lowercasedNewInputType = potentialInputType.toLowerCase();\n\n // @ts-ignore - we're actually checking that this value is correct.\n if (supportedInputTypes.includes(lowercasedNewInputType))\n return potentialInputType as SupportedInputType;\n\n return 'text';\n };\n\n const parseTextAlign = (\n potentialTextAlign: string | undefined\n ): SupportedTextAlign => {\n if (!potentialTextAlign) return 'left';\n const lowercasedNewTextAlign = potentialTextAlign.toLowerCase();\n\n // @ts-ignore - we're actually checking that this value is correct.\n if (supportedTextAlign.includes(lowercasedNewTextAlign))\n return potentialTextAlign as SupportedTextAlign;\n\n return 'left';\n };\n\n /** Base parameters for {@link gdjs.TextInputRuntimeObject} */\n export interface TextInputObjectData extends ObjectData {\n /** The base parameters of the TextInput */\n content: {\n initialValue: string;\n placeholder: string;\n fontResourceName: string;\n fontSize: float;\n inputType: SupportedInputType;\n textColor: string;\n fillColor: string;\n fillOpacity: float;\n borderColor: string;\n borderOpacity: float;\n borderWidth: float;\n disabled: boolean;\n readOnly: boolean;\n // ---- Values can be undefined because of support for these feature was added in v5.5.222.\n paddingX?: float;\n paddingY?: float;\n textAlign?: SupportedTextAlign;\n maxLength?: integer;\n // ----\n };\n }\n\n export type TextInputNetworkSyncDataType = {\n opa: float;\n wid: float;\n hei: float;\n txt: string;\n frn: string;\n fs: number;\n place: string;\n it: SupportedInputType;\n tc: string;\n fc: string;\n fo: float;\n bc: string;\n bo: float;\n bw: float;\n dis: boolean;\n ro: boolean;\n };\n\n export type TextInputNetworkSyncData = ObjectNetworkSyncData &\n TextInputNetworkSyncDataType;\n\n const DEFAULT_WIDTH = 300;\n const DEFAULT_HEIGHT = 30;\n\n const clampPadding = (value: float, dimension: float, borderWidth: float) => {\n return Math.max(0, Math.min(dimension / 2 - borderWidth, value));\n };\n\n /**\n * Shows a text input on the screen the player can type text into.\n */\n export class TextInputRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.TextContainer, gdjs.Resizable, gdjs.OpacityHandler\n {\n private _string: string;\n private _placeholder: string;\n private opacity: float = 255;\n private _width: float = DEFAULT_WIDTH;\n private _height: float = DEFAULT_HEIGHT;\n private _fontResourceName: string;\n private _fontSize: float;\n private _inputType: SupportedInputType;\n private _textColor: [float, float, float];\n private _fillColor: [float, float, float];\n private _fillOpacity: float;\n private _paddingX: integer;\n private _paddingY: integer;\n private _textAlign: SupportedTextAlign;\n private _maxLength: integer;\n private _borderColor: [float, float, float];\n private _borderOpacity: float;\n private _borderWidth: float;\n private _disabled: boolean;\n private _readOnly: boolean;\n private _isSubmitted: boolean;\n _renderer: TextInputRuntimeObjectRenderer;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: TextInputObjectData\n ) {\n super(instanceContainer, objectData);\n\n this._string = objectData.content.initialValue;\n this._placeholder = objectData.content.placeholder;\n this._fontResourceName = objectData.content.fontResourceName;\n this._fontSize = objectData.content.fontSize || 20;\n this._inputType = parseInputType(objectData.content.inputType);\n this._textColor = gdjs.rgbOrHexToRGBColor(objectData.content.textColor);\n this._fillColor = gdjs.rgbOrHexToRGBColor(objectData.content.fillColor);\n this._fillOpacity = objectData.content.fillOpacity;\n this._borderColor = gdjs.rgbOrHexToRGBColor(\n objectData.content.borderColor\n );\n this._borderOpacity = objectData.content.borderOpacity;\n this._borderWidth = objectData.content.borderWidth;\n this._disabled = objectData.content.disabled;\n this._readOnly = objectData.content.readOnly;\n this._textAlign = parseTextAlign(objectData.content.textAlign);\n this._maxLength = objectData.content.maxLength || 0;\n this._paddingX =\n objectData.content.paddingX !== undefined\n ? objectData.content.paddingX\n : 2;\n this._paddingY =\n objectData.content.paddingY !== undefined\n ? objectData.content.paddingY\n : 1;\n this._isSubmitted = false;\n this._renderer = new gdjs.TextInputRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return null;\n }\n\n updateFromObjectData(\n oldObjectData: TextInputObjectData,\n newObjectData: TextInputObjectData\n ): boolean {\n if (\n oldObjectData.content.initialValue !==\n newObjectData.content.initialValue\n ) {\n if (this._string === oldObjectData.content.initialValue) {\n this.setString(newObjectData.content.initialValue);\n }\n }\n if (\n oldObjectData.content.placeholder !== newObjectData.content.placeholder\n ) {\n this.setPlaceholder(newObjectData.content.placeholder);\n }\n if (\n oldObjectData.content.fontResourceName !==\n newObjectData.content.fontResourceName\n ) {\n this.setFontResourceName(newObjectData.content.fontResourceName);\n }\n if (oldObjectData.content.fontSize !== newObjectData.content.fontSize) {\n this.setFontSize(newObjectData.content.fontSize);\n }\n if (oldObjectData.content.inputType !== newObjectData.content.inputType) {\n this.setInputType(newObjectData.content.inputType);\n }\n if (oldObjectData.content.textColor !== newObjectData.content.textColor) {\n this.setTextColor(newObjectData.content.textColor);\n }\n if (oldObjectData.content.fillColor !== newObjectData.content.fillColor) {\n this.setFillColor(newObjectData.content.fillColor);\n }\n if (\n oldObjectData.content.fillOpacity !== newObjectData.content.fillOpacity\n ) {\n this.setFillOpacity(newObjectData.content.fillOpacity);\n }\n if (\n oldObjectData.content.borderColor !== newObjectData.content.borderColor\n ) {\n this.setBorderColor(newObjectData.content.borderColor);\n }\n if (\n oldObjectData.content.borderOpacity !==\n newObjectData.content.borderOpacity\n ) {\n this.setBorderOpacity(newObjectData.content.borderOpacity);\n }\n if (\n oldObjectData.content.borderWidth !== newObjectData.content.borderWidth\n ) {\n this.setBorderWidth(newObjectData.content.borderWidth);\n }\n if (oldObjectData.content.disabled !== newObjectData.content.disabled) {\n this.setDisabled(newObjectData.content.disabled);\n }\n if (oldObjectData.content.readOnly !== newObjectData.content.readOnly) {\n this.setReadOnly(newObjectData.content.readOnly);\n }\n if (\n newObjectData.content.maxLength !== undefined &&\n oldObjectData.content.maxLength !== newObjectData.content.maxLength\n ) {\n this.setMaxLength(newObjectData.content.maxLength);\n }\n if (\n newObjectData.content.textAlign &&\n oldObjectData.content.textAlign !== newObjectData.content.textAlign\n ) {\n this._textAlign = newObjectData.content.textAlign;\n }\n if (\n newObjectData.content.paddingX !== undefined &&\n oldObjectData.content.paddingX !== newObjectData.content.paddingX\n ) {\n this.setPaddingX(newObjectData.content.paddingX);\n }\n if (\n newObjectData.content.paddingY !== undefined &&\n oldObjectData.content.paddingY !== newObjectData.content.paddingY\n ) {\n this.setPaddingY(newObjectData.content.paddingY);\n }\n\n return true;\n }\n\n getNetworkSyncData(): TextInputNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n opa: this.getOpacity(),\n wid: this.getWidth(),\n hei: this.getHeight(),\n txt: this.getText(),\n frn: this.getFontResourceName(),\n fs: this.getFontSize(),\n place: this.getPlaceholder(),\n it: this.getInputType(),\n tc: this.getTextColor(),\n fc: this.getFillColor(),\n fo: this.getFillOpacity(),\n bc: this.getBorderColor(),\n bo: this.getBorderOpacity(),\n bw: this.getBorderWidth(),\n dis: this.isDisabled(),\n ro: this.isReadOnly(),\n };\n }\n\n updateFromNetworkSyncData(syncData: TextInputNetworkSyncData): void {\n super.updateFromNetworkSyncData(syncData);\n\n if (syncData.opa !== undefined) this.setOpacity(syncData.opa);\n if (syncData.wid !== undefined) this.setWidth(syncData.wid);\n if (syncData.hei !== undefined) this.setHeight(syncData.hei);\n if (syncData.txt !== undefined) this.setText(syncData.txt);\n if (syncData.frn !== undefined) this.setFontResourceName(syncData.frn);\n if (syncData.fs !== undefined) this.setFontSize(syncData.fs);\n if (syncData.place !== undefined) this.setPlaceholder(syncData.place);\n if (syncData.it !== undefined) this.setInputType(syncData.it);\n if (syncData.tc !== undefined) this.setTextColor(syncData.tc);\n if (syncData.fc !== undefined) this.setFillColor(syncData.fc);\n if (syncData.fo !== undefined) this.setFillOpacity(syncData.fo);\n if (syncData.bc !== undefined) this.setBorderColor(syncData.bc);\n if (syncData.bo !== undefined) this.setBorderOpacity(syncData.bo);\n if (syncData.bw !== undefined) this.setBorderWidth(syncData.bw);\n if (syncData.dis !== undefined) this.setDisabled(syncData.dis);\n if (syncData.ro !== undefined) this.setReadOnly(syncData.ro);\n }\n\n updatePreRender(instanceContainer: RuntimeInstanceContainer): void {\n this._isSubmitted = false;\n this._renderer.updatePreRender();\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'initialValue') {\n this.setString(property.value);\n } else if (property.name === 'placeholder') {\n this.setPlaceholder(property.value);\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n this._renderer.updatePadding();\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n }\n\n onScenePaused(runtimeScene: gdjs.RuntimeScene): void {\n this._renderer.onScenePaused();\n }\n\n onSceneResumed(runtimeScene: gdjs.RuntimeScene): void {\n this._renderer.onSceneResumed();\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.onDestroy();\n }\n\n setOpacity(opacity: float): void {\n this.opacity = Math.max(0, Math.min(255, opacity));\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n setSize(width: number, height: number): void {\n this.setWidth(width);\n this.setHeight(height);\n }\n\n setWidth(width: float): void {\n this._width = width;\n this._renderer.updatePadding();\n }\n\n setHeight(height: float): void {\n this._height = height;\n this._renderer.updatePadding();\n }\n\n /**\n * Return the width of the object.\n * @return The width of the object\n */\n getWidth(): float {\n return this._width;\n }\n\n /**\n * Return the width of the object.\n * @return The height of the object\n */\n getHeight(): float {\n return this._height;\n }\n\n /**\n * Get the text entered in the text input.\n * @deprecated use `getText` instead\n */\n getString() {\n return this.getText();\n }\n\n /**\n * Replace the text inside the text input.\n * @deprecated use `setText` instead\n */\n setString(text: string) {\n this.setText(text);\n }\n\n getText() {\n return this._string;\n }\n\n setText(newString: string) {\n if (newString === this._string) return;\n\n this._string = newString;\n this._renderer.updateString();\n }\n\n /**\n * Called by the renderer when the value of the input shown on the screen\n * was changed (because the user typed something).\n * This does not propagate back the value to the renderer, which would\n * result in the cursor being sent back to the end of the text.\n *\n * Do not use this if you are not inside the renderer - use `setString` instead.\n */\n onRendererInputValueChanged(inputValue: string) {\n this._string = inputValue;\n }\n\n onRendererFormSubmitted() {\n this._isSubmitted = true;\n }\n\n getFontResourceName() {\n return this._fontResourceName;\n }\n\n setFontResourceName(resourceName: string) {\n if (this._fontResourceName === resourceName) return;\n\n this._fontResourceName = resourceName;\n this._renderer.updateFont();\n }\n\n getFontSize() {\n return this._fontSize;\n }\n\n setFontSize(newSize: number) {\n this._fontSize = newSize;\n }\n\n /**\n * Get the placeholder shown when no text is entered\n */\n getPlaceholder() {\n return this._placeholder;\n }\n\n /**\n * Replace the text inside the text input.\n */\n setPlaceholder(newPlaceholder: string) {\n if (newPlaceholder === this._placeholder) return;\n\n this._placeholder = newPlaceholder;\n this._renderer.updatePlaceholder();\n }\n\n /**\n * Get the type of the input.\n */\n getInputType() {\n return this._inputType;\n }\n\n /**\n * Set the type of the input.\n */\n setInputType(newInputType: string) {\n const lowercasedNewInputType = newInputType.toLowerCase();\n if (lowercasedNewInputType === this._inputType) return;\n\n this._inputType = parseInputType(lowercasedNewInputType);\n this._renderer.updateInputType();\n }\n\n setTextColor(newColor: string) {\n this._textColor = gdjs.rgbOrHexToRGBColor(newColor);\n this._renderer.updateTextColor();\n }\n\n getTextColor(): string {\n return (\n this._textColor[0] + ';' + this._textColor[1] + ';' + this._textColor[2]\n );\n }\n\n _getRawTextColor(): [float, float, float] {\n return this._textColor;\n }\n\n setFillColor(newColor: string) {\n this._fillColor = gdjs.rgbOrHexToRGBColor(newColor);\n this._renderer.updateFillColorAndOpacity();\n }\n\n getFillColor(): string {\n return (\n this._fillColor[0] + ';' + this._fillColor[1] + ';' + this._fillColor[2]\n );\n }\n\n _getRawFillColor(): [float, float, float] {\n return this._fillColor;\n }\n\n setFillOpacity(newOpacity: float) {\n this._fillOpacity = Math.max(0, Math.min(255, newOpacity));\n this._renderer.updateFillColorAndOpacity();\n }\n\n getFillOpacity(): float {\n return this._fillOpacity;\n }\n\n setBorderColor(newColor: string) {\n this._borderColor = gdjs.rgbOrHexToRGBColor(newColor);\n this._renderer.updateBorderColorAndOpacity();\n }\n\n getBorderColor(): string {\n return (\n this._borderColor[0] +\n ';' +\n this._borderColor[1] +\n ';' +\n this._borderColor[2]\n );\n }\n\n _getRawBorderColor(): [float, float, float] {\n return this._borderColor;\n }\n\n setBorderOpacity(newOpacity: float) {\n this._borderOpacity = Math.max(0, Math.min(255, newOpacity));\n this._renderer.updateBorderColorAndOpacity();\n }\n\n getBorderOpacity(): float {\n return this._borderOpacity;\n }\n\n setBorderWidth(width: float) {\n this._borderWidth = Math.max(0, width);\n this._renderer.updateBorderWidth();\n }\n\n getBorderWidth(): float {\n return this._borderWidth;\n }\n\n setDisabled(value: boolean) {\n this._disabled = value;\n this._renderer.updateDisabled();\n }\n\n isDisabled(): boolean {\n return this._disabled;\n }\n\n setReadOnly(value: boolean) {\n this._readOnly = value;\n this._renderer.updateReadOnly();\n }\n\n isReadOnly(): boolean {\n return this._readOnly;\n }\n\n isFocused(): boolean {\n return this._renderer.isFocused();\n }\n isSubmitted(): boolean {\n return this._isSubmitted;\n }\n\n getMaxLength(): integer {\n return this._maxLength;\n }\n setMaxLength(value: integer) {\n if (this._maxLength === value) return;\n\n this._maxLength = value;\n this._renderer.updateMaxLength();\n }\n\n getPaddingX(): integer {\n return clampPadding(this._paddingX, this._width, this._borderWidth);\n }\n setPaddingX(value: integer) {\n if (this._paddingX === value) return;\n if (value < 0) {\n this._paddingX = 0;\n return;\n }\n\n this._paddingX = value;\n this._renderer.updatePadding();\n }\n getPaddingY(): integer {\n return clampPadding(this._paddingY, this._height, this._borderWidth);\n }\n setPaddingY(value: integer) {\n if (this._paddingY === value) return;\n if (value < 0) {\n this._paddingY = 0;\n return;\n }\n\n this._paddingY = value;\n this._renderer.updatePadding();\n }\n\n getTextAlign(): SupportedTextAlign {\n return this._textAlign;\n }\n\n setTextAlign(newTextAlign: string) {\n const parsedTextAlign = parseTextAlign(newTextAlign);\n if (parsedTextAlign === this._textAlign) return;\n\n this._textAlign = parsedTextAlign;\n this._renderer.updateTextAlign();\n }\n\n focus(): void {\n if (!this.isFocused()) {\n // If the input was not previously focused, reset input manager because there is\n // no reason to maintain its state. It avoids bugs where a key is pressed, the text\n // input is focused and then the input manager does not have access to the keyup event\n // and considers the key still pressed.\n this.getInstanceContainer()\n .getGame()\n .getInputManager()\n .clearAllPressedKeys();\n }\n this._renderer.focus();\n }\n }\n gdjs.registerObject(\n 'TextInput::TextInputObject',\n gdjs.TextInputRuntimeObject\n );\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAsB,CAC1B,OACA,QACA,WACA,SACA,mBACA,MACA,SACA,aAEI,EAAqB,CAAC,OAAQ,SAAU,SAIxC,EAAiB,AAAC,GAAmD,CACzE,KAAM,GAAyB,EAAmB,cAGlD,MAAI,GAAoB,SAAS,GACxB,EAEF,QAGH,EAAiB,AACrB,GACuB,CACvB,GAAI,CAAC,EAAoB,MAAO,OAChC,KAAM,GAAyB,EAAmB,cAGlD,MAAI,GAAmB,SAAS,GACvB,EAEF,QAmDH,EAAgB,IAChB,EAAiB,GAEjB,EAAe,CAAC,EAAc,EAAkB,IAC7C,KAAK,IAAI,EAAG,KAAK,IAAI,EAAY,EAAI,EAAa,IAMpD,eACG,GAAK,aAEf,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n const supportedInputTypes = [\n 'text',\n 'email',\n 'password',\n 'number',\n 'telephone number',\n 'url',\n 'search',\n 'text area',\n ] as const;\n const supportedTextAlign = ['left', 'center', 'right'] as const;\n\n type SupportedInputType = (typeof supportedInputTypes)[number];\n type SupportedTextAlign = (typeof supportedTextAlign)[number];\n const parseInputType = (potentialInputType: string): SupportedInputType => {\n const lowercasedNewInputType = potentialInputType.toLowerCase();\n\n // @ts-ignore - we're actually checking that this value is correct.\n if (supportedInputTypes.includes(lowercasedNewInputType))\n return potentialInputType as SupportedInputType;\n\n return 'text';\n };\n\n const parseTextAlign = (\n potentialTextAlign: string | undefined\n ): SupportedTextAlign => {\n if (!potentialTextAlign) return 'left';\n const lowercasedNewTextAlign = potentialTextAlign.toLowerCase();\n\n // @ts-ignore - we're actually checking that this value is correct.\n if (supportedTextAlign.includes(lowercasedNewTextAlign))\n return potentialTextAlign as SupportedTextAlign;\n\n return 'left';\n };\n\n /** Base parameters for {@link gdjs.TextInputRuntimeObject} */\n export interface TextInputObjectData extends ObjectData {\n /** The base parameters of the TextInput */\n content: {\n initialValue: string;\n placeholder: string;\n fontResourceName: string;\n fontSize: float;\n inputType: SupportedInputType;\n textColor: string;\n fillColor: string;\n fillOpacity: float;\n borderColor: string;\n borderOpacity: float;\n borderWidth: float;\n disabled: boolean;\n readOnly: boolean;\n // ---- Values can be undefined because of support for these feature was added in v5.5.222.\n spellCheck?: boolean;\n paddingX?: float;\n paddingY?: float;\n textAlign?: SupportedTextAlign;\n maxLength?: integer;\n // ----\n };\n }\n\n export type TextInputNetworkSyncDataType = {\n opa: float;\n txt: string;\n frn: string;\n fs: number;\n place: string;\n it: SupportedInputType;\n tc: string;\n fc: string;\n fo: float;\n bc: string;\n bo: float;\n bw: float;\n dis: boolean;\n ro: boolean;\n sc: boolean;\n };\n\n export type TextInputNetworkSyncData = ObjectNetworkSyncData &\n TextInputNetworkSyncDataType;\n\n const DEFAULT_WIDTH = 300;\n const DEFAULT_HEIGHT = 30;\n\n const clampPadding = (value: float, dimension: float, borderWidth: float) => {\n return Math.max(0, Math.min(dimension / 2 - borderWidth, value));\n };\n\n /**\n * Shows a text input on the screen the player can type text into.\n */\n export class TextInputRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.TextContainer, gdjs.Resizable, gdjs.OpacityHandler\n {\n private _string: string;\n private _placeholder: string;\n private opacity: float = 255;\n private _width: float = DEFAULT_WIDTH;\n private _height: float = DEFAULT_HEIGHT;\n private _fontResourceName: string;\n private _fontSize: float;\n private _inputType: SupportedInputType;\n private _textColor: [float, float, float];\n private _fillColor: [float, float, float];\n private _fillOpacity: float;\n private _paddingX: integer;\n private _paddingY: integer;\n private _textAlign: SupportedTextAlign;\n private _maxLength: integer;\n private _borderColor: [float, float, float];\n private _borderOpacity: float;\n private _borderWidth: float;\n private _disabled: boolean;\n private _readOnly: boolean;\n private _spellCheck: boolean;\n private _isSubmitted: boolean;\n _renderer: TextInputRuntimeObjectRenderer;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: TextInputObjectData\n ) {\n super(instanceContainer, objectData);\n\n this._string = objectData.content.initialValue;\n this._placeholder = objectData.content.placeholder;\n this._fontResourceName = objectData.content.fontResourceName;\n this._fontSize = objectData.content.fontSize || 20;\n this._inputType = parseInputType(objectData.content.inputType);\n this._textColor = gdjs.rgbOrHexToRGBColor(objectData.content.textColor);\n this._fillColor = gdjs.rgbOrHexToRGBColor(objectData.content.fillColor);\n this._fillOpacity = objectData.content.fillOpacity;\n this._borderColor = gdjs.rgbOrHexToRGBColor(\n objectData.content.borderColor\n );\n this._borderOpacity = objectData.content.borderOpacity;\n this._borderWidth = objectData.content.borderWidth;\n this._disabled = objectData.content.disabled;\n this._readOnly = objectData.content.readOnly;\n this._spellCheck =\n objectData.content.spellCheck !== undefined\n ? objectData.content.spellCheck\n : false;\n this._textAlign = parseTextAlign(objectData.content.textAlign);\n this._maxLength = objectData.content.maxLength || 0;\n this._paddingX =\n objectData.content.paddingX !== undefined\n ? objectData.content.paddingX\n : 2;\n this._paddingY =\n objectData.content.paddingY !== undefined\n ? objectData.content.paddingY\n : 1;\n this._isSubmitted = false;\n this._renderer = new gdjs.TextInputRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return null;\n }\n\n updateFromObjectData(\n oldObjectData: TextInputObjectData,\n newObjectData: TextInputObjectData\n ): boolean {\n if (\n oldObjectData.content.initialValue !==\n newObjectData.content.initialValue\n ) {\n if (this._string === oldObjectData.content.initialValue) {\n this.setString(newObjectData.content.initialValue);\n }\n }\n if (\n oldObjectData.content.placeholder !== newObjectData.content.placeholder\n ) {\n this.setPlaceholder(newObjectData.content.placeholder);\n }\n if (\n oldObjectData.content.fontResourceName !==\n newObjectData.content.fontResourceName\n ) {\n this.setFontResourceName(newObjectData.content.fontResourceName);\n }\n if (oldObjectData.content.fontSize !== newObjectData.content.fontSize) {\n this.setFontSize(newObjectData.content.fontSize);\n }\n if (oldObjectData.content.inputType !== newObjectData.content.inputType) {\n this.setInputType(newObjectData.content.inputType);\n }\n if (oldObjectData.content.textColor !== newObjectData.content.textColor) {\n this.setTextColor(newObjectData.content.textColor);\n }\n if (oldObjectData.content.fillColor !== newObjectData.content.fillColor) {\n this.setFillColor(newObjectData.content.fillColor);\n }\n if (\n oldObjectData.content.fillOpacity !== newObjectData.content.fillOpacity\n ) {\n this.setFillOpacity(newObjectData.content.fillOpacity);\n }\n if (\n oldObjectData.content.borderColor !== newObjectData.content.borderColor\n ) {\n this.setBorderColor(newObjectData.content.borderColor);\n }\n if (\n oldObjectData.content.borderOpacity !==\n newObjectData.content.borderOpacity\n ) {\n this.setBorderOpacity(newObjectData.content.borderOpacity);\n }\n if (\n oldObjectData.content.borderWidth !== newObjectData.content.borderWidth\n ) {\n this.setBorderWidth(newObjectData.content.borderWidth);\n }\n if (oldObjectData.content.disabled !== newObjectData.content.disabled) {\n this.setDisabled(newObjectData.content.disabled);\n }\n if (oldObjectData.content.readOnly !== newObjectData.content.readOnly) {\n this.setReadOnly(newObjectData.content.readOnly);\n }\n if (\n newObjectData.content.spellCheck !== undefined &&\n oldObjectData.content.spellCheck !== newObjectData.content.spellCheck\n ) {\n this.setSpellCheck(newObjectData.content.spellCheck);\n }\n if (\n newObjectData.content.maxLength !== undefined &&\n oldObjectData.content.maxLength !== newObjectData.content.maxLength\n ) {\n this.setMaxLength(newObjectData.content.maxLength);\n }\n if (\n newObjectData.content.textAlign &&\n oldObjectData.content.textAlign !== newObjectData.content.textAlign\n ) {\n this._textAlign = newObjectData.content.textAlign;\n }\n if (\n newObjectData.content.paddingX !== undefined &&\n oldObjectData.content.paddingX !== newObjectData.content.paddingX\n ) {\n this.setPaddingX(newObjectData.content.paddingX);\n }\n if (\n newObjectData.content.paddingY !== undefined &&\n oldObjectData.content.paddingY !== newObjectData.content.paddingY\n ) {\n this.setPaddingY(newObjectData.content.paddingY);\n }\n\n return true;\n }\n\n getNetworkSyncData(): TextInputNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n opa: this.getOpacity(),\n txt: this.getText(),\n frn: this.getFontResourceName(),\n fs: this.getFontSize(),\n place: this.getPlaceholder(),\n it: this.getInputType(),\n tc: this.getTextColor(),\n fc: this.getFillColor(),\n fo: this.getFillOpacity(),\n bc: this.getBorderColor(),\n bo: this.getBorderOpacity(),\n bw: this.getBorderWidth(),\n dis: this.isDisabled(),\n ro: this.isReadOnly(),\n sc: this.isSpellCheckEnabled(),\n };\n }\n\n updateFromNetworkSyncData(syncData: TextInputNetworkSyncData): void {\n super.updateFromNetworkSyncData(syncData);\n\n if (syncData.opa !== undefined) this.setOpacity(syncData.opa);\n if (syncData.txt !== undefined) this.setText(syncData.txt);\n if (syncData.frn !== undefined) this.setFontResourceName(syncData.frn);\n if (syncData.fs !== undefined) this.setFontSize(syncData.fs);\n if (syncData.place !== undefined) this.setPlaceholder(syncData.place);\n if (syncData.it !== undefined) this.setInputType(syncData.it);\n if (syncData.tc !== undefined) this.setTextColor(syncData.tc);\n if (syncData.fc !== undefined) this.setFillColor(syncData.fc);\n if (syncData.fo !== undefined) this.setFillOpacity(syncData.fo);\n if (syncData.bc !== undefined) this.setBorderColor(syncData.bc);\n if (syncData.bo !== undefined) this.setBorderOpacity(syncData.bo);\n if (syncData.bw !== undefined) this.setBorderWidth(syncData.bw);\n if (syncData.dis !== undefined) this.setDisabled(syncData.dis);\n if (syncData.ro !== undefined) this.setReadOnly(syncData.ro);\n if (syncData.sc !== undefined) this.setSpellCheck(syncData.sc);\n }\n\n updatePreRender(instanceContainer: RuntimeInstanceContainer): void {\n this._isSubmitted = false;\n this._renderer.updatePreRender();\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'initialValue') {\n this.setString(property.value);\n } else if (property.name === 'placeholder') {\n this.setPlaceholder(property.value);\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n this._renderer.updatePadding();\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n }\n\n onScenePaused(runtimeScene: gdjs.RuntimeScene): void {\n this._renderer.onScenePaused();\n }\n\n onSceneResumed(runtimeScene: gdjs.RuntimeScene): void {\n this._renderer.onSceneResumed();\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.onDestroy();\n }\n\n setOpacity(opacity: float): void {\n this.opacity = Math.max(0, Math.min(255, opacity));\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n setSize(width: number, height: number): void {\n this.setWidth(width);\n this.setHeight(height);\n }\n\n setWidth(width: float): void {\n this._width = width;\n this._renderer.updatePadding();\n }\n\n setHeight(height: float): void {\n this._height = height;\n this._renderer.updatePadding();\n }\n\n /**\n * Return the width of the object.\n * @return The width of the object\n */\n getWidth(): float {\n return this._width;\n }\n\n /**\n * Return the width of the object.\n * @return The height of the object\n */\n getHeight(): float {\n return this._height;\n }\n\n /**\n * Get the text entered in the text input.\n * @deprecated use `getText` instead\n */\n getString() {\n return this.getText();\n }\n\n /**\n * Replace the text inside the text input.\n * @deprecated use `setText` instead\n */\n setString(text: string) {\n this.setText(text);\n }\n\n getText() {\n return this._string;\n }\n\n setText(newString: string) {\n if (newString === this._string) return;\n\n this._string = newString;\n this._renderer.updateString();\n }\n\n /**\n * Called by the renderer when the value of the input shown on the screen\n * was changed (because the user typed something).\n * This does not propagate back the value to the renderer, which would\n * result in the cursor being sent back to the end of the text.\n *\n * Do not use this if you are not inside the renderer - use `setString` instead.\n */\n onRendererInputValueChanged(inputValue: string) {\n this._string = inputValue;\n }\n\n onRendererFormSubmitted() {\n this._isSubmitted = true;\n }\n\n getFontResourceName() {\n return this._fontResourceName;\n }\n\n setFontResourceName(resourceName: string) {\n if (this._fontResourceName === resourceName) return;\n\n this._fontResourceName = resourceName;\n this._renderer.updateFont();\n }\n\n getFontSize() {\n return this._fontSize;\n }\n\n setFontSize(newSize: number) {\n this._fontSize = newSize;\n }\n\n /**\n * Get the placeholder shown when no text is entered\n */\n getPlaceholder() {\n return this._placeholder;\n }\n\n /**\n * Replace the text inside the text input.\n */\n setPlaceholder(newPlaceholder: string) {\n if (newPlaceholder === this._placeholder) return;\n\n this._placeholder = newPlaceholder;\n this._renderer.updatePlaceholder();\n }\n\n /**\n * Get the type of the input.\n */\n getInputType() {\n return this._inputType;\n }\n\n /**\n * Set the type of the input.\n */\n setInputType(newInputType: string) {\n const lowercasedNewInputType = newInputType.toLowerCase();\n if (lowercasedNewInputType === this._inputType) return;\n\n this._inputType = parseInputType(lowercasedNewInputType);\n this._renderer.updateInputType();\n }\n\n setTextColor(newColor: string) {\n this._textColor = gdjs.rgbOrHexToRGBColor(newColor);\n this._renderer.updateTextColor();\n }\n\n getTextColor(): string {\n return (\n this._textColor[0] + ';' + this._textColor[1] + ';' + this._textColor[2]\n );\n }\n\n _getRawTextColor(): [float, float, float] {\n return this._textColor;\n }\n\n setFillColor(newColor: string) {\n this._fillColor = gdjs.rgbOrHexToRGBColor(newColor);\n this._renderer.updateFillColorAndOpacity();\n }\n\n getFillColor(): string {\n return (\n this._fillColor[0] + ';' + this._fillColor[1] + ';' + this._fillColor[2]\n );\n }\n\n _getRawFillColor(): [float, float, float] {\n return this._fillColor;\n }\n\n setFillOpacity(newOpacity: float) {\n this._fillOpacity = Math.max(0, Math.min(255, newOpacity));\n this._renderer.updateFillColorAndOpacity();\n }\n\n getFillOpacity(): float {\n return this._fillOpacity;\n }\n\n setBorderColor(newColor: string) {\n this._borderColor = gdjs.rgbOrHexToRGBColor(newColor);\n this._renderer.updateBorderColorAndOpacity();\n }\n\n getBorderColor(): string {\n return (\n this._borderColor[0] +\n ';' +\n this._borderColor[1] +\n ';' +\n this._borderColor[2]\n );\n }\n\n _getRawBorderColor(): [float, float, float] {\n return this._borderColor;\n }\n\n setBorderOpacity(newOpacity: float) {\n this._borderOpacity = Math.max(0, Math.min(255, newOpacity));\n this._renderer.updateBorderColorAndOpacity();\n }\n\n getBorderOpacity(): float {\n return this._borderOpacity;\n }\n\n setBorderWidth(width: float) {\n this._borderWidth = Math.max(0, width);\n this._renderer.updateBorderWidth();\n }\n\n getBorderWidth(): float {\n return this._borderWidth;\n }\n\n setDisabled(value: boolean) {\n this._disabled = value;\n this._renderer.updateDisabled();\n }\n\n isDisabled(): boolean {\n return this._disabled;\n }\n\n setReadOnly(value: boolean) {\n this._readOnly = value;\n this._renderer.updateReadOnly();\n }\n\n isReadOnly(): boolean {\n return this._readOnly;\n }\n\n setSpellCheck(value: boolean) {\n this._spellCheck = value;\n this._renderer.updateSpellCheck();\n }\n\n isSpellCheckEnabled(): boolean {\n return this._spellCheck;\n }\n\n isFocused(): boolean {\n return this._renderer.isFocused();\n }\n isSubmitted(): boolean {\n return this._isSubmitted;\n }\n\n getMaxLength(): integer {\n return this._maxLength;\n }\n setMaxLength(value: integer) {\n if (this._maxLength === value) return;\n\n this._maxLength = value;\n this._renderer.updateMaxLength();\n }\n\n getPaddingX(): integer {\n return clampPadding(this._paddingX, this._width, this._borderWidth);\n }\n setPaddingX(value: integer) {\n if (this._paddingX === value) return;\n if (value < 0) {\n this._paddingX = 0;\n return;\n }\n\n this._paddingX = value;\n this._renderer.updatePadding();\n }\n getPaddingY(): integer {\n return clampPadding(this._paddingY, this._height, this._borderWidth);\n }\n setPaddingY(value: integer) {\n if (this._paddingY === value) return;\n if (value < 0) {\n this._paddingY = 0;\n return;\n }\n\n this._paddingY = value;\n this._renderer.updatePadding();\n }\n\n getTextAlign(): SupportedTextAlign {\n return this._textAlign;\n }\n\n setTextAlign(newTextAlign: string) {\n const parsedTextAlign = parseTextAlign(newTextAlign);\n if (parsedTextAlign === this._textAlign) return;\n\n this._textAlign = parsedTextAlign;\n this._renderer.updateTextAlign();\n }\n\n focus(): void {\n if (!this.isFocused()) {\n // If the input was not previously focused, reset input manager because there is\n // no reason to maintain its state. It avoids bugs where a key is pressed, the text\n // input is focused and then the input manager does not have access to the keyup event\n // and considers the key still pressed.\n this.getInstanceContainer()\n .getGame()\n .getInputManager()\n .clearAllPressedKeys();\n }\n this._renderer.focus();\n }\n }\n gdjs.registerObject(\n 'TextInput::TextInputObject',\n gdjs.TextInputRuntimeObject\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,E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,EAAM,yBAmjBb,EAAK,eACH,6BACA,EAAK,0BArpBC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(s){const a=class extends s.RuntimeObject{constructor(e,t){super(e,t);this._opacity=255;this._displayMode="all";this._layerIndex=0;this._isTileMapDirty=!1;this._sceneToTileMapTransformation=new s.AffineTransformation;this._tileMapToSceneTransformation=new s.AffineTransformation;this._collisionTileMap=null;this._hitBoxTag="collision";this._transformationIsUpToDate=!1;this._opacity=t.content.opacity,this._atlasImage=t.content.atlasImage,this._rowCount=t.content.rowCount,this._columnCount=t.content.columnCount,this._tileSize=t.content.tileSize,this._initialTileMapAsJsObject={tileWidth:this._tileSize,tileHeight:this._tileSize,dimX:1,dimY:1,layers:[{id:0,alpha:this._opacity/255,tiles:[]}]},this._initialTilesWithHitBox=t.content.tilesWithHitBox.split(",").filter(i=>!!i).map(i=>parseInt(i,10)),this._tileMapManager=s.TileMap.TileMapRuntimeManager.getManager(e),this._renderer=new s.TileMapRuntimeObjectRenderer(this,e),this._loadInitialTileMap(i=>{this._renderer.updatePosition(),this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(i,this._hitBoxTag),this.updateTransformation()}),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updatePreRender(e){if(this._isTileMapDirty){let t=!0;if(this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||this._renderer.refreshPixiTileMap(i)},i=>{t=!1,console.error(`Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)}),!t)return;if(this._collisionTileMap){const i=this._renderer.getTileMap();i&&this._collisionTileMap.updateFromTileMap(i)}this._isTileMapDirty=!1}}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.atlasImage===t.content.atlasImage}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,ai:this._atlasImage,wid:this.getWidth(),hei:this.getHeight()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.op!==void 0&&e.op!==this._opacity&&this.setOpacity(e.op),e.wid!==void 0&&e.wid!==this.getWidth()&&this.setWidth(e.wid),e.hei!==void 0&&e.hei!==this.getHeight()&&this.setHeight(e.hei),e.ai!==void 0}extraInitializationFromInitialInstance(e){for(const t of e.stringProperties)t.name==="tilemap"&&(this._initialTileMapAsJsObject=JSON.parse(t.value));this._loadInitialTileMap(t=>{e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity),this._renderer.updatePosition(),this._collisionTileMap?this._collisionTileMap.updateFromTileMap(t):this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(t,this._hitBoxTag),this.updateTransformation()})}_loadInitialTileMap(e){if(!!this._initialTileMapAsJsObject){if(this._columnCount<=0||this._rowCount<=0){console.error(`Tilemap object ${this.name} is not configured properly.`);return}this._tileMapManager.getOrLoadSimpleTileMap(this._initialTileMapAsJsObject,this.name,this._tileSize,this._columnCount,this._rowCount,t=>{this._initialTilesWithHitBox.forEach(i=>{const o=t.getTileDefinition(i);if(!o){console.warn(`Could not set hit box for tile with id ${i}. Continuing.`);return}o.addHitBox(this._hitBoxTag,[[0,0],[0,t.getTileHeight()],[t.getTileWidth(),t.getTileHeight()],[t.getTileWidth(),0]],!0)}),this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||(this._renderer.updatePixiTileMap(t,i),e(t))},i=>{console.error(`Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)})})}}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setWidth(e){this.getWidth()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this.getHeight()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t),this._transformationIsUpToDate=!1}getScale(){const e=this.getScaleX(),t=this.getScaleY();return e===t?e:Math.sqrt(e*t)}setScale(e){this.setScaleX(e),this.setScaleY(e),this._transformationIsUpToDate=!1}setScaleX(e){e<0&&(e=0),this.getScaleX()!==e&&(this._renderer.setScaleX(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setScaleY(e){e<0&&(e=0),this.getScaleY()!==e&&(this._renderer.setScaleY(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setX(e){super.setX(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setY(e){super.setY(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setAngle(e){super.setAngle(e),this._renderer.updateAngle(),this._transformationIsUpToDate=!1}setOpacity(e){this._opacity=e,this._renderer.updateOpacity(),this._isTileMapDirty=!0}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}getScaleX(){return this._renderer.getScaleX()}getScaleY(){return this._renderer.getScaleY()}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}updateHitBoxes(){this.updateTransformation(),!!this._collisionTileMap&&(this.hitBoxes=Array.from(this._collisionTileMap.getAllHitboxes(this._hitBoxTag)),this.hitBoxesDirty=!1,this.updateAABB())}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.x,this.aabb.min[1]=this.y,this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{if(!this._collisionTileMap)return;const e=this._collisionTileMap.getTransformation(),t=0,i=this._collisionTileMap.getWidth(),o=0,r=this._collisionTileMap.getHeight(),n=this.aabb.min;n[0]=t,n[1]=o,e.transform(n,n);const l=n[0],h=n[1];n[0]=i,n[1]=o,e.transform(n,n);const d=n[0],p=n[1];n[0]=i,n[1]=r,e.transform(n,n);const g=n[0],f=n[1];n[0]=t,n[1]=r,e.transform(n,n);const u=n[0],c=n[1];this.aabb.min[0]=Math.min(l,d,g,u),this.aabb.max[0]=Math.max(l,d,g,u),this.aabb.min[1]=Math.min(h,p,f,c),this.aabb.max[1]=Math.max(h,p,f,c)}}getHitBoxesAround(e,t,i,o){return this.updateTransformation(),this._collisionTileMap?this._collisionTileMap.getHitboxesAround(this._hitBoxTag,e,t,i,o):[]}updateTransformation(){if(this._transformationIsUpToDate)return;const e=Math.abs(this._renderer.getScaleX()),t=Math.abs(this._renderer.getScaleY());this._tileMapToSceneTransformation.setToIdentity(),this._tileMapToSceneTransformation.translate(this.getX(),this.getY());const i=this.getAngle()*Math.PI/180;if(this._tileMapToSceneTransformation.rotateAround(i,this.getCenterX(),this.getCenterY()),this._tileMapToSceneTransformation.scale(e,t),this._collisionTileMap){const o=this._collisionTileMap.getTransformation();o.copyFrom(this._tileMapToSceneTransformation),this._collisionTileMap.setTransformation(o)}this._sceneToTileMapTransformation.copyFrom(this._tileMapToSceneTransformation),this._sceneToTileMapTransformation.invert(),this._transformationIsUpToDate=!0}getSceneXCoordinateOfTileCenter(e,t){const i=a.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[0]}getSceneYCoordinateOfTileCenter(e,t){const i=a.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[1]}getGridCoordinatesFromSceneCoordinates(e,t){this.updateTransformation();const i=a.workingPoint;this._sceneToTileMapTransformation.transform([e,t],i);const o=Math.floor(i[0]/this._tileSize),r=Math.floor(i[1]/this._tileSize);return[o,r]}getColumnIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[0]}getRowIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[1]}getTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this.getTileAtGridCoordinates(i,o)}getTileAtGridCoordinates(e,t){return this._renderer.getTileId(e,t,0)}setTileAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(t,i);this.setTileAtGridCoordinates(e,o,r)}setTileAtGridCoordinates(e,t,i){const o=this._renderer._tileMap;if(!o)return;const r=o.getTileLayer(this._layerIndex);if(!r)return;const n=r.getTileId(t,i);if(e!==n){if(r.setTile(t,i,e),this._collisionTileMap){const l=n!==void 0&&o.getTileDefinition(n),h=o.getTileDefinition(e),d=!!l&&l.hasFullHitBox(this._hitBoxTag),p=!!h&&h.hasFullHitBox(this._hitBoxTag);d!==p&&this._collisionTileMap.invalidateTile(this._layerIndex,t,i)}this._isTileMapDirty=!0,this.invalidateHitboxes()}}flipTileOnYAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnYAtGridCoordinates(o,r,i)}flipTileOnXAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnXAtGridCoordinates(o,r,i)}flipTileOnYAtGridCoordinates(e,t,i){this._renderer.flipTileOnY(e,t,0,i),this._isTileMapDirty=!0}flipTileOnXAtGridCoordinates(e,t,i){this._renderer.flipTileOnX(e,t,0,i),this._isTileMapDirty=!0}isTileFlippedOnXAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnX(i,o,0)}isTileFlippedOnXAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnX(e,t,0)}isTileFlippedOnYAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnY(i,o,0)}isTileFlippedOnYAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnY(e,t,0)}removeTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.removeTileAtGridCoordinates(i,o)}removeTileAtGridCoordinates(e,t){const i=this._renderer._tileMap;if(!i)return;const o=i.getTileLayer(this._layerIndex);!o||o.getTileId(e,t)===void 0||(o.removeTile(e,t),this._collisionTileMap&&this._collisionTileMap.invalidateTile(this._layerIndex,e,t),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridRowCount(e){e<=0||(this._renderer.setGridRowCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridColumnCount(e){e<=0||(this._renderer.setGridColumnCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}getGridRowCount(){return this._renderer.getGridRowCount()}getGridColumnCount(){return this._renderer.getGridColumnCount()}getTilesetColumnCount(){return this._columnCount}getTilesetRowCount(){return this._rowCount}};let T=a;T.workingPoint=[0,0],s.SimpleTileMapRuntimeObject=T,s.registerObject("TileMap::SimpleTileMap",s.SimpleTileMapRuntimeObject)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(a){const s=class extends a.RuntimeObject{constructor(e,t){super(e,t);this._opacity=255;this._displayMode="all";this._layerIndex=0;this._isTileMapDirty=!1;this._sceneToTileMapTransformation=new a.AffineTransformation;this._tileMapToSceneTransformation=new a.AffineTransformation;this._collisionTileMap=null;this._hitBoxTag="collision";this._transformationIsUpToDate=!1;this._opacity=t.content.opacity,this._atlasImage=t.content.atlasImage,this._rowCount=t.content.rowCount,this._columnCount=t.content.columnCount,this._tileSize=t.content.tileSize,this._initialTileMapAsJsObject={tileWidth:this._tileSize,tileHeight:this._tileSize,dimX:1,dimY:1,layers:[{id:0,alpha:this._opacity/255,tiles:[]}]},this._initialTilesWithHitBox=t.content.tilesWithHitBox.split(",").filter(i=>!!i).map(i=>parseInt(i,10)),this._tileMapManager=a.TileMap.TileMapRuntimeManager.getManager(e),this._renderer=new a.TileMapRuntimeObjectRenderer(this,e),this._loadInitialTileMap(i=>{this._renderer.updatePosition(),this._collisionTileMap=new a.TileMap.TransformedCollisionTileMap(i,this._hitBoxTag),this.updateTransformation()}),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updatePreRender(e){if(this._isTileMapDirty){let t=!0;if(this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||this._renderer.refreshPixiTileMap(i)},i=>{t=!1,console.error(`Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)}),!t)return;if(this._collisionTileMap){const i=this._renderer.getTileMap();i&&this._collisionTileMap.updateFromTileMap(i)}this._isTileMapDirty=!1}}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.atlasImage===t.content.atlasImage}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,ai:this._atlasImage}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.op!==void 0&&e.op!==this._opacity&&this.setOpacity(e.op),e.ai!==void 0}extraInitializationFromInitialInstance(e){for(const t of e.stringProperties)t.name==="tilemap"&&(this._initialTileMapAsJsObject=JSON.parse(t.value));this._loadInitialTileMap(t=>{e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity),this._renderer.updatePosition(),this._collisionTileMap?this._collisionTileMap.updateFromTileMap(t):this._collisionTileMap=new a.TileMap.TransformedCollisionTileMap(t,this._hitBoxTag),this.updateTransformation()})}_loadInitialTileMap(e){if(!!this._initialTileMapAsJsObject){if(this._columnCount<=0||this._rowCount<=0){console.error(`Tilemap object ${this.name} is not configured properly.`);return}this._tileMapManager.getOrLoadSimpleTileMap(this._initialTileMapAsJsObject,this.name,this._tileSize,this._columnCount,this._rowCount,t=>{this._initialTilesWithHitBox.forEach(i=>{const o=t.getTileDefinition(i);if(!o){console.warn(`Could not set hit box for tile with id ${i}. Continuing.`);return}o.addHitBox(this._hitBoxTag,[[0,0],[0,t.getTileHeight()],[t.getTileWidth(),t.getTileHeight()],[t.getTileWidth(),0]],!0)}),this._tileMapManager.getOrLoadSimpleTileMapTextureCache(i=>this.getInstanceContainer().getGame().getImageManager().getPIXITexture(i),this._atlasImage,this._tileSize,this._columnCount,this._rowCount,i=>{!i||(this._renderer.updatePixiTileMap(t,i),e(t))},i=>{console.error(`Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,i)})})}}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setWidth(e){this.getWidth()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this.getHeight()!==e&&(this._transformationIsUpToDate=!1,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t),this._transformationIsUpToDate=!1}getScale(){const e=this.getScaleX(),t=this.getScaleY();return e===t?e:Math.sqrt(e*t)}setScale(e){this.setScaleX(e),this.setScaleY(e),this._transformationIsUpToDate=!1}setScaleX(e){e<0&&(e=0),this.getScaleX()!==e&&(this._renderer.setScaleX(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setScaleY(e){e<0&&(e=0),this.getScaleY()!==e&&(this._renderer.setScaleY(e),this.invalidateHitboxes(),this._transformationIsUpToDate=!1)}setX(e){super.setX(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setY(e){super.setY(e),this._renderer.updatePosition(),this._transformationIsUpToDate=!1}setAngle(e){super.setAngle(e),this._renderer.updateAngle(),this._transformationIsUpToDate=!1}setOpacity(e){this._opacity=e,this._renderer.updateOpacity(),this._isTileMapDirty=!0}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}getScaleX(){return this._renderer.getScaleX()}getScaleY(){return this._renderer.getScaleY()}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}updateHitBoxes(){this.updateTransformation(),!!this._collisionTileMap&&(this.hitBoxes=Array.from(this._collisionTileMap.getAllHitboxes(this._hitBoxTag)),this.hitBoxesDirty=!1,this.updateAABB())}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.x,this.aabb.min[1]=this.y,this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{if(!this._collisionTileMap)return;const e=this._collisionTileMap.getTransformation(),t=0,i=this._collisionTileMap.getWidth(),o=0,r=this._collisionTileMap.getHeight(),n=this.aabb.min;n[0]=t,n[1]=o,e.transform(n,n);const l=n[0],h=n[1];n[0]=i,n[1]=o,e.transform(n,n);const d=n[0],p=n[1];n[0]=i,n[1]=r,e.transform(n,n);const g=n[0],c=n[1];n[0]=t,n[1]=r,e.transform(n,n);const f=n[0],u=n[1];this.aabb.min[0]=Math.min(l,d,g,f),this.aabb.max[0]=Math.max(l,d,g,f),this.aabb.min[1]=Math.min(h,p,c,u),this.aabb.max[1]=Math.max(h,p,c,u)}}getHitBoxesAround(e,t,i,o){return this.updateTransformation(),this._collisionTileMap?this._collisionTileMap.getHitboxesAround(this._hitBoxTag,e,t,i,o):[]}updateTransformation(){if(this._transformationIsUpToDate)return;const e=Math.abs(this._renderer.getScaleX()),t=Math.abs(this._renderer.getScaleY());this._tileMapToSceneTransformation.setToIdentity(),this._tileMapToSceneTransformation.translate(this.getX(),this.getY());const i=this.getAngle()*Math.PI/180;if(this._tileMapToSceneTransformation.rotateAround(i,this.getCenterX(),this.getCenterY()),this._tileMapToSceneTransformation.scale(e,t),this._collisionTileMap){const o=this._collisionTileMap.getTransformation();o.copyFrom(this._tileMapToSceneTransformation),this._collisionTileMap.setTransformation(o)}this._sceneToTileMapTransformation.copyFrom(this._tileMapToSceneTransformation),this._sceneToTileMapTransformation.invert(),this._transformationIsUpToDate=!0}getSceneXCoordinateOfTileCenter(e,t){const i=s.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[0]}getSceneYCoordinateOfTileCenter(e,t){const i=s.workingPoint;return this._tileMapToSceneTransformation.transform([(e+.5)*this._tileSize,(t+.5)*this._tileSize],i),i[1]}getGridCoordinatesFromSceneCoordinates(e,t){this.updateTransformation();const i=s.workingPoint;this._sceneToTileMapTransformation.transform([e,t],i);const o=Math.floor(i[0]/this._tileSize),r=Math.floor(i[1]/this._tileSize);return[o,r]}getColumnIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[0]}getRowIndexAtPosition(e,t){return this.getGridCoordinatesFromSceneCoordinates(e,t)[1]}getTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this.getTileAtGridCoordinates(i,o)}getTileAtGridCoordinates(e,t){return this._renderer.getTileId(e,t,0)}setTileAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(t,i);this.setTileAtGridCoordinates(e,o,r)}setTileAtGridCoordinates(e,t,i){const o=this._renderer._tileMap;if(!o)return;const r=o.getTileLayer(this._layerIndex);if(!r)return;const n=r.getTileId(t,i);if(e!==n){if(r.setTile(t,i,e),this._collisionTileMap){const l=n!==void 0&&o.getTileDefinition(n),h=o.getTileDefinition(e),d=!!l&&l.hasFullHitBox(this._hitBoxTag),p=!!h&&h.hasFullHitBox(this._hitBoxTag);d!==p&&this._collisionTileMap.invalidateTile(this._layerIndex,t,i)}this._isTileMapDirty=!0,this.invalidateHitboxes()}}flipTileOnYAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnYAtGridCoordinates(o,r,i)}flipTileOnXAtPosition(e,t,i){const[o,r]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.flipTileOnXAtGridCoordinates(o,r,i)}flipTileOnYAtGridCoordinates(e,t,i){this._renderer.flipTileOnY(e,t,0,i),this._isTileMapDirty=!0}flipTileOnXAtGridCoordinates(e,t,i){this._renderer.flipTileOnX(e,t,0,i),this._isTileMapDirty=!0}isTileFlippedOnXAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnX(i,o,0)}isTileFlippedOnXAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnX(e,t,0)}isTileFlippedOnYAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);return this._renderer.isTileFlippedOnY(i,o,0)}isTileFlippedOnYAtGridCoordinates(e,t){return this._renderer.isTileFlippedOnY(e,t,0)}removeTileAtPosition(e,t){const[i,o]=this.getGridCoordinatesFromSceneCoordinates(e,t);this.removeTileAtGridCoordinates(i,o)}removeTileAtGridCoordinates(e,t){const i=this._renderer._tileMap;if(!i)return;const o=i.getTileLayer(this._layerIndex);!o||o.getTileId(e,t)===void 0||(o.removeTile(e,t),this._collisionTileMap&&this._collisionTileMap.invalidateTile(this._layerIndex,e,t),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridRowCount(e){e<=0||(this._renderer.setGridRowCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}setGridColumnCount(e){e<=0||(this._renderer.setGridColumnCount(e),this._isTileMapDirty=!0,this.invalidateHitboxes())}getGridRowCount(){return this._renderer.getGridRowCount()}getGridColumnCount(){return this._renderer.getGridColumnCount()}getTilesetColumnCount(){return this._columnCount}getTilesetRowCount(){return this._rowCount}};let T=s;T.workingPoint=[0,0],a.SimpleTileMapRuntimeObject=T,a.registerObject("TileMap::SimpleTileMap",a.SimpleTileMapRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=simpletilemapruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TileMap/simpletilemapruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type SimpleTileMapObjectDataType = {\n content: {\n opacity: number;\n atlasImage: string;\n rowCount: number;\n columnCount: number;\n tileSize: number;\n tilesWithHitBox: string;\n };\n };\n\n export type SimpleTileMapObjectData = ObjectData &\n SimpleTileMapObjectDataType;\n\n export type SimpleTileMapNetworkSyncDataType = {\n op: number;\n ai: string;\n wid: number;\n hei: number;\n // TODO: Support tilemap synchronization. Find an efficient way to send tiles changes.\n };\n\n export type SimpleTileMapNetworkSyncData = ObjectNetworkSyncData &\n SimpleTileMapNetworkSyncDataType;\n\n /**\n * Displays a SimpleTileMap object.\n */\n export class SimpleTileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler\n {\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n _opacity: float = 255;\n _atlasImage: string;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n readonly _rowCount: number;\n readonly _columnCount: number;\n readonly _tileSize: number;\n _displayMode = 'all';\n _layerIndex = 0;\n _initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;\n readonly _initialTilesWithHitBox: number[];\n _isTileMapDirty: boolean = false;\n _sceneToTileMapTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n _tileMapToSceneTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap | null = null;\n _hitBoxTag: string = 'collision';\n private _transformationIsUpToDate: boolean = false;\n\n // TODO: Add a debug mode like for TileMapCollisionMaskRuntimeObject to draw?\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: SimpleTileMapObjectDataType\n ) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._atlasImage = objectData.content.atlasImage;\n this._rowCount = objectData.content.rowCount;\n this._columnCount = objectData.content.columnCount;\n this._tileSize = objectData.content.tileSize;\n this._initialTileMapAsJsObject = {\n tileWidth: this._tileSize,\n tileHeight: this._tileSize,\n dimX: 1,\n dimY: 1,\n layers: [{ id: 0, alpha: this._opacity / 255, tiles: [] }],\n };\n this._initialTilesWithHitBox = (\n objectData.content.tilesWithHitBox as string\n )\n .split(',')\n .filter((id) => !!id)\n .map((idAsString) => parseInt(idAsString, 10));\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n this._renderer.updatePosition();\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n\n this.updateTransformation();\n });\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._isTileMapDirty) {\n let shouldContinue = true;\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(\n textureName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.refreshPixiTileMap(textureCache);\n },\n (error) => {\n shouldContinue = false;\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n if (!shouldContinue) return;\n if (this._collisionTileMap) {\n const tileMap = this._renderer.getTileMap();\n if (tileMap) this._collisionTileMap.updateFromTileMap(tileMap);\n }\n this._isTileMapDirty = false;\n }\n }\n\n updateFromObjectData(\n oldObjectData: SimpleTileMapObjectData,\n newObjectData: SimpleTileMapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.atlasImage !== newObjectData.content.atlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n // Map content is updated at hot-reload by extraInitializationFromInitialInstance.\n return true;\n }\n\n getNetworkSyncData(): SimpleTileMapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n ai: this._atlasImage,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: SimpleTileMapNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (\n networkSyncData.op !== undefined &&\n networkSyncData.op !== this._opacity\n ) {\n this.setOpacity(networkSyncData.op);\n }\n if (\n networkSyncData.wid !== undefined &&\n networkSyncData.wid !== this.getWidth()\n ) {\n this.setWidth(networkSyncData.wid);\n }\n if (\n networkSyncData.hei !== undefined &&\n networkSyncData.hei !== this.getHeight()\n ) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.ai !== undefined) {\n // TODO: support changing the atlas texture\n }\n }\n\n extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ): void {\n // 1. load the tilemap from the instance.\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'tilemap') {\n this._initialTileMapAsJsObject = JSON.parse(property.value);\n }\n }\n\n // 2. Update the renderer so that it updates the tilemap object\n // (used for width and position calculations).\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n // 3. Set custom dimensions & opacity if applicable.\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n\n // 4. Update position (calculations based on renderer's dimensions).\n this._renderer.updatePosition();\n\n if (this._collisionTileMap) {\n // If collision tile map is already defined, there's a good chance it means\n // extraInitializationFromInitialInstance is called when hot reloading the\n // scene so the collision is tile map is updated instead of being re-created.\n this._collisionTileMap.updateFromTileMap(tileMap);\n } else {\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n }\n\n this.updateTransformation();\n });\n }\n\n private _loadInitialTileMap(\n tileMapLoadingCallback: (tileMap: TileMapHelper.EditableTileMap) => void\n ): void {\n if (!this._initialTileMapAsJsObject) return;\n if (this._columnCount <= 0 || this._rowCount <= 0) {\n console.error(\n `Tilemap object ${this.name} is not configured properly.`\n );\n return;\n }\n\n this._tileMapManager.getOrLoadSimpleTileMap(\n this._initialTileMapAsJsObject,\n this.name,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (tileMap: TileMapHelper.EditableTileMap) => {\n this._initialTilesWithHitBox.forEach((tileId) => {\n const tileDefinition = tileMap.getTileDefinition(tileId);\n if (!tileDefinition) {\n console.warn(\n `Could not set hit box for tile with id ${tileId}. Continuing.`\n );\n return;\n }\n tileDefinition.addHitBox(\n this._hitBoxTag,\n [\n [0, 0],\n [0, tileMap.getTileHeight()],\n [tileMap.getTileWidth(), tileMap.getTileHeight()],\n [tileMap.getTileWidth(), 0],\n ],\n true\n );\n });\n\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(\n textureName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n tileMapLoadingCallback(tileMap);\n },\n (error) => {\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n this._transformationIsUpToDate = false;\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n this._isTileMapDirty = true;\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n\n /**\n * This method is expensive and should not be called.\n * Prefer using {@link getHitBoxesAround} rather than getHitBoxes.\n */\n getHitBoxes(): gdjs.Polygon[] {\n if (this.hitBoxesDirty) {\n this.updateHitBoxes();\n this.updateAABB();\n this.hitBoxesDirty = false;\n }\n return this.hitBoxes;\n }\n\n updateHitBoxes(): void {\n this.updateTransformation();\n if (!this._collisionTileMap) return;\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._hitBoxTag)\n );\n this.hitBoxesDirty = false;\n this.updateAABB();\n }\n\n // This implementation doesn't use updateHitBoxes.\n // It's important for good performances.\n updateAABB(): void {\n if (this.getAngle() === 0) {\n // Fast computation of AABB for non rotated object\n this.aabb.min[0] = this.x;\n this.aabb.min[1] = this.y;\n this.aabb.max[0] = this.aabb.min[0] + this.getWidth();\n this.aabb.max[1] = this.aabb.min[1] + this.getHeight();\n } else {\n if (!this._collisionTileMap) return;\n const affineTransformation = this._collisionTileMap.getTransformation();\n\n const left = 0;\n const right = this._collisionTileMap.getWidth();\n const top = 0;\n const bottom = this._collisionTileMap.getHeight();\n\n const workingPoint = this.aabb.min;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n this.aabb.min[0] = Math.min(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.max[0] = Math.max(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.min[1] = Math.min(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n this.aabb.max[1] = Math.max(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n }\n }\n\n getHitBoxesAround(\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\n // This implementation doesn't call updateHitBoxes.\n // It's important for good performances because there is no need to\n // update the whole collision mask where only a few hitboxes must be\n // checked.\n this.updateTransformation();\n if (!this._collisionTileMap) return [];\n return this._collisionTileMap.getHitboxesAround(\n this._hitBoxTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n updateTransformation() {\n if (this._transformationIsUpToDate) {\n return;\n }\n const absScaleX = Math.abs(this._renderer.getScaleX());\n const absScaleY = Math.abs(this._renderer.getScaleY());\n\n this._tileMapToSceneTransformation.setToIdentity();\n\n // Translation\n this._tileMapToSceneTransformation.translate(this.getX(), this.getY());\n\n // Rotation\n const angleInRadians = (this.getAngle() * Math.PI) / 180;\n this._tileMapToSceneTransformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n this._tileMapToSceneTransformation.scale(absScaleX, absScaleY);\n if (this._collisionTileMap) {\n const collisionTileMapTransformation =\n this._collisionTileMap.getTransformation();\n collisionTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._collisionTileMap.setTransformation(\n collisionTileMapTransformation\n );\n }\n this._sceneToTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._sceneToTileMapTransformation.invert();\n this._transformationIsUpToDate = true;\n }\n\n getSceneXCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[0];\n }\n\n getSceneYCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[1];\n }\n\n getGridCoordinatesFromSceneCoordinates(\n x: float,\n y: float\n ): [integer, integer] {\n this.updateTransformation();\n\n const gridCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._sceneToTileMapTransformation.transform([x, y], gridCoordinates);\n\n const columnIndex = Math.floor(gridCoordinates[0] / this._tileSize);\n const rowIndex = Math.floor(gridCoordinates[1] / this._tileSize);\n\n return [columnIndex, rowIndex];\n }\n\n getColumnIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[0];\n }\n\n getRowIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[1];\n }\n\n getTileAtPosition(x: float, y: float): integer {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n return this.getTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n getTileAtGridCoordinates(columnIndex: integer, rowIndex: integer): integer {\n return this._renderer.getTileId(columnIndex, rowIndex, 0);\n }\n\n setTileAtPosition(tileId: number, x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.setTileAtGridCoordinates(tileId, columnIndex, rowIndex);\n }\n\n setTileAtGridCoordinates(\n tileId: number,\n columnIndex: integer,\n rowIndex: integer\n ) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (tileId === oldTileId) {\n return;\n }\n layer.setTile(columnIndex, rowIndex, tileId);\n\n if (this._collisionTileMap) {\n const oldTileDefinition =\n oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);\n const newTileDefinition = tileMap.getTileDefinition(tileId);\n const hadFullHitBox =\n !!oldTileDefinition &&\n oldTileDefinition.hasFullHitBox(this._hitBoxTag);\n const haveFullHitBox =\n !!newTileDefinition &&\n newTileDefinition.hasFullHitBox(this._hitBoxTag);\n if (hadFullHitBox !== haveFullHitBox) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n flipTileOnYAtPosition(x: float, y: float, flip: boolean) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnYAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnXAtPosition(x: float, y: float, flip: boolean) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnXAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnYAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnY(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n flipTileOnXAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnX(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n isTileFlippedOnXAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnXAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n removeTileAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.removeTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (oldTileId === undefined) {\n return;\n }\n layer.removeTile(columnIndex, rowIndex);\n if (this._collisionTileMap) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridRowCount(targetRowCount: integer) {\n if (targetRowCount <= 0) return;\n this._renderer.setGridRowCount(targetRowCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridColumnCount(targetColumnCount: integer) {\n if (targetColumnCount <= 0) return;\n this._renderer.setGridColumnCount(targetColumnCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n getGridRowCount(): integer {\n return this._renderer.getGridRowCount();\n }\n\n getGridColumnCount(): integer {\n return this._renderer.getGridColumnCount();\n }\n\n getTilesetColumnCount(): integer {\n return this._columnCount;\n }\n\n getTilesetRowCount(): integer {\n return this._rowCount;\n }\n }\n gdjs.registerObject(\n 'TileMap::SimpleTileMap',\n gdjs.SimpleTileMapRuntimeObject\n );\n}\n"],
|
|
5
|
-
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,
|
|
4
|
+
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type SimpleTileMapObjectDataType = {\n content: {\n opacity: number;\n atlasImage: string;\n rowCount: number;\n columnCount: number;\n tileSize: number;\n tilesWithHitBox: string;\n };\n };\n\n export type SimpleTileMapObjectData = ObjectData &\n SimpleTileMapObjectDataType;\n\n export type SimpleTileMapNetworkSyncDataType = {\n op: number;\n ai: string;\n // TODO: Support tilemap synchronization. Find an efficient way to send tiles changes.\n };\n\n export type SimpleTileMapNetworkSyncData = ObjectNetworkSyncData &\n SimpleTileMapNetworkSyncDataType;\n\n /**\n * Displays a SimpleTileMap object.\n */\n export class SimpleTileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler\n {\n /**\n * A reusable Point to avoid allocations.\n */\n private static readonly workingPoint: FloatPoint = [0, 0];\n\n _opacity: float = 255;\n _atlasImage: string;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n readonly _rowCount: number;\n readonly _columnCount: number;\n readonly _tileSize: number;\n _displayMode = 'all';\n _layerIndex = 0;\n _initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;\n readonly _initialTilesWithHitBox: number[];\n _isTileMapDirty: boolean = false;\n _sceneToTileMapTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n _tileMapToSceneTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n _collisionTileMap: gdjs.TileMap.TransformedCollisionTileMap | null = null;\n _hitBoxTag: string = 'collision';\n private _transformationIsUpToDate: boolean = false;\n\n // TODO: Add a debug mode like for TileMapCollisionMaskRuntimeObject to draw?\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: SimpleTileMapObjectDataType\n ) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._atlasImage = objectData.content.atlasImage;\n this._rowCount = objectData.content.rowCount;\n this._columnCount = objectData.content.columnCount;\n this._tileSize = objectData.content.tileSize;\n this._initialTileMapAsJsObject = {\n tileWidth: this._tileSize,\n tileHeight: this._tileSize,\n dimX: 1,\n dimY: 1,\n layers: [{ id: 0, alpha: this._opacity / 255, tiles: [] }],\n };\n this._initialTilesWithHitBox = (\n objectData.content.tilesWithHitBox as string\n )\n .split(',')\n .filter((id) => !!id)\n .map((idAsString) => parseInt(idAsString, 10));\n this._tileMapManager =\n gdjs.TileMap.TileMapRuntimeManager.getManager(instanceContainer);\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n this._renderer.updatePosition();\n\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n\n this.updateTransformation();\n });\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._isTileMapDirty) {\n let shouldContinue = true;\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(\n textureName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.refreshPixiTileMap(textureCache);\n },\n (error) => {\n shouldContinue = false;\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during prerender. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n if (!shouldContinue) return;\n if (this._collisionTileMap) {\n const tileMap = this._renderer.getTileMap();\n if (tileMap) this._collisionTileMap.updateFromTileMap(tileMap);\n }\n this._isTileMapDirty = false;\n }\n }\n\n updateFromObjectData(\n oldObjectData: SimpleTileMapObjectData,\n newObjectData: SimpleTileMapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.atlasImage !== newObjectData.content.atlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n // Map content is updated at hot-reload by extraInitializationFromInitialInstance.\n return true;\n }\n\n getNetworkSyncData(): SimpleTileMapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n ai: this._atlasImage,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: SimpleTileMapNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (\n networkSyncData.op !== undefined &&\n networkSyncData.op !== this._opacity\n ) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.ai !== undefined) {\n // TODO: support changing the atlas texture\n }\n }\n\n extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ): void {\n // 1. load the tilemap from the instance.\n for (const property of initialInstanceData.stringProperties) {\n if (property.name === 'tilemap') {\n this._initialTileMapAsJsObject = JSON.parse(property.value);\n }\n }\n\n // 2. Update the renderer so that it updates the tilemap object\n // (used for width and position calculations).\n this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {\n // 3. Set custom dimensions & opacity if applicable.\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n\n // 4. Update position (calculations based on renderer's dimensions).\n this._renderer.updatePosition();\n\n if (this._collisionTileMap) {\n // If collision tile map is already defined, there's a good chance it means\n // extraInitializationFromInitialInstance is called when hot reloading the\n // scene so the collision is tile map is updated instead of being re-created.\n this._collisionTileMap.updateFromTileMap(tileMap);\n } else {\n this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(\n tileMap,\n this._hitBoxTag\n );\n }\n\n this.updateTransformation();\n });\n }\n\n private _loadInitialTileMap(\n tileMapLoadingCallback: (tileMap: TileMapHelper.EditableTileMap) => void\n ): void {\n if (!this._initialTileMapAsJsObject) return;\n if (this._columnCount <= 0 || this._rowCount <= 0) {\n console.error(\n `Tilemap object ${this.name} is not configured properly.`\n );\n return;\n }\n\n this._tileMapManager.getOrLoadSimpleTileMap(\n this._initialTileMapAsJsObject,\n this.name,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (tileMap: TileMapHelper.EditableTileMap) => {\n this._initialTilesWithHitBox.forEach((tileId) => {\n const tileDefinition = tileMap.getTileDefinition(tileId);\n if (!tileDefinition) {\n console.warn(\n `Could not set hit box for tile with id ${tileId}. Continuing.`\n );\n return;\n }\n tileDefinition.addHitBox(\n this._hitBoxTag,\n [\n [0, 0],\n [0, tileMap.getTileHeight()],\n [tileMap.getTileWidth(), tileMap.getTileHeight()],\n [tileMap.getTileWidth(), 0],\n ],\n true\n );\n });\n\n this._tileMapManager.getOrLoadSimpleTileMapTextureCache(\n (textureName) => {\n return this.getInstanceContainer()\n .getGame()\n .getImageManager()\n .getPIXITexture(\n textureName\n ) as unknown as PIXI.BaseTexture<PIXI.Resource>;\n },\n this._atlasImage,\n this._tileSize,\n this._columnCount,\n this._rowCount,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n tileMapLoadingCallback(tileMap);\n },\n (error) => {\n console.error(\n `Could not load texture cache for atlas ${this._atlasImage} during initial loading. The tilemap might be badly configured or an issues happened with the loaded atlas image:`,\n error\n );\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._transformationIsUpToDate = false;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n this._transformationIsUpToDate = false;\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n this._transformationIsUpToDate = false;\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n this._transformationIsUpToDate = false;\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n this._isTileMapDirty = true;\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n\n /**\n * This method is expensive and should not be called.\n * Prefer using {@link getHitBoxesAround} rather than getHitBoxes.\n */\n getHitBoxes(): gdjs.Polygon[] {\n if (this.hitBoxesDirty) {\n this.updateHitBoxes();\n this.updateAABB();\n this.hitBoxesDirty = false;\n }\n return this.hitBoxes;\n }\n\n updateHitBoxes(): void {\n this.updateTransformation();\n if (!this._collisionTileMap) return;\n this.hitBoxes = Array.from(\n this._collisionTileMap.getAllHitboxes(this._hitBoxTag)\n );\n this.hitBoxesDirty = false;\n this.updateAABB();\n }\n\n // This implementation doesn't use updateHitBoxes.\n // It's important for good performances.\n updateAABB(): void {\n if (this.getAngle() === 0) {\n // Fast computation of AABB for non rotated object\n this.aabb.min[0] = this.x;\n this.aabb.min[1] = this.y;\n this.aabb.max[0] = this.aabb.min[0] + this.getWidth();\n this.aabb.max[1] = this.aabb.min[1] + this.getHeight();\n } else {\n if (!this._collisionTileMap) return;\n const affineTransformation = this._collisionTileMap.getTransformation();\n\n const left = 0;\n const right = this._collisionTileMap.getWidth();\n const top = 0;\n const bottom = this._collisionTileMap.getHeight();\n\n const workingPoint = this.aabb.min;\n\n workingPoint[0] = left;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topLeftX = workingPoint[0];\n const topLeftY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = top;\n affineTransformation.transform(workingPoint, workingPoint);\n const topRightX = workingPoint[0];\n const topRightY = workingPoint[1];\n\n workingPoint[0] = right;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomRightX = workingPoint[0];\n const bottomRightY = workingPoint[1];\n\n workingPoint[0] = left;\n workingPoint[1] = bottom;\n affineTransformation.transform(workingPoint, workingPoint);\n const bottomLeftX = workingPoint[0];\n const bottomLeftY = workingPoint[1];\n\n this.aabb.min[0] = Math.min(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.max[0] = Math.max(\n topLeftX,\n topRightX,\n bottomRightX,\n bottomLeftX\n );\n this.aabb.min[1] = Math.min(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n this.aabb.max[1] = Math.max(\n topLeftY,\n topRightY,\n bottomRightY,\n bottomLeftY\n );\n }\n }\n\n getHitBoxesAround(\n left: float,\n top: float,\n right: float,\n bottom: float\n ): Iterable<gdjs.Polygon> {\n // This implementation doesn't call updateHitBoxes.\n // It's important for good performances because there is no need to\n // update the whole collision mask where only a few hitboxes must be\n // checked.\n this.updateTransformation();\n if (!this._collisionTileMap) return [];\n return this._collisionTileMap.getHitboxesAround(\n this._hitBoxTag,\n left,\n top,\n right,\n bottom\n );\n }\n\n updateTransformation() {\n if (this._transformationIsUpToDate) {\n return;\n }\n const absScaleX = Math.abs(this._renderer.getScaleX());\n const absScaleY = Math.abs(this._renderer.getScaleY());\n\n this._tileMapToSceneTransformation.setToIdentity();\n\n // Translation\n this._tileMapToSceneTransformation.translate(this.getX(), this.getY());\n\n // Rotation\n const angleInRadians = (this.getAngle() * Math.PI) / 180;\n this._tileMapToSceneTransformation.rotateAround(\n angleInRadians,\n this.getCenterX(),\n this.getCenterY()\n );\n\n // Scale\n this._tileMapToSceneTransformation.scale(absScaleX, absScaleY);\n if (this._collisionTileMap) {\n const collisionTileMapTransformation =\n this._collisionTileMap.getTransformation();\n collisionTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._collisionTileMap.setTransformation(\n collisionTileMapTransformation\n );\n }\n this._sceneToTileMapTransformation.copyFrom(\n this._tileMapToSceneTransformation\n );\n this._sceneToTileMapTransformation.invert();\n this._transformationIsUpToDate = true;\n }\n\n getSceneXCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[0];\n }\n\n getSceneYCoordinateOfTileCenter(\n columnIndex: integer,\n rowIndex: integer\n ): float {\n const sceneCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._tileMapToSceneTransformation.transform(\n [\n (columnIndex + 0.5) * this._tileSize,\n (rowIndex + 0.5) * this._tileSize,\n ],\n sceneCoordinates\n );\n return sceneCoordinates[1];\n }\n\n getGridCoordinatesFromSceneCoordinates(\n x: float,\n y: float\n ): [integer, integer] {\n this.updateTransformation();\n\n const gridCoordinates: FloatPoint =\n SimpleTileMapRuntimeObject.workingPoint;\n this._sceneToTileMapTransformation.transform([x, y], gridCoordinates);\n\n const columnIndex = Math.floor(gridCoordinates[0] / this._tileSize);\n const rowIndex = Math.floor(gridCoordinates[1] / this._tileSize);\n\n return [columnIndex, rowIndex];\n }\n\n getColumnIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[0];\n }\n\n getRowIndexAtPosition(x: float, y: float): integer {\n return this.getGridCoordinatesFromSceneCoordinates(x, y)[1];\n }\n\n getTileAtPosition(x: float, y: float): integer {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n return this.getTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n getTileAtGridCoordinates(columnIndex: integer, rowIndex: integer): integer {\n return this._renderer.getTileId(columnIndex, rowIndex, 0);\n }\n\n setTileAtPosition(tileId: number, x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.setTileAtGridCoordinates(tileId, columnIndex, rowIndex);\n }\n\n setTileAtGridCoordinates(\n tileId: number,\n columnIndex: integer,\n rowIndex: integer\n ) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (tileId === oldTileId) {\n return;\n }\n layer.setTile(columnIndex, rowIndex, tileId);\n\n if (this._collisionTileMap) {\n const oldTileDefinition =\n oldTileId !== undefined && tileMap.getTileDefinition(oldTileId);\n const newTileDefinition = tileMap.getTileDefinition(tileId);\n const hadFullHitBox =\n !!oldTileDefinition &&\n oldTileDefinition.hasFullHitBox(this._hitBoxTag);\n const haveFullHitBox =\n !!newTileDefinition &&\n newTileDefinition.hasFullHitBox(this._hitBoxTag);\n if (hadFullHitBox !== haveFullHitBox) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n flipTileOnYAtPosition(x: float, y: float, flip: boolean) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnYAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnXAtPosition(x: float, y: float, flip: boolean) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.flipTileOnXAtGridCoordinates(columnIndex, rowIndex, flip);\n }\n\n flipTileOnYAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnY(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n flipTileOnXAtGridCoordinates(\n columnIndex: integer,\n rowIndex: integer,\n flip: boolean\n ) {\n this._renderer.flipTileOnX(columnIndex, rowIndex, 0, flip);\n this._isTileMapDirty = true;\n // No need to invalidate hit boxes since at the moment, collision mask\n // cannot be configured on each tile.\n }\n\n isTileFlippedOnXAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnXAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnX(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n isTileFlippedOnYAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n return this._renderer.isTileFlippedOnY(columnIndex, rowIndex, 0);\n }\n\n removeTileAtPosition(x: float, y: float) {\n const [columnIndex, rowIndex] =\n this.getGridCoordinatesFromSceneCoordinates(x, y);\n this.removeTileAtGridCoordinates(columnIndex, rowIndex);\n }\n\n removeTileAtGridCoordinates(columnIndex: integer, rowIndex: integer) {\n const tileMap = this._renderer._tileMap;\n if (!tileMap) {\n return;\n }\n const layer = tileMap.getTileLayer(this._layerIndex);\n if (!layer) {\n return;\n }\n const oldTileId = layer.getTileId(columnIndex, rowIndex);\n if (oldTileId === undefined) {\n return;\n }\n layer.removeTile(columnIndex, rowIndex);\n if (this._collisionTileMap) {\n this._collisionTileMap.invalidateTile(\n this._layerIndex,\n columnIndex,\n rowIndex\n );\n }\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridRowCount(targetRowCount: integer) {\n if (targetRowCount <= 0) return;\n this._renderer.setGridRowCount(targetRowCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n setGridColumnCount(targetColumnCount: integer) {\n if (targetColumnCount <= 0) return;\n this._renderer.setGridColumnCount(targetColumnCount);\n this._isTileMapDirty = true;\n this.invalidateHitboxes();\n }\n\n getGridRowCount(): integer {\n return this._renderer.getGridRowCount();\n }\n\n getGridColumnCount(): integer {\n return this._renderer.getGridColumnCount();\n }\n\n getTilesetColumnCount(): integer {\n return this._columnCount;\n }\n\n getTilesetRowCount(): integer {\n return this._rowCount;\n }\n }\n gdjs.registerObject(\n 'TileMap::SimpleTileMap',\n gdjs.SimpleTileMapRuntimeObject\n );\n}\n"],
|
|
5
|
+
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CA2BS,qBACG,GAAK,aAEf,CA4BE,YACE,EACA,EACA,CACA,MAAM,EAAmB,GA1B3B,cAAkB,IAOlB,kBAAe,MACf,iBAAc,EAGd,qBAA2B,GAC3B,mCACE,GAAI,GAAK,qBACX,mCACE,GAAI,GAAK,qBACX,uBAAqE,KACrE,gBAAqB,YACb,+BAAqC,GAS3C,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,0BAA4B,CAC/B,UAAW,KAAK,UAChB,WAAY,KAAK,UACjB,KAAM,EACN,KAAM,EACN,OAAQ,CAAC,CAAE,GAAI,EAAG,MAAO,KAAK,SAAW,IAAK,MAAO,MAEvD,KAAK,wBACH,EAAW,QAAQ,gBAElB,MAAM,KACN,OAAO,AAAC,GAAO,CAAC,CAAC,GACjB,IAAI,AAAC,GAAe,SAAS,EAAY,KAC5C,KAAK,gBACH,EAAK,QAAQ,sBAAsB,WAAW,GAChD,KAAK,UAAY,GAAI,GAAK,6BACxB,KACA,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EAAa,EAAU,GAGhE,2BAA2B,EAAU,EAAU,CAC7C,KAAM,CAAC,EAAa,GAClB,KAAK,uCAAuC,EAAG,GAEjD,MAAO,MAAK,UAAU,iBAAiB,EAAa,EAAU,GAGhE,kCAAkC,EAAsB,EAAmB,CACzE,MAAO,MAAK,UAAU,iBAAiB,EAAa,EAAU,GAGhE,qBAAqB,EAAU,EAAU,CACvC,KAAM,CAAC,EAAa,GAClB,KAAK,uCAAuC,EAAG,GACjD,KAAK,4BAA4B,EAAa,GAGhD,4BAA4B,EAAsB,EAAmB,CACnE,KAAM,GAAU,KAAK,UAAU,SAC/B,GAAI,CAAC,EACH,OAEF,KAAM,GAAQ,EAAQ,aAAa,KAAK,aAKxC,AAJI,CAAC,GAID,AADc,EAAM,UAAU,EAAa,KAC7B,QAGlB,GAAM,WAAW,EAAa,GAC1B,KAAK,mBACP,KAAK,kBAAkB,eACrB,KAAK,YACL,EACA,GAGJ,KAAK,gBAAkB,GACvB,KAAK,sBAGP,gBAAgB,EAAyB,CACvC,AAAI,GAAkB,GACtB,MAAK,UAAU,gBAAgB,GAC/B,KAAK,gBAAkB,GACvB,KAAK,sBAGP,mBAAmB,EAA4B,CAC7C,AAAI,GAAqB,GACzB,MAAK,UAAU,mBAAmB,GAClC,KAAK,gBAAkB,GACvB,KAAK,sBAGP,iBAA2B,CACzB,MAAO,MAAK,UAAU,kBAGxB,oBAA8B,CAC5B,MAAO,MAAK,UAAU,qBAGxB,uBAAiC,CAC/B,MAAO,MAAK,aAGd,oBAA8B,CAC5B,MAAO,MAAK,YA1wBT,QAOmB,AAPnB,EAOmB,aAA2B,CAAC,EAAG,GAPlD,EAAM,6BA6wBb,EAAK,eACH,yBACA,EAAK,8BA1yBC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(s){class _ extends s.RuntimeObject{constructor(i,t){super(i,t);this._transformationIsUpToDate=!1;this._tilemapJsonFile=t.content.tilemapJsonFile,this._tilesetJsonFile=t.content.tilesetJsonFile,this._collisionMaskTag=t.content.collisionMaskTag,this._layerIndex=t.content.useAllLayers||t.content.useAllLayers===void 0?null:Number.isFinite(t.content.layerIndex)?t.content.layerIndex:1,this._debugMode=t.content.debugMode,this._fillColor=s.rgbOrHexStringToNumber(t.content.fillColor),this._outlineColor=s.rgbOrHexStringToNumber(t.content.outlineColor),this._fillOpacity=t.content.fillOpacity,this._outlineOpacity=t.content.outlineOpacity,this._outlineSize=t.content.outlineSize,this._tileMapManager=s.TileMap.TileMapRuntimeManager.getManager(i),this._width=0,this._height=0,this._scaleX=1,this._scaleY=1;const o=new TileMapHelper.EditableTileMap(1,1,0,0,new Map);this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(o,this._collisionMaskTag,this._layerIndex),this._renderer=new s.TileMap.TileMapCollisionMaskRenderer(this,i),this._updateTileMap(),this.onCreated()}updatePreRender(i){super.updatePreRender(i),this._debugMode&&this.hitBoxesDirty&&this.updateHitBoxes()}getRendererObject(){return this._renderer.getRendererObject()}getVisibilityAABB(){return null}updateFromObjectData(i,t){return i.content.tilemapJsonFile!==t.content.tilemapJsonFile&&this.setTilemapJsonFile(t.content.tilemapJsonFile),i.content.tilesetJsonFile!==t.content.tilesetJsonFile&&this.setTilesetJsonFile(t.content.tilesetJsonFile),i.content.debugMode!==t.content.debugMode&&this.setDebugMode(t.content.debugMode),i.content.fillColor!==t.content.fillColor&&this.setFillColor(s.rgbOrHexStringToNumber(t.content.fillColor)),i.content.outlineColor!==t.content.outlineColor&&this.setOutlineColor(s.rgbOrHexStringToNumber(t.content.outlineColor)),i.fillOpacity!==t.fillOpacity&&this.setFillOpacity(t.fillOpacity),i.outlineOpacity!==t.outlineOpacity&&this.setOutlineOpacity(t.outlineOpacity),i.outlineSize!==t.outlineSize&&this.setOutlineSize(t.outlineSize),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),tmjf:this.getTilemapJsonFile(),tsjf:this.getTilesetJsonFile(),dm:this.getDebugMode(),oc:this.getOutlineColor(),fc:this.getFillColor(),os:this.getOutlineSize(),fo:this.getFillOpacity(),oo:this.getOutlineOpacity()
|
|
1
|
+
var gdjs;(function(s){class _ extends s.RuntimeObject{constructor(i,t){super(i,t);this._transformationIsUpToDate=!1;this._tilemapJsonFile=t.content.tilemapJsonFile,this._tilesetJsonFile=t.content.tilesetJsonFile,this._collisionMaskTag=t.content.collisionMaskTag,this._layerIndex=t.content.useAllLayers||t.content.useAllLayers===void 0?null:Number.isFinite(t.content.layerIndex)?t.content.layerIndex:1,this._debugMode=t.content.debugMode,this._fillColor=s.rgbOrHexStringToNumber(t.content.fillColor),this._outlineColor=s.rgbOrHexStringToNumber(t.content.outlineColor),this._fillOpacity=t.content.fillOpacity,this._outlineOpacity=t.content.outlineOpacity,this._outlineSize=t.content.outlineSize,this._tileMapManager=s.TileMap.TileMapRuntimeManager.getManager(i),this._width=0,this._height=0,this._scaleX=1,this._scaleY=1;const o=new TileMapHelper.EditableTileMap(1,1,0,0,new Map);this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(o,this._collisionMaskTag,this._layerIndex),this._renderer=new s.TileMap.TileMapCollisionMaskRenderer(this,i),this._updateTileMap(),this.onCreated()}updatePreRender(i){super.updatePreRender(i),this._debugMode&&this.hitBoxesDirty&&this.updateHitBoxes()}getRendererObject(){return this._renderer.getRendererObject()}getVisibilityAABB(){return null}updateFromObjectData(i,t){return i.content.tilemapJsonFile!==t.content.tilemapJsonFile&&this.setTilemapJsonFile(t.content.tilemapJsonFile),i.content.tilesetJsonFile!==t.content.tilesetJsonFile&&this.setTilesetJsonFile(t.content.tilesetJsonFile),i.content.debugMode!==t.content.debugMode&&this.setDebugMode(t.content.debugMode),i.content.fillColor!==t.content.fillColor&&this.setFillColor(s.rgbOrHexStringToNumber(t.content.fillColor)),i.content.outlineColor!==t.content.outlineColor&&this.setOutlineColor(s.rgbOrHexStringToNumber(t.content.outlineColor)),i.fillOpacity!==t.fillOpacity&&this.setFillOpacity(t.fillOpacity),i.outlineOpacity!==t.outlineOpacity&&this.setOutlineOpacity(t.outlineOpacity),i.outlineSize!==t.outlineSize&&this.setOutlineSize(t.outlineSize),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),tmjf:this.getTilemapJsonFile(),tsjf:this.getTilesetJsonFile(),dm:this.getDebugMode(),oc:this.getOutlineColor(),fc:this.getFillColor(),os:this.getOutlineSize(),fo:this.getFillOpacity(),oo:this.getOutlineOpacity()}}updateFromNetworkSyncData(i){super.updateFromNetworkSyncData(i),i.tmjf!==void 0&&this.setTilemapJsonFile(i.tmjf),i.tsjf!==void 0&&this.setTilesetJsonFile(i.tsjf),i.dm!==void 0&&this.setDebugMode(i.dm),i.oc!==void 0&&this.setOutlineColor(i.oc),i.fc!==void 0&&this.setFillColor(i.fc),i.os!==void 0&&this.setOutlineSize(i.os),i.fo!==void 0&&this.setFillOpacity(i.fo),i.oo!==void 0&&this.setOutlineOpacity(i.oo)}extraInitializationFromInitialInstance(i){i.customSize&&(this.setWidth(i.width),this.setHeight(i.height))}_updateTileMap(){this._tileMapManager.getOrLoadTileMap(this._tilemapJsonFile,this._tilesetJsonFile,0,i=>{!i||(this._collisionTileMap=new s.TileMap.TransformedCollisionTileMap(i,this._collisionMaskTag,this._layerIndex),this.hitBoxes=Array.from(this._collisionTileMap.getAllHitboxes(this._collisionMaskTag)),this._renderer.redrawCollisionMask(),this._width=this._collisionTileMap.getWidth()*this._scaleX,this._height=this._collisionTileMap.getHeight()*this._scaleY)})}updateHitBoxes(){this.updateTransformation();for(const i of this._collisionTileMap.getAllHitboxes(this._collisionMaskTag));this.hitBoxesDirty=!1,this._renderer.redrawCollisionMask(),this.updateAABB()}updateTransformation(){if(this._transformationIsUpToDate)return;const i=this._collisionTileMap.getTransformation(),t=Math.abs(this._scaleX),o=Math.abs(this._scaleY);i.setToIdentity(),i.translate(this.x,this.y);const l=this.angle*Math.PI/180;i.rotateAround(l,this.getCenterX(),this.getCenterY()),i.scale(t,o),this._collisionTileMap.setTransformation(i),this._transformationIsUpToDate=!0}getHitBoxes(){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.hitBoxes}getHitBoxesAround(i,t,o,l){return this.updateTransformation(),this._collisionTileMap.getHitboxesAround(this._collisionMaskTag,i,t,o,l)}insideObject(i,t){return this.updateTransformation(),this._collisionTileMap.pointIsInsideTile(i,t,this._collisionMaskTag)}updateAABB(){if(this.getAngle()===0)this.aabb.min[0]=this.x,this.aabb.min[1]=this.y,this.aabb.max[0]=this.aabb.min[0]+this.getWidth(),this.aabb.max[1]=this.aabb.min[1]+this.getHeight();else{const i=this._collisionTileMap.getTransformation(),t=0,o=this._collisionTileMap.getWidth(),l=0,n=this._collisionTileMap.getHeight(),e=this.aabb.min;e[0]=t,e[1]=l,i.transform(e,e);const a=e[0],r=e[1];e[0]=o,e[1]=l,i.transform(e,e);const h=e[0],p=e[1];e[0]=o,e[1]=n,i.transform(e,e);const f=e[0],g=e[1];e[0]=t,e[1]=n,i.transform(e,e);const u=e[0],d=e[1];this.aabb.min[0]=Math.min(a,h,f,u),this.aabb.max[0]=Math.max(a,h,f,u),this.aabb.min[1]=Math.min(r,p,g,d),this.aabb.max[1]=Math.max(r,p,g,d)}}setTilemapJsonFile(i){this._tilemapJsonFile=i,this._updateTileMap()}getTilemapJsonFile(){return this._tilemapJsonFile}isTilemapJsonFile(i){return this._tilemapJsonFile===i}setTilesetJsonFile(i){this._tilesetJsonFile=i,this._updateTileMap()}getTilesetJsonFile(){return this._tilesetJsonFile}isTilesetJsonFile(i){return this._tilesetJsonFile===i}getDebugMode(){return this._debugMode}setDebugMode(i){this._debugMode=i,this._renderer.redrawCollisionMask()}getFillColor(){return this._fillColor}getOutlineColor(){return this._outlineColor}setFillColor(i){this._fillColor=i}setOutlineColor(i){this._outlineColor=i}setOutlineSize(i){this._outlineSize=i}getOutlineSize(){return this._outlineSize}setFillOpacity(i){this._fillOpacity=i}getFillOpacity(){return this._fillOpacity}setOutlineOpacity(i){this._outlineOpacity=i}getOutlineOpacity(){return this._outlineOpacity}setX(i){super.setX(i),this._transformationIsUpToDate=!1}setY(i){super.setY(i),this._transformationIsUpToDate=!1}setAngle(i){super.setAngle(i),this._transformationIsUpToDate=!1}setWidth(i){this._width!==i&&(this._scaleX=i/this._collisionTileMap.getWidth(),this._width=i,this._transformationIsUpToDate=!1,this.invalidateHitboxes())}setHeight(i){this._height!==i&&(this._scaleY=i/this._collisionTileMap.getHeight(),this._height=i,this._transformationIsUpToDate=!1,this.invalidateHitboxes())}setSize(i,t){this.setWidth(i),this.setHeight(t)}getScale(){const i=this.getScaleX(),t=this.getScaleY();return i===t?i:Math.sqrt(i*t)}setScale(i){this.setScaleX(i),this.setScaleY(i)}setScaleX(i){i<0&&(i=0),this._scaleX!==i&&(this._scaleX=i,this._width=i*this._collisionTileMap.getWidth(),this._transformationIsUpToDate=!1,this.invalidateHitboxes())}setScaleY(i){i<0&&(i=0),this._scaleY!==i&&(this._scaleY=i,this._height=i*this._collisionTileMap.getHeight(),this._transformationIsUpToDate=!1,this.invalidateHitboxes())}getWidth(){return this._width}getHeight(){return this._height}getScaleX(){return this._scaleX}getScaleY(){return this._scaleY}}s.TileMapCollisionMaskRuntimeObject=_,s.registerObject("TileMap::CollisionMask",s.TileMapCollisionMaskRuntimeObject),_.supportsReinitialization=!1})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=tilemapcollisionmaskruntimeobject.js.map
|