gdcore-tools 2.0.0-gd-v5.4.217-autobuild → 2.0.0-gd-v5.4.219-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.
Files changed (57) hide show
  1. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  2. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  3. package/dist/Runtime/Extensions/3D/JsExtension.js +7 -3
  4. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  5. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  6. package/dist/Runtime/Extensions/DialogueTree/JsExtension.js +44 -32
  7. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js +2 -2
  8. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
  9. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +15 -0
  10. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  11. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  12. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  13. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  14. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  15. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  16. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  17. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  18. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  19. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  20. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  21. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  22. package/dist/Runtime/Model3DManager.js +1 -1
  23. package/dist/Runtime/Model3DManager.js.map +2 -2
  24. package/dist/Runtime/ResourceLoader.js +1 -1
  25. package/dist/Runtime/ResourceLoader.js.map +2 -2
  26. package/dist/Runtime/RuntimeLayer.js +1 -1
  27. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  28. package/dist/Runtime/capturemanager.js +2 -0
  29. package/dist/Runtime/capturemanager.js.map +7 -0
  30. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
  31. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  32. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  33. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  34. package/dist/Runtime/jsonmanager.js +1 -1
  35. package/dist/Runtime/jsonmanager.js.map +2 -2
  36. package/dist/Runtime/layer.js +1 -1
  37. package/dist/Runtime/layer.js.map +2 -2
  38. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
  39. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  40. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  41. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  42. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  43. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  44. package/dist/Runtime/runtimegame.js +1 -1
  45. package/dist/Runtime/runtimegame.js.map +2 -2
  46. package/dist/Runtime/runtimewatermark.js +2 -2
  47. package/dist/Runtime/runtimewatermark.js.map +2 -2
  48. package/dist/Runtime/scenestack.js +1 -1
  49. package/dist/Runtime/scenestack.js.map +2 -2
  50. package/dist/Runtime/spriteruntimeobject.js +1 -1
  51. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  52. package/dist/Runtime/types/global-types.d.ts +20 -3
  53. package/dist/Runtime/types/project-data.d.ts +1 -1
  54. package/dist/lib/libGD.cjs +1 -1
  55. package/dist/lib/libGD.wasm +0 -0
  56. package/gd.d.ts +35 -7
  57. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var gdjs;(function(r){class o extends r.CustomRuntimeObject{constructor(t,i){super(t,i);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0;this._renderer.reinitialize(this,t)}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY),t.flippedZ&&this.flipZ(t.flippedZ)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){return this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._z+this._minZ}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(1,0,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundY(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,1,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundZ(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,0,1);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}getUnscaledDepth(){return this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(const e of this._instanceContainer.getAdhocListOfAllInstances())!e.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(e)||(t=Math.min(t,e.getUnrotatedAABBMinZ()),i=Math.max(i,e.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,i=1),this._minZ=t,this._maxZ=i}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,i,e){this._customCenterZ=e,this.setRotationCenter(t,i)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const i=this.getUnscaledDepth();if(i===0)return;const e=t/i;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[2]*=e,this._innerArea.max[2]*=e):this.setScaleZ(e)}setScale(t){super.setScale(t),this.setScaleZ(t)}setScaleZ(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleZ)&&(this._scaleZ=t*(this._flippedZ?-1:1),this.getRenderer().updateSize()))}getScale(){const t=this.getScaleX(),i=this.getScaleY(),e=this.getScaleZ();return t===i&&t===e?t:Math.pow(t*i*e,1/3)}getScaleZ(){return Math.abs(this._scaleZ)}flipZ(t){t!==this._flippedZ&&(this._flippedZ=t,this.getRenderer().updateSize())}isFlippedZ(){return this._flippedZ}}o._temporaryVector=new THREE.Vector3,r.CustomRuntimeObject3D=o})(gdjs||(gdjs={}));
