gdcore-tools 2.0.0-beta6 → 2.0.0-beta8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/Runtime/Cordova/config.xml +4 -0
  2. package/dist/Runtime/Cordova/package.json +12 -20
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  6. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
  10. package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  12. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  13. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  14. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
  16. package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
  17. package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
  18. package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
  19. package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
  20. package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
  21. package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
  22. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  23. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  24. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
  25. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  26. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  27. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  28. package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
  29. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  30. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  31. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +40 -49
  32. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  33. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  34. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
  35. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
  37. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  38. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
  39. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  40. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
  41. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  42. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
  43. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  44. package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +18 -21
  45. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
  46. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
  47. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
  48. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
  49. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  50. package/dist/Runtime/Extensions/Lighting/JsExtension.js +50 -38
  51. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
  52. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  53. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +15 -0
  54. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  55. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  56. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  57. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  58. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  59. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
  60. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  61. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  62. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  63. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +76 -24
  64. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  65. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  66. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  67. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  68. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  69. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  70. package/dist/Runtime/Extensions/Spine/JsExtension.js +45 -36
  71. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  72. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/TextInput/JsExtension.js +52 -55
  74. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  75. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  76. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  77. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  78. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js +1 -1
  79. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  80. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  81. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  82. package/dist/Runtime/Extensions/TileMap/JsExtension.js +430 -261
  83. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
  84. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  85. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
  86. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  87. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
  88. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
  89. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
  90. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
  91. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
  92. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  93. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  94. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  95. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  96. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  97. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  98. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  99. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  100. package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
  101. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  102. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  103. package/dist/Runtime/ResourceLoader.js +1 -1
  104. package/dist/Runtime/ResourceLoader.js.map +2 -2
  105. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  106. package/dist/Runtime/debugger-client/hot-reloader.js +2 -2
  107. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  108. package/dist/Runtime/events-tools/inputtools.js +1 -1
  109. package/dist/Runtime/events-tools/inputtools.js.map +2 -2
  110. package/dist/Runtime/events-tools/objecttools.js +1 -1
  111. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  112. package/dist/Runtime/gd.js +1 -1
  113. package/dist/Runtime/gd.js.map +2 -2
  114. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  115. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  116. package/dist/Runtime/inputmanager.js +1 -1
  117. package/dist/Runtime/inputmanager.js.map +2 -2
  118. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  119. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  120. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
  121. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  122. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  123. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  124. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
  125. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  126. package/dist/Runtime/runtimegame.js +1 -1
  127. package/dist/Runtime/runtimegame.js.map +1 -1
  128. package/dist/Runtime/runtimeobject.js +1 -1
  129. package/dist/Runtime/runtimeobject.js.map +2 -2
  130. package/dist/Runtime/spriteruntimeobject.js +1 -1
  131. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  132. package/dist/Runtime/types/project-data.d.ts +5 -0
  133. package/dist/lib/libGD.cjs +1 -1
  134. package/dist/lib/libGD.d.cts +5 -0
  135. package/dist/lib/libGD.wasm +0 -0
  136. package/dist/loaders.cjs +3 -1
  137. package/dist/loaders.d.cts +2 -0
  138. package/gd.d.ts +74 -30
  139. package/package.json +3 -3
@@ -22,11 +22,8 @@
22
22
  */
