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/TileMap/tilemapruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type TilemapObjectDataType = {\n content: {\n opacity: number;\n tilemapJsonFile: string;\n tilesetJsonFile: string;\n tilemapAtlasImage: string;\n displayMode: string;\n layerIndex: integer;\n levelIndex: integer;\n animationSpeedScale: number;\n animationFps: number;\n };\n };\n\n export type TilemapObjectData = ObjectData & TilemapObjectDataType;\n\n export type TilemapNetworkSyncDataType = {\n op: number;\n tmjf: string;\n tsjf: string;\n tmai: string;\n dm: string;\n lai: number;\n lei: number;\n asps: number;\n wid: number;\n hei: number;\n };\n\n export type TilemapNetworkSyncData = ObjectNetworkSyncData &\n TilemapNetworkSyncDataType;\n\n /**\n * Displays a Tilemap object (LDtk and Tiled).\n */\n export class TileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler {\n _frameElapsedTime: float = 0;\n _opacity: float;\n _tilemapJsonFile: string;\n _tilesetJsonFile: string;\n _tilemapAtlasImage: string;\n _displayMode: string;\n _layerIndex: integer;\n _levelIndex: integer;\n _animationSpeedScale: number;\n _animationFps: number;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, objectData) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._tilemapJsonFile = objectData.content.tilemapJsonFile;\n this._tilesetJsonFile = objectData.content.tilesetJsonFile;\n this._tilemapAtlasImage = objectData.content.tilemapAtlasImage;\n this._displayMode = objectData.content.displayMode;\n this._layerIndex = objectData.content.layerIndex;\n this._levelIndex = objectData.content.levelIndex;\n this._animationSpeedScale = objectData.content.animationSpeedScale;\n this._animationFps = objectData.content.animationFps;\n this._tileMapManager = gdjs.TileMap.TileMapRuntimeManager.getManager(\n instanceContainer\n );\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._updateTileMap();\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 update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationSpeedScale <= 0 || this._animationFps === 0) {\n return;\n }\n const elapsedTime = this.getElapsedTime() / 1000;\n this._frameElapsedTime += elapsedTime * this._animationSpeedScale;\n while (this._frameElapsedTime > 1 / this._animationFps) {\n this._renderer.incrementAnimationFrameX(instanceContainer);\n this._frameElapsedTime -= 1 / this._animationFps;\n }\n }\n\n updateFromObjectData(\n oldObjectData: TilemapObjectData,\n newObjectData: TilemapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.tilemapJsonFile !==\n newObjectData.content.tilemapJsonFile\n ) {\n this.setTilemapJsonFile(newObjectData.content.tilemapJsonFile);\n }\n if (\n oldObjectData.content.tilesetJsonFile !==\n newObjectData.content.tilesetJsonFile\n ) {\n this.setTilesetJsonFile(newObjectData.content.tilesetJsonFile);\n }\n if (\n oldObjectData.content.displayMode !== newObjectData.content.displayMode\n ) {\n this.setDisplayMode(newObjectData.content.displayMode);\n }\n if (\n oldObjectData.content.layerIndex !== newObjectData.content.layerIndex\n ) {\n this.setLayerIndex(newObjectData.content.layerIndex);\n }\n if (\n oldObjectData.content.levelIndex !== newObjectData.content.levelIndex\n ) {\n this.setLevelIndex(newObjectData.content.levelIndex);\n }\n if (\n oldObjectData.content.animationSpeedScale !==\n newObjectData.content.animationSpeedScale\n ) {\n this.setAnimationSpeedScale(newObjectData.content.animationSpeedScale);\n }\n if (\n oldObjectData.content.animationFps !==\n newObjectData.content.animationFps\n ) {\n this.setAnimationFps(newObjectData.content.animationFps);\n }\n if (\n oldObjectData.content.tilemapAtlasImage !==\n newObjectData.content.tilemapAtlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): TilemapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n tmjf: this._tilemapJsonFile,\n tsjf: this._tilesetJsonFile,\n tmai: this._tilemapAtlasImage,\n dm: this._displayMode,\n lai: this._layerIndex,\n lei: this._levelIndex,\n asps: this._animationSpeedScale,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: TilemapNetworkSyncData): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.tmjf !== undefined) {\n this.setTilemapJsonFile(networkSyncData.tmjf);\n }\n if (networkSyncData.tsjf !== undefined) {\n this.setTilesetJsonFile(networkSyncData.tsjf);\n }\n if (networkSyncData.tmai !== undefined) {\n this._tilemapAtlasImage = networkSyncData.tmai;\n }\n if (networkSyncData.dm !== undefined) {\n this.setDisplayMode(networkSyncData.dm);\n }\n if (networkSyncData.lai !== undefined) {\n this.setLayerIndex(networkSyncData.lai);\n }\n if (networkSyncData.lei !== undefined) {\n this.setLevelIndex(networkSyncData.lei);\n }\n if (networkSyncData.asps !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.asps);\n }\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n }\n\n extraInitializationFromInitialInstance(initialInstanceData): void {\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n private _updateTileMap(): void {\n this._tileMapManager.getOrLoadTileMap(\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (tileMap: TileMapHelper.EditableTileMap | null) => {\n if (!tileMap) {\n // getOrLoadTileMap already warn.\n return;\n }\n this._tileMapManager.getOrLoadTextureCache(\n (textureName) => {\n const game = this.getInstanceContainer().getGame();\n const mappedName = game.resolveEmbeddedResource(\n this._tilemapJsonFile,\n textureName\n );\n return (game\n .getImageManager()\n .getPIXITexture(mappedName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._tilemapAtlasImage,\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Set the Tilemap file to display.\n */\n setTilemapJsonFile(tilemapJsonFile: string): void {\n this._tilemapJsonFile = tilemapJsonFile;\n this._updateTileMap();\n }\n\n getTilemapJsonFile(): string {\n return this._tilemapJsonFile;\n }\n\n isTilemapJsonFile(selectedTilemapJsonFile: string): boolean {\n return this._tilemapJsonFile === selectedTilemapJsonFile;\n }\n\n setTilesetJsonFile(tilesetJsonFile: string): void {\n this._tilesetJsonFile = tilesetJsonFile;\n this._updateTileMap();\n }\n\n getTilesetJsonFile(): string {\n return this._tilesetJsonFile;\n }\n\n setAnimationFps(animationFps: float) {\n this._animationFps = animationFps;\n }\n\n getAnimationFps(): float {\n return this._animationFps;\n }\n\n isTilesetJsonFile(selectedTilesetJsonFile: string): boolean {\n return this._tilesetJsonFile === selectedTilesetJsonFile;\n }\n\n isDisplayMode(selectedDisplayMode: string): boolean {\n return this._displayMode === selectedDisplayMode;\n }\n\n setDisplayMode(displayMode: string): void {\n this._displayMode = displayMode;\n this._updateTileMap();\n }\n\n getDisplayMode(): string {\n return this._displayMode;\n }\n\n setLayerIndex(layerIndex): void {\n this._layerIndex = layerIndex;\n this._updateTileMap();\n }\n\n getLayerIndex(): integer {\n return this._layerIndex;\n }\n\n setLevelIndex(levelIndex): void {\n this._levelIndex = levelIndex;\n this._updateTileMap();\n }\n\n getLevelIndex() {\n return this._levelIndex;\n }\n\n setAnimationSpeedScale(animationSpeedScale): void {\n this._animationSpeedScale = animationSpeedScale;\n }\n\n getAnimationSpeedScale(): float {\n return this._animationSpeedScale;\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n }\n gdjs.registerObject('TileMap::TileMap', gdjs.TileMapRuntimeObject);\n}\n"],
|
|
5
|
-
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CAoCS,eACG,GAAK,aACiD,CAc9D,YAAY,EAAkD,EAAY,CACxE,MAAM,EAAmB,GAd3B,uBAA2B,EAezB,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,mBAAqB,EAAW,QAAQ,kBAC7C,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,qBAAuB,EAAW,QAAQ,oBAC/C,KAAK,cAAgB,EAAW,QAAQ,aACxC,KAAK,gBAAkB,EAAK,QAAQ,sBAAsB,WACxD,GAEF,KAAK,UAAY,GAAI,GAA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MAAM,0BAA0B,GAE5B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,OAAS,QAC3B,KAAK,mBAAmB,EAAgB,MAEtC,EAAgB,OAAS,QAC3B,KAAK,mBAAmB,EAAgB,MAEtC,EAAgB,OAAS,QAC3B,MAAK,mBAAqB,EAAgB,MAExC,EAAgB,KAAO,QACzB,KAAK,eAAe,EAAgB,IAElC,EAAgB,MAAQ,QAC1B,KAAK,cAAc,EAAgB,KAEjC,EAAgB,MAAQ,QAC1B,KAAK,cAAc,EAAgB,KAEjC,EAAgB,OAAS,QAC3B,KAAK,uBAAuB,EAAgB,MAE1C,EAAgB,MAAQ,QAC1B,KAAK,SAAS,EAAgB,KAE5B,EAAgB,MAAQ,QAC1B,KAAK,UAAU,EAAgB,KAInC,uCAAuC,EAA2B,CAChE,AAAI,EAAoB,YACtB,MAAK,SAAS,EAAoB,OAClC,KAAK,UAAU,EAAoB,
|
|
4
|
+
"sourcesContent": ["/// <reference path=\"helper/TileMapHelper.d.ts\" />\nnamespace gdjs {\n export type TilemapObjectDataType = {\n content: {\n opacity: number;\n tilemapJsonFile: string;\n tilesetJsonFile: string;\n tilemapAtlasImage: string;\n displayMode: string;\n layerIndex: integer;\n levelIndex: integer;\n animationSpeedScale: number;\n animationFps: number;\n };\n };\n\n export type TilemapObjectData = ObjectData & TilemapObjectDataType;\n\n export type TilemapNetworkSyncDataType = {\n op: number;\n tmjf: string;\n tsjf: string;\n tmai: string;\n dm: string;\n lai: number;\n lei: number;\n asps: number;\n wid: number;\n hei: number;\n };\n\n export type TilemapNetworkSyncData = ObjectNetworkSyncData &\n TilemapNetworkSyncDataType;\n\n /**\n * Displays a Tilemap object (LDtk and Tiled).\n */\n export class TileMapRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.Scalable, gdjs.OpacityHandler {\n _frameElapsedTime: float = 0;\n _opacity: float;\n _tilemapJsonFile: string;\n _tilesetJsonFile: string;\n _tilemapAtlasImage: string;\n _displayMode: string;\n _layerIndex: integer;\n _levelIndex: integer;\n _animationSpeedScale: number;\n _animationFps: number;\n _tileMapManager: gdjs.TileMap.TileMapRuntimeManager;\n _renderer: gdjs.TileMapRuntimeObjectPixiRenderer;\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, objectData) {\n super(instanceContainer, objectData);\n this._opacity = objectData.content.opacity;\n this._tilemapJsonFile = objectData.content.tilemapJsonFile;\n this._tilesetJsonFile = objectData.content.tilesetJsonFile;\n this._tilemapAtlasImage = objectData.content.tilemapAtlasImage;\n this._displayMode = objectData.content.displayMode;\n this._layerIndex = objectData.content.layerIndex;\n this._levelIndex = objectData.content.levelIndex;\n this._animationSpeedScale = objectData.content.animationSpeedScale;\n this._animationFps = objectData.content.animationFps;\n this._tileMapManager = gdjs.TileMap.TileMapRuntimeManager.getManager(\n instanceContainer\n );\n this._renderer = new gdjs.TileMapRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._updateTileMap();\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 update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationSpeedScale <= 0 || this._animationFps === 0) {\n return;\n }\n const elapsedTime = this.getElapsedTime() / 1000;\n this._frameElapsedTime += elapsedTime * this._animationSpeedScale;\n while (this._frameElapsedTime > 1 / this._animationFps) {\n this._renderer.incrementAnimationFrameX(instanceContainer);\n this._frameElapsedTime -= 1 / this._animationFps;\n }\n }\n\n updateFromObjectData(\n oldObjectData: TilemapObjectData,\n newObjectData: TilemapObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (\n oldObjectData.content.tilemapJsonFile !==\n newObjectData.content.tilemapJsonFile\n ) {\n this.setTilemapJsonFile(newObjectData.content.tilemapJsonFile);\n }\n if (\n oldObjectData.content.tilesetJsonFile !==\n newObjectData.content.tilesetJsonFile\n ) {\n this.setTilesetJsonFile(newObjectData.content.tilesetJsonFile);\n }\n if (\n oldObjectData.content.displayMode !== newObjectData.content.displayMode\n ) {\n this.setDisplayMode(newObjectData.content.displayMode);\n }\n if (\n oldObjectData.content.layerIndex !== newObjectData.content.layerIndex\n ) {\n this.setLayerIndex(newObjectData.content.layerIndex);\n }\n if (\n oldObjectData.content.levelIndex !== newObjectData.content.levelIndex\n ) {\n this.setLevelIndex(newObjectData.content.levelIndex);\n }\n if (\n oldObjectData.content.animationSpeedScale !==\n newObjectData.content.animationSpeedScale\n ) {\n this.setAnimationSpeedScale(newObjectData.content.animationSpeedScale);\n }\n if (\n oldObjectData.content.animationFps !==\n newObjectData.content.animationFps\n ) {\n this.setAnimationFps(newObjectData.content.animationFps);\n }\n if (\n oldObjectData.content.tilemapAtlasImage !==\n newObjectData.content.tilemapAtlasImage\n ) {\n // TODO: support changing the atlas texture\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): TilemapNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n tmjf: this._tilemapJsonFile,\n tsjf: this._tilesetJsonFile,\n tmai: this._tilemapAtlasImage,\n dm: this._displayMode,\n lai: this._layerIndex,\n lei: this._levelIndex,\n asps: this._animationSpeedScale,\n wid: this.getWidth(),\n hei: this.getHeight(),\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: TilemapNetworkSyncData): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.tmjf !== undefined) {\n this.setTilemapJsonFile(networkSyncData.tmjf);\n }\n if (networkSyncData.tsjf !== undefined) {\n this.setTilesetJsonFile(networkSyncData.tsjf);\n }\n if (networkSyncData.tmai !== undefined) {\n this._tilemapAtlasImage = networkSyncData.tmai;\n }\n if (networkSyncData.dm !== undefined) {\n this.setDisplayMode(networkSyncData.dm);\n }\n if (networkSyncData.lai !== undefined) {\n this.setLayerIndex(networkSyncData.lai);\n }\n if (networkSyncData.lei !== undefined) {\n this.setLevelIndex(networkSyncData.lei);\n }\n if (networkSyncData.asps !== undefined) {\n this.setAnimationSpeedScale(networkSyncData.asps);\n }\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n }\n\n extraInitializationFromInitialInstance(initialInstanceData): void {\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n }\n\n private _updateTileMap(): void {\n this._tileMapManager.getOrLoadTileMap(\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (tileMap: TileMapHelper.EditableTileMap | null) => {\n if (!tileMap) {\n // getOrLoadTileMap already warn.\n return;\n }\n this._tileMapManager.getOrLoadTextureCache(\n (textureName) => {\n const game = this.getInstanceContainer().getGame();\n const mappedName = game.resolveEmbeddedResource(\n this._tilemapJsonFile,\n textureName\n );\n return (game\n .getImageManager()\n .getPIXITexture(mappedName) as unknown) as PIXI.BaseTexture<\n PIXI.Resource\n >;\n },\n this._tilemapAtlasImage,\n this._tilemapJsonFile,\n this._tilesetJsonFile,\n this._levelIndex,\n (textureCache: TileMapHelper.TileTextureCache | null) => {\n if (!textureCache) {\n // getOrLoadTextureCache already log warns and errors.\n return;\n }\n this._renderer.updatePixiTileMap(tileMap, textureCache);\n }\n );\n }\n );\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\n }\n\n /**\n * Set the Tilemap file to display.\n */\n setTilemapJsonFile(tilemapJsonFile: string): void {\n this._tilemapJsonFile = tilemapJsonFile;\n this._updateTileMap();\n }\n\n getTilemapJsonFile(): string {\n return this._tilemapJsonFile;\n }\n\n isTilemapJsonFile(selectedTilemapJsonFile: string): boolean {\n return this._tilemapJsonFile === selectedTilemapJsonFile;\n }\n\n setTilesetJsonFile(tilesetJsonFile: string): void {\n this._tilesetJsonFile = tilesetJsonFile;\n this._updateTileMap();\n }\n\n getTilesetJsonFile(): string {\n return this._tilesetJsonFile;\n }\n\n setAnimationFps(animationFps: float) {\n this._animationFps = animationFps;\n }\n\n getAnimationFps(): float {\n return this._animationFps;\n }\n\n isTilesetJsonFile(selectedTilesetJsonFile: string): boolean {\n return this._tilesetJsonFile === selectedTilesetJsonFile;\n }\n\n isDisplayMode(selectedDisplayMode: string): boolean {\n return this._displayMode === selectedDisplayMode;\n }\n\n setDisplayMode(displayMode: string): void {\n this._displayMode = displayMode;\n this._updateTileMap();\n }\n\n getDisplayMode(): string {\n return this._displayMode;\n }\n\n setLayerIndex(layerIndex): void {\n this._layerIndex = layerIndex;\n this._updateTileMap();\n }\n\n getLayerIndex(): integer {\n return this._layerIndex;\n }\n\n setLevelIndex(levelIndex): void {\n this._levelIndex = levelIndex;\n this._updateTileMap();\n }\n\n getLevelIndex() {\n return this._levelIndex;\n }\n\n setAnimationSpeedScale(animationSpeedScale): void {\n this._animationSpeedScale = animationSpeedScale;\n }\n\n getAnimationSpeedScale(): float {\n return this._animationSpeedScale;\n }\n\n setWidth(width: float): void {\n if (this.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n setHeight(height: float): void {\n if (this.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param scale The new scale (must be greater than 0).\n */\n setScale(scale: float): void {\n this.setScaleX(scale);\n this.setScaleY(scale);\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param scaleX The new scale (must be greater than 0).\n */\n setScaleX(scaleX: float): void {\n if (scaleX < 0) {\n scaleX = 0;\n }\n if (this.getScaleX() === scaleX) return;\n\n this._renderer.setScaleX(scaleX);\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its width).\n *\n * @param scaleY The new scale (must be greater than 0).\n */\n setScaleY(scaleY: float): void {\n if (scaleY < 0) {\n scaleY = 0;\n }\n if (this.getScaleY() === scaleY) return;\n\n this._renderer.setScaleY(scaleY);\n this.invalidateHitboxes();\n }\n\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n setOpacity(opacity: float): void {\n this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this._opacity;\n }\n\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n getScaleX(): float {\n return this._renderer.getScaleX();\n }\n\n getScaleY(): float {\n return this._renderer.getScaleY();\n }\n }\n gdjs.registerObject('TileMap::TileMap', gdjs.TileMapRuntimeObject);\n}\n"],
|
|
5
|
+
"mappings": "AACA,GAAU,MAAV,UAAU,EAAV,CAoCS,eACG,GAAK,aACiD,CAc9D,YAAY,EAAkD,EAAY,CACxE,MAAM,EAAmB,GAd3B,uBAA2B,EAezB,KAAK,SAAW,EAAW,QAAQ,QACnC,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,iBAAmB,EAAW,QAAQ,gBAC3C,KAAK,mBAAqB,EAAW,QAAQ,kBAC7C,KAAK,aAAe,EAAW,QAAQ,YACvC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,YAAc,EAAW,QAAQ,WACtC,KAAK,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AAgB,GAEzB,MAAK,UAAU,UAAU,GACzB,KAAK,sBAGP,KAAK,EAAgB,CACnB,MAAM,KAAK,GACX,KAAK,UAAU,iBAGjB,KAAK,EAAgB,CACnB,MAAM,KAAK,GACX,KAAK,UAAU,iBAGjB,SAAS,EAAoB,CAC3B,MAAM,SAAS,GACf,KAAK,UAAU,cAGjB,WAAW,EAAsB,CAC/B,KAAK,SAAW,EAChB,KAAK,UAAU,gBAGjB,YAAoB,CAClB,MAAO,MAAK,SAGd,UAAkB,CAChB,MAAO,MAAK,UAAU,WAGxB,WAAmB,CACjB,MAAO,MAAK,UAAU,YAGxB,WAAmB,CACjB,MAAO,MAAK,UAAU,YAGxB,WAAmB,CACjB,MAAO,MAAK,UAAU,aAhZnB,EAAM,uBAmZb,EAAK,eAAe,mBAAoB,EAAK,wBAvbrC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){class r extends i.RuntimeObject{constructor(e,t){super(e,t);this._xOffset=0;this._yOffset=0;this.opacity=255;this._renderer=new i.TiledSpriteRuntimeObjectRenderer(this,e,t.texture),this._width=0,this._height=0,this.setWidth(t.width),this.setHeight(t.height),this.onCreated()}updateFromObjectData(e,t){return e.texture!==t.texture&&this.setTexture(t.texture,this.getRuntimeScene()),e.width!==t.width&&this.setWidth(t.width),e.height!==t.height&&this.setHeight(t.height),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),wid:this.getWidth(),hei:this.getHeight(),xo:this.getXOffset(),yo:this.getYOffset(),op:this.getOpacity(),color:this.getColor()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.wid!==void 0&&this.setWidth(e.wid),e.hei!==void 0&&this.setHeight(e.hei),e.xo!==void 0&&this.setXOffset(e.xo),e.yo!==void 0&&this.setYOffset(e.yo),e.op!==void 0&&this.setOpacity(e.op),e.color!==void 0&&this.setColor(e.color)}getRendererObject(){return this._renderer.getRendererObject()}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height))}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setTexture(e,t){this._renderer.setTexture(e,t)}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}getWidth(){return this._width}getHeight(){return this._height}setWidth(e){this._width!==e&&(this._width=e,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this._height!==e&&(this._height=e,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t)}setXOffset(e){this._xOffset=e,this._renderer.updateXOffset()}setYOffset(e){this._yOffset=e,this._renderer.updateYOffset()}getXOffset(){return this._xOffset}getYOffset(){return this._yOffset}setOpacity(e){e<0&&(e=0),e>255&&(e=255),this.opacity=e,this._renderer.updateOpacity()}getOpacity(){return this.opacity}setColor(e){this._renderer.setColor(e)}getColor(){return this._renderer.getColor()}getScale(){const e=Math.abs(this.getScaleX()),t=Math.abs(this.getScaleY());return e===t?e:Math.sqrt(e*t)}getScaleX(){return this._width/this._renderer.getTextureWidth()}getScaleY(){return this._height/this._renderer.getTextureHeight()}setScale(e){this.setWidth(this._renderer.getTextureWidth()*e),this.setHeight(this._renderer.getTextureHeight()*e)}setScaleX(e){this.setWidth(this._renderer.getTextureWidth()*e)}setScaleY(e){this.setHeight(this._renderer.getTextureHeight()*e)}}i.TiledSpriteRuntimeObject=r,i.registerObject("TiledSpriteObject::TiledSprite",i.TiledSpriteRuntimeObject)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(i){class r extends i.RuntimeObject{constructor(e,t){super(e,t);this._xOffset=0;this._yOffset=0;this.opacity=255;this._renderer=new i.TiledSpriteRuntimeObjectRenderer(this,e,t.texture),this._width=0,this._height=0,this.setWidth(t.width),this.setHeight(t.height),this.onCreated()}updateFromObjectData(e,t){return e.texture!==t.texture&&this.setTexture(t.texture,this.getRuntimeScene()),e.width!==t.width&&this.setWidth(t.width),e.height!==t.height&&this.setHeight(t.height),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),wid:this.getWidth(),hei:this.getHeight(),xo:this.getXOffset(),yo:this.getYOffset(),op:this.getOpacity(),color:this.getColor()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.wid!==void 0&&this.setWidth(e.wid),e.hei!==void 0&&this.setHeight(e.hei),e.xo!==void 0&&this.setXOffset(e.xo),e.yo!==void 0&&this.setYOffset(e.yo),e.op!==void 0&&this.setOpacity(e.op),e.color!==void 0&&this.setColor(e.color)}getRendererObject(){return this._renderer.getRendererObject()}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity)}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setTexture(e,t){this._renderer.setTexture(e,t)}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}getWidth(){return this._width}getHeight(){return this._height}setWidth(e){this._width!==e&&(this._width=e,this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this._height!==e&&(this._height=e,this._renderer.setHeight(e),this.invalidateHitboxes())}setSize(e,t){this.setWidth(e),this.setHeight(t)}setXOffset(e){this._xOffset=e,this._renderer.updateXOffset()}setYOffset(e){this._yOffset=e,this._renderer.updateYOffset()}getXOffset(){return this._xOffset}getYOffset(){return this._yOffset}setOpacity(e){e<0&&(e=0),e>255&&(e=255),this.opacity=e,this._renderer.updateOpacity()}getOpacity(){return this.opacity}setColor(e){this._renderer.setColor(e)}getColor(){return this._renderer.getColor()}getScale(){const e=Math.abs(this.getScaleX()),t=Math.abs(this.getScaleY());return e===t?e:Math.sqrt(e*t)}getScaleX(){return this._width/this._renderer.getTextureWidth()}getScaleY(){return this._height/this._renderer.getTextureHeight()}setScale(e){this.setWidth(this._renderer.getTextureWidth()*e),this.setHeight(this._renderer.getTextureHeight()*e)}setScaleX(e){this.setWidth(this._renderer.getTextureWidth()*e)}setScaleY(e){this.setHeight(this._renderer.getTextureHeight()*e)}}i.TiledSpriteRuntimeObject=r,i.registerObject("TiledSpriteObject::TiledSprite",i.TiledSpriteRuntimeObject)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=tiledspriteruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/TiledSpriteObject/tiledspriteruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * 2013 Florian Rival (Florian.Rival@gmail.com)\n */\nnamespace gdjs {\n /** Initial properties for a Tiled Sprite object */\n export type TiledSpriteObjectDataType = {\n /** Default width of the object, if the instance has no custom width. */\n width: number;\n /** Default height of the object, if the instance has no custom height. */\n height: number;\n texture: string;\n };\n\n export type TiledSpriteObjectData = ObjectData & TiledSpriteObjectDataType;\n\n export type TiledSpriteNetworkSyncDataType = {\n wid: number;\n hei: number;\n xo: number;\n yo: number;\n op: number;\n color: string;\n };\n\n export type TiledSpriteNetworkSyncData = ObjectNetworkSyncData &\n TiledSpriteNetworkSyncDataType;\n\n /**\n * The TiledSpriteRuntimeObject displays a tiled texture.\n */\n export class TiledSpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.OpacityHandler {\n _xOffset: float = 0;\n _yOffset: float = 0;\n opacity: float = 255;\n\n // Width and height can be stored because they do not depend on the\n // size of the texture being used (contrary to most objects).\n _width: float;\n _height: float;\n\n _renderer: gdjs.TiledSpriteRuntimeObjectRenderer;\n\n /**\n * @param instanceContainer The container the object belongs to.\n * @param tiledSpriteObjectData The initial properties of the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n tiledSpriteObjectData: TiledSpriteObjectData\n ) {\n super(instanceContainer, tiledSpriteObjectData);\n this._renderer = new gdjs.TiledSpriteRuntimeObjectRenderer(\n this,\n instanceContainer,\n tiledSpriteObjectData.texture\n );\n this._width = 0;\n this._height = 0;\n this.setWidth(tiledSpriteObjectData.width);\n this.setHeight(tiledSpriteObjectData.height);\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n updateFromObjectData(oldObjectData, newObjectData): boolean {\n if (oldObjectData.texture !== newObjectData.texture) {\n this.setTexture(newObjectData.texture, this.getRuntimeScene());\n }\n if (oldObjectData.width !== newObjectData.width) {\n this.setWidth(newObjectData.width);\n }\n if (oldObjectData.height !== newObjectData.height) {\n this.setHeight(newObjectData.height);\n }\n return true;\n }\n\n getNetworkSyncData(): TiledSpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n wid: this.getWidth(),\n hei: this.getHeight(),\n xo: this.getXOffset(),\n yo: this.getYOffset(),\n op: this.getOpacity(),\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TiledSpriteNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n // Texture is not synchronized, see if this is asked or not.\n\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.xo !== undefined) {\n this.setXOffset(networkSyncData.xo);\n }\n if (networkSyncData.yo !== undefined) {\n this.setYOffset(networkSyncData.yo);\n }\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.color !== undefined) {\n this.setColor(networkSyncData.color);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\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.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n /**\n * Set the X position of the Tiled Sprite object.\n * @param x The new X position.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the Y position of the Tiled Sprite object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Assign a new texture to the Tiled Sprite object.\n * @param textureName The name of the image texture resource.\n * @param instanceContainer The container in which the texture is used.\n */\n setTexture(\n textureName: string,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ): void {\n this._renderer.setTexture(textureName, instanceContainer);\n }\n\n /**\n * Set the angle of the Tiled Sprite object.\n * @param angle The new angle.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Get the width of the Tiled Sprite object.\n * @returns The width of the Tiled Sprite object\n */\n getWidth(): float {\n return this._width;\n }\n\n /**\n * Get the height of the Tiled Sprite object.\n * @returns The height of the Tiled Sprite object\n */\n getHeight(): float {\n return this._height;\n }\n\n /**\n * Set the width of the Tiled Sprite object.\n * @param width The new width.\n */\n setWidth(width: float): void {\n if (this._width === width) return;\n\n this._width = width;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the Tiled Sprite object.\n * @param height The new height.\n */\n setHeight(height: float): void {\n if (this._height === height) return;\n\n this._height = height;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the size of the Tiled Sprite object.\n * @param width The new width.\n * @param height The new height.\n */\n setSize(width: float, height: float): void {\n this.setWidth(width);\n this.setHeight(height);\n }\n\n /**\n * Set the offset on the X-axis when displaying the image of the Tiled Sprite object.\n * @param xOffset The new offset on the X-axis.\n */\n setXOffset(xOffset: number): void {\n this._xOffset = xOffset;\n this._renderer.updateXOffset();\n }\n\n /**\n * Set the offset on the Y-axis when displaying the image of the Tiled Sprite object.\n * @param yOffset The new offset on the Y-axis.\n */\n setYOffset(yOffset: number): void {\n this._yOffset = yOffset;\n this._renderer.updateYOffset();\n }\n\n /**\n * Get the offset on the X-axis of the Tiled Sprite object.\n * @returns The offset on the X-axis\n */\n getXOffset(): number {\n return this._xOffset;\n }\n\n /**\n * Get the offset on the Y-axis of the Tiled Sprite object.\n * @returns The offset on the Y-axis\n */\n getYOffset(): number {\n return this._yOffset;\n }\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 getOpacity(): number {\n return this.opacity;\n }\n\n /**\n * Change the tint of the tiled sprite object.\n *\n * @param rgbColor The color, in RGB format (\"128;200;255\").\n */\n setColor(rgbColor: string): void {\n this._renderer.setColor(rgbColor);\n }\n\n /**\n * Get the tint of the tiled sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n // Implement support for get/set scale:\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this.getScaleX());\n const scaleY = Math.abs(this.getScaleY());\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get x-scale of the tiled sprite object.\n */\n getScaleX(): float {\n return this._width / this._renderer.getTextureWidth();\n }\n\n /**\n * Get y-scale of the tiled sprite object.\n */\n getScaleY(): float {\n return this._height / this._renderer.getTextureHeight();\n }\n\n /**\n * Set the tiled sprite object scale.\n * @param newScale The new scale for the tiled sprite object.\n */\n setScale(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n\n /**\n * Set the tiled sprite object x-scale.\n * @param newScale The new x-scale for the tiled sprite object.\n */\n setScaleX(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n }\n\n /**\n * Set the tiled sprite object y-scale.\n * @param newScale The new y-scale for the tiled sprite object.\n */\n setScaleY(newScale: float): void {\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n }\n gdjs.registerObject(\n 'TiledSpriteObject::TiledSprite',\n gdjs.TiledSpriteRuntimeObject\n );\n}\n"],
|
|
5
|
-
"mappings": "AAIA,GAAU,MAAV,UAAU,EAAV,CA2BS,eACG,GAAK,aACkC,CAgB/C,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAnB3B,cAAkB,EAClB,cAAkB,EAClB,aAAiB,IAkBf,KAAK,UAAY,GAAI,GAAK,iCACxB,KACA,EACA,EAAsB,SAExB,KAAK,OAAS,EACd,KAAK,QAAU,EACf,KAAK,SAAS,EAAsB,OACpC,KAAK,UAAU,EAAsB,QAGrC,KAAK,YAGP,qBAAqB,EAAe,EAAwB,CAC1D,MAAI,GAAc,UAAY,EAAc,SAC1C,KAAK,WAAW,EAAc,QAAS,KAAK,mBAE1C,EAAc,QAAU,EAAc,OACxC,KAAK,SAAS,EAAc,OAE1B,EAAc,SAAW,EAAc,QACzC,KAAK,UAAU,EAAc,QAExB,GAGT,oBAAiD,CAC/C,MAAO,IACF,MAAM,qBACT,IAAK,KAAK,WACV,IAAK,KAAK,YACV,GAAI,KAAK,aACT,GAAI,KAAK,aACT,GAAI,KAAK,aACT,MAAO,KAAK,YAIhB,0BACE,EACM,CACN,MAAM,0BAA0B,GAI5B,EAAgB,MAAQ,QAC1B,KAAK,SAAS,EAAgB,KAE5B,EAAgB,MAAQ,QAC1B,KAAK,UAAU,EAAgB,KAE7B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,KAAO,QACzB,KAAK,WAAW,EAAgB,IAE9B,EAAgB,QAAU,QAC5B,KAAK,SAAS,EAAgB,OAIlC,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAGxB,aAAoB,CAClB,MAAM,cACN,KAAK,UAAU,UAMjB,uCAAuC,EAAmC,CACxE,AAAI,EAAoB,YACtB,MAAK,SAAS,EAAoB,OAClC,KAAK,UAAU,EAAoB,
|
|
4
|
+
"sourcesContent": ["/*\n * GDevelop JS Platform\n * 2013 Florian Rival (Florian.Rival@gmail.com)\n */\nnamespace gdjs {\n /** Initial properties for a Tiled Sprite object */\n export type TiledSpriteObjectDataType = {\n /** Default width of the object, if the instance has no custom width. */\n width: number;\n /** Default height of the object, if the instance has no custom height. */\n height: number;\n texture: string;\n };\n\n export type TiledSpriteObjectData = ObjectData & TiledSpriteObjectDataType;\n\n export type TiledSpriteNetworkSyncDataType = {\n wid: number;\n hei: number;\n xo: number;\n yo: number;\n op: number;\n color: string;\n };\n\n export type TiledSpriteNetworkSyncData = ObjectNetworkSyncData &\n TiledSpriteNetworkSyncDataType;\n\n /**\n * The TiledSpriteRuntimeObject displays a tiled texture.\n */\n export class TiledSpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.Resizable, gdjs.OpacityHandler {\n _xOffset: float = 0;\n _yOffset: float = 0;\n opacity: float = 255;\n\n // Width and height can be stored because they do not depend on the\n // size of the texture being used (contrary to most objects).\n _width: float;\n _height: float;\n\n _renderer: gdjs.TiledSpriteRuntimeObjectRenderer;\n\n /**\n * @param instanceContainer The container the object belongs to.\n * @param tiledSpriteObjectData The initial properties of the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n tiledSpriteObjectData: TiledSpriteObjectData\n ) {\n super(instanceContainer, tiledSpriteObjectData);\n this._renderer = new gdjs.TiledSpriteRuntimeObjectRenderer(\n this,\n instanceContainer,\n tiledSpriteObjectData.texture\n );\n this._width = 0;\n this._height = 0;\n this.setWidth(tiledSpriteObjectData.width);\n this.setHeight(tiledSpriteObjectData.height);\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n updateFromObjectData(oldObjectData, newObjectData): boolean {\n if (oldObjectData.texture !== newObjectData.texture) {\n this.setTexture(newObjectData.texture, this.getRuntimeScene());\n }\n if (oldObjectData.width !== newObjectData.width) {\n this.setWidth(newObjectData.width);\n }\n if (oldObjectData.height !== newObjectData.height) {\n this.setHeight(newObjectData.height);\n }\n return true;\n }\n\n getNetworkSyncData(): TiledSpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n wid: this.getWidth(),\n hei: this.getHeight(),\n xo: this.getXOffset(),\n yo: this.getYOffset(),\n op: this.getOpacity(),\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TiledSpriteNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n // Texture is not synchronized, see if this is asked or not.\n\n if (networkSyncData.wid !== undefined) {\n this.setWidth(networkSyncData.wid);\n }\n if (networkSyncData.hei !== undefined) {\n this.setHeight(networkSyncData.hei);\n }\n if (networkSyncData.xo !== undefined) {\n this.setXOffset(networkSyncData.xo);\n }\n if (networkSyncData.yo !== undefined) {\n this.setYOffset(networkSyncData.yo);\n }\n if (networkSyncData.op !== undefined) {\n this.setOpacity(networkSyncData.op);\n }\n if (networkSyncData.color !== undefined) {\n this.setColor(networkSyncData.color);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.destroy();\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.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n }\n\n /**\n * Set the X position of the Tiled Sprite object.\n * @param x The new X position.\n */\n setX(x: float): void {\n super.setX(x);\n this._renderer.updatePosition();\n }\n\n /**\n * Set the Y position of the Tiled Sprite object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n super.setY(y);\n this._renderer.updatePosition();\n }\n\n /**\n * Assign a new texture to the Tiled Sprite object.\n * @param textureName The name of the image texture resource.\n * @param instanceContainer The container in which the texture is used.\n */\n setTexture(\n textureName: string,\n instanceContainer: gdjs.RuntimeInstanceContainer\n ): void {\n this._renderer.setTexture(textureName, instanceContainer);\n }\n\n /**\n * Set the angle of the Tiled Sprite object.\n * @param angle The new angle.\n */\n setAngle(angle: float): void {\n super.setAngle(angle);\n this._renderer.updateAngle();\n }\n\n /**\n * Get the width of the Tiled Sprite object.\n * @returns The width of the Tiled Sprite object\n */\n getWidth(): float {\n return this._width;\n }\n\n /**\n * Get the height of the Tiled Sprite object.\n * @returns The height of the Tiled Sprite object\n */\n getHeight(): float {\n return this._height;\n }\n\n /**\n * Set the width of the Tiled Sprite object.\n * @param width The new width.\n */\n setWidth(width: float): void {\n if (this._width === width) return;\n\n this._width = width;\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the Tiled Sprite object.\n * @param height The new height.\n */\n setHeight(height: float): void {\n if (this._height === height) return;\n\n this._height = height;\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the size of the Tiled Sprite object.\n * @param width The new width.\n * @param height The new height.\n */\n setSize(width: float, height: float): void {\n this.setWidth(width);\n this.setHeight(height);\n }\n\n /**\n * Set the offset on the X-axis when displaying the image of the Tiled Sprite object.\n * @param xOffset The new offset on the X-axis.\n */\n setXOffset(xOffset: number): void {\n this._xOffset = xOffset;\n this._renderer.updateXOffset();\n }\n\n /**\n * Set the offset on the Y-axis when displaying the image of the Tiled Sprite object.\n * @param yOffset The new offset on the Y-axis.\n */\n setYOffset(yOffset: number): void {\n this._yOffset = yOffset;\n this._renderer.updateYOffset();\n }\n\n /**\n * Get the offset on the X-axis of the Tiled Sprite object.\n * @returns The offset on the X-axis\n */\n getXOffset(): number {\n return this._xOffset;\n }\n\n /**\n * Get the offset on the Y-axis of the Tiled Sprite object.\n * @returns The offset on the Y-axis\n */\n getYOffset(): number {\n return this._yOffset;\n }\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 getOpacity(): number {\n return this.opacity;\n }\n\n /**\n * Change the tint of the tiled sprite object.\n *\n * @param rgbColor The color, in RGB format (\"128;200;255\").\n */\n setColor(rgbColor: string): void {\n this._renderer.setColor(rgbColor);\n }\n\n /**\n * Get the tint of the tiled sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n // Implement support for get/set scale:\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this.getScaleX());\n const scaleY = Math.abs(this.getScaleY());\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get x-scale of the tiled sprite object.\n */\n getScaleX(): float {\n return this._width / this._renderer.getTextureWidth();\n }\n\n /**\n * Get y-scale of the tiled sprite object.\n */\n getScaleY(): float {\n return this._height / this._renderer.getTextureHeight();\n }\n\n /**\n * Set the tiled sprite object scale.\n * @param newScale The new scale for the tiled sprite object.\n */\n setScale(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n\n /**\n * Set the tiled sprite object x-scale.\n * @param newScale The new x-scale for the tiled sprite object.\n */\n setScaleX(newScale: float): void {\n this.setWidth(this._renderer.getTextureWidth() * newScale);\n }\n\n /**\n * Set the tiled sprite object y-scale.\n * @param newScale The new y-scale for the tiled sprite object.\n */\n setScaleY(newScale: float): void {\n this.setHeight(this._renderer.getTextureHeight() * newScale);\n }\n }\n gdjs.registerObject(\n 'TiledSpriteObject::TiledSprite',\n gdjs.TiledSpriteRuntimeObject\n );\n}\n"],
|
|
5
|
+
"mappings": "AAIA,GAAU,MAAV,UAAU,EAAV,CA2BS,eACG,GAA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AAoB,GAOnD,UAAU,EAAuB,CAC/B,KAAK,UAAU,KAAK,UAAU,mBAAqB,IA5ThD,EAAM,2BA+Tb,EAAK,eACH,iCACA,EAAK,4BA5VC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -623,6 +623,7 @@ module.exports = {
|
|
|
623
623
|
tweenBehavior,
|
|
624
624
|
new gd.BehaviorsSharedData()
|
|
625
625
|
)
|
|
626
|
+
.setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
|
|
626
627
|
.setIncludeFile('Extensions/TweenBehavior/TweenManager.js')
|
|
627
628
|
.addIncludeFile('Extensions/TweenBehavior/tweenruntimebehavior.js');
|
|
628
629
|
|
|
@@ -35,78 +35,65 @@ module.exports = {
|
|
|
35
35
|
.setIcon('JsPlatform/Extensions/videoicon16.png');
|
|
36
36
|
|
|
37
37
|
var videoObject = new gd.ObjectJsImplementation();
|
|
38
|
-
videoObject.updateProperty = function (
|
|
39
|
-
objectContent,
|
|
40
|
-
propertyName,
|
|
41
|
-
newValue
|
|
42
|
-
) {
|
|
38
|
+
videoObject.updateProperty = function (propertyName, newValue) {
|
|
43
39
|
if (propertyName === 'Opacity') {
|
|
44
|
-
|
|
40
|
+
this.content.opacity = parseFloat(newValue);
|
|
45
41
|
return true;
|
|
46
42
|
}
|
|
47
43
|
if (propertyName === 'Looped') {
|
|
48
|
-
|
|
44
|
+
this.content.loop = newValue === '1';
|
|
49
45
|
return true;
|
|
50
46
|
}
|
|
51
47
|
if (propertyName === 'Volume') {
|
|
52
|
-
|
|
48
|
+
this.content.volume = parseFloat(newValue);
|
|
53
49
|
return true;
|
|
54
50
|
}
|
|
55
51
|
if (propertyName === 'videoResource') {
|
|
56
|
-
|
|
52
|
+
this.content.videoResource = newValue;
|
|
57
53
|
return true;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
return false;
|
|
61
57
|
};
|
|
62
|
-
videoObject.getProperties = function (
|
|
58
|
+
videoObject.getProperties = function () {
|
|
63
59
|
var objectProperties = new gd.MapStringPropertyDescriptor();
|
|
64
60
|
|
|
65
|
-
objectProperties
|
|
66
|
-
.getOrCreate('Opacity')
|
|
67
|
-
.setValue(objectContent.opacity.toString())
|
|
68
|
-
.setType('number')
|
|
69
|
-
.setLabel(_('Video opacity (0-255)'))
|
|
70
|
-
.setGroup(_('Appearance'));
|
|
71
61
|
objectProperties
|
|
72
62
|
.getOrCreate('Looped')
|
|
73
|
-
.setValue(
|
|
63
|
+
.setValue(this.content.loop ? 'true' : 'false')
|
|
74
64
|
.setType('boolean')
|
|
75
65
|
.setLabel(_('Loop the video'))
|
|
76
66
|
.setGroup(_('Playback settings'));
|
|
77
67
|
objectProperties
|
|
78
68
|
.getOrCreate('Volume')
|
|
79
|
-
.setValue(
|
|
69
|
+
.setValue(this.content.volume.toString())
|
|
80
70
|
.setType('number')
|
|
81
71
|
.setLabel(_('Video volume (0-100)'))
|
|
82
72
|
.setGroup(_('Playback settings'));
|
|
83
73
|
objectProperties
|
|
84
74
|
.getOrCreate('videoResource')
|
|
85
|
-
.setValue(
|
|
75
|
+
.setValue(this.content.videoResource)
|
|
86
76
|
.setType('resource')
|
|
87
77
|
.addExtraInfo('video')
|
|
88
78
|
.setLabel(_('Video resource'));
|
|
89
79
|
|
|
90
80
|
return objectProperties;
|
|
91
81
|
};
|
|
92
|
-
videoObject.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})
|
|
99
|
-
);
|
|
82
|
+
videoObject.content = {
|
|
83
|
+
opacity: 255,
|
|
84
|
+
loop: false,
|
|
85
|
+
volume: 100,
|
|
86
|
+
videoResource: '',
|
|
87
|
+
};
|
|
100
88
|
|
|
101
89
|
videoObject.updateInitialInstanceProperty = function (
|
|
102
|
-
objectContent,
|
|
103
90
|
instance,
|
|
104
91
|
propertyName,
|
|
105
92
|
newValue
|
|
106
93
|
) {
|
|
107
94
|
return false;
|
|
108
95
|
};
|
|
109
|
-
videoObject.getInitialInstanceProperties = function (
|
|
96
|
+
videoObject.getInitialInstanceProperties = function (instance) {
|
|
110
97
|
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
|
111
98
|
return instanceProperties;
|
|
112
99
|
};
|
|
@@ -589,10 +576,11 @@ module.exports = {
|
|
|
589
576
|
|
|
590
577
|
_getVideoTexture() {
|
|
591
578
|
// Get the video resource to use
|
|
592
|
-
const
|
|
593
|
-
.
|
|
594
|
-
.
|
|
595
|
-
|
|
579
|
+
const object = gd.castObject(
|
|
580
|
+
this._associatedObjectConfiguration,
|
|
581
|
+
gd.ObjectJsImplementation
|
|
582
|
+
);
|
|
583
|
+
const videoResource = object.content.videoResource;
|
|
596
584
|
|
|
597
585
|
// This returns a VideoTexture with autoPlay set to false
|
|
598
586
|
return this._pixiResourcesLoader.getPIXIVideoTexture(
|
|
@@ -606,10 +594,12 @@ module.exports = {
|
|
|
606
594
|
*/
|
|
607
595
|
update() {
|
|
608
596
|
// Check if the video resource has changed
|
|
609
|
-
const
|
|
610
|
-
.
|
|
611
|
-
.
|
|
612
|
-
|
|
597
|
+
const object = gd.castObject(
|
|
598
|
+
this._associatedObjectConfiguration,
|
|
599
|
+
gd.ObjectJsImplementation
|
|
600
|
+
);
|
|
601
|
+
const videoResource = object.content.videoResource;
|
|
602
|
+
|
|
613
603
|
if (videoResource !== this._videoResource) {
|
|
614
604
|
this._videoResource = videoResource;
|
|
615
605
|
this._pixiObject.texture = this._getVideoTexture();
|
|
@@ -619,19 +609,13 @@ module.exports = {
|
|
|
619
609
|
|
|
620
610
|
that._pixiObject.texture.on('error', function () {
|
|
621
611
|
that._pixiObject.texture.off('error', this);
|
|
612
|
+
if (this._wasDestroyed) return;
|
|
622
613
|
|
|
623
614
|
that._pixiObject.texture = that._pixiResourcesLoader.getInvalidPIXITexture();
|
|
624
615
|
});
|
|
625
616
|
}
|
|
626
617
|
}
|
|
627
618
|
|
|
628
|
-
// Update opacity
|
|
629
|
-
const opacity = +this._associatedObjectConfiguration
|
|
630
|
-
.getProperties()
|
|
631
|
-
.get('Opacity')
|
|
632
|
-
.getValue();
|
|
633
|
-
this._pixiObject.alpha = opacity / 255;
|
|
634
|
-
|
|
635
619
|
// Read position and angle from the instance
|
|
636
620
|
this._pixiObject.position.x =
|
|
637
621
|
this._instance.getX() + this._pixiObject.width / 2;
|
|
@@ -645,6 +629,13 @@ module.exports = {
|
|
|
645
629
|
this._pixiObject.width = this.getCustomWidth();
|
|
646
630
|
this._pixiObject.height = this.getCustomHeight();
|
|
647
631
|
}
|
|
632
|
+
|
|
633
|
+
// Do not hide completely an object so it can still be manipulated
|
|
634
|
+
const alphaForDisplay = Math.max(
|
|
635
|
+
this._instance.getOpacity() / 255,
|
|
636
|
+
0.5
|
|
637
|
+
);
|
|
638
|
+
this._pixiObject.alpha = alphaForDisplay;
|
|
648
639
|
}
|
|
649
640
|
|
|
650
641
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(i){class n extends i.RuntimeObject{constructor(e,t){super(e,t);this._pausedAsScenePaused=!1;this._opacity=t.content.opacity,this._loop=t.content.loop,this._volume=t.content.volume,this._videoResource=t.content.videoResource,this._renderer=new i.VideoRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.loop!==t.content.loop&&this.setLoop(t.content.loop),e.content.volume!==t.content.volume&&this.setVolume(t.content.volume),e.content.videoResource===t.content.videoResource}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,wid:this.getWidth(),hei:this.getHeight(),pla:this.isPlayed(),loop:this.isLooped(),ct:this.getCurrentTime(),ps:this.getPlaybackSpeed()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),this._opacity!==void 0&&this._opacity&&e.op&&this.setOpacity(e.op),this.getWidth()!==void 0&&this.getWidth()!==e.wid&&this.setWidth(e.wid),this.getHeight()!==void 0&&this.getHeight()!==e.hei&&this.setHeight(e.hei),e.pla!==void 0&&this.isPlayed()!==e.pla&&(e.pla?this.play():this.pause()),e.loop!==void 0&&this.isLooped()!==e.loop&&this.setLoop(e.loop),e.ct!==void 0&&Math.abs(this.getCurrentTime()-e.ct)>3&&this.setCurrentTime(e.ct),e.ps!==void 0&&this.getPlaybackSpeed()!==e.ps&&this.setPlaybackSpeed(e.ps)}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height))}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}update(e){this._renderer.ensureUpToDate()}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}setOpacity(e){this._opacity=e,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWidth(e){this._renderer.getWidth()!==e&&(this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this._renderer.getHeight()!==e&&(this._renderer.setHeight(e),this.invalidateHitboxes())}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}play(){this._renderer.play()}pause(){this._renderer.pause()}setLoop(e){this._renderer.setLoop(e)}mute(e){this._renderer.setMute(e)}isMuted(){return this._renderer.isMuted()}setVolume(e){this._volume=i.evtTools.common.clamp(i.evtTools.common.normalize(e,0,100),0,1)*100,this._renderer.updateVolume()}getVolume(){return i.evtTools.common.normalize(this._renderer.getVolume(),0,1)*100}isPlayed(){return this._renderer.isPlayed()}isPaused(){return!this._renderer.isPlayed()}isLooped(){return this._renderer.isLooped()}getDuration(){return this._renderer.getDuration()}isEnded(){return this._renderer.isEnded()}setCurrentTime(e){this._renderer.setCurrentTime(e)}getCurrentTime(){return this._renderer.getCurrentTime()}setPlaybackSpeed(e){this._playbackSpeed=i.evtTools.common.clamp(e,.5,2),this._renderer.setPlaybackSpeed(this._playbackSpeed)}getPlaybackSpeed(){return this._renderer.getPlaybackSpeed()}}i.VideoRuntimeObject=n,i.registerObject("Video::VideoObject",i.VideoRuntimeObject),i.registerRuntimeSceneUnloadedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const o=e[t];o instanceof i.VideoRuntimeObject&&o.isPlayed()&&o.pause()}}),i.registerRuntimeScenePausedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const o=e[t];o instanceof i.VideoRuntimeObject&&o.isPlayed()&&(o.pause(),o._pausedAsScenePaused=!0)}}),i.registerRuntimeSceneResumedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const o=e[t];o instanceof i.VideoRuntimeObject&&o._pausedAsScenePaused&&o.play()}})})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(i){class n extends i.RuntimeObject{constructor(e,t){super(e,t);this._pausedAsScenePaused=!1;this._opacity=t.content.opacity,this._loop=t.content.loop,this._volume=t.content.volume,this._videoResource=t.content.videoResource,this._renderer=new i.VideoRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(e,t){return e.content.opacity!==t.content.opacity&&this.setOpacity(t.content.opacity),e.content.loop!==t.content.loop&&this.setLoop(t.content.loop),e.content.volume!==t.content.volume&&this.setVolume(t.content.volume),e.content.videoResource===t.content.videoResource}getNetworkSyncData(){return{...super.getNetworkSyncData(),op:this._opacity,wid:this.getWidth(),hei:this.getHeight(),pla:this.isPlayed(),loop:this.isLooped(),ct:this.getCurrentTime(),ps:this.getPlaybackSpeed()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),this._opacity!==void 0&&this._opacity&&e.op&&this.setOpacity(e.op),this.getWidth()!==void 0&&this.getWidth()!==e.wid&&this.setWidth(e.wid),this.getHeight()!==void 0&&this.getHeight()!==e.hei&&this.setHeight(e.hei),e.pla!==void 0&&this.isPlayed()!==e.pla&&(e.pla?this.play():this.pause()),e.loop!==void 0&&this.isLooped()!==e.loop&&this.setLoop(e.loop),e.ct!==void 0&&Math.abs(this.getCurrentTime()-e.ct)>3&&this.setCurrentTime(e.ct),e.ps!==void 0&&this.getPlaybackSpeed()!==e.ps&&this.setPlaybackSpeed(e.ps)}extraInitializationFromInitialInstance(e){e.customSize&&(this.setWidth(e.width),this.setHeight(e.height)),e.opacity!==void 0&&this.setOpacity(e.opacity)}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}update(e){this._renderer.ensureUpToDate()}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}setOpacity(e){this._opacity=e,this._renderer.updateOpacity()}getOpacity(){return this._opacity}setWidth(e){this._renderer.getWidth()!==e&&(this._renderer.setWidth(e),this.invalidateHitboxes())}setHeight(e){this._renderer.getHeight()!==e&&(this._renderer.setHeight(e),this.invalidateHitboxes())}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}play(){this._renderer.play()}pause(){this._renderer.pause()}setLoop(e){this._renderer.setLoop(e)}mute(e){this._renderer.setMute(e)}isMuted(){return this._renderer.isMuted()}setVolume(e){this._volume=i.evtTools.common.clamp(i.evtTools.common.normalize(e,0,100),0,1)*100,this._renderer.updateVolume()}getVolume(){return i.evtTools.common.normalize(this._renderer.getVolume(),0,1)*100}isPlayed(){return this._renderer.isPlayed()}isPaused(){return!this._renderer.isPlayed()}isLooped(){return this._renderer.isLooped()}getDuration(){return this._renderer.getDuration()}isEnded(){return this._renderer.isEnded()}setCurrentTime(e){this._renderer.setCurrentTime(e)}getCurrentTime(){return this._renderer.getCurrentTime()}setPlaybackSpeed(e){this._playbackSpeed=i.evtTools.common.clamp(e,.5,2),this._renderer.setPlaybackSpeed(this._playbackSpeed)}getPlaybackSpeed(){return this._renderer.getPlaybackSpeed()}}i.VideoRuntimeObject=n,i.registerObject("Video::VideoObject",i.VideoRuntimeObject),i.registerRuntimeSceneUnloadedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const o=e[t];o instanceof i.VideoRuntimeObject&&o.isPlayed()&&o.pause()}}),i.registerRuntimeScenePausedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const o=e[t];o instanceof i.VideoRuntimeObject&&o.isPlayed()&&(o.pause(),o._pausedAsScenePaused=!0)}}),i.registerRuntimeSceneResumedCallback(function(r){const e=r.getAdhocListOfAllInstances();for(let t=0;t<e.length;++t){const o=e[t];o instanceof i.VideoRuntimeObject&&o._pausedAsScenePaused&&o.play()}})})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=videoruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/Video/videoruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n /** The initial properties for {@link gdjs.VideoRuntimeObject} */\n export type VideoObjectDataType = {\n /** The base parameters of the video */\n content: {\n /** The opacity of the video */\n opacity: number;\n /** Does the video loops itself? */\n loop: boolean;\n /** The volume of the video */\n volume: number;\n /** Name of the resource corresponding to the video */\n videoResource: string;\n };\n };\n\n export type VideoObjectData = ObjectData & VideoObjectDataType;\n\n export type VideoNetworkSyncDataType = {\n op: float;\n wid: float;\n hei: float;\n // We don't sync volume, as it's probably a user setting?\n pla: boolean;\n loop: boolean;\n ct: float;\n ps: number;\n };\n\n export type VideoNetworkSyncData = ObjectNetworkSyncData &\n VideoNetworkSyncDataType;\n\n /**\n * An object displaying a video on screen.\n *\n * For the same video resource, only one video is being created in memory (\n * as a HTMLVideoElement). This means that two objects displaying the same\n * video will have the same state for this video (paused/playing, current time,\n * volume, etc...).\n */\n export class VideoRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.OpacityHandler {\n _opacity: float;\n _loop: boolean;\n _volume: float;\n _videoResource: string;\n\n // Use a boolean to track if the video was paused because we\n // navigated to another scene, and so should resume if we're back.\n _pausedAsScenePaused: boolean = false;\n _renderer: gdjs.VideoRuntimeObjectRenderer;\n _playbackSpeed: any;\n\n /**\n * @param instanceContainer The scene the object belongs to.\n * @param videoObjectData The data defining the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n videoObjectData: VideoObjectData\n ) {\n super(instanceContainer, videoObjectData);\n this._opacity = videoObjectData.content.opacity;\n this._loop = videoObjectData.content.loop;\n this._volume = videoObjectData.content.volume;\n this._videoResource = videoObjectData.content.videoResource;\n this._renderer = new gdjs.VideoRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updateFromObjectData(\n oldObjectData: VideoObjectData,\n newObjectData: VideoObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (oldObjectData.content.loop !== newObjectData.content.loop) {\n this.setLoop(newObjectData.content.loop);\n }\n if (oldObjectData.content.volume !== newObjectData.content.volume) {\n this.setVolume(newObjectData.content.volume);\n }\n if (\n oldObjectData.content.videoResource !==\n newObjectData.content.videoResource\n ) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): VideoNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n wid: this.getWidth(),\n hei: this.getHeight(),\n pla: this.isPlayed(),\n loop: this.isLooped(),\n ct: this.getCurrentTime(),\n ps: this.getPlaybackSpeed(),\n };\n }\n\n updateFromNetworkSyncData(syncData: VideoNetworkSyncData): void {\n super.updateFromNetworkSyncData(syncData);\n\n if (this._opacity !== undefined && this._opacity && syncData.op) {\n this.setOpacity(syncData.op);\n }\n if (this.getWidth() !== undefined && this.getWidth() !== syncData.wid) {\n this.setWidth(syncData.wid);\n }\n if (this.getHeight() !== undefined && this.getHeight() !== syncData.hei) {\n this.setHeight(syncData.hei);\n }\n if (syncData.pla !== undefined && this.isPlayed() !== syncData.pla) {\n syncData.pla ? this.play() : this.pause();\n }\n if (syncData.loop !== undefined && this.isLooped() !== syncData.loop) {\n this.setLoop(syncData.loop);\n }\n // We don't update the current time too regularly, only if it's off by a lot.\n if (\n syncData.ct !== undefined &&\n Math.abs(this.getCurrentTime() - syncData.ct) > 3 // More than 3 seconds off\n ) {\n this.setCurrentTime(syncData.ct);\n }\n if (\n syncData.ps !== undefined &&\n this.getPlaybackSpeed() !== syncData.ps\n ) {\n this.setPlaybackSpeed(syncData.ps);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The initial instance data\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.onDestroy();\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n this._renderer.ensureUpToDate();\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 this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n /**\n * Get object opacity.\n * @returns The current opacity\n */\n getOpacity(): number {\n return this._opacity;\n }\n\n /**\n * Set the width of the video.\n * @param width The new width in pixels.\n */\n setWidth(width: float): void {\n if (this._renderer.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the video.\n * @param height The new height in pixels.\n */\n setHeight(height: float): void {\n if (this._renderer.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Get the width of the video object.\n * @returns The current width of the object\n */\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the video object.\n * @returns The current height of the object\n */\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n /**\n * Play the video.\n */\n play(): void {\n this._renderer.play();\n }\n\n /**\n * Pause the video.\n */\n pause(): void {\n this._renderer.pause();\n }\n\n /**\n * Set the state looped of the video.\n * @param enable true to loop the video\n */\n setLoop(enable: boolean): void {\n this._renderer.setLoop(enable);\n }\n\n /**\n * Set the state muted of the video.\n * @param enable The new state.\n */\n mute(enable: boolean) {\n this._renderer.setMute(enable);\n }\n\n /**\n * Return the state muted of video object.\n * @returns Is the video muted?\n */\n isMuted(): boolean {\n return this._renderer.isMuted();\n }\n\n /**\n * Set the volume of the video object.\n * @param volume The new volume, between 0 and 100.\n */\n setVolume(volume: number): void {\n this._volume =\n gdjs.evtTools.common.clamp(\n gdjs.evtTools.common.normalize(volume, 0, 100),\n 0,\n 1\n ) * 100;\n this._renderer.updateVolume();\n }\n\n /**\n * Get the volume of the video object.\n * @returns The current video's volume, between 0 and 100.\n */\n getVolume(): number {\n return (\n gdjs.evtTools.common.normalize(this._renderer.getVolume(), 0, 1) * 100\n );\n }\n\n /**\n * Check if the video is being played.\n * @returns Is the video being played?\n */\n isPlayed(): boolean {\n return this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is paused.\n * @returns Is the video being paused?\n */\n isPaused(): boolean {\n return !this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is looping.\n * @returns Is the video looping?\n */\n isLooped(): boolean {\n return this._renderer.isLooped();\n }\n\n /**\n * Return the total time of the video.\n * @returns The duration of the video\n */\n getDuration(): number {\n return this._renderer.getDuration();\n }\n\n /**\n * Check if the video has ended.\n * @returns Has the video ended?\n */\n isEnded(): boolean {\n return this._renderer.isEnded();\n }\n\n /**\n * Set the new time of the video object.\n * @param time The new time.\n */\n setCurrentTime(time: float): void {\n this._renderer.setCurrentTime(time);\n }\n\n /**\n * Get the current time of the video object.\n * @returns The current time of the video\n */\n getCurrentTime(): float {\n return this._renderer.getCurrentTime();\n }\n\n /**\n * Set the new playback speed of the video object.\n * @param playbackSpeed The new playback speed.\n */\n setPlaybackSpeed(playbackSpeed: number): void {\n this._playbackSpeed = gdjs.evtTools.common.clamp(playbackSpeed, 0.5, 2);\n this._renderer.setPlaybackSpeed(this._playbackSpeed);\n }\n\n /**\n * Get the playback speed of the video object.\n * @returns The current playback speed of the video.\n */\n getPlaybackSpeed(): number {\n return this._renderer.getPlaybackSpeed();\n }\n }\n gdjs.registerObject('Video::VideoObject', gdjs.VideoRuntimeObject);\n\n /**\n * When a scene is unloaded, pause any video being run.\n * TODO: Investigate how to dispose the video source?\n */\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n }\n }\n }\n });\n\n /**\n * When a scene is paused, pause any video being run.\n */\n gdjs.registerRuntimeScenePausedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n obj._pausedAsScenePaused = true;\n }\n }\n }\n });\n\n // Flag it to be started again when scene is resumed.\n\n /**\n * When a scene is resumed, resume any video previously paused.\n */\n gdjs.registerRuntimeSceneResumedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and play them if they have been previously paused.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj._pausedAsScenePaused) {\n obj.play();\n }\n }\n }\n });\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAwCS,eACG,GAAK,aACkB,CAgB/B,YACE,EACA,EACA,CACA,MAAM,EAAmB,GAZ3B,0BAAgC,GAa9B,KAAK,SAAW,EAAgB,QAAQ,QACxC,KAAK,MAAQ,EAAgB,QAAQ,KACrC,KAAK,QAAU,EAAgB,QAAQ,OACvC,KAAK,eAAiB,EAAgB,QAAQ,cAC9C,KAAK,UAAY,GAAI,GAAK,2BACxB,KACA,GAIF,KAAK,YAGP,mBAAoB,CAClB,MAAO,MAAK,UAAU,oBAGxB,qBACE,EACA,EACS,CAUT,MATI,GAAc,QAAQ,UAAY,EAAc,QAAQ,SAC1D,KAAK,WAAW,EAAc,QAAQ,SAEpC,EAAc,QAAQ,OAAS,EAAc,QAAQ,MACvD,KAAK,QAAQ,EAAc,QAAQ,MAEjC,EAAc,QAAQ,SAAW,EAAc,QAAQ,QACzD,KAAK,UAAU,EAAc,QAAQ,QAGrC,EAAc,QAAQ,gBACtB,EAAc,QAAQ,cAO1B,oBAA2C,CACzC,MAAO,IACF,MAAM,qBACT,GAAI,KAAK,SACT,IAAK,KAAK,WACV,IAAK,KAAK,YACV,IAAK,KAAK,WACV,KAAM,KAAK,WACX,GAAI,KAAK,iBACT,GAAI,KAAK,oBAIb,0BAA0B,EAAsC,CAC9D,MAAM,0BAA0B,GAE5B,KAAK,WAAa,QAAa,KAAK,UAAY,EAAS,IAC3D,KAAK,WAAW,EAAS,IAEvB,KAAK,aAAe,QAAa,KAAK,aAAe,EAAS,KAChE,KAAK,SAAS,EAAS,KAErB,KAAK,cAAgB,QAAa,KAAK,cAAgB,EAAS,KAClE,KAAK,UAAU,EAAS,KAEtB,EAAS,MAAQ,QAAa,KAAK,aAAe,EAAS,KAC7D,GAAS,IAAM,KAAK,OAAS,KAAK,SAEhC,EAAS,OAAS,QAAa,KAAK,aAAe,EAAS,MAC9D,KAAK,QAAQ,EAAS,MAItB,EAAS,KAAO,QAChB,KAAK,IAAI,KAAK,iBAAmB,EAAS,IAAM,GAEhD,KAAK,eAAe,EAAS,IAG7B,EAAS,KAAO,QAChB,KAAK,qBAAuB,EAAS,IAErC,KAAK,iBAAiB,EAAS,IAQnC,uCAAuC,EAAmC,CACxE,AAAI,EAAoB,YACtB,MAAK,SAAS,EAAoB,OAClC,KAAK,UAAU,EAAoB,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n /** The initial properties for {@link gdjs.VideoRuntimeObject} */\n export type VideoObjectDataType = {\n /** The base parameters of the video */\n content: {\n /** The opacity of the video */\n opacity: number;\n /** Does the video loops itself? */\n loop: boolean;\n /** The volume of the video */\n volume: number;\n /** Name of the resource corresponding to the video */\n videoResource: string;\n };\n };\n\n export type VideoObjectData = ObjectData & VideoObjectDataType;\n\n export type VideoNetworkSyncDataType = {\n op: float;\n wid: float;\n hei: float;\n // We don't sync volume, as it's probably a user setting?\n pla: boolean;\n loop: boolean;\n ct: float;\n ps: number;\n };\n\n export type VideoNetworkSyncData = ObjectNetworkSyncData &\n VideoNetworkSyncDataType;\n\n /**\n * An object displaying a video on screen.\n *\n * For the same video resource, only one video is being created in memory (\n * as a HTMLVideoElement). This means that two objects displaying the same\n * video will have the same state for this video (paused/playing, current time,\n * volume, etc...).\n */\n export class VideoRuntimeObject\n extends gdjs.RuntimeObject\n implements gdjs.OpacityHandler {\n _opacity: float;\n _loop: boolean;\n _volume: float;\n _videoResource: string;\n\n // Use a boolean to track if the video was paused because we\n // navigated to another scene, and so should resume if we're back.\n _pausedAsScenePaused: boolean = false;\n _renderer: gdjs.VideoRuntimeObjectRenderer;\n _playbackSpeed: any;\n\n /**\n * @param instanceContainer The scene the object belongs to.\n * @param videoObjectData The data defining the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n videoObjectData: VideoObjectData\n ) {\n super(instanceContainer, videoObjectData);\n this._opacity = videoObjectData.content.opacity;\n this._loop = videoObjectData.content.loop;\n this._volume = videoObjectData.content.volume;\n this._videoResource = videoObjectData.content.videoResource;\n this._renderer = new gdjs.VideoRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n updateFromObjectData(\n oldObjectData: VideoObjectData,\n newObjectData: VideoObjectData\n ): boolean {\n if (oldObjectData.content.opacity !== newObjectData.content.opacity) {\n this.setOpacity(newObjectData.content.opacity);\n }\n if (oldObjectData.content.loop !== newObjectData.content.loop) {\n this.setLoop(newObjectData.content.loop);\n }\n if (oldObjectData.content.volume !== newObjectData.content.volume) {\n this.setVolume(newObjectData.content.volume);\n }\n if (\n oldObjectData.content.videoResource !==\n newObjectData.content.videoResource\n ) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): VideoNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n op: this._opacity,\n wid: this.getWidth(),\n hei: this.getHeight(),\n pla: this.isPlayed(),\n loop: this.isLooped(),\n ct: this.getCurrentTime(),\n ps: this.getPlaybackSpeed(),\n };\n }\n\n updateFromNetworkSyncData(syncData: VideoNetworkSyncData): void {\n super.updateFromNetworkSyncData(syncData);\n\n if (this._opacity !== undefined && this._opacity && syncData.op) {\n this.setOpacity(syncData.op);\n }\n if (this.getWidth() !== undefined && this.getWidth() !== syncData.wid) {\n this.setWidth(syncData.wid);\n }\n if (this.getHeight() !== undefined && this.getHeight() !== syncData.hei) {\n this.setHeight(syncData.hei);\n }\n if (syncData.pla !== undefined && this.isPlayed() !== syncData.pla) {\n syncData.pla ? this.play() : this.pause();\n }\n if (syncData.loop !== undefined && this.isLooped() !== syncData.loop) {\n this.setLoop(syncData.loop);\n }\n // We don't update the current time too regularly, only if it's off by a lot.\n if (\n syncData.ct !== undefined &&\n Math.abs(this.getCurrentTime() - syncData.ct) > 3 // More than 3 seconds off\n ) {\n this.setCurrentTime(syncData.ct);\n }\n if (\n syncData.ps !== undefined &&\n this.getPlaybackSpeed() !== syncData.ps\n ) {\n this.setPlaybackSpeed(syncData.ps);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The initial instance data\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n }\n\n onDestroyed(): void {\n super.onDestroyed();\n this._renderer.onDestroy();\n }\n\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n this._renderer.ensureUpToDate();\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 this._opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n /**\n * Get object opacity.\n * @returns The current opacity\n */\n getOpacity(): number {\n return this._opacity;\n }\n\n /**\n * Set the width of the video.\n * @param width The new width in pixels.\n */\n setWidth(width: float): void {\n if (this._renderer.getWidth() === width) return;\n\n this._renderer.setWidth(width);\n this.invalidateHitboxes();\n }\n\n /**\n * Set the height of the video.\n * @param height The new height in pixels.\n */\n setHeight(height: float): void {\n if (this._renderer.getHeight() === height) return;\n\n this._renderer.setHeight(height);\n this.invalidateHitboxes();\n }\n\n /**\n * Get the width of the video object.\n * @returns The current width of the object\n */\n getWidth(): float {\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the video object.\n * @returns The current height of the object\n */\n getHeight(): float {\n return this._renderer.getHeight();\n }\n\n /**\n * Play the video.\n */\n play(): void {\n this._renderer.play();\n }\n\n /**\n * Pause the video.\n */\n pause(): void {\n this._renderer.pause();\n }\n\n /**\n * Set the state looped of the video.\n * @param enable true to loop the video\n */\n setLoop(enable: boolean): void {\n this._renderer.setLoop(enable);\n }\n\n /**\n * Set the state muted of the video.\n * @param enable The new state.\n */\n mute(enable: boolean) {\n this._renderer.setMute(enable);\n }\n\n /**\n * Return the state muted of video object.\n * @returns Is the video muted?\n */\n isMuted(): boolean {\n return this._renderer.isMuted();\n }\n\n /**\n * Set the volume of the video object.\n * @param volume The new volume, between 0 and 100.\n */\n setVolume(volume: number): void {\n this._volume =\n gdjs.evtTools.common.clamp(\n gdjs.evtTools.common.normalize(volume, 0, 100),\n 0,\n 1\n ) * 100;\n this._renderer.updateVolume();\n }\n\n /**\n * Get the volume of the video object.\n * @returns The current video's volume, between 0 and 100.\n */\n getVolume(): number {\n return (\n gdjs.evtTools.common.normalize(this._renderer.getVolume(), 0, 1) * 100\n );\n }\n\n /**\n * Check if the video is being played.\n * @returns Is the video being played?\n */\n isPlayed(): boolean {\n return this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is paused.\n * @returns Is the video being paused?\n */\n isPaused(): boolean {\n return !this._renderer.isPlayed();\n }\n\n /**\n * Check if the video is looping.\n * @returns Is the video looping?\n */\n isLooped(): boolean {\n return this._renderer.isLooped();\n }\n\n /**\n * Return the total time of the video.\n * @returns The duration of the video\n */\n getDuration(): number {\n return this._renderer.getDuration();\n }\n\n /**\n * Check if the video has ended.\n * @returns Has the video ended?\n */\n isEnded(): boolean {\n return this._renderer.isEnded();\n }\n\n /**\n * Set the new time of the video object.\n * @param time The new time.\n */\n setCurrentTime(time: float): void {\n this._renderer.setCurrentTime(time);\n }\n\n /**\n * Get the current time of the video object.\n * @returns The current time of the video\n */\n getCurrentTime(): float {\n return this._renderer.getCurrentTime();\n }\n\n /**\n * Set the new playback speed of the video object.\n * @param playbackSpeed The new playback speed.\n */\n setPlaybackSpeed(playbackSpeed: number): void {\n this._playbackSpeed = gdjs.evtTools.common.clamp(playbackSpeed, 0.5, 2);\n this._renderer.setPlaybackSpeed(this._playbackSpeed);\n }\n\n /**\n * Get the playback speed of the video object.\n * @returns The current playback speed of the video.\n */\n getPlaybackSpeed(): number {\n return this._renderer.getPlaybackSpeed();\n }\n }\n gdjs.registerObject('Video::VideoObject', gdjs.VideoRuntimeObject);\n\n /**\n * When a scene is unloaded, pause any video being run.\n * TODO: Investigate how to dispose the video source?\n */\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n }\n }\n }\n });\n\n /**\n * When a scene is paused, pause any video being run.\n */\n gdjs.registerRuntimeScenePausedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and pause them.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj.isPlayed()) {\n obj.pause();\n obj._pausedAsScenePaused = true;\n }\n }\n }\n });\n\n // Flag it to be started again when scene is resumed.\n\n /**\n * When a scene is resumed, resume any video previously paused.\n */\n gdjs.registerRuntimeSceneResumedCallback(function (runtimeScene) {\n // Manually find all the gdjs.VideoRuntimeObject living on the scene,\n // and play them if they have been previously paused.\n const instances = runtimeScene.getAdhocListOfAllInstances();\n for (let i = 0; i < instances.length; ++i) {\n const obj = instances[i];\n if (obj instanceof gdjs.VideoRuntimeObject) {\n if (obj._pausedAsScenePaused) {\n obj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s;(function(i){const c=new i.Logger("ResourceLoader"),R=(t,e,s)=>{if(t.startsWith("data:")||t.startsWith("blob:"))return t;const n=t.indexOf("?")===-1?"?":"&";return t+n+e+"="+s},_=t=>t.startsWith("https://project-resources.gdevelop.io/")||t.startsWith("https://project-resources-dev.gdevelop.io/"),g=20,f=5,d=3;class v{constructor(e){this.isFinished=!1;this.sceneName=e,this.onProgressCallbacks=new Array,this.onFinishCallbacks=new Array}registerCallback(e,s){if(this.isFinished){e();return}this.onFinishCallbacks.push(e),s&&this.onProgressCallbacks.push(s)}onProgress(e,s){for(const n of this.onProgressCallbacks)n(e,s)}onFinish(){this.isFinished=!0;for(const e of this.onFinishCallbacks)e()}}class w{constructor(e,s,n,r){this._sceneToLoadQueue=new Array;this._spineAtlasManager=null;this._spineManager=null;this.currentLoadingSceneName="";this.currentSceneLoadingProgress=0;this._isLoadingInForeground=!0;this._runtimeGame=e,this._resources=new Map,this._globalResources=n,this._sceneResources=new Map,this._sceneNamesToLoad=new Set,this._sceneNamesToMakeReady=new Set,this.setResources(s,n,r),this._imageManager=new i.ImageManager(this),this._soundManager=new i.SoundManager(this),this._fontManager=new i.FontManager(this),this._jsonManager=new i.JsonManager(this),this._bitmapFontManager=new i.BitmapFontManager(this,this._imageManager),this._model3DManager=new i.Model3DManager(this),i.SpineAtlasManager&&i.SpineManager&&(this._spineAtlasManager=new i.SpineAtlasManager(this,this._imageManager),this._spineManager=new i.SpineManager(this,this._spineAtlasManager));const a=[this._imageManager,this._soundManager,this._fontManager,this._jsonManager,this._bitmapFontManager,this._model3DManager];this._spineAtlasManager&&a.push(this._spineAtlasManager),this._spineManager&&a.push(this._spineManager),this._resourceManagersMap=new Map;for(const o of a)for(const u of o.getResourceKinds())this._resourceManagersMap.set(u,o)}getRuntimeGame(){return this._runtimeGame}setResources(e,s,n){this._globalResources=s,this._sceneResources.clear(),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear();for(const r of n)this._sceneResources.set(r.name,r.usedResources.map(a=>a.name)),this._sceneNamesToLoad.add(r.name),this._sceneNamesToMakeReady.add(r.name);this._sceneToLoadQueue.length=0;for(let r=n.length-1;r>=0;r--){const a=n[r];this._sceneToLoadQueue.push(new v(a.name))}this._resources.clear();for(const r of e)this._resources.set(r.name,r)}async loadAllResources(e){let s=0;await h([...this._resources.values()],g,d,async n=>{await this._loadResource(n),await this._processResource(n),s++,e(s,this._resources.size)}),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear()}async loadGlobalAndFirstSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;const a=[...this._globalResources,...n.values()];await h(a,g,d,async o=>{const u=this._resources.get(o);if(!u){c.warn('Unable to find resource "'+o+'".');return}await this._loadResource(u),await this._processResource(u),r++,s(r,a.length)}),this._setSceneAssetsLoaded(e),this._setSceneAssetsReady(e)}async loadAllSceneInBackground(){for(;this._sceneToLoadQueue.length>0;){const e=this._sceneToLoadQueue[this._sceneToLoadQueue.length-1];e!==void 0&&(this.currentLoadingSceneName=e.sceneName,this.areSceneAssetsLoaded(e.sceneName)?this._sceneToLoadQueue.pop():(await this._doLoadSceneResources(e.sceneName,async(s,n)=>e.onProgress(s,n)),this._sceneToLoadQueue.splice(this._sceneToLoadQueue.findIndex(s=>s===e),1),e.onFinish()))}this.currentLoadingSceneName=""}async _doLoadSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;await h([...n.values()],this._isLoadingInForeground?g:f,d,async a=>{const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');return}await this._loadResource(o),r++,this.currentSceneLoadingProgress=r/this._resources.size,s&&await s(r,this._resources.size)}),this._setSceneAssetsLoaded(e)}async _loadResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.loadResource(e.name)}async loadAndProcessSceneResources(e,s){if(this.areSceneAssetsReady(e))return;await this.loadSceneResources(e,s);const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;for(const a of n){const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');continue}await this._processResource(o),r++,s&&await s(r,n.length)}this._setSceneAssetsReady(e)}async loadSceneResources(e,s){this._isLoadingInForeground=!0;const n=this._prioritizeScene(e);return new Promise((r,a)=>{if(!n){this._isLoadingInForeground=!1,r();return}n.registerCallback(()=>{this._isLoadingInForeground=!1,r()},s)})}_prioritizeScene(e){const s=this._sceneToLoadQueue.findIndex(r=>r.sceneName===e);if(s<0)return null;const n=this._sceneToLoadQueue[s];return this._sceneToLoadQueue.splice(s,1),this._sceneToLoadQueue.push(n),n}async _processResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.processResource(e.name)}getSceneLoadingProgress(e){return e===this.currentLoadingSceneName?this.currentSceneLoadingProgress:this.areSceneAssetsLoaded(e)?1:0}areSceneAssetsLoaded(e){return!this._sceneNamesToLoad.has(e)}areSceneAssetsReady(e){return!this._sceneNamesToMakeReady.has(e)}_setSceneAssetsLoaded(e){this._sceneNamesToLoad.delete(e)}_setSceneAssetsReady(e){this._sceneNamesToMakeReady.delete(e)}getResource(e){return this._resources.get(e)||null}getFullUrl(e){const{gdevelopResourceToken:s}=this._runtimeGame._options;return!s||!_(e)?e:R(e,"gd_resource_token",encodeURIComponent(s))}checkIfCredentialsRequired(e){return this._runtimeGame._options.gdevelopResourceToken?!1:!!_(e)}getSoundManager(){return this._soundManager}getImageManager(){return this._imageManager}getFontManager(){return this._fontManager}getBitmapFontManager(){return this._bitmapFontManager}getJsonManager(){return this._jsonManager}getModel3DManager(){return this._model3DManager}getSpineManager(){return this._spineManager}getSpineAtlasManager(){return this._spineAtlasManager}}i.ResourceLoader=w;const m=(t,e,s)=>{const n=[],r=[];let a=0,o=0;return new Promise((u,y)=>{const p=()=>{if(t.length===0){u({results:n,errors:r});return}for(;a<e&&o<t.length;){const M=t[o++];a++,s(M).then(l=>n.push(l)).catch(l=>r.push({item:M,error:l})).finally(()=>{a--,o===t.length&&a===0?u({results:n,errors:r}):p()})}};p()})},h=async(t,e,s,n)=>{const r=await m(t,e,n);r.errors.length!==0&&c.warn("Some assets couldn't be downloaded. Trying again now.");for(let a=1;a<s&&r.errors.length!==0;a++){const o=await m(t,e,n);r.results.push.apply(r.results,o.results),r.errors=o.errors}return r}})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(i){const c=new i.Logger("ResourceLoader"),R=(t,e,s)=>{if(t.startsWith("data:")||t.startsWith("blob:"))return t;const n=t.indexOf("?")===-1?"?":"&";return t+n+e+"="+s},_=t=>t.startsWith("https://project-resources.gdevelop.io/")||t.startsWith("https://project-resources-dev.gdevelop.io/"),g=20,f=5,d=3;class v{constructor(e){this.isFinished=!1;this.sceneName=e,this.onProgressCallbacks=new Array,this.onFinishCallbacks=new Array}registerCallback(e,s){if(this.isFinished){e();return}this.onFinishCallbacks.push(e),s&&this.onProgressCallbacks.push(s)}onProgress(e,s){for(const n of this.onProgressCallbacks)n(e,s)}onFinish(){this.isFinished=!0;for(const e of this.onFinishCallbacks)e()}}class w{constructor(e,s,n,r){this._sceneToLoadQueue=new Array;this._spineAtlasManager=null;this._spineManager=null;this.currentLoadingSceneName="";this.currentSceneLoadingProgress=0;this._isLoadingInForeground=!0;this._runtimeGame=e,this._resources=new Map,this._globalResources=n,this._sceneResources=new Map,this._sceneNamesToLoad=new Set,this._sceneNamesToMakeReady=new Set,this.setResources(s,n,r),this._imageManager=new i.ImageManager(this),this._soundManager=new i.SoundManager(this),this._fontManager=new i.FontManager(this),this._jsonManager=new i.JsonManager(this),this._bitmapFontManager=new i.BitmapFontManager(this,this._imageManager),this._model3DManager=new i.Model3DManager(this),i.SpineAtlasManager&&i.SpineManager&&(this._spineAtlasManager=new i.SpineAtlasManager(this,this._imageManager),this._spineManager=new i.SpineManager(this,this._spineAtlasManager));const a=[this._imageManager,this._soundManager,this._fontManager,this._jsonManager,this._bitmapFontManager,this._model3DManager];this._spineAtlasManager&&a.push(this._spineAtlasManager),this._spineManager&&a.push(this._spineManager),this._resourceManagersMap=new Map;for(const o of a)for(const u of o.getResourceKinds())this._resourceManagersMap.set(u,o)}getRuntimeGame(){return this._runtimeGame}setResources(e,s,n){this._globalResources=s,this._sceneResources.clear(),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear();for(const r of n)this._sceneResources.set(r.name,r.usedResources.map(a=>a.name)),this._sceneNamesToLoad.add(r.name),this._sceneNamesToMakeReady.add(r.name);this._sceneToLoadQueue.length=0;for(let r=n.length-1;r>=0;r--){const a=n[r];this._sceneToLoadQueue.push(new v(a.name))}this._resources.clear();for(const r of e)!r.file||this._resources.set(r.name,r)}async loadAllResources(e){let s=0;await h([...this._resources.values()],g,d,async n=>{await this._loadResource(n),await this._processResource(n),s++,e(s,this._resources.size)}),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear()}async loadGlobalAndFirstSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;const a=[...this._globalResources,...n.values()];await h(a,g,d,async o=>{const u=this._resources.get(o);if(!u){c.warn('Unable to find resource "'+o+'".');return}await this._loadResource(u),await this._processResource(u),r++,s(r,a.length)}),this._setSceneAssetsLoaded(e),this._setSceneAssetsReady(e)}async loadAllSceneInBackground(){for(;this._sceneToLoadQueue.length>0;){const e=this._sceneToLoadQueue[this._sceneToLoadQueue.length-1];e!==void 0&&(this.currentLoadingSceneName=e.sceneName,this.areSceneAssetsLoaded(e.sceneName)?this._sceneToLoadQueue.pop():(await this._doLoadSceneResources(e.sceneName,async(s,n)=>e.onProgress(s,n)),this._sceneToLoadQueue.splice(this._sceneToLoadQueue.findIndex(s=>s===e),1),e.onFinish()))}this.currentLoadingSceneName=""}async _doLoadSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;await h([...n.values()],this._isLoadingInForeground?g:f,d,async a=>{const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');return}await this._loadResource(o),r++,this.currentSceneLoadingProgress=r/this._resources.size,s&&await s(r,this._resources.size)}),this._setSceneAssetsLoaded(e)}async _loadResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.loadResource(e.name)}async loadAndProcessSceneResources(e,s){if(this.areSceneAssetsReady(e))return;await this.loadSceneResources(e,s);const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;for(const a of n){const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');continue}await this._processResource(o),r++,s&&await s(r,n.length)}this._setSceneAssetsReady(e)}async loadSceneResources(e,s){this._isLoadingInForeground=!0;const n=this._prioritizeScene(e);return new Promise((r,a)=>{if(!n){this._isLoadingInForeground=!1,r();return}n.registerCallback(()=>{this._isLoadingInForeground=!1,r()},s)})}_prioritizeScene(e){const s=this._sceneToLoadQueue.findIndex(r=>r.sceneName===e);if(s<0)return null;const n=this._sceneToLoadQueue[s];return this._sceneToLoadQueue.splice(s,1),this._sceneToLoadQueue.push(n),n}async _processResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.processResource(e.name)}getSceneLoadingProgress(e){return e===this.currentLoadingSceneName?this.currentSceneLoadingProgress:this.areSceneAssetsLoaded(e)?1:0}areSceneAssetsLoaded(e){return!this._sceneNamesToLoad.has(e)}areSceneAssetsReady(e){return!this._sceneNamesToMakeReady.has(e)}_setSceneAssetsLoaded(e){this._sceneNamesToLoad.delete(e)}_setSceneAssetsReady(e){this._sceneNamesToMakeReady.delete(e)}getResource(e){return this._resources.get(e)||null}getFullUrl(e){const{gdevelopResourceToken:s}=this._runtimeGame._options;return!s||!_(e)?e:R(e,"gd_resource_token",encodeURIComponent(s))}checkIfCredentialsRequired(e){return this._runtimeGame._options.gdevelopResourceToken?!1:!!_(e)}getSoundManager(){return this._soundManager}getImageManager(){return this._imageManager}getFontManager(){return this._fontManager}getBitmapFontManager(){return this._bitmapFontManager}getJsonManager(){return this._jsonManager}getModel3DManager(){return this._model3DManager}getSpineManager(){return this._spineManager}getSpineAtlasManager(){return this._spineAtlasManager}}i.ResourceLoader=w;const m=(t,e,s)=>{const n=[],r=[];let a=0,o=0;return new Promise((u,y)=>{const p=()=>{if(t.length===0){u({results:n,errors:r});return}for(;a<e&&o<t.length;){const M=t[o++];a++,s(M).then(l=>n.push(l)).catch(l=>r.push({item:M,error:l})).finally(()=>{a--,o===t.length&&a===0?u({results:n,errors:r}):p()})}};p()})},h=async(t,e,s,n)=>{const r=await m(t,e,n);r.errors.length!==0&&c.warn("Some assets couldn't be downloaded. Trying again now.");for(let a=1;a<s&&r.errors.length!==0;a++){const o=await m(t,e,n);r.results.push.apply(r.results,o.results),r.errors=o.errors}return r}})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=ResourceLoader.js.map
|