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
|
@@ -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 (
|
|
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.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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 (
|
|
172
|
-
|
|
166
|
+
objectTileMap.getInitialInstanceProperties = function (instance) {
|
|
167
|
+
const instanceProperties = new gd.MapStringPropertyDescriptor();
|
|
173
168
|
return instanceProperties;
|
|
174
169
|
};
|
|
175
170
|
|
|
@@ -184,7 +179,6 @@ const defineTileMap = function (extension, _, gd) {
|
|
|
184
179
|
objectTileMap
|
|
185
180
|
)
|
|
186
181
|
.setCategoryFullName(_('Advanced'))
|
|
187
|
-
.addDefaultBehavior('EffectCapability::EffectBehavior')
|
|
188
182
|
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
|
189
183
|
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
|
190
184
|
.addDefaultBehavior('OpacityCapability::OpacityBehavior')
|
|
@@ -598,11 +592,8 @@ const defineTileMap = function (extension, _, gd) {
|
|
|
598
592
|
*/
|
|
599
593
|
const defineSimpleTileMap = function (extension, _, gd) {
|
|
600
594
|
var objectSimpleTileMap = new gd.ObjectJsImplementation();
|
|
601
|
-
objectSimpleTileMap.updateProperty = function (
|
|
602
|
-
objectContent
|
|
603
|
-
propertyName,
|
|
604
|
-
newValue
|
|
605
|
-
) {
|
|
595
|
+
objectSimpleTileMap.updateProperty = function (propertyName, newValue) {
|
|
596
|
+
const objectContent = this.content;
|
|
606
597
|
if (propertyName === 'atlasImage') {
|
|
607
598
|
objectContent.atlasImage = newValue;
|
|
608
599
|
return true;
|
|
@@ -626,12 +617,18 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
626
617
|
|
|
627
618
|
return false;
|
|
628
619
|
};
|
|
629
|
-
objectSimpleTileMap.getProperties = function (
|
|
620
|
+
objectSimpleTileMap.getProperties = function () {
|
|
630
621
|
var objectProperties = new gd.MapStringPropertyDescriptor();
|
|
622
|
+
const objectContent = this.content;
|
|
631
623
|
|
|
632
624
|
objectProperties.set(
|
|
633
625
|
'columnCount',
|
|
634
|
-
new gd.PropertyDescriptor(
|
|
626
|
+
new gd.PropertyDescriptor(
|
|
627
|
+
(typeof objectContent.columnCount === 'undefined'
|
|
628
|
+
? 4
|
|
629
|
+
: objectContent.columnCount
|
|
630
|
+
).toString()
|
|
631
|
+
)
|
|
635
632
|
.setType('number')
|
|
636
633
|
.setLabel(_('Columns'))
|
|
637
634
|
.setDescription(_('Number of columns.'))
|
|
@@ -639,7 +636,12 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
639
636
|
);
|
|
640
637
|
objectProperties.set(
|
|
641
638
|
'rowCount',
|
|
642
|
-
new gd.PropertyDescriptor(
|
|
639
|
+
new gd.PropertyDescriptor(
|
|
640
|
+
(typeof objectContent.rowCount === 'undefined'
|
|
641
|
+
? 4
|
|
642
|
+
: objectContent.rowCount
|
|
643
|
+
).toString()
|
|
644
|
+
)
|
|
643
645
|
.setType('number')
|
|
644
646
|
.setLabel(_('Rows'))
|
|
645
647
|
.setDescription(_('Number of rows.'))
|
|
@@ -647,10 +649,16 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
647
649
|
);
|
|
648
650
|
objectProperties.set(
|
|
649
651
|
'tileSize',
|
|
650
|
-
new gd.PropertyDescriptor(
|
|
652
|
+
new gd.PropertyDescriptor(
|
|
653
|
+
(typeof objectContent.tileSize === 'undefined'
|
|
654
|
+
? 8
|
|
655
|
+
: objectContent.tileSize
|
|
656
|
+
).toString()
|
|
657
|
+
)
|
|
651
658
|
.setType('number')
|
|
652
659
|
.setLabel(_('Tile size'))
|
|
653
660
|
.setDescription(_('Tile size in pixels.'))
|
|
661
|
+
.setHidden(true) // Hidden because a full editor is needed to recompute column/row counts
|
|
654
662
|
);
|
|
655
663
|
objectProperties.set(
|
|
656
664
|
'tilesWithHitBox',
|
|
@@ -670,19 +678,18 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
670
678
|
.addExtraInfo('image')
|
|
671
679
|
.setLabel(_('Atlas image'))
|
|
672
680
|
.setDescription(_('The Atlas image containing the tileset.'))
|
|
681
|
+
.setHidden(true) // Hidden because a full editor is needed to recompute column/row counts
|
|
673
682
|
);
|
|
674
683
|
|
|
675
684
|
return objectProperties;
|
|
676
685
|
};
|
|
677
|
-
objectSimpleTileMap.
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
})
|
|
685
|
-
);
|
|
686
|
+
objectSimpleTileMap.content = {
|
|
687
|
+
atlasImage: '',
|
|
688
|
+
rowCount: 1,
|
|
689
|
+
columnCount: 1,
|
|
690
|
+
tileSize: 8,
|
|
691
|
+
tilesWithHitBox: '',
|
|
692
|
+
};
|
|
686
693
|
|
|
687
694
|
objectSimpleTileMap.updateInitialInstanceProperty = function (
|
|
688
695
|
instance,
|
|
@@ -696,10 +703,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
696
703
|
return false;
|
|
697
704
|
};
|
|
698
705
|
|
|
699
|
-
objectSimpleTileMap.getInitialInstanceProperties = function (
|
|
700
|
-
objectContent,
|
|
701
|
-
instance
|
|
702
|
-
) {
|
|
706
|
+
objectSimpleTileMap.getInitialInstanceProperties = function (instance) {
|
|
703
707
|
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
|
704
708
|
|
|
705
709
|
instanceProperties
|
|
@@ -721,7 +725,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
721
725
|
objectSimpleTileMap
|
|
722
726
|
)
|
|
723
727
|
.setCategoryFullName(_('General'))
|
|
724
|
-
.
|
|
728
|
+
.setOpenFullEditorLabel(_('Edit tileset and collisions'))
|
|
725
729
|
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
|
726
730
|
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
|
727
731
|
.addDefaultBehavior('OpacityCapability::OpacityBehavior')
|
|
@@ -737,7 +741,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
737
741
|
.addExpression(
|
|
738
742
|
'TilesetColumnCount',
|
|
739
743
|
_('Tileset column count'),
|
|
740
|
-
_('Get the number of
|
|
744
|
+
_('Get the number of columns in the tileset.'),
|
|
741
745
|
'',
|
|
742
746
|
'JsPlatform/Extensions/tile_map.svg'
|
|
743
747
|
)
|
|
@@ -748,7 +752,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
748
752
|
.addExpression(
|
|
749
753
|
'TilesetRowCount',
|
|
750
754
|
_('Tileset row count'),
|
|
751
|
-
_('Get the number of
|
|
755
|
+
_('Get the number of rows in the tileset.'),
|
|
752
756
|
'',
|
|
753
757
|
'JsPlatform/Extensions/tile_map.svg'
|
|
754
758
|
)
|
|
@@ -817,7 +821,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
817
821
|
'TileIdAtPosition',
|
|
818
822
|
_('Tile (at position)'),
|
|
819
823
|
_('the id of the tile at the scene coordinates'),
|
|
820
|
-
_('the tile id at scene coordinates _PARAM3_ ; _PARAM4_'),
|
|
824
|
+
_('the tile id in _PARAM0_ at scene coordinates _PARAM3_ ; _PARAM4_'),
|
|
821
825
|
'',
|
|
822
826
|
'JsPlatform/Extensions/tile_map.svg'
|
|
823
827
|
)
|
|
@@ -834,7 +838,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
834
838
|
_('Flip tile vertically (at position)'),
|
|
835
839
|
_('Flip tile vertically at scene coordinates.'),
|
|
836
840
|
_(
|
|
837
|
-
'Flip tile vertically at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
841
|
+
'Flip tile vertically in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
838
842
|
),
|
|
839
843
|
_('Effects'),
|
|
840
844
|
'res/actions/flipY24.png',
|
|
@@ -853,7 +857,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
853
857
|
_('Flip tile horizontally (at position)'),
|
|
854
858
|
_('Flip tile horizontally at scene coordinates.'),
|
|
855
859
|
_(
|
|
856
|
-
'Flip tile horizontally at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
860
|
+
'Flip tile horizontally in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
857
861
|
),
|
|
858
862
|
_('Effects'),
|
|
859
863
|
'res/actions/flipX24.png',
|
|
@@ -871,7 +875,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
871
875
|
'RemoveTileAtPosition',
|
|
872
876
|
_('Remove tile (at position)'),
|
|
873
877
|
_('Remove the tile at the scene coordinates.'),
|
|
874
|
-
_('Remove tile at scene coordinates _PARAM1_ ; _PARAM2_'),
|
|
878
|
+
_('Remove tile in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_'),
|
|
875
879
|
'',
|
|
876
880
|
'JsPlatform/Extensions/tile_map.svg',
|
|
877
881
|
'JsPlatform/Extensions/tile_map.svg'
|
|
@@ -905,7 +909,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
905
909
|
_('Flip tile vertically (on the grid)'),
|
|
906
910
|
_('Flip tile vertically at grid coordinates.'),
|
|
907
911
|
_(
|
|
908
|
-
'Flip tile vertically at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
912
|
+
'Flip tile vertically in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
909
913
|
),
|
|
910
914
|
_('Effects'),
|
|
911
915
|
'res/actions/flipY24.png',
|
|
@@ -924,7 +928,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
924
928
|
_('Flip tile horizontally (on the grid)'),
|
|
925
929
|
_('Flip tile horizontally at grid coordinates.'),
|
|
926
930
|
_(
|
|
927
|
-
'Flip tile horizontally at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
931
|
+
'Flip tile horizontally in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
|
|
928
932
|
),
|
|
929
933
|
_('Effects'),
|
|
930
934
|
'res/actions/flipX24.png',
|
|
@@ -942,7 +946,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
942
946
|
'RemoveTileAtGridCoordinates',
|
|
943
947
|
_('Remove tile (on the grid)'),
|
|
944
948
|
_('Remove the tile at the grid coordinates.'),
|
|
945
|
-
_('Remove tile at grid coordinates _PARAM1_ ; _PARAM2_'),
|
|
949
|
+
_('Remove tile in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_'),
|
|
946
950
|
'',
|
|
947
951
|
'JsPlatform/Extensions/tile_map.svg',
|
|
948
952
|
'JsPlatform/Extensions/tile_map.svg'
|
|
@@ -959,7 +963,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
959
963
|
_('Tile flipped horizontally (at position)'),
|
|
960
964
|
_('Check if tile at scene coordinates is flipped horizontally.'),
|
|
961
965
|
_(
|
|
962
|
-
'The tile at scene coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
|
|
966
|
+
'The tile in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
|
|
963
967
|
),
|
|
964
968
|
_('Effects'),
|
|
965
969
|
'res/actions/flipX24.png',
|
|
@@ -977,7 +981,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
977
981
|
_('Tile flipped vertically (at position)'),
|
|
978
982
|
_('Check if tile at scene coordinates is flipped vertically.'),
|
|
979
983
|
_(
|
|
980
|
-
'The tile at scene coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
|
|
984
|
+
'The tile in _PARAM0_ at scene coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
|
|
981
985
|
),
|
|
982
986
|
_('Effects'),
|
|
983
987
|
'res/actions/flipY24.png',
|
|
@@ -995,7 +999,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
995
999
|
_('Tile flipped horizontally (on the grid)'),
|
|
996
1000
|
_('Check if tile at grid coordinates is flipped horizontally.'),
|
|
997
1001
|
_(
|
|
998
|
-
'The tile at grid coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
|
|
1002
|
+
'The tile in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_ is flipped horizontally'
|
|
999
1003
|
),
|
|
1000
1004
|
_('Effects'),
|
|
1001
1005
|
'res/actions/flipX24.png',
|
|
@@ -1013,7 +1017,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
1013
1017
|
_('Tile flipped vertically (on the grid)'),
|
|
1014
1018
|
_('Check if tile at grid coordinates is flipped vertically.'),
|
|
1015
1019
|
_(
|
|
1016
|
-
'The tile at grid coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
|
|
1020
|
+
'The tile in _PARAM0_ at grid coordinates _PARAM1_ ; _PARAM2_ is flipped vertically'
|
|
1017
1021
|
),
|
|
1018
1022
|
_('Effects'),
|
|
1019
1023
|
'res/actions/flipY24.png',
|
|
@@ -1063,11 +1067,8 @@ const defineSimpleTileMap = function (extension, _, gd) {
|
|
|
1063
1067
|
*/
|
|
1064
1068
|
const defineCollisionMask = function (extension, _, gd) {
|
|
1065
1069
|
var collisionMaskObject = new gd.ObjectJsImplementation();
|
|
1066
|
-
collisionMaskObject.updateProperty = function (
|
|
1067
|
-
objectContent
|
|
1068
|
-
propertyName,
|
|
1069
|
-
newValue
|
|
1070
|
-
) {
|
|
1070
|
+
collisionMaskObject.updateProperty = function (propertyName, newValue) {
|
|
1071
|
+
const objectContent = this.content;
|
|
1071
1072
|
if (propertyName === 'tilemapJsonFile') {
|
|
1072
1073
|
objectContent.tilemapJsonFile = newValue;
|
|
1073
1074
|
return true;
|
|
@@ -1080,6 +1081,14 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1080
1081
|
objectContent.collisionMaskTag = newValue;
|
|
1081
1082
|
return true;
|
|
1082
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
|
+
}
|
|
1083
1092
|
if (propertyName === 'debugMode') {
|
|
1084
1093
|
objectContent.debugMode = newValue === '1';
|
|
1085
1094
|
return true;
|
|
@@ -1107,8 +1116,9 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1107
1116
|
|
|
1108
1117
|
return false;
|
|
1109
1118
|
};
|
|
1110
|
-
collisionMaskObject.getProperties = function (
|
|
1111
|
-
|
|
1119
|
+
collisionMaskObject.getProperties = function () {
|
|
1120
|
+
const objectProperties = new gd.MapStringPropertyDescriptor();
|
|
1121
|
+
const objectContent = this.content;
|
|
1112
1122
|
|
|
1113
1123
|
objectProperties.set(
|
|
1114
1124
|
'tilemapJsonFile',
|
|
@@ -1147,6 +1157,28 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1147
1157
|
)
|
|
1148
1158
|
)
|
|
1149
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
|
+
);
|
|
1150
1182
|
objectProperties.set(
|
|
1151
1183
|
'debugMode',
|
|
1152
1184
|
new gd.PropertyDescriptor(objectContent.debugMode ? 'true' : 'false')
|
|
@@ -1155,12 +1187,14 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1155
1187
|
.setDescription(
|
|
1156
1188
|
_('When activated, it displays the hitboxes in the given color.')
|
|
1157
1189
|
)
|
|
1190
|
+
.setGroup(_('Appearance'))
|
|
1158
1191
|
);
|
|
1159
1192
|
objectProperties.set(
|
|
1160
1193
|
'outlineColor',
|
|
1161
1194
|
new gd.PropertyDescriptor(objectContent.outlineColor)
|
|
1162
1195
|
.setType('color')
|
|
1163
1196
|
.setLabel(_('Outline color'))
|
|
1197
|
+
.setGroup(_('Appearance'))
|
|
1164
1198
|
);
|
|
1165
1199
|
objectProperties.set(
|
|
1166
1200
|
'outlineOpacity',
|
|
@@ -1171,6 +1205,7 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1171
1205
|
)
|
|
1172
1206
|
.setType('number')
|
|
1173
1207
|
.setLabel(_('Outline opacity (0-255)'))
|
|
1208
|
+
.setGroup(_('Appearance'))
|
|
1174
1209
|
);
|
|
1175
1210
|
objectProperties.set(
|
|
1176
1211
|
'outlineSize',
|
|
@@ -1181,12 +1216,14 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1181
1216
|
)
|
|
1182
1217
|
.setType('number')
|
|
1183
1218
|
.setLabel(_('Outline size (in pixels)'))
|
|
1219
|
+
.setGroup(_('Appearance'))
|
|
1184
1220
|
);
|
|
1185
1221
|
objectProperties.set(
|
|
1186
1222
|
'fillColor',
|
|
1187
1223
|
new gd.PropertyDescriptor(objectContent.fillColor)
|
|
1188
1224
|
.setType('color')
|
|
1189
1225
|
.setLabel(_('Fill color'))
|
|
1226
|
+
.setGroup(_('Appearance'))
|
|
1190
1227
|
);
|
|
1191
1228
|
objectProperties.set(
|
|
1192
1229
|
'fillOpacity',
|
|
@@ -1197,36 +1234,33 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1197
1234
|
)
|
|
1198
1235
|
.setType('number')
|
|
1199
1236
|
.setLabel(_('Fill opacity (0-255)'))
|
|
1237
|
+
.setGroup(_('Appearance'))
|
|
1200
1238
|
);
|
|
1201
1239
|
|
|
1202
1240
|
return objectProperties;
|
|
1203
1241
|
};
|
|
1204
|
-
collisionMaskObject.
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
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
|
+
};
|
|
1217
1255
|
|
|
1218
1256
|
collisionMaskObject.updateInitialInstanceProperty = function (
|
|
1219
|
-
objectContent,
|
|
1220
1257
|
instance,
|
|
1221
1258
|
propertyName,
|
|
1222
1259
|
newValue
|
|
1223
1260
|
) {
|
|
1224
1261
|
return false;
|
|
1225
1262
|
};
|
|
1226
|
-
collisionMaskObject.getInitialInstanceProperties = function (
|
|
1227
|
-
content,
|
|
1228
|
-
instance
|
|
1229
|
-
) {
|
|
1263
|
+
collisionMaskObject.getInitialInstanceProperties = function (instance) {
|
|
1230
1264
|
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
|
1231
1265
|
return instanceProperties;
|
|
1232
1266
|
};
|
|
@@ -1240,7 +1274,6 @@ const defineCollisionMask = function (extension, _, gd) {
|
|
|
1240
1274
|
collisionMaskObject
|
|
1241
1275
|
)
|
|
1242
1276
|
.setCategoryFullName(_('Advanced'))
|
|
1243
|
-
.addDefaultBehavior('EffectCapability::EffectBehavior')
|
|
1244
1277
|
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
|
|
1245
1278
|
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
|
|
1246
1279
|
.setIncludeFile('Extensions/TileMap/tilemapcollisionmaskruntimeobject.js')
|
|
@@ -1614,11 +1647,20 @@ module.exports = {
|
|
|
1614
1647
|
|
|
1615
1648
|
this.tileMapPixiObject = new Tilemap.CompositeTilemap();
|
|
1616
1649
|
this._pixiObject = this.tileMapPixiObject;
|
|
1650
|
+
this._editableTileMap = null;
|
|
1617
1651
|
|
|
1618
1652
|
// Implement `containsPoint` so that we can set `interactive` to true and
|
|
1619
1653
|
// the Tilemap will properly emit events when hovered/clicked.
|
|
1620
1654
|
// By default, this is not implemented in pixi-tilemap.
|
|
1621
1655
|
this._pixiObject.containsPoint = (position) => {
|
|
1656
|
+
if (!this._pixiObject) {
|
|
1657
|
+
// Ease debugging by throwing now rather than waiting for an exception later.
|
|
1658
|
+
throw new Error(
|
|
1659
|
+
'containsPoint called on a destroyed PIXI object - this object was not properly removed from the PIXI container.'
|
|
1660
|
+
);
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1622
1664
|
// Turns the world position to the local object coordinates
|
|
1623
1665
|
const localPosition = new PIXI.Point();
|
|
1624
1666
|
this._pixiObject.worldTransform.applyInverse(position, localPosition);
|
|
@@ -1634,28 +1676,38 @@ module.exports = {
|
|
|
1634
1676
|
this.width = 48;
|
|
1635
1677
|
this.height = 48;
|
|
1636
1678
|
this.update();
|
|
1637
|
-
this.updateTileMap();
|
|
1638
1679
|
}
|
|
1639
1680
|
|
|
1640
1681
|
onRemovedFromScene() {
|
|
1641
1682
|
super.onRemovedFromScene();
|
|
1642
1683
|
// Keep textures because they are shared by all tile maps.
|
|
1643
1684
|
this._pixiObject.destroy(false);
|
|
1685
|
+
|
|
1686
|
+
// Not strictly necessary, but helps finding wrong
|
|
1687
|
+
// handling of this._pixiObject in its container.
|
|
1688
|
+
this._pixiObject = null;
|
|
1644
1689
|
}
|
|
1645
1690
|
|
|
1646
|
-
|
|
1691
|
+
_replacePixiObject(newPixiObject) {
|
|
1692
|
+
if (this._pixiObject !== null)
|
|
1693
|
+
this._pixiContainer.removeChild(this._pixiObject);
|
|
1694
|
+
this._pixiObject = newPixiObject;
|
|
1695
|
+
this._pixiContainer.addChild(this._pixiObject);
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
_onLoadingError() {
|
|
1647
1699
|
this.errorPixiObject =
|
|
1648
1700
|
this.errorPixiObject ||
|
|
1649
1701
|
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
|
1650
|
-
|
|
1651
|
-
this.
|
|
1702
|
+
|
|
1703
|
+
this._replacePixiObject(this.errorPixiObject);
|
|
1652
1704
|
}
|
|
1653
1705
|
|
|
1654
|
-
|
|
1706
|
+
_onLoadingSuccess() {
|
|
1655
1707
|
if (this.errorPixiObject) {
|
|
1656
|
-
this.
|
|
1708
|
+
this._replacePixiObject(this.tileMapPixiObject);
|
|
1709
|
+
|
|
1657
1710
|
this.errorPixiObject = null;
|
|
1658
|
-
this._pixiObject = this.tileMapPixiObject;
|
|
1659
1711
|
}
|
|
1660
1712
|
}
|
|
1661
1713
|
|
|
@@ -1670,37 +1722,12 @@ module.exports = {
|
|
|
1670
1722
|
* This is used to reload the Tilemap
|
|
1671
1723
|
*/
|
|
1672
1724
|
updateTileMap() {
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
const
|
|
1679
|
-
.getProperties()
|
|
1680
|
-
.get('tilemapJsonFile')
|
|
1681
|
-
.getValue();
|
|
1682
|
-
const tilesetJsonFile = this._associatedObjectConfiguration
|
|
1683
|
-
.getProperties()
|
|
1684
|
-
.get('tilesetJsonFile')
|
|
1685
|
-
.getValue();
|
|
1686
|
-
const layerIndex = parseInt(
|
|
1687
|
-
this._associatedObjectConfiguration
|
|
1688
|
-
.getProperties()
|
|
1689
|
-
.get('layerIndex')
|
|
1690
|
-
.getValue(),
|
|
1691
|
-
10
|
|
1692
|
-
);
|
|
1693
|
-
const levelIndex = parseInt(
|
|
1694
|
-
this._associatedObjectConfiguration
|
|
1695
|
-
.getProperties()
|
|
1696
|
-
.get('levelIndex')
|
|
1697
|
-
.getValue(),
|
|
1698
|
-
10
|
|
1699
|
-
);
|
|
1700
|
-
const displayMode = this._associatedObjectConfiguration
|
|
1701
|
-
.getProperties()
|
|
1702
|
-
.get('displayMode')
|
|
1703
|
-
.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;
|
|
1704
1731
|
|
|
1705
1732
|
const tilemapResource = this._project
|
|
1706
1733
|
.getResourcesManager()
|
|
@@ -1733,12 +1760,15 @@ module.exports = {
|
|
|
1733
1760
|
levelIndex,
|
|
1734
1761
|
pako,
|
|
1735
1762
|
(tileMap) => {
|
|
1763
|
+
if (this._wasDestroyed) return;
|
|
1736
1764
|
if (!tileMap) {
|
|
1737
|
-
this.
|
|
1765
|
+
this._onLoadingError();
|
|
1738
1766
|
// _loadTileMapWithCallback already log errors
|
|
1739
1767
|
return;
|
|
1740
1768
|
}
|
|
1741
1769
|
|
|
1770
|
+
this._editableTileMap = tileMap;
|
|
1771
|
+
|
|
1742
1772
|
/** @type {TileMapHelper.TileTextureCache} */
|
|
1743
1773
|
manager.getOrLoadTextureCache(
|
|
1744
1774
|
this._loadTileMapWithCallback.bind(this),
|
|
@@ -1752,18 +1782,20 @@ module.exports = {
|
|
|
1752
1782
|
tilesetJsonFile,
|
|
1753
1783
|
levelIndex,
|
|
1754
1784
|
(textureCache) => {
|
|
1785
|
+
if (this._wasDestroyed) return;
|
|
1755
1786
|
if (!textureCache) {
|
|
1756
|
-
this.
|
|
1787
|
+
this._onLoadingError();
|
|
1757
1788
|
// getOrLoadTextureCache already log warns and errors.
|
|
1758
1789
|
return;
|
|
1759
1790
|
}
|
|
1760
|
-
this.
|
|
1791
|
+
this._onLoadingSuccess();
|
|
1792
|
+
if (!this._editableTileMap) return;
|
|
1761
1793
|
|
|
1762
|
-
this.width =
|
|
1763
|
-
this.height =
|
|
1794
|
+
this.width = this._editableTileMap.getWidth();
|
|
1795
|
+
this.height = this._editableTileMap.getHeight();
|
|
1764
1796
|
TilemapHelper.PixiTileMapHelper.updatePixiTileMap(
|
|
1765
1797
|
this.tileMapPixiObject,
|
|
1766
|
-
|
|
1798
|
+
this._editableTileMap,
|
|
1767
1799
|
textureCache,
|
|
1768
1800
|
displayMode,
|
|
1769
1801
|
layerIndex
|
|
@@ -1779,11 +1811,75 @@ module.exports = {
|
|
|
1779
1811
|
} else {
|
|
1780
1812
|
// Wait for the atlas image to load.
|
|
1781
1813
|
atlasTexture.once('update', () => {
|
|
1814
|
+
if (this._wasDestroyed) return;
|
|
1782
1815
|
loadTileMap();
|
|
1783
1816
|
});
|
|
1784
1817
|
}
|
|
1785
1818
|
}
|
|
1786
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
|
+
|
|
1787
1883
|
// GDJS doesn't use Promise to avoid allocation.
|
|
1788
1884
|
_loadTileMapWithCallback(tilemapJsonFile, tilesetJsonFile, callback) {
|
|
1789
1885
|
this._loadTileMap(tilemapJsonFile, tilesetJsonFile).then(callback);
|
|
@@ -1824,6 +1920,35 @@ module.exports = {
|
|
|
1824
1920
|
* This is called to update the PIXI object on the scene editor
|
|
1825
1921
|
*/
|
|
1826
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
|
+
|
|
1827
1952
|
if (this._instance.hasCustomSize()) {
|
|
1828
1953
|
this._pixiObject.scale.x = this.getCustomWidth() / this.width;
|
|
1829
1954
|
this._pixiObject.scale.y = this.getCustomHeight() / this.height;
|
|
@@ -1854,6 +1979,30 @@ module.exports = {
|
|
|
1854
1979
|
this._pixiObject.rotation = RenderedInstance.toRad(
|
|
1855
1980
|
this._instance.getAngle()
|
|
1856
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
|
+
}
|
|
1857
2006
|
}
|
|
1858
2007
|
|
|
1859
2008
|
/**
|
|
@@ -1880,8 +2029,10 @@ module.exports = {
|
|
|
1880
2029
|
* Renderer for instances of SimpleTileMap inside the IDE.
|
|
1881
2030
|
*/
|
|
1882
2031
|
class RenderedSimpleTileMapInstance extends RenderedInstance {
|
|
2032
|
+
_getStartedText = 'Select this instance\nto start painting';
|
|
2033
|
+
_noAtlasText = 'Set up an atlas image\nin the tilemap object.';
|
|
1883
2034
|
_placeholderTextPixiObject = new PIXI.Text(
|
|
1884
|
-
'
|
|
2035
|
+
'',
|
|
1885
2036
|
new PIXI.TextStyle({
|
|
1886
2037
|
fontFamily: 'Arial',
|
|
1887
2038
|
fontSize: 16,
|
|
@@ -1923,6 +2074,14 @@ module.exports = {
|
|
|
1923
2074
|
// the Tilemap will properly emit events when hovered/clicked.
|
|
1924
2075
|
// By default, this is not implemented in pixi-tilemap.
|
|
1925
2076
|
this._pixiObject.containsPoint = (position) => {
|
|
2077
|
+
if (!this._pixiObject) {
|
|
2078
|
+
// Ease debugging by throwing now rather than waiting for an exception later.
|
|
2079
|
+
throw new Error(
|
|
2080
|
+
'containsPoint called on a destroyed PIXI object - this object was not properly removed from the PIXI container.'
|
|
2081
|
+
);
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
1926
2085
|
// Turns the world position to the local object coordinates
|
|
1927
2086
|
const localPosition = new PIXI.Point();
|
|
1928
2087
|
if (this.tileMapPixiObject.visible) {
|
|
@@ -1966,21 +2125,32 @@ module.exports = {
|
|
|
1966
2125
|
super.onRemovedFromScene();
|
|
1967
2126
|
// Keep textures because they are shared by all tile maps.
|
|
1968
2127
|
this._pixiObject.destroy(false);
|
|
2128
|
+
|
|
2129
|
+
// Not strictly necessary, but helps finding wrong
|
|
2130
|
+
// handling of this._pixiObject in its container.
|
|
2131
|
+
this._pixiObject = null;
|
|
1969
2132
|
}
|
|
1970
2133
|
|
|
1971
|
-
|
|
2134
|
+
_replacePixiObject(newPixiObject) {
|
|
2135
|
+
if (this._pixiObject !== null)
|
|
2136
|
+
this._pixiContainer.removeChild(this._pixiObject);
|
|
2137
|
+
this._pixiObject = newPixiObject;
|
|
2138
|
+
this._pixiContainer.addChild(this._pixiObject);
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
_onLoadingError() {
|
|
1972
2142
|
this.errorPixiObject =
|
|
1973
2143
|
this.errorPixiObject ||
|
|
1974
2144
|
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
|
1975
|
-
|
|
1976
|
-
this.
|
|
2145
|
+
|
|
2146
|
+
this._replacePixiObject(this.errorPixiObject);
|
|
1977
2147
|
}
|
|
1978
2148
|
|
|
1979
|
-
|
|
2149
|
+
_onLoadingSuccess() {
|
|
1980
2150
|
if (this.errorPixiObject) {
|
|
1981
|
-
this.
|
|
2151
|
+
this._replacePixiObject(this.tileMapPixiObject);
|
|
2152
|
+
|
|
1982
2153
|
this.errorPixiObject = null;
|
|
1983
|
-
this._pixiObject = this.tileMapPixiObject;
|
|
1984
2154
|
}
|
|
1985
2155
|
}
|
|
1986
2156
|
|
|
@@ -1988,10 +2158,12 @@ module.exports = {
|
|
|
1988
2158
|
* Return the path to the thumbnail of the specified object.
|
|
1989
2159
|
*/
|
|
1990
2160
|
static getThumbnail(project, resourcesLoader, objectConfiguration) {
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
.
|
|
1994
|
-
|
|
2161
|
+
const object = gd.castObject(
|
|
2162
|
+
objectConfiguration,
|
|
2163
|
+
gd.ObjectJsImplementation
|
|
2164
|
+
);
|
|
2165
|
+
|
|
2166
|
+
const atlasImageResourceName = object.content.atlasImage || '';
|
|
1995
2167
|
return resourcesLoader.getResourceFullUrl(
|
|
1996
2168
|
project,
|
|
1997
2169
|
atlasImageResourceName,
|
|
@@ -2007,35 +2179,20 @@ module.exports = {
|
|
|
2007
2179
|
* This is used to reload the Tilemap
|
|
2008
2180
|
*/
|
|
2009
2181
|
updateTileMap() {
|
|
2010
|
-
const
|
|
2011
|
-
.
|
|
2012
|
-
.
|
|
2013
|
-
|
|
2182
|
+
const object = gd.castObject(
|
|
2183
|
+
this._associatedObjectConfiguration,
|
|
2184
|
+
gd.ObjectJsImplementation
|
|
2185
|
+
);
|
|
2186
|
+
const atlasImageResourceName = object.content.atlasImage;
|
|
2187
|
+
if (!atlasImageResourceName) return;
|
|
2188
|
+
|
|
2014
2189
|
const tilemapAsJSObject = JSON.parse(
|
|
2015
2190
|
this._instance.getRawStringProperty('tilemap') || '{}'
|
|
2016
2191
|
);
|
|
2017
2192
|
|
|
2018
|
-
const tileSize =
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
.get('tileSize')
|
|
2022
|
-
.getValue(),
|
|
2023
|
-
10
|
|
2024
|
-
);
|
|
2025
|
-
const columnCount = parseInt(
|
|
2026
|
-
this._associatedObjectConfiguration
|
|
2027
|
-
.getProperties()
|
|
2028
|
-
.get('columnCount')
|
|
2029
|
-
.getValue(),
|
|
2030
|
-
10
|
|
2031
|
-
);
|
|
2032
|
-
const rowCount = parseInt(
|
|
2033
|
-
this._associatedObjectConfiguration
|
|
2034
|
-
.getProperties()
|
|
2035
|
-
.get('rowCount')
|
|
2036
|
-
.getValue(),
|
|
2037
|
-
10
|
|
2038
|
-
);
|
|
2193
|
+
const tileSize = object.content.tileSize;
|
|
2194
|
+
const columnCount = object.content.columnCount;
|
|
2195
|
+
const rowCount = object.content.rowCount;
|
|
2039
2196
|
|
|
2040
2197
|
const atlasTexture = this._pixiResourcesLoader.getPIXITexture(
|
|
2041
2198
|
this._project,
|
|
@@ -2047,51 +2204,58 @@ module.exports = {
|
|
|
2047
2204
|
const manager = TilemapHelper.TileMapManager.getManager(
|
|
2048
2205
|
this._project
|
|
2049
2206
|
);
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
this.
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
this._editableTileMap = tileMap;
|
|
2064
|
-
|
|
2065
|
-
manager.getOrLoadSimpleTileMapTextureCache(
|
|
2066
|
-
(textureName) =>
|
|
2067
|
-
this._pixiResourcesLoader.getPIXITexture(
|
|
2068
|
-
this._project,
|
|
2069
|
-
textureName
|
|
2070
|
-
),
|
|
2071
|
-
atlasImageResourceName,
|
|
2072
|
-
tileSize,
|
|
2073
|
-
columnCount,
|
|
2074
|
-
rowCount,
|
|
2075
|
-
(
|
|
2076
|
-
/** @type {TileMapHelper.TileTextureCache | null} */
|
|
2077
|
-
textureCache
|
|
2078
|
-
) => {
|
|
2079
|
-
this.onLoadingSuccess();
|
|
2080
|
-
if (!this._editableTileMap) return;
|
|
2081
|
-
|
|
2082
|
-
this.width = this._editableTileMap.getWidth();
|
|
2083
|
-
this.height = this._editableTileMap.getHeight();
|
|
2084
|
-
TilemapHelper.PixiTileMapHelper.updatePixiTileMap(
|
|
2085
|
-
this.tileMapPixiObject,
|
|
2086
|
-
this._editableTileMap,
|
|
2087
|
-
textureCache,
|
|
2088
|
-
'all', // No notion of visibility on simple tile maps.
|
|
2089
|
-
0 // Only one layer is used on simple tile maps.
|
|
2090
|
-
);
|
|
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;
|
|
2091
2220
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
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
|
+
}
|
|
2095
2259
|
};
|
|
2096
2260
|
|
|
2097
2261
|
if (atlasTexture.valid) {
|
|
@@ -2099,38 +2263,26 @@ module.exports = {
|
|
|
2099
2263
|
} else {
|
|
2100
2264
|
// Wait for the atlas image to load.
|
|
2101
2265
|
atlasTexture.once('update', () => {
|
|
2266
|
+
if (this._wasDestroyed) return;
|
|
2102
2267
|
loadTileMap();
|
|
2103
2268
|
});
|
|
2104
2269
|
}
|
|
2105
2270
|
}
|
|
2106
2271
|
|
|
2272
|
+
/**
|
|
2273
|
+
* This is called to update the PIXI object on the scene editor, without reloading the tilemap.
|
|
2274
|
+
*/
|
|
2107
2275
|
updatePixiTileMap() {
|
|
2108
|
-
const
|
|
2109
|
-
.
|
|
2110
|
-
.
|
|
2111
|
-
.getValue();
|
|
2112
|
-
|
|
2113
|
-
const tileSize = parseInt(
|
|
2114
|
-
this._associatedObjectConfiguration
|
|
2115
|
-
.getProperties()
|
|
2116
|
-
.get('tileSize')
|
|
2117
|
-
.getValue(),
|
|
2118
|
-
10
|
|
2119
|
-
);
|
|
2120
|
-
const columnCount = parseInt(
|
|
2121
|
-
this._associatedObjectConfiguration
|
|
2122
|
-
.getProperties()
|
|
2123
|
-
.get('columnCount')
|
|
2124
|
-
.getValue(),
|
|
2125
|
-
10
|
|
2126
|
-
);
|
|
2127
|
-
const rowCount = parseInt(
|
|
2128
|
-
this._associatedObjectConfiguration
|
|
2129
|
-
.getProperties()
|
|
2130
|
-
.get('rowCount')
|
|
2131
|
-
.getValue(),
|
|
2132
|
-
10
|
|
2276
|
+
const object = gd.castObject(
|
|
2277
|
+
this._associatedObjectConfiguration,
|
|
2278
|
+
gd.ObjectJsImplementation
|
|
2133
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;
|
|
2134
2286
|
/** @type {TileMapHelper.TileMapManager} */
|
|
2135
2287
|
const manager = TilemapHelper.TileMapManager.getManager(this._project);
|
|
2136
2288
|
|
|
@@ -2148,7 +2300,8 @@ module.exports = {
|
|
|
2148
2300
|
/** @type {TileMapHelper.TileTextureCache | null} */
|
|
2149
2301
|
textureCache
|
|
2150
2302
|
) => {
|
|
2151
|
-
this.
|
|
2303
|
+
if (this._wasDestroyed) return;
|
|
2304
|
+
this._onLoadingSuccess();
|
|
2152
2305
|
if (!this._editableTileMap) return;
|
|
2153
2306
|
|
|
2154
2307
|
this.width = this._editableTileMap.getWidth();
|
|
@@ -2168,13 +2321,24 @@ module.exports = {
|
|
|
2168
2321
|
* This is called to update the PIXI object on the scene editor
|
|
2169
2322
|
*/
|
|
2170
2323
|
update() {
|
|
2324
|
+
const object = gd.castObject(
|
|
2325
|
+
this._associatedObjectConfiguration,
|
|
2326
|
+
gd.ObjectJsImplementation
|
|
2327
|
+
);
|
|
2328
|
+
const atlasImageResourceName = object.content.atlasImage;
|
|
2329
|
+
|
|
2171
2330
|
const isTileMapEmpty = this._editableTileMap
|
|
2172
2331
|
? this._editableTileMap.isEmpty()
|
|
2173
2332
|
: false;
|
|
2174
2333
|
let objectToChange;
|
|
2175
|
-
if (
|
|
2176
|
-
|
|
2334
|
+
if (this.errorPixiObject) {
|
|
2335
|
+
objectToChange = this.errorPixiObject;
|
|
2336
|
+
} else if (isTileMapEmpty || !atlasImageResourceName) {
|
|
2177
2337
|
this.tileMapPixiObject.visible = false;
|
|
2338
|
+
this._placeholderPixiObject.visible = true;
|
|
2339
|
+
this._placeholderTextPixiObject.text = !atlasImageResourceName
|
|
2340
|
+
? this._noAtlasText
|
|
2341
|
+
: this._getStartedText;
|
|
2178
2342
|
objectToChange = this._placeholderPixiObject;
|
|
2179
2343
|
} else {
|
|
2180
2344
|
this._placeholderPixiObject.visible = false;
|
|
@@ -2214,6 +2378,26 @@ module.exports = {
|
|
|
2214
2378
|
objectToChange.rotation = RenderedInstance.toRad(
|
|
2215
2379
|
this._instance.getAngle()
|
|
2216
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
|
+
}
|
|
2217
2401
|
}
|
|
2218
2402
|
|
|
2219
2403
|
/**
|
|
@@ -2240,6 +2424,16 @@ module.exports = {
|
|
|
2240
2424
|
* Renderer for instances of TileMap collision mask inside the IDE.
|
|
2241
2425
|
*/
|
|
2242
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
|
+
|
|
2243
2437
|
constructor(
|
|
2244
2438
|
project,
|
|
2245
2439
|
instance,
|
|
@@ -2262,6 +2456,14 @@ module.exports = {
|
|
|
2262
2456
|
// the Tilemap will properly emit events when hovered/clicked.
|
|
2263
2457
|
// By default, this is not implemented in pixi-tilemap.
|
|
2264
2458
|
this._pixiObject.containsPoint = (position) => {
|
|
2459
|
+
if (!this._pixiObject) {
|
|
2460
|
+
// Ease debugging by throwing now rather than waiting for an exception later.
|
|
2461
|
+
throw new Error(
|
|
2462
|
+
'containsPoint called on a destroyed PIXI object - this object was not properly removed from the PIXI container.'
|
|
2463
|
+
);
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2265
2467
|
// Turns the world position to the local object coordinates
|
|
2266
2468
|
const localPosition = new PIXI.Point();
|
|
2267
2469
|
this._pixiObject.worldTransform.applyInverse(position, localPosition);
|
|
@@ -2278,27 +2480,37 @@ module.exports = {
|
|
|
2278
2480
|
this.width = 48;
|
|
2279
2481
|
this.height = 48;
|
|
2280
2482
|
this.update();
|
|
2281
|
-
this.updateTileMap();
|
|
2282
2483
|
}
|
|
2283
2484
|
|
|
2284
2485
|
onRemovedFromScene() {
|
|
2285
2486
|
super.onRemovedFromScene();
|
|
2286
2487
|
this._pixiObject.destroy();
|
|
2488
|
+
|
|
2489
|
+
// Not strictly necessary, but helps finding wrong
|
|
2490
|
+
// handling of this._pixiObject in its container.
|
|
2491
|
+
this._pixiObject = null;
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
_replacePixiObject(newPixiObject) {
|
|
2495
|
+
if (this._pixiObject !== null)
|
|
2496
|
+
this._pixiContainer.removeChild(this._pixiObject);
|
|
2497
|
+
this._pixiObject = newPixiObject;
|
|
2498
|
+
this._pixiContainer.addChild(this._pixiObject);
|
|
2287
2499
|
}
|
|
2288
2500
|
|
|
2289
|
-
|
|
2501
|
+
_onLoadingError() {
|
|
2290
2502
|
this.errorPixiObject =
|
|
2291
2503
|
this.errorPixiObject ||
|
|
2292
2504
|
new PIXI.Sprite(this._pixiResourcesLoader.getInvalidPIXITexture());
|
|
2293
|
-
|
|
2294
|
-
this.
|
|
2505
|
+
|
|
2506
|
+
this._replacePixiObject(this.errorPixiObject);
|
|
2295
2507
|
}
|
|
2296
2508
|
|
|
2297
|
-
|
|
2509
|
+
_onLoadingSuccess() {
|
|
2298
2510
|
if (this.errorPixiObject) {
|
|
2299
|
-
this.
|
|
2511
|
+
this._replacePixiObject(this.tileMapPixiObject);
|
|
2512
|
+
|
|
2300
2513
|
this.errorPixiObject = null;
|
|
2301
|
-
this._pixiObject = this.tileMapPixiObject;
|
|
2302
2514
|
}
|
|
2303
2515
|
}
|
|
2304
2516
|
|
|
@@ -2313,48 +2525,15 @@ module.exports = {
|
|
|
2313
2525
|
* This is used to reload the Tilemap
|
|
2314
2526
|
*/
|
|
2315
2527
|
updateTileMap() {
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
const
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
.get('tilemapJsonFile')
|
|
2326
|
-
.getValue();
|
|
2327
|
-
const tilesetJsonFile = this._associatedObjectConfiguration
|
|
2328
|
-
.getProperties()
|
|
2329
|
-
.get('tilesetJsonFile')
|
|
2330
|
-
.getValue();
|
|
2331
|
-
const collisionMaskTag = this._associatedObjectConfiguration
|
|
2332
|
-
.getProperties()
|
|
2333
|
-
.get('collisionMaskTag')
|
|
2334
|
-
.getValue();
|
|
2335
|
-
const outlineColor = objectsRenderingService.rgbOrHexToHexNumber(
|
|
2336
|
-
this._associatedObjectConfiguration
|
|
2337
|
-
.getProperties()
|
|
2338
|
-
.get('outlineColor')
|
|
2339
|
-
.getValue()
|
|
2340
|
-
);
|
|
2341
|
-
const fillColor = objectsRenderingService.rgbOrHexToHexNumber(
|
|
2342
|
-
this._associatedObjectConfiguration
|
|
2343
|
-
.getProperties()
|
|
2344
|
-
.get('fillColor')
|
|
2345
|
-
.getValue()
|
|
2346
|
-
);
|
|
2347
|
-
const outlineOpacity =
|
|
2348
|
-
+this._associatedObjectConfiguration
|
|
2349
|
-
.getProperties()
|
|
2350
|
-
.get('outlineOpacity')
|
|
2351
|
-
.getValue() / 255;
|
|
2352
|
-
const fillOpacity =
|
|
2353
|
-
+this._associatedObjectConfiguration
|
|
2354
|
-
.getProperties()
|
|
2355
|
-
.get('fillOpacity')
|
|
2356
|
-
.getValue() / 255;
|
|
2357
|
-
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;
|
|
2358
2537
|
|
|
2359
2538
|
/** @type {TileMapHelper.TileMapManager} */
|
|
2360
2539
|
const manager = TilemapHelper.TileMapManager.getManager(this._project);
|
|
@@ -2365,12 +2544,13 @@ module.exports = {
|
|
|
2365
2544
|
0, // levelIndex
|
|
2366
2545
|
pako,
|
|
2367
2546
|
(tileMap) => {
|
|
2547
|
+
if (this._wasDestroyed) return;
|
|
2368
2548
|
if (!tileMap) {
|
|
2369
|
-
this.
|
|
2549
|
+
this._onLoadingError();
|
|
2370
2550
|
// _loadTiledMapWithCallback already log errors
|
|
2371
2551
|
return;
|
|
2372
2552
|
}
|
|
2373
|
-
this.
|
|
2553
|
+
this._onLoadingSuccess();
|
|
2374
2554
|
|
|
2375
2555
|
this.width = tileMap.getWidth();
|
|
2376
2556
|
this.height = tileMap.getHeight();
|
|
@@ -2378,6 +2558,7 @@ module.exports = {
|
|
|
2378
2558
|
this._pixiObject,
|
|
2379
2559
|
tileMap,
|
|
2380
2560
|
collisionMaskTag,
|
|
2561
|
+
layerIndex,
|
|
2381
2562
|
outlineSize,
|
|
2382
2563
|
outlineColor,
|
|
2383
2564
|
outlineOpacity,
|
|
@@ -2427,6 +2608,49 @@ module.exports = {
|
|
|
2427
2608
|
* This is called to update the PIXI object on the scene editor
|
|
2428
2609
|
*/
|
|
2429
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
|
+
|
|
2430
2654
|
if (this._instance.hasCustomSize()) {
|
|
2431
2655
|
this._pixiObject.scale.x = this.getCustomWidth() / this.width;
|
|
2432
2656
|
this._pixiObject.scale.y = this.getCustomHeight() / this.height;
|