23
23
  const defineTileMap = function (extension, _, gd) {
24
24
  var objectTileMap = new gd.ObjectJsImplementation();
25
- objectTileMap.updateProperty = function (
26
- objectContent,
27
- propertyName,
28
- newValue
29
- ) {
25
+ objectTileMap.updateProperty = function (propertyName, newValue) {
26
+ const objectContent = this.content;
30
27
  if (propertyName === 'tilemapJsonFile') {
31
28
  objectContent.tilemapJsonFile = newValue;
32
29
  return true;
@@ -62,8 +59,9 @@ const defineTileMap = function (extension, _, gd) {
62
59
 
63
60
  return false;
64
61
  };
65
- objectTileMap.getProperties = function (objectContent) {
62
+ objectTileMap.getProperties = function () {
66
63
  var objectProperties = new gd.MapStringPropertyDescriptor();
64
+ const objectContent = this.content;
67
65
 
68
66
  objectProperties.set(
69
67
  'tilemapJsonFile',
@@ -147,29 +145,26 @@ const defineTileMap = function (extension, _, gd) {
147
145
 
148
146
  return objectProperties;
149
147
  };
150
- objectTileMap.setRawJSONContent(
151
- JSON.stringify({
152
- tilemapJsonFile: '',
153
- tilesetJsonFile: '',
154
- tilemapAtlasImage: '',
155
- displayMode: 'visible',
156
- layerIndex: 0,
157
- levelIndex: 0,
158
- animationSpeedScale: 1,
159
- animationFps: 4,
160
- })
161
- );
148
+ objectTileMap.content = {
149
+ tilemapJsonFile: '',
150
+ tilesetJsonFile: '',
151
+ tilemapAtlasImage: '',
152
+ displayMode: 'visible',
153
+ layerIndex: 0,
154
+ levelIndex: 0,
155
+ animationSpeedScale: 1,
156
+ animationFps: 4,
157
+ };
162
158
 
163
159
  objectTileMap.updateInitialInstanceProperty = function (
164
- objectContent,
165
160
  instance,
166
161
  propertyName,
167
162
  newValue
168
163
  ) {
169
164
  return false;
170
165
  };
171
- objectTileMap.getInitialInstanceProperties = function (content, instance) {
172
- var instanceProperties = new gd.MapStringPropertyDescriptor();
166
+ objectTileMap.getInitialInstanceProperties = function (instance) {
167
+ const instanceProperties = new gd.MapStringPropertyDescriptor();
173
168
  return instanceProperties;
174
169
  };
175
170
 
@@ -597,11 +592,8 @@ const defineTileMap = function (extension, _, gd) {
597
592
  */
598
593
  const defineSimpleTileMap = function (extension, _, gd) {
599
594
  var objectSimpleTileMap = new gd.ObjectJsImplementation();
600
- objectSimpleTileMap.updateProperty = function (
601
- objectContent,
602
- propertyName,
603
- newValue
604
- ) {
595
+ objectSimpleTileMap.updateProperty = function (propertyName, newValue) {
596
+ const objectContent = this.content;
605
597
  if (propertyName === 'atlasImage') {
606
598
  objectContent.atlasImage = newValue;
607
599
  return true;
@@ -625,12 +617,18 @@ const defineSimpleTileMap = function (extension, _, gd) {
625
617
 
626
618
  return false;
627
619
  };
628
- objectSimpleTileMap.getProperties = function (objectContent) {
620
+ objectSimpleTileMap.getProperties = function () {
629
621
  var objectProperties = new gd.MapStringPropertyDescriptor();
622
+ const objectContent = this.content;
630
623
 
631
624
  objectProperties.set(
632
625
  'columnCount',
633
- new gd.PropertyDescriptor((objectContent.columnCount || 4).toString())
626
+ new gd.PropertyDescriptor(
627
+ (typeof objectContent.columnCount === 'undefined'
628
+ ? 4
629
+ : objectContent.columnCount
630
+ ).toString()
631
+ )
634
632
  .setType('number')
635
633
  .setLabel(_('Columns'))
636
634
  .setDescription(_('Number of columns.'))
@@ -638,7 +636,12 @@ const defineSimpleTileMap = function (extension, _, gd) {
638
636
  );
639
637
  objectProperties.set(
640
638
  'rowCount',
641
- new gd.PropertyDescriptor((objectContent.rowCount || 4).toString())
639
+ new gd.PropertyDescriptor(
640
+ (typeof objectContent.rowCount === 'undefined'
641
+ ? 4
642
+ : objectContent.rowCount
643
+ ).toString()
644
+ )
642
645
  .setType('number')
643
646
  .setLabel(_('Rows'))
644
647
  .setDescription(_('Number of rows.'))
@@ -646,10 +649,16 @@ const defineSimpleTileMap = function (extension, _, gd) {
646
649
  );
647
650
  objectProperties.set(
648
651
  'tileSize',
649
- new gd.PropertyDescriptor((objectContent.tileSize || 8).toString())
652
+ new gd.PropertyDescriptor(
653
+ (typeof objectContent.tileSize === 'undefined'
654
+ ? 8
655
+ : objectContent.tileSize
656
+ ).toString()
657
+ )
650
658
  .setType('number')
651
659
  .setLabel(_('Tile size'))
652
660
  .setDescription(_('Tile size in pixels.'))
661
+ .setHidden(true) // Hidden because a full editor is needed to recompute column/row counts
653
662
  );
654
663
  objectProperties.set(
655
664
  'tilesWithHitBox',
@@ -669,19 +678,18 @@ const defineSimpleTileMap = function (extension, _, gd) {
669
678
  .addExtraInfo('image')
670
679
  .setLabel(_('Atlas image'))
671
680
  .setDescription(_('The Atlas image containing the tileset.'))
681
+ .setHidden(true) // Hidden because a full editor is needed to recompute column/row counts
672
682
  );
673
683
 
674
684
  return objectProperties;
675
685
  };
676
- objectSimpleTileMap.setRawJSONContent(
677
- JSON.stringify({
678
- atlasImage: '',
679
- rowCount: 1,
680
- columnCount: 1,
681
- tileSize: 8,
682
- tilesWithHitBox: '',
683
- })
684
- );
686
+ objectSimpleTileMap.content = {
687
+ atlasImage: '',
688
+ rowCount: 1,
689
+ columnCount: 1,
690
+ tileSize: 8,
691
+ tilesWithHitBox: '',
692
+ };
685
693
 
686
694
  objectSimpleTileMap.updateInitialInstanceProperty = function (
687
695
  instance,
@@ -695,10 +703,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
695
703
  return false;
696
704
  };
697
705
 
698
- objectSimpleTileMap.getInitialInstanceProperties = function (
699
- objectContent,
700
- instance
701
- ) {
706
+ objectSimpleTileMap.getInitialInstanceProperties = function (instance) {
702
707
  var instanceProperties = new gd.MapStringPropertyDescriptor();
703
708
 
704
709
  instanceProperties
@@ -720,6 +725,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
720
725
  objectSimpleTileMap
721
726
  )
722
727
  .setCategoryFullName(_('General'))
728
+ .setOpenFullEditorLabel(_('Edit tileset and collisions'))
723
729
  .addDefaultBehavior('ResizableCapability::ResizableBehavior')
724
730
  .addDefaultBehavior('ScalableCapability::ScalableBehavior')
725
731
  .addDefaultBehavior('OpacityCapability::OpacityBehavior')
@@ -735,7 +741,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
735
741
  .addExpression(
736
742
  'TilesetColumnCount',
737
743
  _('Tileset column count'),
738
- _('Get the number of column in the tileset.'),
744
+ _('Get the number of columns in the tileset.'),
739
745
  '',
740
746
  'JsPlatform/Extensions/tile_map.svg'
741
747
  )
@@ -746,7 +752,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
746
752
  .addExpression(
747
753
  'TilesetRowCount',
748
754
  _('Tileset row count'),
749
- _('Get the number of row in the tileset.'),
755
+ _('Get the number of rows in the tileset.'),
750
756
  '',
751
757
  'JsPlatform/Extensions/tile_map.svg'
752
758
  )
@@ -815,7 +821,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
815
821
  'TileIdAtPosition',
816
822
  _('Tile (at position)'),
817
823
  _('the id of the tile at the scene coordinates'),
818
- _('the tile id at scene coordinates _PARAM3_ ; _PARAM4_'),
824
+ _('the tile id in _PARAM0_ at scene coordinates _PARAM3_ ; _PARAM4_'),
819
825
  '',
820
826
  'JsPlatform/Extensions/tile_map.svg'
821
827
  )
@@ -832,7 +838,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
832
838
  _('Flip tile vertically (at position)'),
833
839
  _('Flip tile vertically at scene coordinates.'),
834
840
  _(
835
- 'Flip tile vertically at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
841
+ 'Flip tile vertically in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
836
842
  ),
837
843
  _('Effects'),
838
844
  'res/actions/flipY24.png',
@@ -851,7 +857,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
851
857
  _('Flip tile horizontally (at position)'),
852
858
  _('Flip tile horizontally at scene coordinates.'),
853
859
  _(
854
- 'Flip tile horizontally at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
860
+ 'Flip tile horizontally in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
855
861
  ),
856
862
  _('Effects'),
857
863
  'res/actions/flipX24.png',
@@ -869,7 +875,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
869
875
  'RemoveTileAtPosition',
870
876
  _('Remove tile (at position)'),
871
877
  _('Remove the tile at the scene coordinates.'),
872
- _('Remove tile at scene coordinates _PARAM1_ ; _PARAM2_'),
878
+ _('Remove tile in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_'),
873
879
  '',
874
880
  'JsPlatform/Extensions/tile_map.svg',
875
881
  'JsPlatform/Extensions/tile_map.svg'
@@ -903,7 +909,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
903
909
  _('Flip tile vertically (on the grid)'),
904
910
  _('Flip tile vertically at grid coordinates.'),
905
911
  _(
906
- 'Flip tile vertically at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
912
+ 'Flip tile vertically in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
907
913
  ),
908
914
  _('Effects'),
909
915
  'res/actions/flipY24.png',
@@ -922,7 +928,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
922
928
  _('Flip tile horizontally (on the grid)'),
923
929
  _('Flip tile horizontally at grid coordinates.'),
924
930
  _(
925
- 'Flip tile horizontally at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
931
+ 'Flip tile horizontally in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
926
932
  ),
927
933
  _('Effects'),
928
934
  'res/actions/flipX24.png',
@@ -940,7 +946,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
940
946
  'RemoveTileAtGridCoordinates',
941
947
  _('Remove tile (on the grid)'),
942
948
  _('Remove the tile at the grid coordinates.'),
943
- _('Remove tile at grid coordinates _PARAM1_ ; _PARAM2_'),
949
+ _('Remove tile in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_'),
944
950
  '',
945
951
  'JsPlatform/Extensions/tile_map.svg',
946
952
  'JsPlatform/Extensions/tile_map.svg'
@@ -957,7 +963,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
957
963
  _('Tile flipped horizontally (at position)'),
958
964
  _('Check if tile at scene coordinates is flipped horizontally.'),
959
965
  _(
960
- 'The tile at scene coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
966
+ 'The tile in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
961
967
  ),
962
968
  _('Effects'),
963
969
  'res/actions/flipX24.png',
@@ -975,7 +981,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
975
981
  _('Tile flipped vertically (at position)'),
976
982
  _('Check if tile at scene coordinates is flipped vertically.'),
977
983
  _(
978
- 'The tile at scene coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
984
+ 'The tile in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
979
985
  ),
980
986
  _('Effects'),
981
987
  'res/actions/flipY24.png',
@@ -993,7 +999,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
993
999
  _('Tile flipped horizontally (on the grid)'),
994
1000
  _('Check if tile at grid coordinates is flipped horizontally.'),
995
1001
  _(
996
- 'The tile at grid coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
1002
+ 'The tile in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
997
1003
  ),
998
1004
  _('Effects'),
999
1005
  'res/actions/flipX24.png',
@@ -1011,7 +1017,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
1011
1017
  _('Tile flipped vertically (on the grid)'),
1012
1018
  _('Check if tile at grid coordinates is flipped vertically.'),
1013
1019
  _(
1014
- 'The tile at grid coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
1020
+ 'The tile in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
1015
1021
  ),
1016
1022
  _('Effects'),
1017
1023
  'res/actions/flipY24.png',
@@ -1061,11 +1067,8 @@ const defineSimpleTileMap = function (extension, _, gd) {
1061
1067
  */
1062
1068
  const defineCollisionMask = function (extension, _, gd) {
1063
1069
  var collisionMaskObject = new gd.ObjectJsImplementation();
1064
- collisionMaskObject.updateProperty = function (
1065
- objectContent,
1066
- propertyName,
1067
- newValue
1068
- ) {
1070
+ collisionMaskObject.updateProperty = function (propertyName, newValue) {
1071
+ const objectContent = this.content;
1069
1072
  if (propertyName === 'tilemapJsonFile') {
1070
1073
  objectContent.tilemapJsonFile = newValue;
1071
1074
  return true;
@@ -1078,6 +1081,14 @@ const defineCollisionMask = function (extension, _, gd) {
1078
1081
  objectContent.collisionMaskTag = newValue;
1079
1082
  return true;
1080
1083
  }
1084
+ if (propertyName === 'layerIndex') {
1085
+ objectContent.layerIndex = parseFloat(newValue);
1086
+ return true;
1087
+ }
1088
+ if (propertyName === 'useAllLayers') {
1089
+ objectContent.useAllLayers = newValue === '1';
1090
+ return true;
1091
+ }
1081
1092
  if (propertyName === 'debugMode') {
1082
1093
  objectContent.debugMode = newValue === '1';
1083
1094
  return true;
@@ -1105,8 +1116,9 @@ const defineCollisionMask = function (extension, _, gd) {
1105
1116
 
1106
1117
  return false;
1107
1118
  };
1108
- collisionMaskObject.getProperties = function (objectContent) {
1109
- var objectProperties = new gd.MapStringPropertyDescriptor();
1119
+ collisionMaskObject.getProperties = function () {
1120
+ const objectProperties = new gd.MapStringPropertyDescriptor();
1121
+ const objectContent = this.content;
1110
1122
 
1111
1123
  objectProperties.set(
1112
1124
  'tilemapJsonFile',
@@ -1145,6 +1157,28 @@ const defineCollisionMask = function (extension, _, gd) {
1145
1157
  )
1146
1158
  )
1147
1159
  );
1160
+ objectProperties.set(
1161
+ 'layerIndex',
1162
+ new gd.PropertyDescriptor((objectContent.layerIndex || 1).toString())
1163
+ .setType('number')
1164
+ .setLabel(_('Layer index'))
1165
+ .setGroup(_('Layers'))
1166
+ .setAdvanced(true)
1167
+ );
1168
+ objectProperties.set(
1169
+ 'useAllLayers',
1170
+ new gd.PropertyDescriptor(
1171
+ objectContent.useAllLayers ||
1172
+ objectContent.useAllLayers === undefined ||
1173
+ objectContent.useAllLayers === null
1174
+ ? 'true'
1175
+ : 'false'
1176
+ )
1177
+ .setType('boolean')
1178
+ .setLabel(_('Use all layers'))
1179
+ .setGroup(_('Layers'))
1180
+ .setAdvanced(true)
1181
+ );
1148
1182
  objectProperties.set(
1149
1183
  'debugMode',
1150
1184
  new gd.PropertyDescriptor(objectContent.debugMode ? 'true' : 'false')
@@ -1153,12 +1187,14 @@ const defineCollisionMask = function (extension, _, gd) {
1153
1187
  .setDescription(
1154
1188
  _('When activated, it displays the hitboxes in the given color.')
1155
1189
  )
1190
+ .setGroup(_('Appearance'))
1156
1191
  );
1157
1192
  objectProperties.set(
1158
1193
  'outlineColor',
1159
1194
  new gd.PropertyDescriptor(objectContent.outlineColor)
1160
1195
  .setType('color')
1161
1196
  .setLabel(_('Outline color'))
1197
+ .setGroup(_('Appearance'))
1162
1198
  );
1163
1199
  objectProperties.set(
1164
1200
  'outlineOpacity',
@@ -1169,6 +1205,7 @@ const defineCollisionMask = function (extension, _, gd) {
1169
1205
  )
1170
1206
  .setType('number')
1171
1207
  .setLabel(_('Outline opacity (0-255)'))
1208
+ .setGroup(_('Appearance'))
1172
1209
  );
1173
1210
  objectProperties.set(
1174
1211
  'outlineSize',
@@ -1179,12 +1216,14 @@ const defineCollisionMask = function (extension, _, gd) {
1179
1216
  )
1180
1217
  .setType('number')
1181
1218
  .setLabel(_('Outline size (in pixels)'))
1219
+ .setGroup(_('Appearance'))
1182
1220
  );
1183
1221
  objectProperties.set(
1184
1222
  'fillColor',
1185
1223
  new gd.PropertyDescriptor(objectContent.fillColor)
1186
1224
  .setType('color')
1187
1225
  .setLabel(_('Fill color'))
1226
+ .setGroup(_('Appearance'))
1188
1227
  );
1189
1228
  objectProperties.set(
1190
1229
  'fillOpacity',
@@ -1195,36 +1234,33 @@ const defineCollisionMask = function (extension, _, gd) {
1195
1234
  )
1196
1235
  .setType('number')
1197
1236
  .setLabel(_('Fill opacity (0-255)'))
1237
+ .setGroup(_('Appearance'))
1198
1238
  );
1199
1239
 
1200
1240
  return objectProperties;
1201
1241
  };
1202
- collisionMaskObject.setRawJSONContent(
1203
- JSON.stringify({
1204
- tilemapJsonFile: '',
1205
- tilesetJsonFile: '',
1206
- collisionMaskTag: '',
1207
- debugMode: false,
1208
- fillColor: '255;255;255',
1209
- outlineColor: '255;255;255',
1210
- fillOpacity: 64,
1211
- outlineOpacity: 128,
1212
- outlineSize: 1,
1213
- })
1214
- );
1242
+ collisionMaskObject.content = {
1243
+ tilemapJsonFile: '',
1244
+ tilesetJsonFile: '',
1245
+ collisionMaskTag: '',
1246
+ layerIndex: 1,
1247
+ useAllLayers: true,
1248
+ debugMode: false,
1249
+ fillColor: '255;255;255',
1250
+ outlineColor: '255;255;255',
1251
+ fillOpacity: 64,
1252
+ outlineOpacity: 128,
1253
+ outlineSize: 1,
1254
+ };
1215
1255
 
1216
1256
  collisionMaskObject.updateInitialInstanceProperty = function (
1217
- objectContent,
1218
1257
  instance,
1219
1258
  propertyName,
1220
1259
  newValue
1221
1260
  ) {
1222
1261
  return false;
1223
1262
  };
1224
- collisionMaskObject.getInitialInstanceProperties = function (
1225
- content,
1226
- instance
1227
- ) {
1263
+ collisionMaskObject.getInitialInstanceProperties = function (instance) {
1228
1264
  var instanceProperties = new gd.MapStringPropertyDescriptor();
1229
1265
  return instanceProperties;
1230
1266
  };
@@ -1611,6 +1647,7 @@ module.exports = {
1611
1647
 
1612
1648
  this.tileMapPixiObject = new Tilemap.CompositeTilemap();
1613
1649
  this._pixiObject = this.tileMapPixiObject;
1650
+ this._editableTileMap = null;
1614
1651
 
1615
1652
  // Implement `containsPoint` so that we can set `interactive` to true and
1616
1653
  // the Tilemap will properly emit events when hovered/clicked.
@@ -1639,7 +1676,6 @@ module.exports = {
1639
1676
  this.width = 48;
1640
1677
  this.height = 48;
1641
1678
  this.update();
1642
- this.updateTileMap();
1643
1679
  }
1644
1680
 
1645
1681
  onRemovedFromScene() {
@@ -1686,37 +1722,12 @@ module.exports = {
1686
1722
  * This is used to reload the Tilemap
1687
1723
  */
1688
1724
  updateTileMap() {
1689
- // Get the tileset resource to use
1690
- const tilemapAtlasImage = this._associatedObjectConfiguration
1691
- .getProperties()
1692
- .get('tilemapAtlasImage')
1693
- .getValue();
1694
- const tilemapJsonFile = this._associatedObjectConfiguration
1695
- .getProperties()
1696
- .get('tilemapJsonFile')
1697
- .getValue();
1698
- const tilesetJsonFile = this._associatedObjectConfiguration
1699
- .getProperties()
1700
- .get('tilesetJsonFile')
1701
- .getValue();
1702
- const layerIndex = parseInt(
1703
- this._associatedObjectConfiguration
1704
- .getProperties()
1705
- .get('layerIndex')
1706
- .getValue(),
1707
- 10
1708
- );
1709
- const levelIndex = parseInt(
1710
- this._associatedObjectConfiguration
1711
- .getProperties()
1712
- .get('levelIndex')
1713
- .getValue(),
1714
- 10
1715
- );
1716
- const displayMode = this._associatedObjectConfiguration
1717
- .getProperties()
1718
- .get('displayMode')
1719
- .getValue();
1725
+ const tilemapAtlasImage = this._tilemapAtlasImage;
1726
+ const tilemapJsonFile = this._tilemapJsonFile;
1727
+ const tilesetJsonFile = this._tilesetJsonFile;
1728
+ const layerIndex = this._layerIndex;
1729
+ const levelIndex = this._levelIndex;
1730
+ const displayMode = this._displayMode;
1720
1731
 
1721
1732
  const tilemapResource = this._project
1722
1733
  .getResourcesManager()
@@ -1749,12 +1760,15 @@ module.exports = {
1749
1760
  levelIndex,
1750
1761
  pako,
1751
1762
  (tileMap) => {
1763
+ if (this._wasDestroyed) return;
1752
1764
  if (!tileMap) {
1753
1765
  this._onLoadingError();
1754
1766
  // _loadTileMapWithCallback already log errors
1755
1767
  return;
1756
1768
  }
1757
1769
 
1770
+ this._editableTileMap = tileMap;
1771
+
1758
1772
  /** @type {TileMapHelper.TileTextureCache} */
1759
1773
  manager.getOrLoadTextureCache(
1760
1774
  this._loadTileMapWithCallback.bind(this),
@@ -1768,18 +1782,20 @@ module.exports = {
1768
1782
  tilesetJsonFile,
1769
1783
  levelIndex,
1770
1784
  (textureCache) => {
1785
+ if (this._wasDestroyed) return;
1771
1786
  if (!textureCache) {
1772
1787
  this._onLoadingError();
1773
1788
  // getOrLoadTextureCache already log warns and errors.
1774
1789
  return;
1775
1790
  }
1776
1791
  this._onLoadingSuccess();
1792
+ if (!this._editableTileMap) return;
1777
1793
 
1778
- this.width = tileMap.getWidth();
1779
- this.height = tileMap.getHeight();
1794
+ this.width = this._editableTileMap.getWidth();
1795
+ this.height = this._editableTileMap.getHeight();
1780
1796
  TilemapHelper.PixiTileMapHelper.updatePixiTileMap(
1781
1797
  this.tileMapPixiObject,
1782
- tileMap,
1798
+ this._editableTileMap,
1783
1799
  textureCache,
1784
1800
  displayMode,
1785
1801
  layerIndex
@@ -1795,11 +1811,75 @@ module.exports = {
1795
1811
  } else {
1796
1812
  // Wait for the atlas image to load.
1797
1813
  atlasTexture.once('update', () => {
1814
+ if (this._wasDestroyed) return;
1798
1815
  loadTileMap();
1799
1816
  });
1800
1817
  }
1801
1818
  }
1802
1819
 
1820
+ /**
1821
+ * This is called to update the PIXI object on the scene editor, without reloading the tilemap.
1822
+ */
1823
+ updatePixiTileMap() {
1824
+ const tilemapAtlasImage = this._tilemapAtlasImage;
1825
+ const tilemapJsonFile = this._tilemapJsonFile;
1826
+ const tilesetJsonFile = this._tilesetJsonFile;
1827
+ const layerIndex = this._layerIndex;
1828
+ const levelIndex = this._levelIndex;
1829
+ const displayMode = this._displayMode;
1830
+
1831
+ const tilemapResource = this._project
1832
+ .getResourcesManager()
1833
+ .getResource(tilemapJsonFile);
1834
+
1835
+ let metadata = {};
1836
+ try {
1837
+ const tilemapMetadataAsString = tilemapResource.getMetadata();
1838
+ if (tilemapMetadataAsString)
1839
+ metadata = JSON.parse(tilemapMetadataAsString);
1840
+ } catch (error) {
1841
+ console.warn('Malformed metadata in a tilemap object:', error);
1842
+ }
1843
+ const mapping = metadata.embeddedResourcesMapping || {};
1844
+
1845
+ /** @type {TileMapHelper.TileMapManager} */
1846
+ const manager = TilemapHelper.TileMapManager.getManager(this._project);
1847
+
1848
+ /** @type {TileMapHelper.TileTextureCache} */
1849
+ manager.getOrLoadTextureCache(
1850
+ this._loadTileMapWithCallback.bind(this),
1851
+ (textureName) =>
1852
+ this._pixiResourcesLoader.getPIXITexture(
1853
+ this._project,
1854
+ mapping[textureName] || textureName
1855
+ ),
1856
+ tilemapAtlasImage,
1857
+ tilemapJsonFile,
1858
+ tilesetJsonFile,
1859
+ levelIndex,
1860
+ (textureCache) => {
1861
+ if (this._wasDestroyed) return;
1862
+ if (!textureCache) {
1863
+ this._onLoadingError();
1864
+ // getOrLoadTextureCache already log warns and errors.
1865
+ return;
1866
+ }
1867
+ this._onLoadingSuccess();
1868
+ if (!this._editableTileMap) return;
1869
+
1870
+ this.width = this._editableTileMap.getWidth();
1871
+ this.height = this._editableTileMap.getHeight();
1872
+ TilemapHelper.PixiTileMapHelper.updatePixiTileMap(
1873
+ this.tileMapPixiObject,
1874
+ this._editableTileMap,
1875
+ textureCache,
1876
+ displayMode,
1877
+ layerIndex
1878
+ );
1879
+ }
1880
+ );
1881
+ }
1882
+
1803
1883
  // GDJS doesn't use Promise to avoid allocation.
1804
1884
  _loadTileMapWithCallback(tilemapJsonFile, tilesetJsonFile, callback) {
1805
1885
  this._loadTileMap(tilemapJsonFile, tilesetJsonFile).then(callback);
@@ -1840,6 +1920,35 @@ module.exports = {
1840
1920
  * This is called to update the PIXI object on the scene editor
1841
1921
  */
1842
1922
  update() {
1923
+ const object = gd.castObject(
1924
+ this._associatedObjectConfiguration,
1925
+ gd.ObjectJsImplementation
1926
+ );
1927
+
1928
+ const tilemapAtlasImage = object.content.tilemapAtlasImage;
1929
+ const tilemapJsonFile = object.content.tilemapJsonFile;
1930
+ const tilesetJsonFile = object.content.tilesetJsonFile;
1931
+ const layerIndex = object.content.layerIndex;
1932
+ const levelIndex = object.content.levelIndex;
1933
+ const displayMode = object.content.displayMode;
1934
+
1935
+ if (
1936
+ tilemapAtlasImage !== this._tilemapAtlasImage ||
1937
+ tilemapJsonFile !== this._tilemapJsonFile ||
1938
+ tilesetJsonFile !== this._tilesetJsonFile ||
1939
+ layerIndex !== this._layerIndex ||
1940
+ levelIndex !== this._levelIndex ||
1941
+ displayMode !== this._displayMode
1942
+ ) {
1943
+ this._tilemapAtlasImage = tilemapAtlasImage;
1944
+ this._tilemapJsonFile = tilemapJsonFile;
1945
+ this._tilesetJsonFile = tilesetJsonFile;
1946
+ this._layerIndex = layerIndex;
1947
+ this._levelIndex = levelIndex;
1948
+ this._displayMode = displayMode;
1949
+ this.updateTileMap();
1950
+ }
1951
+
1843
1952
  if (this._instance.hasCustomSize()) {
1844
1953
  this._pixiObject.scale.x = this.getCustomWidth() / this.width;
1845
1954
  this._pixiObject.scale.y = this.getCustomHeight() / this.height;
@@ -1870,6 +1979,30 @@ module.exports = {
1870
1979
  this._pixiObject.rotation = RenderedInstance.toRad(
1871
1980
  this._instance.getAngle()
1872
1981
  );
1982
+
1983
+ // Update the opacity, if needed.
1984
+ // Do not hide completely an object so it can still be manipulated
1985
+ const alphaForDisplay = Math.max(
1986
+ this._instance.getOpacity() / 255,
1987
+ 0.5
1988
+ );
1989
+
1990
+ if (
1991
+ this._editableTileMap &&
1992
+ this._pixiObject.alpha !== alphaForDisplay
1993
+ ) {
1994
+ this._pixiObject.alpha = alphaForDisplay;
1995
+ for (const layer of this._editableTileMap.getLayers()) {
1996
+ // Only update layers that are of type TileMapHelper.EditableTileMapLayer.
1997
+ // @ts-ignore - only this type of layer has setAlpha.
1998
+ if (layer.setAlpha) {
1999
+ const editableLayer = /** @type {TileMapHelper.EditableTileMapLayer} */ (layer);
2000
+ editableLayer.setAlpha(alphaForDisplay);
2001
+ }
2002
+ }
2003
+ // Only update the tilemap if the alpha has changed.
2004
+ this.updatePixiTileMap();
2005
+ }
1873
2006
  }
1874
2007
 
1875
2008
  /**
@@ -1896,8 +2029,10 @@ module.exports = {
1896
2029
  * Renderer for instances of SimpleTileMap inside the IDE.
1897
2030
  */
1898
2031
  class RenderedSimpleTileMapInstance extends RenderedInstance {
2032
+ _getStartedText = 'Select this instance\nto start painting';
2033
+ _noAtlasText = 'Set up an atlas image\nin the tilemap object.';
1899
2034
  _placeholderTextPixiObject = new PIXI.Text(
1900
- 'Select this instance\nto start painting',
2035
+ '',
1901
2036
  new PIXI.TextStyle({
1902
2037
  fontFamily: 'Arial',
1903
2038
  fontSize: 16,
@@ -2023,10 +2158,12 @@ module.exports = {
2023
2158
  * Return the path to the thumbnail of the specified object.
2024
2159
  */
2025
2160
  static getThumbnail(project, resourcesLoader, objectConfiguration) {
2026
- const atlasImageResourceName = objectConfiguration
2027
- .getProperties()
2028
- .get('atlasImage')
2029
- .getValue();
2161
+ const object = gd.castObject(
2162
+ objectConfiguration,
2163
+ gd.ObjectJsImplementation
2164
+ );
2165
+
2166
+ const atlasImageResourceName = object.content.atlasImage || '';
2030
2167
  return resourcesLoader.getResourceFullUrl(
2031
2168
  project,
2032
2169
  atlasImageResourceName,
@@ -2042,35 +2179,20 @@ module.exports = {
2042
2179
  * This is used to reload the Tilemap
2043
2180
  */
2044
2181
  updateTileMap() {
2045
- const atlasImageResourceName = this._associatedObjectConfiguration
2046
- .getProperties()
2047
- .get('atlasImage')
2048
- .getValue();
2182
+ const object = gd.castObject(
2183
+ this._associatedObjectConfiguration,
2184
+ gd.ObjectJsImplementation
2185
+ );
2186
+ const atlasImageResourceName = object.content.atlasImage;
2187
+ if (!atlasImageResourceName) return;
2188
+
2049
2189
  const tilemapAsJSObject = JSON.parse(
2050
2190
  this._instance.getRawStringProperty('tilemap') || '{}'
2051
2191
  );
2052
2192
 
2053
- const tileSize = parseInt(
2054
- this._associatedObjectConfiguration
2055
- .getProperties()
2056
- .get('tileSize')
2057
- .getValue(),
2058
- 10
2059
- );
2060
- const columnCount = parseInt(
2061
- this._associatedObjectConfiguration
2062
- .getProperties()
2063
- .get('columnCount')
2064
- .getValue(),
2065
- 10
2066
- );
2067
- const rowCount = parseInt(
2068
- this._associatedObjectConfiguration
2069
- .getProperties()
2070
- .get('rowCount')
2071
- .getValue(),
2072
- 10
2073
- );
2193
+ const tileSize = object.content.tileSize;
2194
+ const columnCount = object.content.columnCount;
2195
+ const rowCount = object.content.rowCount;
2074
2196
 
2075
2197
  const atlasTexture = this._pixiResourcesLoader.getPIXITexture(
2076
2198
  this._project,
@@ -2082,51 +2204,58 @@ module.exports = {
2082
2204
  const manager = TilemapHelper.TileMapManager.getManager(
2083
2205
  this._project
2084
2206
  );
2085
- manager.getOrLoadSimpleTileMap(
2086
- tilemapAsJSObject,
2087
- this._objectName,
2088
- tileSize,
2089
- columnCount,
2090
- rowCount,
2091
- (tileMap) => {
2092
- if (!tileMap) {
2093
- this._onLoadingError();
2094
- console.error('Could not parse tilemap.');
2095
- return;
2096
- }
2097
-
2098
- this._editableTileMap = tileMap;
2099
-
2100
- manager.getOrLoadSimpleTileMapTextureCache(
2101
- (textureName) =>
2102
- this._pixiResourcesLoader.getPIXITexture(
2103
- this._project,
2104
- textureName
2105
- ),
2106
- atlasImageResourceName,
2107
- tileSize,
2108
- columnCount,
2109
- rowCount,
2110
- (
2111
- /** @type {TileMapHelper.TileTextureCache | null} */
2112
- textureCache
2113
- ) => {
2114
- this._onLoadingSuccess();
2115
- if (!this._editableTileMap) return;
2116
-
2117
- this.width = this._editableTileMap.getWidth();
2118
- this.height = this._editableTileMap.getHeight();
2119
- TilemapHelper.PixiTileMapHelper.updatePixiTileMap(
2120
- this.tileMapPixiObject,
2121
- this._editableTileMap,
2122
- textureCache,
2123
- 'all', // No notion of visibility on simple tile maps.
2124
- 0 // Only one layer is used on simple tile maps.
2125
- );
2207
+ try {
2208
+ manager.getOrLoadSimpleTileMap(
2209
+ tilemapAsJSObject,
2210
+ this._objectName,
2211
+ tileSize,
2212
+ columnCount,
2213
+ rowCount,
2214
+ (tileMap) => {
2215
+ if (this._wasDestroyed) return;
2216
+ if (!tileMap) {
2217
+ this._onLoadingError();
2218
+ console.error('Could not parse tilemap.');
2219
+ return;
2126
2220
  }
2127
- );
2128
- }
2129
- );
2221
+
2222
+ this._editableTileMap = tileMap;
2223
+
2224
+ manager.getOrLoadSimpleTileMapTextureCache(
2225
+ (textureName) =>
2226
+ this._pixiResourcesLoader.getPIXITexture(
2227
+ this._project,
2228
+ textureName
2229
+ ),
2230
+ atlasImageResourceName,
2231
+ tileSize,
2232
+ columnCount,
2233
+ rowCount,
2234
+ (
2235
+ /** @type {TileMapHelper.TileTextureCache | null} */
2236
+ textureCache
2237
+ ) => {
2238
+ if (this._wasDestroyed) return;
2239
+ this._onLoadingSuccess();
2240
+ if (!this._editableTileMap) return;
2241
+
2242
+ this.width = this._editableTileMap.getWidth();
2243
+ this.height = this._editableTileMap.getHeight();
2244
+ TilemapHelper.PixiTileMapHelper.updatePixiTileMap(
2245
+ this.tileMapPixiObject,
2246
+ this._editableTileMap,
2247
+ textureCache,
2248
+ 'all', // No notion of visibility on simple tile maps.
2249
+ 0 // Only one layer is used on simple tile maps.
2250
+ );
2251
+ }
2252
+ );
2253
+ }
2254
+ );
2255
+ } catch (error) {
2256
+ this._onLoadingError();
2257
+ console.error('Could not load tilemap:', error);
2258
+ }
2130
2259
  };
2131
2260
 
2132
2261
  if (atlasTexture.valid) {
@@ -2134,38 +2263,26 @@ module.exports = {
2134
2263
  } else {
2135
2264
  // Wait for the atlas image to load.
2136
2265
  atlasTexture.once('update', () => {
2266
+ if (this._wasDestroyed) return;
2137
2267
  loadTileMap();
2138
2268
  });
2139
2269
  }
2140
2270
  }
2141
2271
 
2272
+ /**
2273
+ * This is called to update the PIXI object on the scene editor, without reloading the tilemap.
2274
+ */
2142
2275
  updatePixiTileMap() {
2143
- const atlasImageResourceName = this._associatedObjectConfiguration
2144
- .getProperties()
2145
- .get('atlasImage')
2146
- .getValue();
2147
-
2148
- const tileSize = parseInt(
2149
- this._associatedObjectConfiguration
2150
- .getProperties()
2151
- .get('tileSize')
2152
- .getValue(),
2153
- 10
2154
- );
2155
- const columnCount = parseInt(
2156
- this._associatedObjectConfiguration
2157
- .getProperties()
2158
- .get('columnCount')
2159
- .getValue(),
2160
- 10
2161
- );
2162
- const rowCount = parseInt(
2163
- this._associatedObjectConfiguration
2164
- .getProperties()
2165
- .get('rowCount')
2166
- .getValue(),
2167
- 10
2276
+ const object = gd.castObject(
2277
+ this._associatedObjectConfiguration,
2278
+ gd.ObjectJsImplementation
2168
2279
  );
2280
+
2281
+ const atlasImageResourceName = object.content.atlasImage;
2282
+
2283
+ const tileSize = object.content.tileSize;
2284
+ const columnCount = object.content.columnCount;
2285
+ const rowCount = object.content.rowCount;
2169
2286
  /** @type {TileMapHelper.TileMapManager} */
2170
2287
  const manager = TilemapHelper.TileMapManager.getManager(this._project);
2171
2288
 
@@ -2183,6 +2300,7 @@ module.exports = {
2183
2300
  /** @type {TileMapHelper.TileTextureCache | null} */
2184
2301
  textureCache
2185
2302
  ) => {
2303
+ if (this._wasDestroyed) return;
2186
2304
  this._onLoadingSuccess();
2187
2305
  if (!this._editableTileMap) return;
2188
2306
 
@@ -2203,13 +2321,24 @@ module.exports = {
2203
2321
  * This is called to update the PIXI object on the scene editor
2204
2322
  */
2205
2323
  update() {
2324
+ const object = gd.castObject(
2325
+ this._associatedObjectConfiguration,
2326
+ gd.ObjectJsImplementation
2327
+ );
2328
+ const atlasImageResourceName = object.content.atlasImage;
2329
+
2206
2330
  const isTileMapEmpty = this._editableTileMap
2207
2331
  ? this._editableTileMap.isEmpty()
2208
2332
  : false;
2209
2333
  let objectToChange;
2210
- if (isTileMapEmpty) {
2211
- this._placeholderPixiObject.visible = true;
2334
+ if (this.errorPixiObject) {
2335
+ objectToChange = this.errorPixiObject;
2336
+ } else if (isTileMapEmpty || !atlasImageResourceName) {
2212
2337
  this.tileMapPixiObject.visible = false;
2338
+ this._placeholderPixiObject.visible = true;
2339
+ this._placeholderTextPixiObject.text = !atlasImageResourceName
2340
+ ? this._noAtlasText
2341
+ : this._getStartedText;
2213
2342
  objectToChange = this._placeholderPixiObject;
2214
2343
  } else {
2215
2344
  this._placeholderPixiObject.visible = false;
@@ -2249,6 +2378,26 @@ module.exports = {
2249
2378
  objectToChange.rotation = RenderedInstance.toRad(
2250
2379
  this._instance.getAngle()
2251
2380
  );
2381
+
2382
+ // Update the opacity, if needed.
2383
+ // Do not hide completely an object so it can still be manipulated
2384
+ const alphaForDisplay = Math.max(
2385
+ this._instance.getOpacity() / 255,
2386
+ 0.5
2387
+ );
2388
+
2389
+ if (this._editableTileMap && objectToChange.alpha !== alphaForDisplay) {
2390
+ objectToChange.alpha = alphaForDisplay;
2391
+ for (const layer of this._editableTileMap.getLayers()) {
2392
+ // Only update layers that are of type TileMapHelper.EditableTileMapLayer.
2393
+ // @ts-ignore - only this type of layer has setAlpha.
2394
+ if (layer.setAlpha) {
2395
+ const editableLayer = /** @type {TileMapHelper.EditableTileMapLayer} */ (layer);
2396
+ editableLayer.setAlpha(alphaForDisplay);
2397
+ }
2398
+ }
2399
+ this.updatePixiTileMap();
2400
+ }
2252
2401
  }
2253
2402
 
2254
2403
  /**
@@ -2275,6 +2424,16 @@ module.exports = {
2275
2424
  * Renderer for instances of TileMap collision mask inside the IDE.
2276
2425
  */
2277
2426
  class RenderedCollisionMaskInstance extends RenderedInstance {
2427
+ _tilemapJsonFile = '';
2428
+ _tilesetJsonFile = '';
2429
+ _collisionMaskTag = '';
2430
+ _layerIndex = null;
2431
+ _outlineColor = 0xffffff;
2432
+ _fillColor = 0xffffff;
2433
+ _outlineOpacity = 0;
2434
+ _fillOpacity = 0;
2435
+ _outlineSize = 1;
2436
+
2278
2437
  constructor(
2279
2438
  project,
2280
2439
  instance,
@@ -2291,7 +2450,6 @@ module.exports = {
2291
2450
  );
2292
2451
 
2293
2452
  this.tileMapPixiObject = new PIXI.Graphics();
2294
- this.tileMapPixiObject._0iAmTheTileMapPixiObject = true;
2295
2453
  this._pixiObject = this.tileMapPixiObject;
2296
2454
 
2297
2455
  // Implement `containsPoint` so that we can set `interactive` to true and
@@ -2322,7 +2480,6 @@ module.exports = {
2322
2480
  this.width = 48;
2323
2481
  this.height = 48;
2324
2482
  this.update();
2325
- this.updateTileMap();
2326
2483
  }
2327
2484
 
2328
2485
  onRemovedFromScene() {
@@ -2368,48 +2525,15 @@ module.exports = {
2368
2525
  * This is used to reload the Tilemap
2369
2526
  */
2370
2527
  updateTileMap() {
2371
- // This might become useful in the future
2372
- /*
2373
- const tilemapAtlasImage = this._associatedObjectConfiguration
2374
- .getProperties(this.project)
2375
- .get('tilemapAtlasImage')
2376
- .getValue();
2377
- */
2378
- const tilemapJsonFile = this._associatedObjectConfiguration
2379
- .getProperties()
2380
- .get('tilemapJsonFile')
2381
- .getValue();
2382
- const tilesetJsonFile = this._associatedObjectConfiguration
2383
- .getProperties()
2384
- .get('tilesetJsonFile')
2385
- .getValue();
2386
- const collisionMaskTag = this._associatedObjectConfiguration
2387
- .getProperties()
2388
- .get('collisionMaskTag')
2389
- .getValue();
2390
- const outlineColor = objectsRenderingService.rgbOrHexToHexNumber(
2391
- this._associatedObjectConfiguration
2392
- .getProperties()
2393
- .get('outlineColor')
2394
- .getValue()
2395
- );
2396
- const fillColor = objectsRenderingService.rgbOrHexToHexNumber(
2397
- this._associatedObjectConfiguration
2398
- .getProperties()
2399
- .get('fillColor')
2400
- .getValue()
2401
- );
2402
- const outlineOpacity =
2403
- +this._associatedObjectConfiguration
2404
- .getProperties()
2405
- .get('outlineOpacity')
2406
- .getValue() / 255;
2407
- const fillOpacity =
2408
- +this._associatedObjectConfiguration
2409
- .getProperties()
2410
- .get('fillOpacity')
2411
- .getValue() / 255;
2412
- const outlineSize = 1;
2528
+ const tilemapJsonFile = this._tilemapJsonFile;
2529
+ const tilesetJsonFile = this._tilesetJsonFile;
2530
+ const collisionMaskTag = this._collisionMaskTag;
2531
+ const layerIndex = this._layerIndex;
2532
+ const outlineColor = this._outlineColor;
2533
+ const fillColor = this._fillColor;
2534
+ const outlineOpacity = this._outlineOpacity;
2535
+ const fillOpacity = this._fillOpacity;
2536
+ const outlineSize = this._outlineSize;
2413
2537
 
2414
2538
  /** @type {TileMapHelper.TileMapManager} */
2415
2539
  const manager = TilemapHelper.TileMapManager.getManager(this._project);
@@ -2420,6 +2544,7 @@ module.exports = {
2420
2544
  0, // levelIndex
2421
2545
  pako,
2422
2546
  (tileMap) => {
2547
+ if (this._wasDestroyed) return;
2423
2548
  if (!tileMap) {
2424
2549
  this._onLoadingError();
2425
2550
  // _loadTiledMapWithCallback already log errors
@@ -2433,6 +2558,7 @@ module.exports = {
2433
2558
  this._pixiObject,
2434
2559
  tileMap,
2435
2560
  collisionMaskTag,
2561
+ layerIndex,
2436
2562
  outlineSize,
2437
2563
  outlineColor,
2438
2564
  outlineOpacity,
@@ -2482,6 +2608,49 @@ module.exports = {
2482
2608
  * This is called to update the PIXI object on the scene editor
2483
2609
  */
2484
2610
  update() {
2611
+ const object = gd.castObject(
2612
+ this._associatedObjectConfiguration,
2613
+ gd.ObjectJsImplementation
2614
+ );
2615
+
2616
+ const tilemapJsonFile = object.content.tilemapJsonFile;
2617
+ const tilesetJsonFile = object.content.tilesetJsonFile;
2618
+ const collisionMaskTag = object.content.collisionMaskTag;
2619
+ const useAllLayers = object.content.useAllLayers;
2620
+ const layerIndex = useAllLayers ? null : object.content.layerIndex;
2621
+ const outlineColor = objectsRenderingService.rgbOrHexToHexNumber(
2622
+ object.content.outlineColor
2623
+ );
2624
+ const fillColor = objectsRenderingService.rgbOrHexToHexNumber(
2625
+ object.content.fillColor
2626
+ );
2627
+ const outlineOpacity = object.content.outlineOpacity / 255;
2628
+ const fillOpacity = object.content.fillOpacity / 255;
2629
+ const outlineSize = object.content.outlineSize || 0;
2630
+
2631
+ if (
2632
+ tilemapJsonFile !== this._tilemapJsonFile ||
2633
+ tilesetJsonFile !== this._tilesetJsonFile ||
2634
+ collisionMaskTag !== this._collisionMaskTag ||
2635
+ layerIndex !== this._layerIndex ||
2636
+ outlineColor !== this._outlineColor ||
2637
+ fillColor !== this._fillColor ||
2638
+ outlineOpacity !== this._outlineOpacity ||
2639
+ fillOpacity !== this._fillOpacity ||
2640
+ outlineSize !== this._outlineSize
2641
+ ) {
2642
+ this._tilemapJsonFile = tilemapJsonFile;
2643
+ this._tilesetJsonFile = tilesetJsonFile;
2644
+ this._collisionMaskTag = collisionMaskTag;
2645
+ this._layerIndex = layerIndex;
2646
+ this._outlineColor = outlineColor;
2647
+ this._fillColor = fillColor;
2648
+ this._outlineOpacity = outlineOpacity;
2649
+ this._fillOpacity = fillOpacity;
2650
+ this._outlineSize = outlineSize;
2651
+ this.updateTileMap();
2652
+ }
2653
+
2485
2654
  if (this._instance.hasCustomSize()) {
2486
2655
  this._pixiObject.scale.x = this.getCustomWidth() / this.width;
2487
2656
  this._pixiObject.scale.y = this.getCustomHeight() / this.height;