gdcore-tools 2.0.0-beta5 → 2.0.0-beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Cordova/config.xml +4 -0
- package/dist/Runtime/Cordova/package.json +12 -20
- package/dist/Runtime/CustomRuntimeObject.js +1 -1
- package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
- package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
- package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
- package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
- package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
- package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
- package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
- package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
- package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
- package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
- package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
- package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
- package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
- package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
- package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/BitmapText/JsExtension.js +40 -49
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/JsExtension.js +2 -2
- package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
- package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
- package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +18 -21
- package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
- package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
- package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
- package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
- package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
- package/dist/Runtime/Extensions/Lighting/JsExtension.js +50 -38
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +112 -7
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
- package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +127 -40
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
- package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/JsExtension.js +77 -36
- package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/JsExtension.js +55 -56
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/JsExtension.js +511 -287
- package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
- package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
- package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +12 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
- package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
- package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -0
- package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
- package/dist/Runtime/ResourceLoader.js +1 -1
- package/dist/Runtime/ResourceLoader.js.map +2 -2
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/SpriteAnimator.js +1 -1
- package/dist/Runtime/SpriteAnimator.js.map +2 -2
- package/dist/Runtime/debugger-client/InGameDebugger.js +1 -1
- package/dist/Runtime/debugger-client/InGameDebugger.js.map +2 -2
- package/dist/Runtime/debugger-client/abstract-debugger-client.js +1 -1
- package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
- package/dist/Runtime/debugger-client/hot-reloader.js +2 -1
- package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
- package/dist/Runtime/debugger-client/minimal-debugger-client.js +2 -0
- package/dist/Runtime/debugger-client/minimal-debugger-client.js.map +7 -0
- package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
- package/dist/Runtime/debugger-client/window-message-debugger-client.js.map +2 -2
- package/dist/Runtime/events-tools/inputtools.js +1 -1
- package/dist/Runtime/events-tools/inputtools.js.map +2 -2
- package/dist/Runtime/events-tools/objecttools.js +1 -1
- package/dist/Runtime/events-tools/objecttools.js.map +2 -2
- package/dist/Runtime/gd.js +1 -1
- package/dist/Runtime/gd.js.map +2 -2
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
- package/dist/Runtime/inputmanager.js +1 -1
- package/dist/Runtime/inputmanager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
- package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/runtimeobject.js +1 -1
- package/dist/Runtime/runtimeobject.js.map +2 -2
- package/dist/Runtime/runtimescene.js +1 -1
- package/dist/Runtime/runtimescene.js.map +2 -2
- package/dist/Runtime/scenestack.js +1 -1
- package/dist/Runtime/scenestack.js.map +2 -2
- package/dist/Runtime/spriteruntimeobject.js +1 -1
- package/dist/Runtime/spriteruntimeobject.js.map +2 -2
- package/dist/Runtime/types/project-data.d.ts +36 -8
- package/dist/Runtime/variablescontainer.js +1 -1
- package/dist/Runtime/variablescontainer.js.map +2 -2
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +149 -75
- package/package.json +3 -3
|
@@ -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 export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n _relativeToOriginalWindowSize: any;\n _leftEdgeAnchor: any;\n _rightEdgeAnchor: any;\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 // TODO EBO Make it work with event based objects or hide this behavior for them.\n const game = instanceContainer.getGame();\n let rendererWidth = game.getGameResolutionWidth();\n let rendererHeight = game.getGameResolutionHeight();\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n if (this._invalidDistances) {\n if (this._relativeToOriginalWindowSize) {\n rendererWidth = game.getOriginalWidth();\n rendererHeight = game.getOriginalHeight();\n }\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = layer.convertCoords(\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n 0,\n workingPoint\n );\n\n //Left edge\n if (\n this._leftEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_LEFT\n ) {\n this._leftEdgeDistance = topLeftPixel[0];\n } else {\n if (\n this._leftEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_RIGHT\n ) {\n this._leftEdgeDistance = rendererWidth - topLeftPixel[0];\n } else {\n if (\n this._leftEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.PROPORTIONAL\n ) {\n this._leftEdgeDistance = topLeftPixel[0] / rendererWidth;\n }\n }\n }\n\n //Top edge\n if (\n this._topEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_TOP\n ) {\n this._topEdgeDistance = topLeftPixel[1];\n } else {\n if (\n this._topEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_BOTTOM\n ) {\n this._topEdgeDistance = rendererHeight - topLeftPixel[1];\n } else {\n if (\n this._topEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.PROPORTIONAL\n ) {\n this._topEdgeDistance = topLeftPixel[1] / rendererHeight;\n }\n }\n }\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = layer.convertCoords(\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n 0,\n workingPoint\n );\n\n //Right edge\n if (\n this._rightEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_LEFT\n ) {\n this._rightEdgeDistance = bottomRightPixel[0];\n } else {\n if (\n this._rightEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_RIGHT\n ) {\n this._rightEdgeDistance = rendererWidth - bottomRightPixel[0];\n } else {\n if (\n this._rightEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.PROPORTIONAL\n ) {\n this._rightEdgeDistance = bottomRightPixel[0] / rendererWidth;\n }\n }\n }\n\n //Bottom edge\n if (\n this._bottomEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_TOP\n ) {\n this._bottomEdgeDistance = bottomRightPixel[1];\n } else {\n if (\n this._bottomEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_BOTTOM\n ) {\n this._bottomEdgeDistance = rendererHeight - bottomRightPixel[1];\n } else {\n if (\n this._bottomEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.PROPORTIONAL\n ) {\n this._bottomEdgeDistance = bottomRightPixel[1] / rendererHeight;\n }\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 (\n this._leftEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_LEFT\n ) {\n leftPixel = this._leftEdgeDistance;\n } else {\n if (\n this._leftEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_RIGHT\n ) {\n leftPixel = rendererWidth - this._leftEdgeDistance;\n } else {\n if (\n this._leftEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.PROPORTIONAL\n ) {\n leftPixel = this._leftEdgeDistance * rendererWidth;\n }\n }\n }\n\n //Top edge\n if (\n this._topEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_TOP\n ) {\n topPixel = this._topEdgeDistance;\n } else {\n if (\n this._topEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_BOTTOM\n ) {\n topPixel = rendererHeight - this._topEdgeDistance;\n } else {\n if (\n this._topEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.PROPORTIONAL\n ) {\n topPixel = this._topEdgeDistance * rendererHeight;\n }\n }\n }\n\n //Right edge\n if (\n this._rightEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_LEFT\n ) {\n rightPixel = this._rightEdgeDistance;\n } else {\n if (\n this._rightEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.WINDOW_RIGHT\n ) {\n rightPixel = rendererWidth - this._rightEdgeDistance;\n } else {\n if (\n this._rightEdgeAnchor ===\n AnchorRuntimeBehavior.HorizontalAnchor.PROPORTIONAL\n ) {\n rightPixel = this._rightEdgeDistance * rendererWidth;\n }\n }\n }\n\n //Bottom edge\n if (\n this._bottomEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_TOP\n ) {\n bottomPixel = this._bottomEdgeDistance;\n } else {\n if (\n this._bottomEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.WINDOW_BOTTOM\n ) {\n bottomPixel = rendererHeight - this._bottomEdgeDistance;\n } else {\n if (\n this._bottomEdgeAnchor ===\n AnchorRuntimeBehavior.VerticalAnchor.PROPORTIONAL\n ) {\n bottomPixel = this._bottomEdgeDistance * rendererHeight;\n }\n }\n }\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = layer.convertInverseCoords(\n leftPixel,\n topPixel,\n 0,\n workingPoint\n );\n const left = topLeftCoord[0];\n const top = topLeftCoord[1];\n\n const bottomRightCoord = layer.convertInverseCoords(\n rightPixel,\n bottomPixel,\n 0,\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 (\n this._rightEdgeAnchor !==\n AnchorRuntimeBehavior.HorizontalAnchor.NONE\n ) {\n this.owner.setWidth(right - left);\n }\n if (\n this._bottomEdgeAnchor !== AnchorRuntimeBehavior.VerticalAnchor.NONE\n ) {\n this.owner.setHeight(bottom - top);\n }\n if (\n this._leftEdgeAnchor !== AnchorRuntimeBehavior.HorizontalAnchor.NONE\n ) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (\n this._topEdgeAnchor !== AnchorRuntimeBehavior.VerticalAnchor.NONE\n ) {\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 !==\n AnchorRuntimeBehavior.HorizontalAnchor.NONE &&\n this._leftEdgeAnchor !== AnchorRuntimeBehavior.HorizontalAnchor.NONE\n ) {\n this.owner.setWidth(right - left);\n this.owner.setX(left);\n } else {\n if (\n this._leftEdgeAnchor !==\n AnchorRuntimeBehavior.HorizontalAnchor.NONE\n ) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (\n this._rightEdgeAnchor !==\n AnchorRuntimeBehavior.HorizontalAnchor.NONE\n ) {\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 !==\n AnchorRuntimeBehavior.VerticalAnchor.NONE &&\n this._topEdgeAnchor !== AnchorRuntimeBehavior.VerticalAnchor.NONE\n ) {\n this.owner.setHeight(bottom - top);\n this.owner.setY(top);\n } else {\n if (\n this._topEdgeAnchor !== AnchorRuntimeBehavior.VerticalAnchor.NONE\n ) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (\n this._bottomEdgeAnchor !==\n AnchorRuntimeBehavior.VerticalAnchor.NONE\n ) {\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 static HorizontalAnchor = {\n NONE: 0,\n WINDOW_LEFT: 1,\n WINDOW_RIGHT: 2,\n PROPORTIONAL: 3,\n };\n static VerticalAnchor = {\n NONE: 0,\n WINDOW_TOP: 1,\n WINDOW_BOTTOM: 2,\n PROPORTIONAL: 3,\n };\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,
|
|
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,EAAg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EACxB,KAAK,MAAM,KACT,KAAK,MAAM,SAAW,KAAK,MAAM,eAC7B,EACA,EACI,MAAK,MAAM,OAAS,KAAK,MAAM,gBAAkB,EACjD,KAAK,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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,11 +34,8 @@ module.exports = {
|
|
|
34
34
|
.setIcon('JsPlatform/Extensions/bbcode32.png');
|
|
35
35
|
|
|
36
36
|
var objectBBText = new gd.ObjectJsImplementation();
|
|
37
|
-
objectBBText.updateProperty = function (
|
|
38
|
-
objectContent
|
|
39
|
-
propertyName,
|
|
40
|
-
newValue
|
|
41
|
-
) {
|
|
37
|
+
objectBBText.updateProperty = function (propertyName, newValue) {
|
|
38
|
+
const objectContent = this.content;
|
|
42
39
|
if (propertyName in objectContent) {
|
|
43
40
|
if (typeof objectContent[propertyName] === 'boolean')
|
|
44
41
|
objectContent[propertyName] = newValue === '1';
|
|
@@ -50,8 +47,9 @@ module.exports = {
|
|
|
50
47
|
|
|
51
48
|
return false;
|
|
52
49
|
};
|
|
53
|
-
objectBBText.getProperties = function (
|
|
50
|
+
objectBBText.getProperties = function () {
|
|
54
51
|
const objectProperties = new gd.MapStringPropertyDescriptor();
|
|
52
|
+
const objectContent = this.content;
|
|
55
53
|
|
|
56
54
|
objectProperties
|
|
57
55
|
.getOrCreate('text')
|
|
@@ -66,13 +64,6 @@ module.exports = {
|
|
|
66
64
|
.setLabel(_('Base color'))
|
|
67
65
|
.setGroup(_('Appearance'));
|
|
68
66
|
|
|
69
|
-
objectProperties
|
|
70
|
-
.getOrCreate('opacity')
|
|
71
|
-
.setValue(objectContent.opacity.toString())
|
|
72
|
-
.setType('number')
|
|
73
|
-
.setLabel(_('Opacity (0-255)'))
|
|
74
|
-
.setGroup(_('Appearance'));
|
|
75
|
-
|
|
76
67
|
objectProperties
|
|
77
68
|
.getOrCreate('fontSize')
|
|
78
69
|
.setValue(objectContent.fontSize.toString())
|
|
@@ -114,29 +105,26 @@ module.exports = {
|
|
|
114
105
|
|
|
115
106
|
return objectProperties;
|
|
116
107
|
};
|
|
117
|
-
objectBBText.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
);
|
|
108
|
+
objectBBText.content = {
|
|
109
|
+
text:
|
|
110
|
+
'[b]bold[/b] [i]italic[/i] [size=15]smaller[/size] [font=times]times[/font] font\n[spacing=12]spaced out[/spacing]\n[outline=yellow]outlined[/outline] [shadow=red]DropShadow[/shadow] ',
|
|
111
|
+
opacity: 255,
|
|
112
|
+
fontSize: 20,
|
|
113
|
+
visible: true,
|
|
114
|
+
color: '0;0;0',
|
|
115
|
+
fontFamily: 'Arial',
|
|
116
|
+
align: 'left',
|
|
117
|
+
wordWrap: true,
|
|
118
|
+
};
|
|
130
119
|
|
|
131
120
|
objectBBText.updateInitialInstanceProperty = function (
|
|
132
|
-
objectContent,
|
|
133
121
|
instance,
|
|
134
122
|
propertyName,
|
|
135
123
|
newValue
|
|
136
124
|
) {
|
|
137
125
|
return false;
|
|
138
126
|
};
|
|
139
|
-
objectBBText.getInitialInstanceProperties = function (
|
|
127
|
+
objectBBText.getInitialInstanceProperties = function (instance) {
|
|
140
128
|
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
|
141
129
|
return instanceProperties;
|
|
142
130
|
};
|
|
@@ -538,25 +526,33 @@ module.exports = {
|
|
|
538
526
|
* This is called to update the PIXI object on the scene editor
|
|
539
527
|
*/
|
|
540
528
|
update() {
|
|
541
|
-
const
|
|
529
|
+
const object = gd.castObject(
|
|
530
|
+
this._associatedObjectConfiguration,
|
|
531
|
+
gd.ObjectJsImplementation
|
|
532
|
+
);
|
|
542
533
|
|
|
543
|
-
const rawText =
|
|
534
|
+
const rawText = object.content.text;
|
|
544
535
|
if (rawText !== this._pixiObject.text) {
|
|
545
536
|
this._pixiObject.text = rawText;
|
|
546
537
|
}
|
|
547
538
|
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
);
|
|
539
|
+
const color = object.content.color;
|
|
540
|
+
const newColor = objectsRenderingService.rgbOrHexToHexNumber(color);
|
|
541
|
+
if (newColor !== this._pixiObject.textStyles.default.fill) {
|
|
542
|
+
this._pixiObject.textStyles.default.fill = newColor;
|
|
543
|
+
this._pixiObject.dirty = true;
|
|
544
|
+
}
|
|
555
545
|
|
|
556
|
-
const fontSize =
|
|
557
|
-
|
|
546
|
+
const fontSize = object.content.fontSize;
|
|
547
|
+
const newDefaultFontsize = `${fontSize}px`;
|
|
548
|
+
if (
|
|
549
|
+
newDefaultFontsize !== this._pixiObject.textStyles.default.fontSize
|
|
550
|
+
) {
|
|
551
|
+
this._pixiObject.textStyles.default.fontSize = `${fontSize}px`;
|
|
552
|
+
this._pixiObject.dirty = true;
|
|
553
|
+
}
|
|
558
554
|
|
|
559
|
-
const fontResourceName =
|
|
555
|
+
const fontResourceName = object.content.fontFamily;
|
|
560
556
|
|
|
561
557
|
if (this._fontResourceName !== fontResourceName) {
|
|
562
558
|
this._fontResourceName = fontResourceName;
|
|
@@ -577,13 +573,13 @@ module.exports = {
|
|
|
577
573
|
});
|
|
578
574
|
}
|
|
579
575
|
|
|
580
|
-
const wordWrap =
|
|
576
|
+
const wordWrap = object.content.wordWrap;
|
|
581
577
|
if (wordWrap !== this._pixiObject._style.wordWrap) {
|
|
582
578
|
this._pixiObject._style.wordWrap = wordWrap;
|
|
583
579
|
this._pixiObject.dirty = true;
|
|
584
580
|
}
|
|
585
581
|
|
|
586
|
-
const align =
|
|
582
|
+
const align = object.content.align;
|
|
587
583
|
if (align !== this._pixiObject._style.align) {
|
|
588
584
|
this._pixiObject._style.align = align;
|
|
589
585
|
this._pixiObject.dirty = true;
|
|
@@ -607,6 +603,13 @@ module.exports = {
|
|
|
607
603
|
this._pixiObject.dirty = true;
|
|
608
604
|
}
|
|
609
605
|
}
|
|
606
|
+
|
|
607
|
+
// Do not hide completely an object so it can still be manipulated
|
|
608
|
+
const alphaForDisplay = Math.max(
|
|
609
|
+
this._instance.getOpacity() / 255,
|
|
610
|
+
0.5
|
|
611
|
+
);
|
|
612
|
+
this._pixiObject.alpha = alphaForDisplay;
|
|
610
613
|
}
|
|
611
614
|
|
|
612
615
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){class n extends i.RuntimeObject{constructor(t,e){super(t,e);this._wrappingWidth=250;this._opacity=parseFloat(e.content.opacity),this._text=e.content.text,this._color=i.rgbOrHexToRGBColor(e.content.color),this._fontFamily=e.content.fontFamily,this._fontSize=parseFloat(e.content.fontSize),this._wordWrap=e.content.wordWrap,this._align=e.content.align,this._renderer=new i.BBTextRuntimeObjectRenderer(this,t),this.hidden=!e.content.visible,this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(t,e){return t.content.opacity!==e.content.opacity&&this.setOpacity(e.content.opacity),t.content.visible!==e.content.visible&&this.hide(!e.content.visible),t.content.text!==e.content.text&&this.setBBText(e.content.text),t.content.color!==e.content.color&&(this._color=i.rgbOrHexToRGBColor(e.content.color),this._renderer.updateColor()),t.content.fontFamily!==e.content.fontFamily&&this.setFontFamily(e.content.fontFamily),t.content.fontSize!==e.content.fontSize&&this.setFontSize(e.content.fontSize),t.content.wordWrap!==e.content.wordWrap&&this.setWordWrap(e.content.wordWrap),t.content.align!==e.content.align&&this.setAlignment(e.content.align),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),text:this._text,o:this._opacity,c:this._color,ff:this._fontFamily,fs:this._fontSize,wwrap:this._wordWrap,wwidth:this._wrappingWidth,align:this._align,hidden:this.hidden}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),this._text!==void 0&&this.setBBText(t.text),this._opacity!==void 0&&this.setOpacity(t.o),this._color!==void 0&&(this._color=t.c,this._renderer.updateColor()),this._fontFamily!==void 0&&this.setFontFamily(t.ff),this._fontSize!==void 0&&this.setFontSize(t.fs),this._wordWrap!==void 0&&this.setWordWrap(t.wwrap),this._wrappingWidth!==void 0&&this.setWrappingWidth(t.wwidth),this._align!==void 0&&this.setAlignment(t.align),this.hidden!==void 0&&this.hide(t.hidden)}extraInitializationFromInitialInstance(t){t.customSize?this.setWrappingWidth(t.width):this.setWrappingWidth(250)}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setBBText(t){this._text=t,this._renderer.updateText(),this.invalidateHitboxes()}getBBText(){return this._text}setColor(t){this._color=i.rgbOrHexToRGBColor(t),this._renderer.updateColor()}getColor(){return this._color[0]+";"+this._color[1]+";"+this._color[2]}setFontSize(t){this._fontSize=t,this._renderer.updateFontSize()}getFontSize(){return this._fontSize}setFontFamily(t){this._fontFamily=t,this._renderer.updateFontFamily()}getFontFamily(){return this._fontFamily}setAlignment(t){this._align=t,this._renderer.updateAlignment()}getAlignment(){return this._align}setX(t){super.setX(t),this._renderer.updatePosition()}setY(t){super.setY(t),this._renderer.updatePosition()}setAngle(t){super.setAngle(t),this._renderer.updateAngle()}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this._opacity=t,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWrappingWidth(t){this._wrappingWidth!==t&&(this._wrappingWidth=t,this._renderer.updateWrappingWidth(),this.invalidateHitboxes())}getWrappingWidth(){return this._wrappingWidth}setWordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this._renderer.updateWordWrap(),this.invalidateHitboxes())}getWordWrap(){return this._wordWrap}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}}i.BBTextRuntimeObject=n,i.registerObject("BBText::BBText",i.BBTextRuntimeObject)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(i){class n extends i.RuntimeObject{constructor(t,e){super(t,e);this._wrappingWidth=250;this._opacity=parseFloat(e.content.opacity),this._text=e.content.text,this._color=i.rgbOrHexToRGBColor(e.content.color),this._fontFamily=e.content.fontFamily,this._fontSize=parseFloat(e.content.fontSize),this._wordWrap=e.content.wordWrap,this._align=e.content.align,this._renderer=new i.BBTextRuntimeObjectRenderer(this,t),this.hidden=!e.content.visible,this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(t,e){return t.content.opacity!==e.content.opacity&&this.setOpacity(e.content.opacity),t.content.visible!==e.content.visible&&this.hide(!e.content.visible),t.content.text!==e.content.text&&this.setBBText(e.content.text),t.content.color!==e.content.color&&(this._color=i.rgbOrHexToRGBColor(e.content.color),this._renderer.updateColor()),t.content.fontFamily!==e.content.fontFamily&&this.setFontFamily(e.content.fontFamily),t.content.fontSize!==e.content.fontSize&&this.setFontSize(e.content.fontSize),t.content.wordWrap!==e.content.wordWrap&&this.setWordWrap(e.content.wordWrap),t.content.align!==e.content.align&&this.setAlignment(e.content.align),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),text:this._text,o:this._opacity,c:this._color,ff:this._fontFamily,fs:this._fontSize,wwrap:this._wordWrap,wwidth:this._wrappingWidth,align:this._align,hidden:this.hidden}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),this._text!==void 0&&this.setBBText(t.text),this._opacity!==void 0&&this.setOpacity(t.o),this._color!==void 0&&(this._color=t.c,this._renderer.updateColor()),this._fontFamily!==void 0&&this.setFontFamily(t.ff),this._fontSize!==void 0&&this.setFontSize(t.fs),this._wordWrap!==void 0&&this.setWordWrap(t.wwrap),this._wrappingWidth!==void 0&&this.setWrappingWidth(t.wwidth),this._align!==void 0&&this.setAlignment(t.align),this.hidden!==void 0&&this.hide(t.hidden)}extraInitializationFromInitialInstance(t){t.customSize?this.setWrappingWidth(t.width):this.setWrappingWidth(250),t.opacity!==void 0&&this.setOpacity(t.opacity)}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}setBBText(t){this._text=t,this._renderer.updateText(),this.invalidateHitboxes()}getBBText(){return this._text}setColor(t){this._color=i.rgbOrHexToRGBColor(t),this._renderer.updateColor()}getColor(){return this._color[0]+";"+this._color[1]+";"+this._color[2]}setFontSize(t){this._fontSize=t,this._renderer.updateFontSize()}getFontSize(){return this._fontSize}setFontFamily(t){this._fontFamily=t,this._renderer.updateFontFamily()}getFontFamily(){return this._fontFamily}setAlignment(t){this._align=t,this._renderer.updateAlignment()}getAlignment(){return this._align}setX(t){super.setX(t),this._renderer.updatePosition()}setY(t){super.setY(t),this._renderer.updatePosition()}setAngle(t){super.setAngle(t),this._renderer.updateAngle()}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this._opacity=t,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWrappingWidth(t){this._wrappingWidth!==t&&(this._wrappingWidth=t,this._renderer.updateWrappingWidth(),this.invalidateHitboxes())}getWrappingWidth(){return this._wrappingWidth}setWordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this._renderer.updateWordWrap(),this.invalidateHitboxes())}getWordWrap(){return this._wordWrap}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}}i.BBTextRuntimeObject=n,i.registerObject("BBText::BBText",i.BBTextRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=bbtextruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/BBText/bbtextruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n /** Base parameters for {@link gdjs.BBTextRuntimeObject} */\n export type BBTextObjectDataType = {\n /** The base parameters of the BBText */\n content: {\n /** The opacity of the BBText */\n opacity: number;\n /** Deprecated - Is the text visible? */\n visible: boolean;\n /** Content of the text */\n text: string;\n /** The color of the text */\n color: string;\n /** The font of the text */\n fontFamily: string;\n /** The size of the text */\n fontSize: number;\n /** Activate word wrap if set to true */\n wordWrap: boolean;\n /** Alignment of the text: \"left\", \"center\" or \"right\" */\n align: 'left' | 'center' | 'right';\n };\n };\n export type BBTextObjectData = ObjectData & BBTextObjectDataType;\n\n export type BBTextObjectNetworkSyncDataType = {\n text: string;\n o: float;\n c: number[];\n ff: string;\n fs: number;\n wwrap: boolean;\n wwidth: float;\n align: string;\n hidden: boolean;\n };\n\n export type BBTextObjectNetworkSyncData = ObjectNetworkSyncData &\n BBTextObjectNetworkSyncDataType;\n\n /**\n * Displays a rich text using BBCode markup (allowing to set parts of the text as bold, italic, use different colors and shadows).\n */\n export class BBTextRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.OpacityHandler {\n _opacity: float;\n\n _text: string;\n\n /** color in format [r, g, b], where each component is in the range [0, 255] */\n _color: integer[];\n _fontFamily: string;\n _fontSize: number;\n\n _wordWrap: boolean;\n _wrappingWidth: float = 250;\n\n // This value is the default wrapping width of the runtime object.\n _align: string;\n _renderer: gdjs.BBTextRuntimeObjectRenderer;\n\n // While this should rather be exposed as a property for all objects, honor the \"visible\"\n // property that is specific to this object.\n hidden: boolean;\n\n /**\n * @param instanceContainer The container the object belongs to.\n * @param objectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: BBTextObjectData\n ) {\n super(instanceContainer, objectData);\n // @ts-ignore - parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string.\n this._opacity = parseFloat(objectData.content.opacity);\n this._text = objectData.content.text;\n this._color = gdjs.rgbOrHexToRGBColor(objectData.content.color);\n this._fontFamily = objectData.content.fontFamily;\n // @ts-ignore - parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string.\n this._fontSize = parseFloat(objectData.content.fontSize);\n this._wordWrap = objectData.content.wordWrap;\n this._align = objectData.content.align;\n this._renderer = new gdjs.BBTextRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this.hidden = !objectData.content.visible;\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n // @ts-ignore\n updateFromObjectData(\n oldObjectData: BBTextObjectDataType,\n newObjectData: BBTextObjectDataType\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (oldObjectData.content.visible !== newObjectData.content.visible) {\n this.hide(!newObjectData.content.visible);\n }\n if (oldObjectData.content.text !== newObjectData.content.text) {\n this.setBBText(newObjectData.content.text);\n }\n if (oldObjectData.content.color !== newObjectData.content.color) {\n this._color = gdjs.rgbOrHexToRGBColor(newObjectData.content.color);\n this._renderer.updateColor();\n }\n if (\n oldObjectData.content.fontFamily !== newObjectData.content.fontFamily\n ) {\n this.setFontFamily(newObjectData.content.fontFamily);\n }\n if (oldObjectData.content.fontSize !== newObjectData.content.fontSize) {\n this.setFontSize(newObjectData.content.fontSize);\n }\n if (oldObjectData.content.wordWrap !== newObjectData.content.wordWrap) {\n this.setWordWrap(newObjectData.content.wordWrap);\n }\n if (oldObjectData.content.align !== newObjectData.content.align) {\n this.setAlignment(newObjectData.content.align);\n }\n return true;\n }\n\n getNetworkSyncData(): BBTextObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n text: this._text,\n o: this._opacity,\n c: this._color,\n ff: this._fontFamily,\n fs: this._fontSize,\n wwrap: this._wordWrap,\n wwidth: this._wrappingWidth,\n align: this._align,\n hidden: this.hidden,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: BBTextObjectNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n if (this._text !== undefined) {\n this.setBBText(networkSyncData.text);\n }\n if (this._opacity !== undefined) {\n this.setOpacity(networkSyncData.o);\n }\n if (this._color !== undefined) {\n this._color = networkSyncData.c;\n this._renderer.updateColor();\n }\n if (this._fontFamily !== undefined) {\n this.setFontFamily(networkSyncData.ff);\n }\n if (this._fontSize !== undefined) {\n this.setFontSize(networkSyncData.fs);\n }\n if (this._wordWrap !== undefined) {\n this.setWordWrap(networkSyncData.wwrap);\n }\n if (this._wrappingWidth !== undefined) {\n this.setWrappingWidth(networkSyncData.wwidth);\n }\n if (this._align !== undefined) {\n this.setAlignment(networkSyncData.align);\n }\n if (this.hidden !== undefined) {\n this.hide(networkSyncData.hidden);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.customSize) {\n this.setWrappingWidth(initialInstanceData.width);\n } else {\n this.setWrappingWidth(\n // This value is the default wrapping width of the runtime object.\n 250\n );\n }\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Set the markup text to display.\n */\n setBBText(text): void {\n this._text = text;\n this._renderer.updateText();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the markup text displayed by the object.\n */\n getBBText() {\n return this._text;\n }\n\n setColor(rgbColorString): void {\n this._color = gdjs.rgbOrHexToRGBColor(rgbColorString);\n this._renderer.updateColor();\n }\n\n /**\n * Get the base color.\n * @return The color as a \"R;G;B\" string, for example: \"255;0;0\"\n */\n getColor(): string {\n return this._color[0] + ';' + this._color[1] + ';' + this._color[2];\n }\n\n setFontSize(fontSize): void {\n this._fontSize = fontSize;\n this._renderer.updateFontSize();\n }\n\n getFontSize() {\n return this._fontSize;\n }\n\n setFontFamily(fontFamily): void {\n this._fontFamily = fontFamily;\n this._renderer.updateFontFamily();\n }\n\n getFontFamily() {\n return this._fontFamily;\n }\n\n setAlignment(align): void {\n this._align = align;\n this._renderer.updateAlignment();\n }\n\n getAlignment() {\n return this._align;\n }\n\n /**\n * Set object position on X axis.\n * @param x The new position X of the object.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set object position on Y axis.\n * @param y The new position Y of the object.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle of the object.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Set object opacity.\n * @param opacity The new opacity of the object (0-255).\n */\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n /**\n * Get object opacity.\n */\n getOpacity() {\n return this._opacity;\n }\n\n /**\n * Set the width.\n * @param width The new width in pixels.\n */\n setWrappingWidth(width: float): void {\n if (this._wrappingWidth === width) return;\n\n this._wrappingWidth = width;\n this._renderer.updateWrappingWidth();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the wrapping width of the object.\n */\n getWrappingWidth(): float {\n return this._wrappingWidth;\n }\n\n setWordWrap(wordWrap: boolean): void {\n if (this._wordWrap === wordWrap) return;\n\n this._wordWrap = wordWrap;\n this._renderer.updateWordWrap();\n this.invalidateHitboxes();\n }\n\n getWordWrap() {\n return this._wordWrap;\n }\n\n /**\n * Get the width of the object.\n */\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n */\n getHeight(): float {\n return this._renderer.getHeight();\n }\n }\n // @ts-ignore\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,MAAO,IACF,MAAM,qBACT,KAAM,KAAK,MACX,EAAG,KAAK,SACR,EAAG,KAAK,OACR,GAAI,KAAK,YACT,GAAI,KAAK,UACT,MAAO,KAAK,UACZ,OAAQ,KAAK,eACb,MAAO,KAAK,OACZ,OAAQ,KAAK,QAIjB,0BACE,EACM,CACN,MAAM,0BAA0B,GAC5B,KAAK,QAAU,QACjB,KAAK,UAAU,EAAgB,MAE7B,KAAK,WAAa,QACpB,KAAK,WAAW,EAAgB,GAE9B,KAAK,SAAW,QAClB,MAAK,OAAS,EAAgB,EAC9B,KAAK,UAAU,eAEb,KAAK,cAAgB,QACvB,KAAK,cAAc,EAAgB,IAEjC,KAAK,YAAc,QACrB,KAAK,YAAY,EAAgB,IAE/B,KAAK,YAAc,QACrB,KAAK,YAAY,EAAgB,OAE/B,KAAK,iBAAmB,QAC1B,KAAK,iBAAiB,EAAgB,QAEpC,KAAK,SAAW,QAClB,KAAK,aAAa,EAAgB,OAEhC,KAAK,SAAW,QAClB,KAAK,KAAK,EAAgB,QAO9B,uCAAuC,EAAmC,CACxE,AAAI,EAAoB,WACtB,KAAK,iBAAiB,EAAoB,OAE1C,KAAK,iBAEH,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n /** Base parameters for {@link gdjs.BBTextRuntimeObject} */\n export type BBTextObjectDataType = {\n /** The base parameters of the BBText */\n content: {\n /** The opacity of the BBText */\n opacity: number;\n /** Deprecated - Is the text visible? */\n visible: boolean;\n /** Content of the text */\n text: string;\n /** The color of the text */\n color: string;\n /** The font of the text */\n fontFamily: string;\n /** The size of the text */\n fontSize: number;\n /** Activate word wrap if set to true */\n wordWrap: boolean;\n /** Alignment of the text: \"left\", \"center\" or \"right\" */\n align: 'left' | 'center' | 'right';\n };\n };\n export type BBTextObjectData = ObjectData & BBTextObjectDataType;\n\n export type BBTextObjectNetworkSyncDataType = {\n text: string;\n o: float;\n c: number[];\n ff: string;\n fs: number;\n wwrap: boolean;\n wwidth: float;\n align: string;\n hidden: boolean;\n };\n\n export type BBTextObjectNetworkSyncData = ObjectNetworkSyncData &\n BBTextObjectNetworkSyncDataType;\n\n /**\n * Displays a rich text using BBCode markup (allowing to set parts of the text as bold, italic, use different colors and shadows).\n */\n export class BBTextRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.OpacityHandler {\n _opacity: float;\n\n _text: string;\n\n /** color in format [r, g, b], where each component is in the range [0, 255] */\n _color: integer[];\n _fontFamily: string;\n _fontSize: number;\n\n _wordWrap: boolean;\n _wrappingWidth: float = 250;\n\n // This value is the default wrapping width of the runtime object.\n _align: string;\n _renderer: gdjs.BBTextRuntimeObjectRenderer;\n\n // While this should rather be exposed as a property for all objects, honor the \"visible\"\n // property that is specific to this object.\n hidden: boolean;\n\n /**\n * @param instanceContainer The container the object belongs to.\n * @param objectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectData: BBTextObjectData\n ) {\n super(instanceContainer, objectData);\n // @ts-ignore - parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string.\n this._opacity = parseFloat(objectData.content.opacity);\n this._text = objectData.content.text;\n this._color = gdjs.rgbOrHexToRGBColor(objectData.content.color);\n this._fontFamily = objectData.content.fontFamily;\n // @ts-ignore - parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string.\n this._fontSize = parseFloat(objectData.content.fontSize);\n this._wordWrap = objectData.content.wordWrap;\n this._align = objectData.content.align;\n this._renderer = new gdjs.BBTextRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this.hidden = !objectData.content.visible;\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n // @ts-ignore\n updateFromObjectData(\n oldObjectData: BBTextObjectDataType,\n newObjectData: BBTextObjectDataType\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (oldObjectData.content.visible !== newObjectData.content.visible) {\n this.hide(!newObjectData.content.visible);\n }\n if (oldObjectData.content.text !== newObjectData.content.text) {\n this.setBBText(newObjectData.content.text);\n }\n if (oldObjectData.content.color !== newObjectData.content.color) {\n this._color = gdjs.rgbOrHexToRGBColor(newObjectData.content.color);\n this._renderer.updateColor();\n }\n if (\n oldObjectData.content.fontFamily !== newObjectData.content.fontFamily\n ) {\n this.setFontFamily(newObjectData.content.fontFamily);\n }\n if (oldObjectData.content.fontSize !== newObjectData.content.fontSize) {\n this.setFontSize(newObjectData.content.fontSize);\n }\n if (oldObjectData.content.wordWrap !== newObjectData.content.wordWrap) {\n this.setWordWrap(newObjectData.content.wordWrap);\n }\n if (oldObjectData.content.align !== newObjectData.content.align) {\n this.setAlignment(newObjectData.content.align);\n }\n return true;\n }\n\n getNetworkSyncData(): BBTextObjectNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n text: this._text,\n o: this._opacity,\n c: this._color,\n ff: this._fontFamily,\n fs: this._fontSize,\n wwrap: this._wordWrap,\n wwidth: this._wrappingWidth,\n align: this._align,\n hidden: this.hidden,\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: BBTextObjectNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n if (this._text !== undefined) {\n this.setBBText(networkSyncData.text);\n }\n if (this._opacity !== undefined) {\n this.setOpacity(networkSyncData.o);\n }\n if (this._color !== undefined) {\n this._color = networkSyncData.c;\n this._renderer.updateColor();\n }\n if (this._fontFamily !== undefined) {\n this.setFontFamily(networkSyncData.ff);\n }\n if (this._fontSize !== undefined) {\n this.setFontSize(networkSyncData.fs);\n }\n if (this._wordWrap !== undefined) {\n this.setWordWrap(networkSyncData.wwrap);\n }\n if (this._wrappingWidth !== undefined) {\n this.setWrappingWidth(networkSyncData.wwidth);\n }\n if (this._align !== undefined) {\n this.setAlignment(networkSyncData.align);\n }\n if (this.hidden !== undefined) {\n this.hide(networkSyncData.hidden);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.customSize) {\n this.setWrappingWidth(initialInstanceData.width);\n } else {\n this.setWrappingWidth(\n // This value is the default wrapping width of the runtime object.\n 250\n );\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Set the markup text to display.\n */\n setBBText(text): void {\n this._text = text;\n this._renderer.updateText();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the markup text displayed by the object.\n */\n getBBText() {\n return this._text;\n }\n\n setColor(rgbColorString): void {\n this._color = gdjs.rgbOrHexToRGBColor(rgbColorString);\n this._renderer.updateColor();\n }\n\n /**\n * Get the base color.\n * @return The color as a \"R;G;B\" string, for example: \"255;0;0\"\n */\n getColor(): string {\n return this._color[0] + ';' + this._color[1] + ';' + this._color[2];\n }\n\n setFontSize(fontSize): void {\n this._fontSize = fontSize;\n this._renderer.updateFontSize();\n }\n\n getFontSize() {\n return this._fontSize;\n }\n\n setFontFamily(fontFamily): void {\n this._fontFamily = fontFamily;\n this._renderer.updateFontFamily();\n }\n\n getFontFamily() {\n return this._fontFamily;\n }\n\n setAlignment(align): void {\n this._align = align;\n this._renderer.updateAlignment();\n }\n\n getAlignment() {\n return this._align;\n }\n\n /**\n * Set object position on X axis.\n * @param x The new position X of the object.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set object position on Y axis.\n * @param y The new position Y of the object.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle of the object.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Set object opacity.\n * @param opacity The new opacity of the object (0-255).\n */\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n /**\n * Get object opacity.\n */\n getOpacity() {\n return this._opacity;\n }\n\n /**\n * Set the width.\n * @param width The new width in pixels.\n */\n setWrappingWidth(width: float): void {\n if (this._wrappingWidth === width) return;\n\n this._wrappingWidth = width;\n this._renderer.updateWrappingWidth();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the wrapping width of the object.\n */\n getWrappingWidth(): float {\n return this._wrappingWidth;\n }\n\n setWordWrap(wordWrap: boolean): void {\n if (this._wordWrap === wordWrap) return;\n\n this._wordWrap = wordWrap;\n this._renderer.updateWordWrap();\n this.invalidateHitboxes();\n }\n\n getWordWrap() {\n return this._wordWrap;\n }\n\n /**\n * Get the width of the object.\n */\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n */\n getHeight(): float {\n return this._renderer.getHeight();\n }\n }\n // @ts-ignore\n gdjs.registerObject('BBText::BBText', gdjs.BBTextRuntimeObject);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CA2CS,eACG,GAAK,aACkB,CAyB/B,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAlB3B,oBAAwB,IAoBtB,KAAK,SAAW,WAAW,EAAW,QAAQ,SAC9C,KAAK,MAAQ,EAAW,QAAQ,KAChC,KAAK,OAAS,EAAK,mBAAmB,EAAW,QAAQ,OACzD,KAAK,YAAc,EAAW,QAAQ,WAEtC,KAAK,UAAY,WAAW,EAAW,QAAQ,UAC/C,KAAK,UAAY,EAAW,QAAQ,SACpC,KAAK,OAAS,EAAW,QAAQ,MACjC,KAAK,UAAY,GAAI,GAAK,4BACxB,KACA,GAEF,KAAK,OAAS,CAAC,EAAW,QAAQ,QAGlC,KAAK,YAGP,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAIxB,qBACE,EACA,EACS,CACT,MAAI,GAAc,QAAQ,UAAY,EAAc,QAAQ,SAC1D,KA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,aAAc,CACZ,MAAO,MAAK,UAMd,UAAkB,CAChB,MAAO,MAAK,UAAU,WAMxB,WAAmB,CACjB,MAAO,MAAK,UAAU,aApTnB,EAAM,sBAwTb,EAAK,eAAe,iBAAkB,EAAK,uBAnWnC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,11 +34,8 @@ module.exports = {
|
|
|
34
34
|
.setIcon('JsPlatform/Extensions/bitmapfont32.png');
|
|
35
35
|
|
|
36
36
|
const bitmapTextObject = new gd.ObjectJsImplementation();
|
|
37
|
-
bitmapTextObject.updateProperty = function (
|
|
38
|
-
objectContent
|
|
39
|
-
propertyName,
|
|
40
|
-
newValue
|
|
41
|
-
) {
|
|
37
|
+
bitmapTextObject.updateProperty = function (propertyName, newValue) {
|
|
38
|
+
const objectContent = this.content;
|
|
42
39
|
if (propertyName in objectContent) {
|
|
43
40
|
if (typeof objectContent[propertyName] === 'boolean')
|
|
44
41
|
objectContent[propertyName] = newValue === '1';
|
|
@@ -50,8 +47,9 @@ module.exports = {
|
|
|
50
47
|
|
|
51
48
|
return false;
|
|
52
49
|
};
|
|
53
|
-
bitmapTextObject.getProperties = function (
|
|
50
|
+
bitmapTextObject.getProperties = function () {
|
|
54
51
|
const objectProperties = new gd.MapStringPropertyDescriptor();
|
|
52
|
+
const objectContent = this.content;
|
|
55
53
|
|
|
56
54
|
objectProperties
|
|
57
55
|
.getOrCreate('text')
|
|
@@ -59,13 +57,6 @@ module.exports = {
|
|
|
59
57
|
.setType('textarea')
|
|
60
58
|
.setLabel(_('Text'));
|
|
61
59
|
|
|
62
|
-
objectProperties
|
|
63
|
-
.getOrCreate('opacity')
|
|
64
|
-
.setValue(objectContent.opacity.toString())
|
|
65
|
-
.setType('number')
|
|
66
|
-
.setLabel(_('Opacity (0-255)'))
|
|
67
|
-
.setGroup(_('Appearance'));
|
|
68
|
-
|
|
69
60
|
objectProperties
|
|
70
61
|
.getOrCreate('align')
|
|
71
62
|
.setValue(objectContent.align)
|
|
@@ -73,7 +64,7 @@ module.exports = {
|
|
|
73
64
|
.addExtraInfo('left')
|
|
74
65
|
.addExtraInfo('center')
|
|
75
66
|
.addExtraInfo('right')
|
|
76
|
-
.setLabel(_('Alignment
|
|
67
|
+
.setLabel(_('Alignment'))
|
|
77
68
|
.setGroup(_('Appearance'));
|
|
78
69
|
|
|
79
70
|
objectProperties
|
|
@@ -89,7 +80,7 @@ module.exports = {
|
|
|
89
80
|
.setValue(objectContent.textureAtlasResourceName)
|
|
90
81
|
.setType('resource')
|
|
91
82
|
.addExtraInfo('image')
|
|
92
|
-
.setLabel(_('Bitmap
|
|
83
|
+
.setLabel(_('Bitmap Atlas'))
|
|
93
84
|
.setGroup(_('Font'));
|
|
94
85
|
|
|
95
86
|
objectProperties
|
|
@@ -115,33 +106,27 @@ module.exports = {
|
|
|
115
106
|
|
|
116
107
|
return objectProperties;
|
|
117
108
|
};
|
|
118
|
-
bitmapTextObject.
|
|
119
|
-
|
|
120
|
-
text
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
})
|
|
131
|
-
);
|
|
109
|
+
bitmapTextObject.content = {
|
|
110
|
+
text:
|
|
111
|
+
'This text use the default bitmap font.\nUse a custom Bitmap Font to create your own texts.',
|
|
112
|
+
opacity: 255,
|
|
113
|
+
scale: 1,
|
|
114
|
+
fontSize: 20,
|
|
115
|
+
tint: '255;255;255',
|
|
116
|
+
bitmapFontResourceName: '',
|
|
117
|
+
textureAtlasResourceName: '',
|
|
118
|
+
align: 'left',
|
|
119
|
+
wordWrap: true,
|
|
120
|
+
};
|
|
132
121
|
|
|
133
122
|
bitmapTextObject.updateInitialInstanceProperty = function (
|
|
134
|
-
objectContent,
|
|
135
123
|
instance,
|
|
136
124
|
propertyName,
|
|
137
125
|
newValue
|
|
138
126
|
) {
|
|
139
127
|
return false;
|
|
140
128
|
};
|
|
141
|
-
bitmapTextObject.getInitialInstanceProperties = function (
|
|
142
|
-
content,
|
|
143
|
-
instance
|
|
144
|
-
) {
|
|
129
|
+
bitmapTextObject.getInitialInstanceProperties = function (instance) {
|
|
145
130
|
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
|
146
131
|
return instanceProperties;
|
|
147
132
|
};
|
|
@@ -666,34 +651,31 @@ module.exports = {
|
|
|
666
651
|
}
|
|
667
652
|
|
|
668
653
|
update() {
|
|
669
|
-
const
|
|
654
|
+
const object = gd.castObject(
|
|
655
|
+
this._associatedObjectConfiguration,
|
|
656
|
+
gd.ObjectJsImplementation
|
|
657
|
+
);
|
|
670
658
|
|
|
671
659
|
// Update the rendered text properties (note: Pixi is only
|
|
672
660
|
// applying changes if there were changed).
|
|
673
|
-
const rawText =
|
|
661
|
+
const rawText = object.content.text;
|
|
674
662
|
this._pixiObject.text = rawText;
|
|
675
663
|
|
|
676
|
-
const
|
|
677
|
-
this._pixiObject.alpha = opacity / 255;
|
|
678
|
-
|
|
679
|
-
const align = properties.get('align').getValue();
|
|
664
|
+
const align = object.content.align;
|
|
680
665
|
this._pixiObject.align = align;
|
|
681
666
|
|
|
682
|
-
const color =
|
|
667
|
+
const color = object.content.tint;
|
|
683
668
|
this._pixiObject.tint = objectsRenderingService.rgbOrHexToHexNumber(
|
|
684
669
|
color
|
|
685
670
|
);
|
|
686
671
|
|
|
687
|
-
const scale =
|
|
672
|
+
const scale = object.content.scale;
|
|
688
673
|
this._pixiObject.scale.set(scale);
|
|
689
674
|
|
|
690
675
|
// Track the changes in font to load the new requested font.
|
|
691
|
-
const bitmapFontResourceName =
|
|
692
|
-
|
|
693
|
-
.
|
|
694
|
-
const textureAtlasResourceName = properties
|
|
695
|
-
.get('textureAtlasResourceName')
|
|
696
|
-
.getValue();
|
|
676
|
+
const bitmapFontResourceName = object.content.bitmapFontResourceName;
|
|
677
|
+
const textureAtlasResourceName =
|
|
678
|
+
object.content.textureAtlasResourceName;
|
|
697
679
|
|
|
698
680
|
if (
|
|
699
681
|
this._currentBitmapFontResourceName !== bitmapFontResourceName ||
|
|
@@ -715,6 +697,8 @@ module.exports = {
|
|
|
715
697
|
this._currentBitmapFontResourceName,
|
|
716
698
|
this._currentTextureAtlasResourceName
|
|
717
699
|
).then((bitmapFont) => {
|
|
700
|
+
if (this._wasDestroyed) return;
|
|
701
|
+
|
|
718
702
|
this._pixiObject.fontName = bitmapFont.font;
|
|
719
703
|
this._pixiObject.fontSize = bitmapFont.size;
|
|
720
704
|
this._pixiObject.dirty = true;
|
|
@@ -722,7 +706,7 @@ module.exports = {
|
|
|
722
706
|
}
|
|
723
707
|
|
|
724
708
|
// Set up the wrapping width if enabled.
|
|
725
|
-
const wordWrap =
|
|
709
|
+
const wordWrap = object.content.wordWrap;
|
|
726
710
|
if (wordWrap && this._instance.hasCustomSize()) {
|
|
727
711
|
this._pixiObject.maxWidth =
|
|
728
712
|
this.getCustomWidth() / this._pixiObject.scale.x;
|
|
@@ -739,6 +723,13 @@ module.exports = {
|
|
|
739
723
|
this._pixiObject.rotation = RenderedInstance.toRad(
|
|
740
724
|
this._instance.getAngle()
|
|
741
725
|
);
|
|
726
|
+
|
|
727
|
+
// Do not hide completely an object so it can still be manipulated
|
|
728
|
+
const alphaForDisplay = Math.max(
|
|
729
|
+
this._instance.getOpacity() / 255,
|
|
730
|
+
0.5
|
|
731
|
+
);
|
|
732
|
+
this._pixiObject.alpha = alphaForDisplay;
|
|
742
733
|
}
|
|
743
734
|
|
|
744
735
|
onRemovedFromScene() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){class r extends i.RuntimeObject{constructor(t,e){super(t,e);this._opacity=e.content.opacity,this._text=e.content.text,this._tint=i.rgbOrHexToRGBColor(e.content.tint),this._bitmapFontResourceName=e.content.bitmapFontResourceName,this._textureAtlasResourceName=e.content.textureAtlasResourceName,this._scaleX=e.content.scale,this._scaleY=e.content.scale,this._wordWrap=e.content.wordWrap,this._wrappingWidth=0,this._align=e.content.align,this._renderer=new i.BitmapTextRuntimeObjectRenderer(this,t),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(t,e){return t.content.opacity!==e.content.opacity&&this.setOpacity(e.content.opacity),t.content.text!==e.content.text&&this.setText(e.content.text),t.content.tint!==e.content.tint&&(this._tint=i.rgbOrHexToRGBColor(e.content.tint),this._renderer.updateTint()),t.content.bitmapFontResourceName!==e.content.bitmapFontResourceName&&this.setBitmapFontResourceName(e.content.bitmapFontResourceName),t.content.textureAtlasResourceName!==e.content.textureAtlasResourceName&&this.setTextureAtlasResourceName(e.content.textureAtlasResourceName),t.content.scale!==e.content.scale&&this.setScale(e.content.scale),t.content.wordWrap!==e.content.wordWrap&&this.setWordWrap(e.content.wordWrap),t.content.align!==e.content.align&&this.setAlignment(e.content.align),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),text:this._text,opa:this._opacity,tint:this._tint,bfrn:this._bitmapFontResourceName,tarn:this._textureAtlasResourceName,scale:this.getScale(),wwrap:this._wordWrap,wwidth:this._wrappingWidth,align:this._align}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),this._text!==void 0&&this.setText(t.text),this._opacity!==void 0&&this.setOpacity(t.opa),this._tint!==void 0&&(this._tint=t.tint,this._renderer.updateTint()),this._bitmapFontResourceName!==void 0&&this.setBitmapFontResourceName(t.bfrn),this._textureAtlasResourceName!==void 0&&this.setTextureAtlasResourceName(t.tarn),this._scaleX!==void 0&&this.setScale(t.scale),this._wordWrap!==void 0&&this.setWordWrap(t.wwrap),this._wrappingWidth!==void 0&&this.setWrappingWidth(t.wwidth),this._align!==void 0&&this.setAlignment(t.align)}extraInitializationFromInitialInstance(t){t.customSize&&this.setWrappingWidth(t.width)}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}setText(t){this._text=t,this._renderer.updateTextContent(),this.invalidateHitboxes()}getText(){return this._text}setTint(t){this._tint=i.rgbOrHexToRGBColor(t),this._renderer.updateTint()}getTint(){return this._tint[0]+";"+this._tint[1]+";"+this._tint[2]}getScale(){const t=this.getScaleX(),e=this.getScaleY();return t===e?t:Math.sqrt(t*e)}getScaleX(){return this._scaleX}getScaleY(){return this._scaleY}setScale(t){this.setScaleX(t),this.setScaleY(t)}setScaleX(t){t<0&&(t=0),this._scaleX!==t&&(this._scaleX=t,this._renderer.updateScale(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),this._scaleY!==t&&(this._scaleY=t,this._renderer.updateScale(),this.invalidateHitboxes())}getFontSize(){return this._renderer.getFontSize()}setBitmapFontAndTextureAtlasResourceName(t,e){t&&(this.setBitmapFontResourceName(t),this._renderer.updateFont()),e&&(this.setTextureAtlasResourceName(e),this._renderer.updateFont())}setBitmapFontResourceName(t){this._bitmapFontResourceName=t}getBitmapFontResourceName(){return this._bitmapFontResourceName}setTextureAtlasResourceName(t){this._textureAtlasResourceName=t}getTextureAtlasResourceName(){return this._textureAtlasResourceName}setAlignment(t){this._align=t,this._renderer.updateAlignment()}getAlignment(){return this._align}setX(t){super.setX(t),this._renderer.updatePosition()}setY(t){super.setY(t),this._renderer.updatePosition()}setAngle(t){super.setAngle(t),this._renderer.updateAngle()}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this._opacity=t,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWrappingWidth(t){this._wrappingWidth=t,this._renderer.updateWrappingWidth(),this.invalidateHitboxes()}getWrappingWidth(){return this._wrappingWidth}setWordWrap(t){this._wordWrap=t,this._renderer.updateWrappingWidth(),this.invalidateHitboxes()}getWordWrap(){return this._wordWrap}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}}i.BitmapTextRuntimeObject=r,i.registerObject("BitmapText::BitmapTextObject",i.BitmapTextRuntimeObject)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(i){class r extends i.RuntimeObject{constructor(t,e){super(t,e);this._opacity=e.content.opacity,this._text=e.content.text,this._tint=i.rgbOrHexToRGBColor(e.content.tint),this._bitmapFontResourceName=e.content.bitmapFontResourceName,this._textureAtlasResourceName=e.content.textureAtlasResourceName,this._scaleX=e.content.scale,this._scaleY=e.content.scale,this._wordWrap=e.content.wordWrap,this._wrappingWidth=0,this._align=e.content.align,this._renderer=new i.BitmapTextRuntimeObjectRenderer(this,t),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(t,e){return t.content.opacity!==e.content.opacity&&this.setOpacity(e.content.opacity),t.content.text!==e.content.text&&this.setText(e.content.text),t.content.tint!==e.content.tint&&(this._tint=i.rgbOrHexToRGBColor(e.content.tint),this._renderer.updateTint()),t.content.bitmapFontResourceName!==e.content.bitmapFontResourceName&&this.setBitmapFontResourceName(e.content.bitmapFontResourceName),t.content.textureAtlasResourceName!==e.content.textureAtlasResourceName&&this.setTextureAtlasResourceName(e.content.textureAtlasResourceName),t.content.scale!==e.content.scale&&this.setScale(e.content.scale),t.content.wordWrap!==e.content.wordWrap&&this.setWordWrap(e.content.wordWrap),t.content.align!==e.content.align&&this.setAlignment(e.content.align),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),text:this._text,opa:this._opacity,tint:this._tint,bfrn:this._bitmapFontResourceName,tarn:this._textureAtlasResourceName,scale:this.getScale(),wwrap:this._wordWrap,wwidth:this._wrappingWidth,align:this._align}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),this._text!==void 0&&this.setText(t.text),this._opacity!==void 0&&this.setOpacity(t.opa),this._tint!==void 0&&(this._tint=t.tint,this._renderer.updateTint()),this._bitmapFontResourceName!==void 0&&this.setBitmapFontResourceName(t.bfrn),this._textureAtlasResourceName!==void 0&&this.setTextureAtlasResourceName(t.tarn),this._scaleX!==void 0&&this.setScale(t.scale),this._wordWrap!==void 0&&this.setWordWrap(t.wwrap),this._wrappingWidth!==void 0&&this.setWrappingWidth(t.wwidth),this._align!==void 0&&this.setAlignment(t.align)}extraInitializationFromInitialInstance(t){t.customSize&&this.setWrappingWidth(t.width),t.opacity!==void 0&&this.setOpacity(t.opacity)}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}setText(t){this._text=t,this._renderer.updateTextContent(),this.invalidateHitboxes()}getText(){return this._text}setTint(t){this._tint=i.rgbOrHexToRGBColor(t),this._renderer.updateTint()}getTint(){return this._tint[0]+";"+this._tint[1]+";"+this._tint[2]}getScale(){const t=this.getScaleX(),e=this.getScaleY();return t===e?t:Math.sqrt(t*e)}getScaleX(){return this._scaleX}getScaleY(){return this._scaleY}setScale(t){this.setScaleX(t),this.setScaleY(t)}setScaleX(t){t<0&&(t=0),this._scaleX!==t&&(this._scaleX=t,this._renderer.updateScale(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),this._scaleY!==t&&(this._scaleY=t,this._renderer.updateScale(),this.invalidateHitboxes())}getFontSize(){return this._renderer.getFontSize()}setBitmapFontAndTextureAtlasResourceName(t,e){t&&(this.setBitmapFontResourceName(t),this._renderer.updateFont()),e&&(this.setTextureAtlasResourceName(e),this._renderer.updateFont())}setBitmapFontResourceName(t){this._bitmapFontResourceName=t}getBitmapFontResourceName(){return this._bitmapFontResourceName}setTextureAtlasResourceName(t){this._textureAtlasResourceName=t}getTextureAtlasResourceName(){return this._textureAtlasResourceName}setAlignment(t){this._align=t,this._renderer.updateAlignment()}getAlignment(){return this._align}setX(t){super.setX(t),this._renderer.updatePosition()}setY(t){super.setY(t),this._renderer.updatePosition()}setAngle(t){super.setAngle(t),this._renderer.updateAngle()}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this._opacity=t,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWrappingWidth(t){this._wrappingWidth=t,this._renderer.updateWrappingWidth(),this.invalidateHitboxes()}getWrappingWidth(){return this._wrappingWidth}setWordWrap(t){this._wordWrap=t,this._renderer.updateWrappingWidth(),this.invalidateHitboxes()}getWordWrap(){return this._wordWrap}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}}i.BitmapTextRuntimeObject=r,i.registerObject("BitmapText::BitmapTextObject",i.BitmapTextRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=bitmaptextruntimeobject.js.map
|