1
+ var gdjs;(function(r){class n extends r.CustomRuntimeObject{constructor(t,i){super(t,i);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0;this._renderer.reinitialize(this,t)}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY),t.flippedZ&&this.flipZ(t.flippedZ)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){let t=0;this._innerArea?t=this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._minZ);const i=this.getScaleZ();return this._flippedZ?this._z+(-t-this.getUnscaledDepth()+2*this.getUnscaledCenterZ())*i:this._z+t*i}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(1,0,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundY(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,1,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundZ(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,0,1);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}getInnerAreaMinZ(){return this._innerArea?this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._minZ)}getInnerAreaMaxZ(){return this._innerArea?this._innerArea.max[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ)}getUnscaledDepth(){return this._innerArea?this._innerArea.max[2]-this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ)}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(const e of this._instanceContainer.getAdhocListOfAllInstances())!e.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(e)||(t=Math.min(t,e.getUnrotatedAABBMinZ()),i=Math.max(i,e.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,i=1),this._minZ=t,this._maxZ=i}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:this._innerArea?(this._innerArea.min[2]+this._innerArea.max[2])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,i,e){this._customCenterZ=e,this.setRotationCenter(t,i)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const i=this.getUnscaledDepth();if(i===0)return;const e=t/i;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[2]*=e,this._innerArea.max[2]*=e):this.setScaleZ(e)}setScale(t){super.setScale(t),this.setScaleZ(t)}setScaleZ(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleZ)&&(this._scaleZ=t*(this._flippedZ?-1:1),this.getRenderer().updateSize()))}getScale(){const t=this.getScaleX(),i=this.getScaleY(),e=this.getScaleZ();return t===i&&t===e?t:Math.pow(t*i*e,1/3)}getScaleZ(){return Math.abs(this._scaleZ)}flipZ(t){t!==this._flippedZ&&(this._flippedZ=t,this.getRenderer().updateSize())}isFlippedZ(){return this._flippedZ}}n._temporaryVector=new THREE.Vector3,r.CustomRuntimeObject3D=n})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=CustomRuntimeObject3D.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/3D/CustomRuntimeObject3D.ts"],
4
- "sourcesContent": ["namespace gdjs {\n export interface Object3DDataContent {\n width: float;\n height: float;\n depth: float;\n }\n /** Base parameters for {@link gdjs.RuntimeObject3D} */\n export interface Object3DData extends ObjectData {\n /** The base parameters of the RuntimeObject3D */\n content: Object3DDataContent;\n }\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: Object3DData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._renderer.reinitialize(this, parent);\n }\n\n protected _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined) {\n this.setDepth(initialInstanceData.depth);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n if (initialInstanceData.flippedZ) {\n this.flipZ(initialInstanceData.flippedZ);\n }\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._z + this._minZ;\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
5
- "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAeS,eACG,GAAK,mBACiB,CAwB9B,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxBR,QAAY,EACZ,WAAe,EACf,WAAe,EACf,aAAiB,EACjB,eAAqB,GAMrB,gBAAoB,EAMpB,gBAAoB,EACpB,oBAAwB,EAQ9B,KAAK,UAAU,aAAa,KAAM,GAG1B,eAAgB,CACxB,KAAM,GAAS,KAAK,cACpB,MAAO,IAAI,GAAK,8BACd,KACA,KAAK,mBACL,GAIM,uBAA8B,CACtC,KAAK,cAAc,aAAa,KAAM,KAAK,aAG7C,aAAkD,CAChD,MAAO,OAAM,cAGf,qBAAsB,CAGpB,MAAO,MAAK,cAAc,sBAG5B,uCAAuC,EAAmC,CACxE,MAAM,uCAAuC,GACzC,EAAoB,QAAU,QAChC,KAAK,SAAS,EAAoB,OAEhC,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAOnC,KAAK,EAAgB,CACnB,AAAI,IAAM,KAAK,IACf,MAAK,GAAK,EACV,KAAK,cAAc,kBAMrB,MAAc,CACZ,MAAO,MAAK,GAYd,cAAsB,CACpB,MAAI,MAAK,+BACP,KAAK,+BAEA,KAAK,GAAK,KAAK,MAYxB,YAAoB,CAClB,MAA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mB,CACjB,MAAO,MAAK,IAAI,KAAK,SAGvB,MAAM,EAAiB,CACrB,AAAI,IAAW,KAAK,WAGpB,MAAK,UAAY,EACjB,KAAK,cAAc,cAGrB,YAAsB,CACpB,MAAO,MAAK,WA/VC,AAxBV,EAwBU,iBAAmB,GAAI,OAAM,QAxBvC,EAAM,0BAfL",
4
+ "sourcesContent": ["namespace gdjs {\n export interface Object3DDataContent {\n width: float;\n height: float;\n depth: float;\n }\n /** Base parameters for {@link gdjs.RuntimeObject3D} */\n export interface Object3DData extends ObjectData {\n /** The base parameters of the RuntimeObject3D */\n content: Object3DDataContent;\n }\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: Object3DData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._renderer.reinitialize(this, parent);\n }\n\n protected _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined) {\n this.setDepth(initialInstanceData.depth);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n if (initialInstanceData.flippedZ) {\n this.flipZ(initialInstanceData.flippedZ);\n }\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n let minZ = 0;\n if (this._innerArea) {\n minZ = this._innerArea.min[2];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minZ = this._minZ;\n }\n const absScaleZ = this.getScaleZ();\n if (!this._flippedZ) {\n return this._z + minZ * absScaleZ;\n } else {\n return (\n this._z +\n (-minZ - this.getUnscaledDepth() + 2 * this.getUnscaledCenterZ()) *\n absScaleZ\n );\n }\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinZ(): number {\n if (this._innerArea) {\n return this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._minZ;\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxZ(): number {\n if (this._innerArea) {\n return this._innerArea.max[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ;\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._innerArea) {\n return this._innerArea.max[2] - this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._innerArea) {\n return (this._innerArea.min[2] + this._innerArea.max[2]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAeS,eACG,GAAK,mBACiB,CAwB9B,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxBR,QAAY,EACZ,WAAe,EACf,WAAe,EACf,aAAiB,EACjB,eAAqB,GAMrB,gBAAoB,EAMpB,gBAAoB,EACpB,oBAAwB,EAQ9B,KAAK,UAAU,aAAa,KAAM,GAG1B,eAAgB,CACxB,KAAM,GAAS,KAAK,cACpB,MAAO,IAAI,GAAK,8BACd,KACA,KAAK,mBACL,GAIM,uBAA8B,CACtC,KAAK,cAAc,aAAa,KAAM,KAAK,aAG7C,aAAkD,CAChD,MAAO,OAAM,cAGf,qBAAsB,CAGpB,MAAO,MAAK,cAAc,sBAG5B,uCAAuC,EAAmC,CACxE,MAAM,uCAAuC,GACzC,EAAoB,QAAU,QAChC,KAAK,SAAS,EAAoB,OAEhC,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAOnC,KAAK,EAAgB,CACnB,AAAI,IAAM,KAAK,IACf,MAAK,GAAK,EACV,KAAK,cAAc,kBAMrB,MAAc,CACZ,MAAO,MAAK,GAYd,cAAsB,CACpB,GAAI,GAAO,EACX,AAAI,KAAK,WACP,EAA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AkB,EACpB,OAEF,KAAM,GAAS,EAAQ,EACvB,AAAI,KAAK,YAAc,KAAK,gCAC1B,MAAK,WAAW,IAAI,IAAM,EAC1B,KAAK,WAAW,IAAI,IAAM,GAE1B,KAAK,UAAU,GASnB,SAAS,EAAwB,CAC/B,MAAM,SAAS,GACf,KAAK,UAAU,GAQjB,UAAU,EAAwB,CAChC,AAAI,KAAK,YAAc,KAAK,iCAIxB,GAAW,GACb,GAAW,GAET,IAAa,KAAK,IAAI,KAAK,UAG/B,MAAK,QAAU,EAAY,MAAK,UAAY,GAAK,GACjD,KAAK,cAAc,eAQrB,UAAmB,CACjB,KAAM,GAAS,KAAK,YACd,EAAS,KAAK,YACd,EAAS,KAAK,YACpB,MAAO,KAAW,GAAU,IAAW,EACnC,EACA,KAAK,IAAI,EAAS,EAAS,EAAQ,EAAI,GAQ7C,WAAmB,CACjB,MAAO,MAAK,IAAI,KAAK,SAGvB,MAAM,EAAiB,CACrB,AAAI,IAAW,KAAK,WAGpB,MAAK,UAAY,EACjB,KAAK,cAAc,cAGrB,YAAsB,CACpB,MAAO,MAAK,WA9YC,AAxBV,EAwBU,iBAAmB,GAAI,OAAM,QAxBvC,EAAM,0BAfL",
6
6
  "names": []
7
7
  }
@@ -3231,9 +3231,9 @@ module.exports = {
3231
3231
  : this._originalDepth / modelDepth;
3232
3232
  const minScaleRatio = Math.min(widthRatio, heightRatio, depthRatio);
3233
3233
  if (!Number.isFinite(minScaleRatio)) {
3234
- this._defaultWidth = modelWidth;
3235
- this._defaultHeight = modelHeight;
3236
- this._defaultDepth = modelDepth;
3234
+ this._defaultWidth = this._originalWidth;
3235
+ this._defaultHeight = this._originalHeight;
3236
+ this._defaultDepth = this._originalDepth;
3237
3237
  } else {
3238
3238
  if (widthRatio === minScaleRatio) {
3239
3239
  this._defaultWidth = this._originalWidth;
@@ -3274,6 +3274,10 @@ module.exports = {
3274
3274
  this._defaultDepth = this._originalDepth;
3275
3275
  }
3276
3276
  }
3277
+ } else {
3278
+ this._defaultWidth = this._originalWidth;
3279
+ this._defaultHeight = this._originalHeight;
3280
+ this._defaultDepth = this._originalDepth;
3277
3281
  }
3278
3282
 
3279
3283
  this._threeObject.add(this._threeModelGroup);
@@ -1,2 +1,2 @@
1
- var gdjs;(function(_){let o;(function(t){t[t.None=0]="None",t[t.WindowLeft=1]="WindowLeft",t[t.WindowRight=2]="WindowRight",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(o||(o={}));let n;(function(t){t[t.None=0]="None",t[t.WindowTop=1]="WindowTop",t[t.WindowBottom=2]="WindowBottom",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(n||(n={}));class R extends _.RuntimeBehavior{constructor(e,i,s){super(e,i,s);this._invalidDistances=!0;this._leftEdgeDistance=0;this._rightEdgeDistance=0;this._topEdgeDistance=0;this._bottomEdgeDistance=0;this._useLegacyBottomAndRightAnchors=!1;this._relativeToOriginalWindowSize=!!i.relativeToOriginalWindowSize,this._leftEdgeAnchor=i.leftEdgeAnchor,this._rightEdgeAnchor=i.rightEdgeAnchor,this._topEdgeAnchor=i.topEdgeAnchor,this._bottomEdgeAnchor=i.bottomEdgeAnchor,this._useLegacyBottomAndRightAnchors=i.useLegacyBottomAndRightAnchors===void 0?!0:i.useLegacyBottomAndRightAnchors}updateFromBehaviorData(e,i){return e.leftEdgeAnchor!==i.leftEdgeAnchor&&(this._leftEdgeAnchor=i.leftEdgeAnchor),e.rightEdgeAnchor!==i.rightEdgeAnchor&&(this._rightEdgeAnchor=i.rightEdgeAnchor),e.topEdgeAnchor!==i.topEdgeAnchor&&(this._topEdgeAnchor=i.topEdgeAnchor),e.bottomEdgeAnchor!==i.bottomEdgeAnchor&&(this._bottomEdgeAnchor=i.bottomEdgeAnchor),e.useLegacyTrajectory!==i.useLegacyTrajectory&&(this._useLegacyBottomAndRightAnchors=i.useLegacyBottomAndRightAnchors),e.relativeToOriginalWindowSize===i.relativeToOriginalWindowSize}onActivate(){this._invalidDistances=!0}doStepPreEvents(e){const i=_.staticArray(_.AnchorRuntimeBehavior.prototype.doStepPreEvents);let s=e.getUnrotatedViewportMinX(),h=e.getUnrotatedViewportMinY(),t=e.getUnrotatedViewportMaxX(),d=e.getUnrotatedViewportMaxY(),l=(t+s)/2,f=(d+h)/2,w=t-s,A=d-h;const b=e.getLayer(this.owner.getLayer());if(this._invalidDistances){this._relativeToOriginalWindowSize&&(s=e.getInitialUnrotatedViewportMinX(),h=e.getInitialUnrotatedViewportMinY(),t=e.getInitialUnrotatedViewportMaxX(),d=e.getInitialUnrotatedViewportMaxY(),l=(t+s)/2,f=(d+h)/2,w=t-s,A=d-h);const r=this._convertCoords(e,b,this.owner.getDrawableX(),this.owner.getDrawableY(),i);this._leftEdgeAnchor===1?this._leftEdgeDistance=r[0]-s:this._leftEdgeAnchor===2?this._leftEdgeDistance=r[0]-t:this._leftEdgeAnchor===3?this._leftEdgeDistance=(r[0]-s)/w:this._leftEdgeAnchor===4&&(this._leftEdgeDistance=r[0]-l),this._topEdgeAnchor===1?this._topEdgeDistance=r[1]-h:this._topEdgeAnchor===2?this._topEdgeDistance=r[1]-d:this._topEdgeAnchor===3?this._topEdgeDistance=(r[1]-h)/A:this._topEdgeAnchor===4&&(this._topEdgeDistance=r[1]-f);const g=this._convertCoords(e,b,this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight(),i);this._rightEdgeAnchor===1?this._rightEdgeDistance=g[0]-s:this._rightEdgeAnchor===2?this._rightEdgeDistance=g[0]-t:this._rightEdgeAnchor===3?this._rightEdgeDistance=(g[0]-s)/w:this._rightEdgeAnchor===4&&(this._rightEdgeDistance=g[0]-l),this._bottomEdgeAnchor===1?this._bottomEdgeDistance=g[1]-h:this._bottomEdgeAnchor===2?this._bottomEdgeDistance=g[1]-d:this._bottomEdgeAnchor===3?this._bottomEdgeDistance=(g[1]-h)/A:this._bottomEdgeAnchor===4&&(this._bottomEdgeDistance=g[1]-f),this._invalidDistances=!1}else{let r=0,g=0,a=0,p=0;this._leftEdgeAnchor===1?r=s+this._leftEdgeDistance:this._leftEdgeAnchor===2?r=t+this._leftEdgeDistance:this._leftEdgeAnchor===3?r=s+this._leftEdgeDistance*w:this._leftEdgeAnchor===4&&(r=l+this._leftEdgeDistance),this._topEdgeAnchor===1?g=h+this._topEdgeDistance:this._topEdgeAnchor===2?g=d+this._topEdgeDistance:this._topEdgeAnchor===3?g=h+this._topEdgeDistance*A:this._topEdgeAnchor===4&&(g=f+this._topEdgeDistance),this._rightEdgeAnchor===1?a=s+this._rightEdgeDistance:this._rightEdgeAnchor===2?a=t+this._rightEdgeDistance:this._rightEdgeAnchor===3?a=s+this._rightEdgeDistance*w:this._rightEdgeAnchor===4&&(a=l+this._rightEdgeDistance),this._bottomEdgeAnchor===1?p=h+this._bottomEdgeDistance:this._bottomEdgeAnchor===2?p=d+this._bottomEdgeDistance:this._bottomEdgeAnchor===3?p=h+this._bottomEdgeDistance*A:this._bottomEdgeAnchor===4&&(p=f+this._bottomEdgeDistance);const D=this._convertInverseCoords(e,b,r,g,i),c=D[0],E=D[1],P=this._convertInverseCoords(e,b,a,p,i),W=P[0],u=P[1];if(this._useLegacyBottomAndRightAnchors)this._rightEdgeAnchor!==0&&this.owner.setWidth(W-c),this._bottomEdgeAnchor!==0&&this.owner.setHeight(u-E),this._leftEdgeAnchor!==0&&this.owner.setX(c+this.owner.getX()-this.owner.getDrawableX()),this._topEdgeAnchor!==0&&this.owner.setY(E+this.owner.getY()-this.owner.getDrawableY());else{if(this._rightEdgeAnchor!==0&&this._leftEdgeAnchor!==0){const m=W-c;this.owner.setX(this.owner.getX()===this.owner.getDrawableX()?c:c+(this.owner.getX()-this.owner.getDrawableX())*m/this.owner.getWidth()),this.owner.setWidth(m)}else this._leftEdgeAnchor!==0&&this.owner.setX(c+this.owner.getX()-this.owner.getDrawableX()),this._rightEdgeAnchor!==0&&this.owner.setX(W+this.owner.getX()-this.owner.getDrawableX()-this.owner.getWidth());if(this._bottomEdgeAnchor!==0&&this._topEdgeAnchor!==0){const m=u-E;this.owner.setY(this.owner.getY()===this.owner.getDrawableY()?E:E+(this.owner.getY()-this.owner.getDrawableY())*m/this.owner.getHeight()),this.owner.setHeight(m)}else this._topEdgeAnchor!==0&&this.owner.setY(E+this.owner.getY()-this.owner.getDrawableY()),this._bottomEdgeAnchor!==0&&this.owner.setY(u+this.owner.getY()-this.owner.getDrawableY()-this.owner.getHeight())}}}doStepPostEvents(e){}_convertCoords(e,i,s,h,t){return e!==e.getScene()?(t[0]=s,t[1]=h,t):i.convertCoords(s,h,0,t)}_convertInverseCoords(e,i,s,h,t){return e!==e.getScene()?(t[0]=s,t[1]=h,t):i.convertInverseCoords(s,h,0,t)}}_.AnchorRuntimeBehavior=R,_.registerBehavior("AnchorBehavior::AnchorBehavior",_.AnchorRuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(E){let o;(function(t){t[t.None=0]="None",t[t.WindowLeft=1]="WindowLeft",t[t.WindowRight=2]="WindowRight",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(o||(o={}));let n;(function(t){t[t.None=0]="None",t[t.WindowTop=1]="WindowTop",t[t.WindowBottom=2]="WindowBottom",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(n||(n={}));class R extends E.RuntimeBehavior{constructor(e,i,s){super(e,i,s);this._invalidDistances=!0;this._leftEdgeDistance=0;this._rightEdgeDistance=0;this._topEdgeDistance=0;this._bottomEdgeDistance=0;this._useLegacyBottomAndRightAnchors=!1;this._relativeToOriginalWindowSize=!!i.relativeToOriginalWindowSize,this._leftEdgeAnchor=i.leftEdgeAnchor,this._rightEdgeAnchor=i.rightEdgeAnchor,this._topEdgeAnchor=i.topEdgeAnchor,this._bottomEdgeAnchor=i.bottomEdgeAnchor,this._useLegacyBottomAndRightAnchors=i.useLegacyBottomAndRightAnchors===void 0?!0:i.useLegacyBottomAndRightAnchors}updateFromBehaviorData(e,i){return e.leftEdgeAnchor!==i.leftEdgeAnchor&&(this._leftEdgeAnchor=i.leftEdgeAnchor),e.rightEdgeAnchor!==i.rightEdgeAnchor&&(this._rightEdgeAnchor=i.rightEdgeAnchor),e.topEdgeAnchor!==i.topEdgeAnchor&&(this._topEdgeAnchor=i.topEdgeAnchor),e.bottomEdgeAnchor!==i.bottomEdgeAnchor&&(this._bottomEdgeAnchor=i.bottomEdgeAnchor),e.useLegacyTrajectory!==i.useLegacyTrajectory&&(this._useLegacyBottomAndRightAnchors=i.useLegacyBottomAndRightAnchors),e.relativeToOriginalWindowSize===i.relativeToOriginalWindowSize}onActivate(){this._invalidDistances=!0}doStepPreEvents(e){const i=E.staticArray(E.AnchorRuntimeBehavior.prototype.doStepPreEvents);let s=e.getUnrotatedViewportMinX(),h=e.getUnrotatedViewportMinY(),t=e.getUnrotatedViewportMaxX(),d=e.getUnrotatedViewportMaxY(),_=(t+s)/2,w=(d+h)/2,f=t-s,a=d-h;const b=e.getLayer(this.owner.getLayer());if(this._invalidDistances){this._relativeToOriginalWindowSize&&(s=e.getInitialUnrotatedViewportMinX(),h=e.getInitialUnrotatedViewportMinY(),t=e.getInitialUnrotatedViewportMaxX(),d=e.getInitialUnrotatedViewportMaxY(),_=(t+s)/2,w=(d+h)/2,f=t-s,a=d-h);const r=this._relativeToOriginalWindowSize?[this.owner.getDrawableX(),this.owner.getDrawableY()]:this._convertInverseCoords(e,b,this.owner.getDrawableX(),this.owner.getDrawableY(),i);this._leftEdgeAnchor===1?this._leftEdgeDistance=r[0]-s:this._leftEdgeAnchor===2?this._leftEdgeDistance=r[0]-t:this._leftEdgeAnchor===3?this._leftEdgeDistance=(r[0]-s)/f:this._leftEdgeAnchor===4&&(this._leftEdgeDistance=r[0]-_),this._topEdgeAnchor===1?this._topEdgeDistance=r[1]-h:this._topEdgeAnchor===2?this._topEdgeDistance=r[1]-d:this._topEdgeAnchor===3?this._topEdgeDistance=(r[1]-h)/a:this._topEdgeAnchor===4&&(this._topEdgeDistance=r[1]-w);const g=this._relativeToOriginalWindowSize?[this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight()]:this._convertInverseCoords(e,b,this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight(),i);this._rightEdgeAnchor===1?this._rightEdgeDistance=g[0]-s:this._rightEdgeAnchor===2?this._rightEdgeDistance=g[0]-t:this._rightEdgeAnchor===3?this._rightEdgeDistance=(g[0]-s)/f:this._rightEdgeAnchor===4&&(this._rightEdgeDistance=g[0]-_),this._bottomEdgeAnchor===1?this._bottomEdgeDistance=g[1]-h:this._bottomEdgeAnchor===2?this._bottomEdgeDistance=g[1]-d:this._bottomEdgeAnchor===3?this._bottomEdgeDistance=(g[1]-h)/a:this._bottomEdgeAnchor===4&&(this._bottomEdgeDistance=g[1]-w),this._invalidDistances=!1}else{let r=0,g=0,A=0,p=0;this._leftEdgeAnchor===1?r=s+this._leftEdgeDistance:this._leftEdgeAnchor===2?r=t+this._leftEdgeDistance:this._leftEdgeAnchor===3?r=s+this._leftEdgeDistance*f:this._leftEdgeAnchor===4&&(r=_+this._leftEdgeDistance),this._topEdgeAnchor===1?g=h+this._topEdgeDistance:this._topEdgeAnchor===2?g=d+this._topEdgeDistance:this._topEdgeAnchor===3?g=h+this._topEdgeDistance*a:this._topEdgeAnchor===4&&(g=w+this._topEdgeDistance),this._rightEdgeAnchor===1?A=s+this._rightEdgeDistance:this._rightEdgeAnchor===2?A=t+this._rightEdgeDistance:this._rightEdgeAnchor===3?A=s+this._rightEdgeDistance*f:this._rightEdgeAnchor===4&&(A=_+this._rightEdgeDistance),this._bottomEdgeAnchor===1?p=h+this._bottomEdgeDistance:this._bottomEdgeAnchor===2?p=d+this._bottomEdgeDistance:this._bottomEdgeAnchor===3?p=h+this._bottomEdgeDistance*a:this._bottomEdgeAnchor===4&&(p=w+this._bottomEdgeDistance);const D=this._convertCoords(e,b,r,g,i);let c=D[0],l=D[1];const P=this._convertCoords(e,b,A,p,i),W=P[0],u=P[1];if(this._useLegacyBottomAndRightAnchors)this._rightEdgeAnchor!==0&&this.owner.setWidth(W-c),this._bottomEdgeAnchor!==0&&this.owner.setHeight(u-l),this._leftEdgeAnchor!==0&&this.owner.setX(c+this.owner.getX()-this.owner.getDrawableX()),this._topEdgeAnchor!==0&&this.owner.setY(l+this.owner.getY()-this.owner.getDrawableY());else{if(this._rightEdgeAnchor!==0&&this._leftEdgeAnchor!==0){const m=W-c;this.owner.setX(this.owner.getX()===this.owner.getDrawableX()?c:c+(this.owner.getX()-this.owner.getDrawableX())*m/this.owner.getWidth()),this.owner.setWidth(m)}else this._leftEdgeAnchor!==0&&this.owner.setX(c+this.owner.getX()-this.owner.getDrawableX()),this._rightEdgeAnchor!==0&&this.owner.setX(W+this.owner.getX()-this.owner.getDrawableX()-this.owner.getWidth());if(this._bottomEdgeAnchor!==0&&this._topEdgeAnchor!==0){const m=u-l;this.owner.setY(this.owner.getY()===this.owner.getDrawableY()?l:l+(this.owner.getY()-this.owner.getDrawableY())*m/this.owner.getHeight()),this.owner.setHeight(m)}else this._topEdgeAnchor!==0&&this.owner.setY(l+this.owner.getY()-this.owner.getDrawableY()),this._bottomEdgeAnchor!==0&&this.owner.setY(u+this.owner.getY()-this.owner.getDrawableY()-this.owner.getHeight())}}}doStepPostEvents(e){}_convertCoords(e,i,s,h,t){return e!==e.getScene()?(t[0]=s,t[1]=h,t):i.convertCoords(s,h,0,t)}_convertInverseCoords(e,i,s,h,t){return e!==e.getScene()?(t[0]=s,t[1]=h,t):i.convertInverseCoords(s,h,0,t)}}E.AnchorRuntimeBehavior=R,E.registerBehavior("AnchorBehavior::AnchorBehavior",E.AnchorRuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=anchorruntimebehavior.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/AnchorBehavior/anchorruntimebehavior.ts"],
4
- "sourcesContent": ["/*\nGDevelop - Anchor Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n const enum HorizontalAnchor {\n None = 0,\n WindowLeft,\n WindowRight,\n Proportional,\n WindowCenter,\n }\n const enum VerticalAnchor {\n None = 0,\n WindowTop,\n WindowBottom,\n Proportional,\n WindowCenter,\n }\n\n export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n _relativeToOriginalWindowSize: any;\n _leftEdgeAnchor: HorizontalAnchor;\n _rightEdgeAnchor: HorizontalAnchor;\n _topEdgeAnchor: any;\n _bottomEdgeAnchor: any;\n _invalidDistances: boolean = true;\n _leftEdgeDistance: number = 0;\n _rightEdgeDistance: number = 0;\n _topEdgeDistance: number = 0;\n _bottomEdgeDistance: number = 0;\n _useLegacyBottomAndRightAnchors: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._relativeToOriginalWindowSize = !!behaviorData.relativeToOriginalWindowSize;\n this._leftEdgeAnchor = behaviorData.leftEdgeAnchor;\n this._rightEdgeAnchor = behaviorData.rightEdgeAnchor;\n this._topEdgeAnchor = behaviorData.topEdgeAnchor;\n this._bottomEdgeAnchor = behaviorData.bottomEdgeAnchor;\n this._useLegacyBottomAndRightAnchors =\n behaviorData.useLegacyBottomAndRightAnchors === undefined\n ? true\n : behaviorData.useLegacyBottomAndRightAnchors;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.leftEdgeAnchor !== newBehaviorData.leftEdgeAnchor) {\n this._leftEdgeAnchor = newBehaviorData.leftEdgeAnchor;\n }\n if (oldBehaviorData.rightEdgeAnchor !== newBehaviorData.rightEdgeAnchor) {\n this._rightEdgeAnchor = newBehaviorData.rightEdgeAnchor;\n }\n if (oldBehaviorData.topEdgeAnchor !== newBehaviorData.topEdgeAnchor) {\n this._topEdgeAnchor = newBehaviorData.topEdgeAnchor;\n }\n if (\n oldBehaviorData.bottomEdgeAnchor !== newBehaviorData.bottomEdgeAnchor\n ) {\n this._bottomEdgeAnchor = newBehaviorData.bottomEdgeAnchor;\n }\n if (\n oldBehaviorData.useLegacyTrajectory !==\n newBehaviorData.useLegacyTrajectory\n ) {\n this._useLegacyBottomAndRightAnchors =\n newBehaviorData.useLegacyBottomAndRightAnchors;\n }\n if (\n oldBehaviorData.relativeToOriginalWindowSize !==\n newBehaviorData.relativeToOriginalWindowSize\n ) {\n return false;\n }\n return true;\n }\n\n onActivate() {\n this._invalidDistances = true;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n let parentMinX = instanceContainer.getUnrotatedViewportMinX();\n let parentMinY = instanceContainer.getUnrotatedViewportMinY();\n let parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n let parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n let parentCenterX = (parentMaxX + parentMinX) / 2;\n let parentCenterY = (parentMaxY + parentMinY) / 2;\n let parentWidth = parentMaxX - parentMinX;\n let parentHeight = parentMaxY - parentMinY;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n if (this._invalidDistances) {\n if (this._relativeToOriginalWindowSize) {\n parentMinX = instanceContainer.getInitialUnrotatedViewportMinX();\n parentMinY = instanceContainer.getInitialUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getInitialUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getInitialUnrotatedViewportMaxY();\n parentCenterX = (parentMaxX + parentMinX) / 2;\n parentCenterY = (parentMaxY + parentMinY) / 2;\n parentWidth = parentMaxX - parentMinX;\n parentHeight = parentMaxY - parentMinY;\n }\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = this._convertCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n workingPoint\n );\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMinX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMaxX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n this._leftEdgeDistance = (topLeftPixel[0] - parentMinX) / parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._leftEdgeDistance = topLeftPixel[0] - parentCenterX;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n this._topEdgeDistance = topLeftPixel[1] - parentMinY;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._topEdgeDistance = topLeftPixel[1] - parentMaxY;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n this._topEdgeDistance = (topLeftPixel[1] - parentMinY) / parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._topEdgeDistance = topLeftPixel[1] - parentCenterY;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = this._convertCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n workingPoint\n );\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMinX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMaxX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n this._rightEdgeDistance =\n (bottomRightPixel[0] - parentMinX) / parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentCenterX;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMinY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMaxY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n this._bottomEdgeDistance =\n (bottomRightPixel[1] - parentMinY) / parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentCenterY;\n }\n\n this._invalidDistances = false;\n } else {\n //Move and resize the object if needed\n let leftPixel = 0;\n let topPixel = 0;\n let rightPixel = 0;\n let bottomPixel = 0;\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n leftPixel = parentMinX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n leftPixel = parentMaxX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n leftPixel = parentMinX + this._leftEdgeDistance * parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n leftPixel = parentCenterX + this._leftEdgeDistance;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n topPixel = parentMinY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n topPixel = parentMaxY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n topPixel = parentMinY + this._topEdgeDistance * parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n topPixel = parentCenterY + this._topEdgeDistance;\n }\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n rightPixel = parentMinX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n rightPixel = parentMaxX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n rightPixel = parentMinX + this._rightEdgeDistance * parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n rightPixel = parentCenterX + this._rightEdgeDistance;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n bottomPixel = parentMinY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n bottomPixel = parentMaxY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n bottomPixel = parentMinY + this._bottomEdgeDistance * parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n bottomPixel = parentCenterY + this._bottomEdgeDistance;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = this._convertInverseCoords(\n instanceContainer,\n layer,\n leftPixel,\n topPixel,\n workingPoint\n );\n const left = topLeftCoord[0];\n const top = topLeftCoord[1];\n\n const bottomRightCoord = this._convertInverseCoords(\n instanceContainer,\n layer,\n rightPixel,\n bottomPixel,\n workingPoint\n );\n const right = bottomRightCoord[0];\n const bottom = bottomRightCoord[1];\n\n // Compatibility with GD <= 5.0.133\n if (this._useLegacyBottomAndRightAnchors) {\n //Move and resize the object according to the anchors\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setWidth(right - left);\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setHeight(bottom - top);\n }\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n }\n // End of compatibility code\n else {\n // Resize if right and left anchors are set\n if (\n this._rightEdgeAnchor !== HorizontalAnchor.None &&\n this._leftEdgeAnchor !== HorizontalAnchor.None\n ) {\n const width = right - left;\n this.owner.setX(\n this.owner.getX() === this.owner.getDrawableX()\n ? left\n : // It uses the position of the origin relatively to the object\n // size to apply it with the new size.\n // This is the same as doing:\n // lerp(left, right, (this.owner.getX() - this.owner.getDrawableX() / this.owner.getWidth())\n // But, the division is done at the end to avoid rounding errors.\n left +\n ((this.owner.getX() - this.owner.getDrawableX()) * width) /\n this.owner.getWidth()\n );\n this.owner.setWidth(width);\n } else {\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n right +\n this.owner.getX() -\n this.owner.getDrawableX() -\n this.owner.getWidth()\n );\n }\n }\n // Resize if top and bottom anchors are set\n if (\n this._bottomEdgeAnchor !== VerticalAnchor.None &&\n this._topEdgeAnchor !== VerticalAnchor.None\n ) {\n const height = bottom - top;\n this.owner.setY(\n this.owner.getY() === this.owner.getDrawableY()\n ? top\n : top +\n ((this.owner.getY() - this.owner.getDrawableY()) * height) /\n this.owner.getHeight()\n );\n this.owner.setHeight(height);\n } else {\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n bottom +\n this.owner.getY() -\n this.owner.getDrawableY() -\n this.owner.getHeight()\n );\n }\n }\n }\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}\n\n private _convertCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertCoords(x, y, 0, result);\n }\n\n private _convertInverseCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertInverseCoords(x, y, 0, result);\n }\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,+BACA,iCACA,mCACA,qCALS,WAOX,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,6BACA,mCACA,mCACA,qCALS,WAQJ,eAAoC,GAAK,eAAgB,CAa9D,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GAZzC,uBAA6B,GAC7B,uBAA4B,EAC5B,wBAA6B,EAC7B,sBAA2B,EAC3B,yBAA8B,EAC9B,qCAA2C,GAQzC,KAAK,8BAAgC,CAAC,CAAC,EAAa,6BACpD,KAAK,gBAAkB,EAAa,eACpC,KAAK,iBAAmB,EAAa,gBACrC,KAAK,eAAiB,EAAa,cACnC,KAAK,kBAAoB,EAAa,iBACtC,KAAK,gCACH,EAAa,iCAAmC,OAC5C,GACA,EAAa,+BAGrB,uBAAuB,EAAiB,EAA0B,CAsBhE,MArBI,GAAgB,iBAAmB,EAAgB,gBACrD,MAAK,gBAAkB,EAAgB,gBAErC,EAAgB,kBAAoB,EAAgB,iBACtD,MAAK,iBAAmB,EAAgB,iBAEtC,EAAgB,gBAAkB,EAAgB,eACpD,MAAK,eAAiB,EAAgB,eAGtC,EAAgB,mBAAqB,EAAgB,kBAErD,MAAK,kBAAoB,EAAgB,kBAGzC,EAAgB,sBAChB,EAAgB,qBAEhB,MAAK,gCACH,EAAgB,gCAGlB,EAAgB,+BAChB,EAAgB,6BAOpB,YAAa,CACX,KAAK,kBAAoB,GAG3B,g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AK,MAAM,aAErB,KAAK,MAAM,UAAU,OAErB,AAAI,MAAK,iBAAmB,GAC1B,KAAK,MAAM,KACT,EAAM,KAAK,MAAM,OAAS,KAAK,MAAM,gBAGrC,KAAK,oBAAsB,GAC7B,KAAK,MAAM,KACT,EACE,KAAK,MAAM,OACX,KAAK,MAAM,eACX,KAAK,MAAM,eAQzB,iBAAiB,EAAkD,EAE3D,eACN,EACA,EACA,EACA,EACA,EACA,CAGA,MADE,KAAsB,EAAkB,WAExC,GAAO,GAAK,EACZ,EAAO,GAAK,EACL,GAEF,EAAM,cAAc,EAAG,EAAG,EAAG,GAG9B,sBACN,EACA,EACA,EACA,EACA,EACA,CAGA,MADE,KAAsB,EAAkB,WAExC,GAAO,GAAK,EACZ,EAAO,GAAK,EACL,GAEF,EAAM,qBAAqB,EAAG,EAAG,EAAG,IA7VxC,EAAM,wBAgWb,EAAK,iBACH,iCACA,EAAK,yBAlXC",
4
+ "sourcesContent": ["/*\nGDevelop - Anchor Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n const enum HorizontalAnchor {\n None = 0,\n WindowLeft,\n WindowRight,\n Proportional,\n WindowCenter,\n }\n const enum VerticalAnchor {\n None = 0,\n WindowTop,\n WindowBottom,\n Proportional,\n WindowCenter,\n }\n\n export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n _relativeToOriginalWindowSize: any;\n _leftEdgeAnchor: HorizontalAnchor;\n _rightEdgeAnchor: HorizontalAnchor;\n _topEdgeAnchor: any;\n _bottomEdgeAnchor: any;\n _invalidDistances: boolean = true;\n _leftEdgeDistance: number = 0;\n _rightEdgeDistance: number = 0;\n _topEdgeDistance: number = 0;\n _bottomEdgeDistance: number = 0;\n _useLegacyBottomAndRightAnchors: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._relativeToOriginalWindowSize = !!behaviorData.relativeToOriginalWindowSize;\n this._leftEdgeAnchor = behaviorData.leftEdgeAnchor;\n this._rightEdgeAnchor = behaviorData.rightEdgeAnchor;\n this._topEdgeAnchor = behaviorData.topEdgeAnchor;\n this._bottomEdgeAnchor = behaviorData.bottomEdgeAnchor;\n this._useLegacyBottomAndRightAnchors =\n behaviorData.useLegacyBottomAndRightAnchors === undefined\n ? true\n : behaviorData.useLegacyBottomAndRightAnchors;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.leftEdgeAnchor !== newBehaviorData.leftEdgeAnchor) {\n this._leftEdgeAnchor = newBehaviorData.leftEdgeAnchor;\n }\n if (oldBehaviorData.rightEdgeAnchor !== newBehaviorData.rightEdgeAnchor) {\n this._rightEdgeAnchor = newBehaviorData.rightEdgeAnchor;\n }\n if (oldBehaviorData.topEdgeAnchor !== newBehaviorData.topEdgeAnchor) {\n this._topEdgeAnchor = newBehaviorData.topEdgeAnchor;\n }\n if (\n oldBehaviorData.bottomEdgeAnchor !== newBehaviorData.bottomEdgeAnchor\n ) {\n this._bottomEdgeAnchor = newBehaviorData.bottomEdgeAnchor;\n }\n if (\n oldBehaviorData.useLegacyTrajectory !==\n newBehaviorData.useLegacyTrajectory\n ) {\n this._useLegacyBottomAndRightAnchors =\n newBehaviorData.useLegacyBottomAndRightAnchors;\n }\n if (\n oldBehaviorData.relativeToOriginalWindowSize !==\n newBehaviorData.relativeToOriginalWindowSize\n ) {\n return false;\n }\n return true;\n }\n\n onActivate() {\n this._invalidDistances = true;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n let parentMinX = instanceContainer.getUnrotatedViewportMinX();\n let parentMinY = instanceContainer.getUnrotatedViewportMinY();\n let parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n let parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n let parentCenterX = (parentMaxX + parentMinX) / 2;\n let parentCenterY = (parentMaxY + parentMinY) / 2;\n let parentWidth = parentMaxX - parentMinX;\n let parentHeight = parentMaxY - parentMinY;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n if (this._invalidDistances) {\n if (this._relativeToOriginalWindowSize) {\n parentMinX = instanceContainer.getInitialUnrotatedViewportMinX();\n parentMinY = instanceContainer.getInitialUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getInitialUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getInitialUnrotatedViewportMaxY();\n parentCenterX = (parentMaxX + parentMinX) / 2;\n parentCenterY = (parentMaxY + parentMinY) / 2;\n parentWidth = parentMaxX - parentMinX;\n parentHeight = parentMaxY - parentMinY;\n }\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = this._relativeToOriginalWindowSize\n ? [this.owner.getDrawableX(), this.owner.getDrawableY()]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n workingPoint\n );\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMinX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMaxX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n this._leftEdgeDistance = (topLeftPixel[0] - parentMinX) / parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._leftEdgeDistance = topLeftPixel[0] - parentCenterX;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n this._topEdgeDistance = topLeftPixel[1] - parentMinY;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._topEdgeDistance = topLeftPixel[1] - parentMaxY;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n this._topEdgeDistance = (topLeftPixel[1] - parentMinY) / parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._topEdgeDistance = topLeftPixel[1] - parentCenterY;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = this._relativeToOriginalWindowSize\n ? [\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n ]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n workingPoint\n );\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMinX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMaxX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n this._rightEdgeDistance =\n (bottomRightPixel[0] - parentMinX) / parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentCenterX;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMinY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMaxY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n this._bottomEdgeDistance =\n (bottomRightPixel[1] - parentMinY) / parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentCenterY;\n }\n\n this._invalidDistances = false;\n } else {\n //Move and resize the object if needed\n let leftPixel = 0;\n let topPixel = 0;\n let rightPixel = 0;\n let bottomPixel = 0;\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n leftPixel = parentMinX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n leftPixel = parentMaxX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n leftPixel = parentMinX + this._leftEdgeDistance * parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n leftPixel = parentCenterX + this._leftEdgeDistance;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n topPixel = parentMinY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n topPixel = parentMaxY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n topPixel = parentMinY + this._topEdgeDistance * parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n topPixel = parentCenterY + this._topEdgeDistance;\n }\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n rightPixel = parentMinX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n rightPixel = parentMaxX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n rightPixel = parentMinX + this._rightEdgeDistance * parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n rightPixel = parentCenterX + this._rightEdgeDistance;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n bottomPixel = parentMinY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n bottomPixel = parentMaxY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n bottomPixel = parentMinY + this._bottomEdgeDistance * parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n bottomPixel = parentCenterY + this._bottomEdgeDistance;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = this._convertCoords(\n instanceContainer,\n layer,\n leftPixel,\n topPixel,\n workingPoint\n );\n let left = topLeftCoord[0];\n let top = topLeftCoord[1];\n\n const bottomRightCoord = this._convertCoords(\n instanceContainer,\n layer,\n rightPixel,\n bottomPixel,\n workingPoint\n );\n const right = bottomRightCoord[0];\n const bottom = bottomRightCoord[1];\n\n // Compatibility with GD <= 5.0.133\n if (this._useLegacyBottomAndRightAnchors) {\n //Move and resize the object according to the anchors\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setWidth(right - left);\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setHeight(bottom - top);\n }\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n }\n // End of compatibility code\n else {\n // Resize if right and left anchors are set\n if (\n this._rightEdgeAnchor !== HorizontalAnchor.None &&\n this._leftEdgeAnchor !== HorizontalAnchor.None\n ) {\n const width = right - left;\n this.owner.setX(\n this.owner.getX() === this.owner.getDrawableX()\n ? left\n : // It uses the position of the origin relatively to the object\n // size to apply it with the new size.\n // This is the same as doing:\n // lerp(left, right, (this.owner.getX() - this.owner.getDrawableX() / this.owner.getWidth())\n // But, the division is done at the end to avoid rounding errors.\n left +\n ((this.owner.getX() - this.owner.getDrawableX()) * width) /\n this.owner.getWidth()\n );\n this.owner.setWidth(width);\n } else {\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n right +\n this.owner.getX() -\n this.owner.getDrawableX() -\n this.owner.getWidth()\n );\n }\n }\n // Resize if top and bottom anchors are set\n if (\n this._bottomEdgeAnchor !== VerticalAnchor.None &&\n this._topEdgeAnchor !== VerticalAnchor.None\n ) {\n const height = bottom - top;\n this.owner.setY(\n this.owner.getY() === this.owner.getDrawableY()\n ? top\n : top +\n ((this.owner.getY() - this.owner.getDrawableY()) * height) /\n this.owner.getHeight()\n );\n this.owner.setHeight(height);\n } else {\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n bottom +\n this.owner.getY() -\n this.owner.getDrawableY() -\n this.owner.getHeight()\n );\n }\n }\n }\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}\n\n private _convertCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertCoords(x, y, 0, result);\n }\n\n private _convertInverseCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertInverseCoords(x, y, 0, result);\n }\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,+BACA,iCACA,mCACA,qCALS,WAOX,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,6BACA,mCACA,mCACA,qCALS,WAQJ,eAAoC,GAAK,eAAgB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,EAAO,GAAK,EACL,GAEF,EAAM,cAAc,EAAG,EAAG,EAAG,GAG9B,sBACN,EACA,EACA,EACA,EACA,EACA,CAGA,MADE,KAAsB,EAAkB,WAExC,GAAO,GAAK,EACZ,EAAO,GAAK,EACL,GAEF,EAAM,qBAAqB,EAAG,EAAG,EAAG,IApWxC,EAAM,wBAuWb,EAAK,iBACH,iCACA,EAAK,yBAzXC",
6
6
  "names": []
7
7
  }
@@ -34,18 +34,18 @@ module.exports = {
34
34
  extension
35
35
  .addAction(
36
36
  'LoadDialogueFromSceneVariable',
37
- _('Load dialogue Tree from a scene variable'),
37
+ _('Load dialogue tree from a scene variable'),
38
38
  _(
39
- 'Load a dialogue data object - Yarn json format, stored in a scene variable. Use this command to load all the Dialogue data at the beginning of the game.'
39
+ 'Load a dialogue data object - Yarn JSON format, stored in a scene variable. Use this command to load all the Dialogue data at the beginning of the game.'
40
40
  ),
41
- _('Load dialogue data from Scene variable _PARAM0_'),
41
+ _('Load dialogue data from scene variable _PARAM0_'),
42
42
  '',
43
43
  'JsPlatform/Extensions/yarn32.png',
44
44
  'JsPlatform/Extensions/yarn32.png'
45
45
  )
46
46
  .addParameter(
47
47
  'scenevar',
48
- _('Scene variable that holds the Yarn Json data'),
48
+ _('Scene variable that holds the Yarn JSON data'),
49
49
  '',
50
50
  false
51
51
  )
@@ -57,11 +57,11 @@ module.exports = {
57
57
  extension
58
58
  .addAction(
59
59
  'LoadDialogueFromJsonFile',
60
- _('Load dialogue Tree from a Json File'),
60
+ _('Load dialogue tree from a JSON file'),
61
61
  _(
62
- 'Load a dialogue data object - Yarn json format, stored in a Json file. Use this command to load all the Dialogue data at the beginning of the game.'
62
+ 'Load a dialogue data object - Yarn JSON format, stored in a JSON file. Use this command to load all the Dialogue data at the beginning of the game.'
63
63
  ),
64
- _('Load dialogue data from json file _PARAM1_'),
64
+ _('Load dialogue data from JSON file _PARAM1_'),
65
65
  '',
66
66
  'JsPlatform/Extensions/yarn32.png',
67
67
  'JsPlatform/Extensions/yarn32.png'
@@ -69,7 +69,7 @@ module.exports = {
69
69
  .addCodeOnlyParameter('currentScene', '')
70
70
  .addParameter(
71
71
  'jsonResource',
72
- _('Json file that holds the Yarn Json data'),
72
+ _('JSON file that holds the Yarn JSON data'),
73
73
  '',
74
74
  false
75
75
  )
@@ -125,11 +125,11 @@ module.exports = {
125
125
  extension
126
126
  .addAction(
127
127
  'ConfirmSelectOption',
128
- _('Confirm selected Option'),
128
+ _('Confirm selected option'),
129
129
  _(
130
130
  'Set the selected option as confirmed, which will validate it and go forward to the next node. Use other actions to select options (see "select next option" and "Select previous option").'
131
131
  ),
132
- _('Confirm selected Option'),
132
+ _('Confirm selected option'),
133
133
  '',
134
134
  'JsPlatform/Extensions/yarn32.png',
135
135
  'JsPlatform/Extensions/yarn32.png'
@@ -140,11 +140,11 @@ module.exports = {
140
140
  extension
141
141
  .addAction(
142
142
  'SelectNextOption',
143
- _('Select next Option'),
143
+ _('Select next option'),
144
144
  _(
145
- 'Select next Option (add 1 to selected option number). Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
145
+ 'Select next option (add 1 to selected option number). Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
146
146
  ),
147
- _('Select next Option'),
147
+ _('Select next option'),
148
148
  '',
149
149
  'JsPlatform/Extensions/yarn32.png',
150
150
  'JsPlatform/Extensions/yarn32.png'
@@ -155,11 +155,11 @@ module.exports = {
155
155
  extension
156
156
  .addAction(
157
157
  'SelectPreviousOption',
158
- _('Select previous Option'),
158
+ _('Select previous option'),
159
159
  _(
160
- 'Select previous Option (subtract 1 from selected option number). Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
160
+ 'Select previous option (subtract 1 from selected option number). Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
161
161
  ),
162
- _('Select previous Option'),
162
+ _('Select previous option'),
163
163
  '',
164
164
  'JsPlatform/Extensions/yarn32.png',
165
165
  'JsPlatform/Extensions/yarn32.png'
@@ -225,8 +225,8 @@ module.exports = {
225
225
  'JsPlatform/Extensions/yarn32.png',
226
226
  'JsPlatform/Extensions/yarn32.png'
227
227
  )
228
- .addParameter('string', _('State Variable Name'), '', false)
229
- .addParameter('string', _('Variable string value'), '', false)
228
+ .addParameter('string', _('State variable name'), '', false)
229
+ .addParameter('string', _('New value'), '', false)
230
230
  .getCodeExtraInformation()
231
231
  .setFunctionName('gdjs.dialogueTree.setVariable');
232
232
 
@@ -242,8 +242,8 @@ module.exports = {
242
242
  'JsPlatform/Extensions/yarn32.png',
243
243
  'JsPlatform/Extensions/yarn32.png'
244
244
  )
245
- .addParameter('string', _('State Variable Name'), '', false)
246
- .addParameter('expression', _('Variable number value'), '', true)
245
+ .addParameter('string', _('State variable name'), '', false)
246
+ .addParameter('expression', _('New value'), '', true)
247
247
  .getCodeExtraInformation()
248
248
  .setFunctionName('gdjs.dialogueTree.setVariable');
249
249
 
@@ -259,8 +259,8 @@ module.exports = {
259
259
  'JsPlatform/Extensions/yarn32.png',
260
260
  'JsPlatform/Extensions/yarn32.png'
261
261
  )
262
- .addParameter('string', _('State Variable Name'), '', false)
263
- .addParameter('trueorfalse', _('Variable boolean value'), '', false)
262
+ .addParameter('string', _('State variable name'), '', false)
263
+ .addParameter('trueorfalse', _('New value'), '', false)
264
264
  .getCodeExtraInformation()
265
265
  .setFunctionName('gdjs.dialogueTree.setVariable');
266
266
 
@@ -336,9 +336,9 @@ module.exports = {
336
336
  extension
337
337
  .addStrExpression(
338
338
  'Option',
339
- _('Get the text of an option from an Options line type'),
339
+ _('Get the text of an option from an options line type'),
340
340
  _(
341
- "Get the text of an option from an Options line type, using the option's Number. The numbers start from 0."
341
+ "Get the text of an option from an options line type, using the option's Number. The numbers start from 0."
342
342
  ),
343
343
  '',
344
344
  'JsPlatform/Extensions/yarn32.png'
@@ -350,9 +350,9 @@ module.exports = {
350
350
  extension
351
351
  .addStrExpression(
352
352
  'HorizontalOptionsList',
353
- _('Get a Horizontal list of options from the Options line type'),
353
+ _('Get a Horizontal list of options from the options line type'),
354
354
  _(
355
- "Get the text of all available options from an Options line type as a horizontal list. You can also pass the selected option's cursor string, which by default is ->"
355
+ "Get the text of all available options from an options line type as a horizontal list. You can also pass the selected option's cursor string, which by default is ->"
356
356
  ),
357
357
  '',
358
358
  'JsPlatform/Extensions/yarn32.png'
@@ -365,9 +365,9 @@ module.exports = {
365
365
  extension
366
366
  .addStrExpression(
367
367
  'VerticalOptionsList',
368
- _('Get a Vertical list of options from the Options line type'),
368
+ _('Get a Vertical list of options from the options line type'),
369
369
  _(
370
- "Get the text of all available options from an Options line type as a vertical list. You can also pass the selected option's cursor string, which by default is ->"
370
+ "Get the text of all available options from an options line type as a vertical list. You can also pass the selected option's cursor string, which by default is ->"
371
371
  ),
372
372
  '',
373
373
  'JsPlatform/Extensions/yarn32.png'
@@ -507,14 +507,26 @@ module.exports = {
507
507
  extension
508
508
  .addExpression(
509
509
  'Variable',
510
- _('Get dialogue state value'),
511
- _('Get dialogue state value'),
510
+ _('Get the number stored in a dialogue state variable'),
511
+ _('Get the number stored in a dialogue state variable'),
512
512
  '',
513
513
  'JsPlatform/Extensions/yarn32.png'
514
514
  )
515
- .addParameter('string', _('Variable Name'), '', false)
515
+ .addParameter('string', _('Dialogue state variable name'), '', false)
516
516
  .getCodeExtraInformation()
517
- .setFunctionName('gdjs.dialogueTree.getVariable');
517
+ .setFunctionName('gdjs.dialogueTree.getVariableAsNumber');
518
+
519
+ extension
520
+ .addStrExpression(
521
+ 'VariableString',
522
+ _('Get the string stored in a dialogue state variable'),
523
+ _('Get the string stored in a dialogue state variable'),
524
+ '',
525
+ 'JsPlatform/Extensions/yarn32.png'
526
+ )
527
+ .addParameter('string', _('Dialogue state variable name'), '', false)
528
+ .getCodeExtraInformation()
529
+ .setFunctionName('gdjs.dialogueTree.getVariableAsString');
518
530
 
519
531
  extension
520
532
  .addCondition(
@@ -1,3 +1,3 @@
1
- var gdjs;(function(e){const s=new e.Logger("Dialogue tree");e.dialogueTree={},e.dialogueTree.runner=new bondage.Runner,e.dialogueTree.loadFromSceneVariable=function(i,t){this.runner=e.dialogueTree.runner;try{this.yarnData=JSON.parse(i.getAsString()),this.runner.load(this.yarnData),t&&t.length>0&&e.dialogueTree.startFrom(t)}catch(a){s.error("Error while loading from scene variable: ",a)}},e.dialogueTree.loadFromJsonFile=function(i,t,a){i.getGame().getJsonManager().loadJson(t,function(r,n){if(r)s.error("An error happened while loading JSON resource:",r);else{if(!n)return;e.dialogueTree.yarnData=n;try{e.dialogueTree.runner.load(e.dialogueTree.yarnData)}catch(o){s.error("An error happened while loading parsing the dialogue tree data:",o)}a&&a.length>0&&e.dialogueTree.startFrom(a)}})},e.dialogueTree.stopRunningDialogue=function(){this.dialogueIsRunning&&(this.dialogueIsRunning=!1),this.dialogueData&&(this.dialogueData=null),this.dialogueText="",this.clipTextEnd=0},e.dialogueTree.isRunning=function(){return this.dialogueIsRunning&&!this.dialogueData&&this.dialogueText&&this.clipTextEnd>=this.dialogueText.length&&(this.dialogueIsRunning=!1),this.dialogueIsRunning},e.dialogueTree.scrollClippedText=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning)){if(e.dialogueTree._isLineTypeCommand()&&this.dialogueDataType==="text"&&this.dialogueBranchTitle===this.dialogueData.data.title&&this.lineNum===this.dialogueData.lineNum&&e.dialogueTree.hasClippedScrollingCompleted()){e.dialogueTree.goToNextDialogueLine();return}this.dialogueText&&this.dialogueDataType==="text"&&this.clipTextEnd<this.dialogueText.length&&(this.clipTextEnd+=1)}},e.dialogueTree.completeClippedTextScrolling=function(){this.pauseScrolling||!this.dialogueIsRunning||!this.dialogueText||this.dialogueDataType!=="text"||(this.clipTextEnd=this.dialogueText.length)},e.dialogueTree.hasClippedScrollingCompleted=function(){return!this.dialogueIsRunning||this.dialogueDataType===""?!1:this.dialogueData&&this.dialogueText.length>0&&this.clipTextEnd>=this.dialogueText.length?(e.dialogueTree.getVariable("debug")&&s.warn("Scroll completed:",this.clipTextEnd,"/",this.dialogueText.length),!0):!1},e.dialogueTree.getClippedLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText.substring(0,this.clipTextEnd+1):""},e.dialogueTree.getLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText:""},e.dialogueTree.commandParametersCount=function(){return this.commandParameters&&this.commandParameters.length>1?this.commandParameters.length-1:0},e.dialogueTree.getCommandParameter=function(i){if(i===-1&&this.commandParameters.length>0)return this.commandParameters[0];if(this.commandParameters&&this.commandParameters.length>=i+1){const t=this.commandParameters[i+1];return t||""}return""},e.dialogueTree.isCommandCalled=function(i){if(!this.dialogueIsRunning)return!1;const t=e.dialogueTree.commandCalls,a=e.dialogueTree.clipTextEnd,r=e.dialogueTree.dialogueText;return this.pauseScrolling||!t?!1:this.commandCalls.some(function(n,o){if(a!==0&&a<n.time)return!1;if(n.cmd==="wait"&&(a===0||a!==r.length)&&(e.dialogueTree.pauseScrolling=!0,setTimeout(function(){e.dialogueTree.pauseScrolling=!1,t.splice(o,1),e.dialogueTree.getVariable("debug")&&s.info("CMD:",n)},parseInt(n.params[1],10))),n.cmd===i)return e.dialogueTree.commandParameters=n.params,t.splice(o,1),e.dialogueTree.getVariable("debug")&&s.info("CMD:",n),!0})},e.dialogueTree._normalizedOptionIndex=function(i){return i>=this.options.length&&(i=this.options.length-1),i<0&&(i=0),i},e.dialogueTree._cycledOptionIndex=function(i){return i>=this.options.length&&(i=0),i<0&&(i=this.options.length-1),i},e.dialogueTree.getLineOption=function(i){return!this.dialogueIsRunning||!this.options.length?[]:(i=e.dialogueTree._normalizedOptionIndex(i),this.options[i])},e.dialogueTree.getLineOptionsText=function(i,t){if(!this.dialogueIsRunning||!this.options.length)return"";let a="";return this.options.forEach(function(r,n){n===e.dialogueTree.selectedOption?a+=i:a+=i.replace(/.*/g," "),a+=r,t&&(a+=`
2
- `)}),a},e.dialogueTree.getLineOptionsTextHorizontal=function(i){return this.getLineOptionsText(i,!1)},e.dialogueTree.getLineOptionsTextVertical=function(i){return this.getLineOptionsText(i,!0)},e.dialogueTree.getLineOptionsCount=function(){return this.dialogueIsRunning&&this.options.length?this.optionsCount:0},e.dialogueTree.confirmSelectOption=function(){if(!!this.dialogueIsRunning&&this.dialogueData.select&&!this.selectedOptionUpdated&&this.selectedOption!==-1){this.commandCalls=[];try{this.dialogueData.select(this.selectedOption),this.dialogueData=this.dialogue.next().value,e.dialogueTree.goToNextDialogueLine()}catch(i){s.error("An error happened when trying to access the dialogue branch!",i)}}},e.dialogueTree.selectNextOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption+=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectPreviousOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption-=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectOption=function(i){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption=e.dialogueTree._normalizedOptionIndex(i),this.selectedOptionUpdated=!0)},e.dialogueTree.getSelectedOption=function(){if(!!this.dialogueIsRunning)return this.dialogueData.select?this.selectedOption:0},e.dialogueTree.hasSelectedOptionChanged=function(){return this.selectedOptionUpdated?(this.selectedOptionUpdated=!1,this.selectedOption===-1&&(this.selectedOption=0),!0):!1},e.dialogueTree.isDialogueLineType=function(i){if(!this.dialogueIsRunning)return!1;if(this.commandCalls&&i==="command"){if(this.commandCalls.some(function(t){return e.dialogueTree.clipTextEnd>t.time&&t.cmd==="wait"}))return!this.pauseScrolling;if(this.commandCalls.length>0&&this.commandParameters.length>0)return!0}return this.dialogueDataType===i},e.dialogueTree.hasDialogueBranch=function(i){return this.runner&&this.runner.yarnNodes&&Object.keys(this.runner.yarnNodes).some(function(t){return t===i})},e.dialogueTree.startFrom=function(i){this.runner=e.dialogueTree.runner,!!this.hasDialogueBranch(i)&&(this.optionsCount=0,this.options=[],this.tagParameters=[],this.dialogue=this.runner.run(i),this.dialogueText="",this.clipTextEnd=0,this.commandCalls=[],this.commandParameters=[],this.pauseScrolling=!1,this.dialogueData=this.dialogue.next().value,this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,e.dialogueTree._isLineTypeText()?this.dialogueDataType="text":e.dialogueTree._isLineTypeOptions()?this.dialogueDataType="options":this.dialogueDataType="command",this.dialogueIsRunning=!0,e.dialogueTree.goToNextDialogueLine())},e.dialogueTree._isLineTypeText=function(){return this.dialogueData instanceof bondage.TextResult},e.dialogueTree._isLineTypeOptions=function(){return this.dialogueData instanceof bondage.OptionsResult},e.dialogueTree._isLineTypeCommand=function(){return this.dialogueData instanceof bondage.CommandResult},e.dialogueTree.goToNextDialogueLine=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning))if(this.optionsCount=0,this.selectedOption=-1,this.selectedOptionUpdated=!1,e.dialogueTree.getVariable("debug")&&s.info("Parsing:",this.dialogueData),!this.dialogueData)e.dialogueTree.stopRunningDialogue();else if(e.dialogueTree._isLineTypeText())this.lineNum===this.dialogueData.lineNum&&this.dialogueBranchTitle===this.dialogueData.data.title?(this.clipTextEnd=this.dialogueText.length-1,this.dialogueText+=(this.dialogueText===""?"":" ")+this.dialogueData.text):(this.clipTextEnd=0,this.dialogueText=this.dialogueData.text),this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,this.dialogueDataType="text",this.dialogueData=this.dialogue.next().value;else if(e.dialogueTree._isLineTypeOptions())this.commandCalls=[],this.dialogueDataType="options",this.dialogueText="",this.clipTextEnd=0,this.optionsCount=this.dialogueData.options.length,this.options=this.dialogueData.options,this.selectedOptionUpdated=!0;else if(e.dialogueTree._isLineTypeCommand()){this.dialogueDataType="command";const i=this.dialogueData.text.split(" "),t=this.commandCalls.length&&this.commandCalls[this.commandCalls.length-1].cmd==="wait"?1:0;this.commandCalls.push({cmd:i[0],params:i,time:this.dialogueText.length+t}),this.dialogueData=this.dialogue.next().value,e.dialogueTree.goToNextDialogueLine()}else this.dialogueDataType="unknown"},e.dialogueTree.getBranchTitle=function(){return this.dialogueIsRunning?this.dialogueBranchTitle:""},e.dialogueTree.branchTitleIs=function(i){return this.dialogueIsRunning?this.dialogueBranchTitle===i:!1},e.dialogueTree.getBranchTags=function(){return this.dialogueIsRunning?this.dialogueBranchTags.join(","):""},e.dialogueTree.getBranchTag=function(i){return this.dialogueIsRunning&&this.dialogueBranchTags.length?(i>this.dialogueBranchTags.length-1&&(i=this.dialogueBranchTags.length-1),this.dialogueBranchTags[i]):""},e.dialogueTree.branchContainsTag=function(i){return this.tagParameters=[],this.dialogueIsRunning&&this.dialogueBranchTags.length?this.dialogueBranchTags.some(function(t){const a=t.match(/([^\(]+)\(([^\)]+)\)/i);return e.dialogueTree.tagParameters=a?a[2].split(","):[],a?a[1]===i:t===i}):!1},e.dialogueTree.getTagParameter=function(i){if(this.dialogueIsRunning&&this.tagParameters.length>=i){const t=this.tagParameters[i];return t||""}return""},e.dialogueTree.getVisitedBranchTitles=function(){return this.dialogueIsRunning?Object.keys(this.runner.visited).join(","):""},e.dialogueTree.branchTitleHasBeenVisited=function(i){return i||(i=this.dialogueBranchTitle),Object.keys(this.runner.visited).includes(i)&&this.runner.visited[i]},e.dialogueTree.getBranchText=function(){return this.dialogueIsRunning?this.dialogueBranchBody:""},e.dialogueTree.getVariable=function(i){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i):""},e.dialogueTree.compareVariable=function(i,t){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i)===t:!1},e.dialogueTree.setVariable=function(i,t){this.runner.variables&&this.runner.variables.set(i,t)},e.dialogueTree.saveState=function(i){const t={variables:e.dialogueTree.runner.variables.data,visited:e.dialogueTree.runner.visited};i.fromJSObject(t)},e.dialogueTree.loadState=function(i){const t=i.toJSObject();if(!t){s.error("Load state variable is empty:",i);return}try{e.dialogueTree.runner.visited=t.visited,e.dialogueTree.runner.variables.data={},Object.keys(t.variables).forEach(function(a){const r=t.variables[a];e.dialogueTree.runner.variables.set(a,r)})}catch(a){s.error("Failed to load state from variable:",i,a)}},e.dialogueTree.clearState=function(){e.dialogueTree.runner.visited={},e.dialogueTree.runner.variables.data={}}})(gdjs||(gdjs={}));
1
+ var gdjs;(function(e){const n=new e.Logger("Dialogue tree");e.dialogueTree={},e.dialogueTree.runner=new bondage.Runner,e.dialogueTree.loadFromSceneVariable=function(i,t){this.runner=e.dialogueTree.runner;try{this.yarnData=JSON.parse(i.getAsString()),this.runner.load(this.yarnData),t&&t.length>0&&e.dialogueTree.startFrom(t)}catch(a){n.error("Error while loading from scene variable: ",a)}},e.dialogueTree.loadFromJsonFile=function(i,t,a){i.getGame().getJsonManager().loadJson(t,function(s,r){if(s)n.error("An error happened while loading JSON resource:",s);else{if(!r)return;e.dialogueTree.yarnData=r;try{e.dialogueTree.runner.load(e.dialogueTree.yarnData)}catch(o){n.error("An error happened while loading parsing the dialogue tree data:",o)}a&&a.length>0&&e.dialogueTree.startFrom(a)}})},e.dialogueTree.stopRunningDialogue=function(){this.dialogueIsRunning&&(this.dialogueIsRunning=!1),this.dialogueData&&(this.dialogueData=null),this.dialogueText="",this.clipTextEnd=0},e.dialogueTree.isRunning=function(){return this.dialogueIsRunning&&!this.dialogueData&&this.dialogueText&&this.clipTextEnd>=this.dialogueText.length&&(this.dialogueIsRunning=!1),this.dialogueIsRunning},e.dialogueTree.scrollClippedText=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning)){if(e.dialogueTree._isLineTypeCommand()&&this.dialogueDataType==="text"&&this.dialogueBranchTitle===this.dialogueData.data.title&&this.lineNum===this.dialogueData.lineNum&&e.dialogueTree.hasClippedScrollingCompleted()){e.dialogueTree.goToNextDialogueLine();return}this.dialogueText&&this.dialogueDataType==="text"&&this.clipTextEnd<this.dialogueText.length&&(this.clipTextEnd+=1)}},e.dialogueTree.completeClippedTextScrolling=function(){this.pauseScrolling||!this.dialogueIsRunning||!this.dialogueText||this.dialogueDataType!=="text"||(this.clipTextEnd=this.dialogueText.length)},e.dialogueTree.hasClippedScrollingCompleted=function(){return!this.dialogueIsRunning||this.dialogueDataType===""?!1:this.dialogueData&&this.dialogueText.length>0&&this.clipTextEnd>=this.dialogueText.length?(e.dialogueTree.getVariable("debug")&&n.warn("Scroll completed:",this.clipTextEnd,"/",this.dialogueText.length),!0):!1},e.dialogueTree.getClippedLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText.substring(0,this.clipTextEnd+1):""},e.dialogueTree.getLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText:""},e.dialogueTree.commandParametersCount=function(){return this.commandParameters&&this.commandParameters.length>1?this.commandParameters.length-1:0},e.dialogueTree.getCommandParameter=function(i){if(i===-1&&this.commandParameters.length>0)return this.commandParameters[0];if(this.commandParameters&&this.commandParameters.length>=i+1){const t=this.commandParameters[i+1];return t||""}return""},e.dialogueTree.isCommandCalled=function(i){if(!this.dialogueIsRunning)return!1;const t=e.dialogueTree.commandCalls,a=e.dialogueTree.clipTextEnd,s=e.dialogueTree.dialogueText;return this.pauseScrolling||!t?!1:this.commandCalls.some(function(r,o){if(a!==0&&a<r.time)return!1;if(r.cmd==="wait"&&(a===0||a!==s.length)&&(e.dialogueTree.pauseScrolling=!0,setTimeout(function(){e.dialogueTree.pauseScrolling=!1,t.splice(o,1),e.dialogueTree.getVariable("debug")&&n.info("CMD:",r)},parseInt(r.params[1],10))),r.cmd===i)return e.dialogueTree.commandParameters=r.params,t.splice(o,1),e.dialogueTree.getVariable("debug")&&n.info("CMD:",r),!0})},e.dialogueTree._normalizedOptionIndex=function(i){return i>=this.options.length&&(i=this.options.length-1),i<0&&(i=0),i},e.dialogueTree._cycledOptionIndex=function(i){return i>=this.options.length&&(i=0),i<0&&(i=this.options.length-1),i},e.dialogueTree.getLineOption=function(i){return!this.dialogueIsRunning||!this.options.length?[]:(i=e.dialogueTree._normalizedOptionIndex(i),this.options[i])},e.dialogueTree.getLineOptionsText=function(i,t){if(!this.dialogueIsRunning||!this.options.length)return"";let a="";return this.options.forEach(function(s,r){r===e.dialogueTree.selectedOption?a+=i:a+=i.replace(/.*/g," "),a+=s,t&&(a+=`
2
+ `)}),a},e.dialogueTree.getLineOptionsTextHorizontal=function(i){return this.getLineOptionsText(i,!1)},e.dialogueTree.getLineOptionsTextVertical=function(i){return this.getLineOptionsText(i,!0)},e.dialogueTree.getLineOptionsCount=function(){return this.dialogueIsRunning&&this.options.length?this.optionsCount:0},e.dialogueTree.confirmSelectOption=function(){if(!!this.dialogueIsRunning&&this.dialogueData.select&&!this.selectedOptionUpdated&&this.selectedOption!==-1){this.commandCalls=[];try{this.dialogueData.select(this.selectedOption);try{this.dialogueData=this.dialogue.next().value}catch(i){n.error("Error while confirming in the dialogue tree. Verify if there is a syntax error? Full error is: ",i);return}e.dialogueTree.goToNextDialogueLine()}catch(i){n.error("An error happened when trying to access the dialogue branch!",i)}}},e.dialogueTree.selectNextOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption+=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectPreviousOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption-=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectOption=function(i){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption=e.dialogueTree._normalizedOptionIndex(i),this.selectedOptionUpdated=!0)},e.dialogueTree.getSelectedOption=function(){if(!!this.dialogueIsRunning)return this.dialogueData.select?this.selectedOption:0},e.dialogueTree.hasSelectedOptionChanged=function(){return this.selectedOptionUpdated?(this.selectedOptionUpdated=!1,this.selectedOption===-1&&(this.selectedOption=0),!0):!1},e.dialogueTree.isDialogueLineType=function(i){if(!this.dialogueIsRunning)return!1;if(this.commandCalls&&i==="command"){if(this.commandCalls.some(function(t){return e.dialogueTree.clipTextEnd>t.time&&t.cmd==="wait"}))return!this.pauseScrolling;if(this.commandCalls.length>0&&this.commandParameters.length>0)return!0}return this.dialogueDataType===i},e.dialogueTree.hasDialogueBranch=function(i){return this.runner&&this.runner.yarnNodes&&Object.keys(this.runner.yarnNodes).some(function(t){return t===i})},e.dialogueTree.startFrom=function(i){if(this.runner=e.dialogueTree.runner,!!this.hasDialogueBranch(i)){this.optionsCount=0,this.options=[],this.tagParameters=[];try{this.dialogue=this.runner.run(i)}catch(t){n.error("Error while setting up the dialogue tree. Verify if there is a syntax error? Full error is: ",t);return}this.dialogueText="",this.clipTextEnd=0,this.commandCalls=[],this.commandParameters=[],this.pauseScrolling=!1;try{this.dialogueData=this.dialogue.next().value}catch(t){n.error("Error while starting the dialogue tree. Verify if there is a syntax error? Full error is: ",t);return}this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,e.dialogueTree._isLineTypeText()?this.dialogueDataType="text":e.dialogueTree._isLineTypeOptions()?this.dialogueDataType="options":this.dialogueDataType="command",this.dialogueIsRunning=!0,e.dialogueTree.goToNextDialogueLine()}},e.dialogueTree._isLineTypeText=function(){return this.dialogueData instanceof bondage.TextResult},e.dialogueTree._isLineTypeOptions=function(){return this.dialogueData instanceof bondage.OptionsResult},e.dialogueTree._isLineTypeCommand=function(){return this.dialogueData instanceof bondage.CommandResult},e.dialogueTree.goToNextDialogueLine=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning))if(this.optionsCount=0,this.selectedOption=-1,this.selectedOptionUpdated=!1,e.dialogueTree.getVariable("debug")&&n.info("Parsing:",this.dialogueData),!this.dialogueData)e.dialogueTree.stopRunningDialogue();else if(e.dialogueTree._isLineTypeText()){this.lineNum===this.dialogueData.lineNum&&this.dialogueBranchTitle===this.dialogueData.data.title?(this.clipTextEnd=this.dialogueText.length-1,this.dialogueText+=(this.dialogueText===""?"":" ")+this.dialogueData.text):(this.clipTextEnd=0,this.dialogueText=this.dialogueData.text),this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,this.dialogueDataType="text";try{this.dialogueData=this.dialogue.next().value}catch(i){n.error("Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ",i);return}}else if(e.dialogueTree._isLineTypeOptions())this.commandCalls=[],this.dialogueDataType="options",this.dialogueText="",this.clipTextEnd=0,this.optionsCount=this.dialogueData.options.length,this.options=this.dialogueData.options,this.selectedOptionUpdated=!0;else if(e.dialogueTree._isLineTypeCommand()){this.dialogueDataType="command";const i=this.dialogueData.text.split(" "),t=this.commandCalls.length&&this.commandCalls[this.commandCalls.length-1].cmd==="wait"?1:0;this.commandCalls.push({cmd:i[0],params:i,time:this.dialogueText.length+t});try{this.dialogueData=this.dialogue.next().value}catch(a){n.error("Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ",a);return}e.dialogueTree.goToNextDialogueLine()}else this.dialogueDataType="unknown"},e.dialogueTree.getBranchTitle=function(){return this.dialogueIsRunning?this.dialogueBranchTitle:""},e.dialogueTree.branchTitleIs=function(i){return this.dialogueIsRunning?this.dialogueBranchTitle===i:!1},e.dialogueTree.getBranchTags=function(){return this.dialogueIsRunning?this.dialogueBranchTags.join(","):""},e.dialogueTree.getBranchTag=function(i){return this.dialogueIsRunning&&this.dialogueBranchTags.length?(i>this.dialogueBranchTags.length-1&&(i=this.dialogueBranchTags.length-1),this.dialogueBranchTags[i]):""},e.dialogueTree.branchContainsTag=function(i){return this.tagParameters=[],this.dialogueIsRunning&&this.dialogueBranchTags.length?this.dialogueBranchTags.some(function(t){const a=t.match(/([^\(]+)\(([^\)]+)\)/i);return e.dialogueTree.tagParameters=a?a[2].split(","):[],a?a[1]===i:t===i}):!1},e.dialogueTree.getTagParameter=function(i){if(this.dialogueIsRunning&&this.tagParameters.length>=i){const t=this.tagParameters[i];return t||""}return""},e.dialogueTree.getVisitedBranchTitles=function(){return this.dialogueIsRunning?Object.keys(this.runner.visited).join(","):""},e.dialogueTree.branchTitleHasBeenVisited=function(i){return i||(i=this.dialogueBranchTitle),Object.keys(this.runner.visited).includes(i)&&this.runner.visited[i]},e.dialogueTree.getBranchText=function(){return this.dialogueIsRunning?this.dialogueBranchBody:""},e.dialogueTree.getVariable=function(i){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i):""},e.dialogueTree.getVariableAsNumber=function(i){if(this.runner.variables&&i in this.runner.variables.data){const t=this.runner.variables.get(i);return typeof t!="number"?parseFloat(t)||0:isFinite(t)?t:0}return 0},e.dialogueTree.getVariableAsString=function(i){return this.runner.variables&&i in this.runner.variables.data?""+this.runner.variables.get(i):""},e.dialogueTree.compareVariable=function(i,t){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i)===t:!1},e.dialogueTree.setVariable=function(i,t){this.runner.variables&&this.runner.variables.set(i,t)},e.dialogueTree.saveState=function(i){const t={variables:e.dialogueTree.runner.variables.data,visited:e.dialogueTree.runner.visited};i.fromJSObject(t)},e.dialogueTree.loadState=function(i){const t=i.toJSObject();if(!t){n.error("Load state variable is empty:",i);return}try{e.dialogueTree.runner.visited=t.visited,e.dialogueTree.runner.variables.data={},Object.keys(t.variables).forEach(function(a){const s=t.variables[a];e.dialogueTree.runner.variables.set(a,s)})}catch(a){n.error("Failed to load state from variable:",i,a)}},e.dialogueTree.clearState=function(){e.dialogueTree.runner.visited={},e.dialogueTree.runner.variables.data={}}})(gdjs||(gdjs={}));
3
3
  //# sourceMappingURL=dialoguetools.js.map