Update class names in the layered tilemap module.

This commit is contained in:
Relintai 2024-03-01 15:36:53 +01:00
parent cbcc125e25
commit ea5845c3cd
38 changed files with 3568 additions and 3568 deletions

View File

@ -7,8 +7,8 @@ def configure(env):
def get_doc_classes():
return [
"TileMap",
"TileSet"
"LayeredTileMap",
"LayeredTileSet"
]
def get_doc_path():

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileData" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Settings for a single tile in a [TileSet].
Settings for a single tile in a [LayeredTileSet].
</brief_description>
<description>
[TileData] object represents a single tile in a [TileSet]. It is usually edited using the tileset editor, but it can be modified at runtime using [method TileMap._tile_data_runtime_update].
[TileData] object represents a single tile in a [LayeredTileSet]. It is usually edited using the tileset editor, but it can be modified at runtime using [method LayeredTileMap._tile_data_runtime_update].
</description>
<tutorials>
</tutorials>
@ -13,7 +13,7 @@
<return type="void" />
<param index="0" name="layer_id" type="int" />
<description>
Adds a collision polygon to the tile on the given TileSet physics layer.
Adds a collision polygon to the tile on the given LayeredTileSet physics layer.
</description>
</method>
<method name="get_collision_polygon_one_way_margin" qualifiers="const">
@ -21,7 +21,7 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Returns the one-way margin (for one-way platforms) of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Returns the one-way margin (for one-way platforms) of the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="get_collision_polygon_points" qualifiers="const">
@ -29,14 +29,14 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Returns the points of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Returns the points of the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="get_collision_polygons_count" qualifiers="const">
<return type="int" />
<param index="0" name="layer_id" type="int" />
<description>
Returns how many polygons the tile has for TileSet physics layer with index [param layer_id].
Returns how many polygons the tile has for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="get_constant_angular_velocity" qualifiers="const">
@ -74,7 +74,7 @@
<param index="2" name="flip_v" type="bool" default="false" />
<param index="3" name="transpose" type="bool" default="false" />
<description>
Returns the navigation polygon of the tile for the TileSet navigation layer with index [param layer_id].
Returns the navigation polygon of the tile for the LayeredTileSet navigation layer with index [param layer_id].
[param flip_h], [param flip_v], and [param transpose] allow transforming the returned polygon.
</description>
</method>
@ -85,13 +85,13 @@
<param index="2" name="flip_v" type="bool" default="false" />
<param index="3" name="transpose" type="bool" default="false" />
<description>
Returns the occluder polygon of the tile for the TileSet occlusion layer with index [param layer_id].
Returns the occluder polygon of the tile for the LayeredTileSet occlusion layer with index [param layer_id].
[param flip_h], [param flip_v], and [param transpose] allow transforming the returned polygon.
</description>
</method>
<method name="get_terrain_peering_bit" qualifiers="const">
<return type="int" />
<param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<param index="0" name="peering_bit" type="int" enum="LayeredTileSet.CellNeighbor" />
<description>
Returns the tile's terrain bit for the given [param peering_bit] direction.
</description>
@ -101,7 +101,7 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Returns whether one-way collisions are enabled for the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Returns whether one-way collisions are enabled for the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="remove_collision_polygon">
@ -109,7 +109,7 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Removes the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Removes the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="set_collision_polygon_one_way">
@ -118,7 +118,7 @@
<param index="1" name="polygon_index" type="int" />
<param index="2" name="one_way" type="bool" />
<description>
Enables/disables one-way collisions on the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Enables/disables one-way collisions on the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="set_collision_polygon_one_way_margin">
@ -127,7 +127,7 @@
<param index="1" name="polygon_index" type="int" />
<param index="2" name="one_way_margin" type="float" />
<description>
Enables/disables one-way collisions on the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Enables/disables one-way collisions on the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="set_collision_polygon_points">
@ -136,7 +136,7 @@
<param index="1" name="polygon_index" type="int" />
<param index="2" name="polygon" type="PackedVector2Array" />
<description>
Sets the points of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
Sets the points of the polygon at index [param polygon_index] for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="set_collision_polygons_count">
@ -144,7 +144,7 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygons_count" type="int" />
<description>
Sets the polygons count for TileSet physics layer with index [param layer_id].
Sets the polygons count for LayeredTileSet physics layer with index [param layer_id].
</description>
</method>
<method name="set_constant_angular_velocity">
@ -168,7 +168,7 @@
<param index="0" name="layer_name" type="String" />
<param index="1" name="value" type="Variant" />
<description>
Sets the tile's custom data value for the TileSet custom data layer with name [param layer_name].
Sets the tile's custom data value for the LayeredTileSet custom data layer with name [param layer_name].
</description>
</method>
<method name="set_custom_data_by_layer_id">
@ -176,7 +176,7 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="value" type="Variant" />
<description>
Sets the tile's custom data value for the TileSet custom data layer with index [param layer_id].
Sets the tile's custom data value for the LayeredTileSet custom data layer with index [param layer_id].
</description>
</method>
<method name="set_navigation_polygon">
@ -184,7 +184,7 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="navigation_polygon" type="NavigationPolygon" />
<description>
Sets the navigation polygon for the TileSet navigation layer with index [param layer_id].
Sets the navigation polygon for the LayeredTileSet navigation layer with index [param layer_id].
</description>
</method>
<method name="set_occluder">
@ -192,12 +192,12 @@
<param index="0" name="layer_id" type="int" />
<param index="1" name="occluder_polygon" type="OccluderPolygon2D" />
<description>
Sets the occluder for the TileSet occlusion layer with index [param layer_id].
Sets the occluder for the LayeredTileSet occlusion layer with index [param layer_id].
</description>
</method>
<method name="set_terrain_peering_bit">
<return type="void" />
<param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<param index="0" name="peering_bit" type="int" enum="LayeredTileSet.CellNeighbor" />
<param index="1" name="terrain" type="int" />
<description>
Sets the tile's terrain bit for the given [param peering_bit] direction.
@ -236,7 +236,7 @@
Vertical point of the tile used for determining y-sorted order.
</member>
<member name="z_index" type="int" setter="set_z_index" getter="get_z_index" default="0">
Ordering index of this tile, relative to [TileMap].
Ordering index of this tile, relative to [LayeredTileMap].
</member>
</members>
<signals>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileMap" inherits="TileMapLayerGroup" keywords="gridmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileMap" inherits="LayeredTileMapLayerGroup" keywords="gridmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Node for 2D tile-based maps.
</brief_description>
<description>
Node for 2D tile-based maps. Tilemaps use a [TileSet] which contain a list of tiles which are used to create grid-based maps. A TileMap may have several layers, layouting tiles on top of each other.
For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a [TileSetScenesCollectionSource] may be initialized after their parent. This is only queued when inside the scene tree.
Node for 2D tile-based maps. Tilemaps use a [LayeredTileSet] which contain a list of tiles which are used to create grid-based maps. A LayeredTileMap may have several layers, layouting tiles on top of each other.
For performance reasons, all LayeredTileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a [LayeredTileSetScenesCollectionSource] may be initialized after their parent. This is only queued when inside the scene tree.
To force an update earlier on, call [method update_internals].
</description>
<tutorials>
@ -24,10 +24,10 @@
<param index="1" name="coords" type="Vector2i" />
<param index="2" name="tile_data" type="TileData" />
<description>
Called with a TileData object about to be used internally by the TileMap, allowing its modification at runtime.
Called with a TileData object about to be used internally by the LayeredTileMap, allowing its modification at runtime.
This method is only called if [method _use_tile_data_runtime_update] is implemented and returns [code]true[/code] for the given tile [param coords] and [param layer].
[b]Warning:[/b] The [param tile_data] object's sub-resources are the same as the one in the TileSet. Modifying them might impact the whole TileSet. Instead, make sure to duplicate those resources.
[b]Note:[/b] If the properties of [param tile_data] object should change over time, use [method notify_runtime_tile_data_update] to notify the TileMap it needs an update.
[b]Warning:[/b] The [param tile_data] object's sub-resources are the same as the one in the LayeredTileSet. Modifying them might impact the whole LayeredTileSet. Instead, make sure to duplicate those resources.
[b]Note:[/b] If the properties of [param tile_data] object should change over time, use [method notify_runtime_tile_data_update] to notify the LayeredTileMap it needs an update.
</description>
</method>
<method name="_use_tile_data_runtime_update" qualifiers="virtual">
@ -37,7 +37,7 @@
<description>
Should return [code]true[/code] if the tile at coordinates [param coords] on layer [param layer] requires a runtime update.
[b]Warning:[/b] Make sure this function only return [code]true[/code] when needed. Any tile processed at runtime without a need for it will imply a significant performance penalty.
[b]Note:[/b] If the result of this function should changed, use [method notify_runtime_tile_data_update] to notify the TileMap it needs an update.
[b]Note:[/b] If the result of this function should changed, use [method notify_runtime_tile_data_update] to notify the LayeredTileMap it needs an update.
</description>
</method>
<method name="add_layer">
@ -80,7 +80,7 @@
<return type="void" />
<param index="0" name="layer" type="int" default="-1" />
<description>
Forces the TileMap and the layer [param layer] to update.
Forces the LayeredTileMap and the layer [param layer] to update.
</description>
</method>
<method name="get_cell_alternative_tile" qualifiers="const">
@ -89,7 +89,7 @@
<param index="1" name="coords" type="Vector2i" />
<param index="2" name="use_proxies" type="bool" default="false" />
<description>
Returns the tile alternative ID of the cell on layer [param layer] at [param coords]. If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
Returns the tile alternative ID of the cell on layer [param layer] at [param coords]. If [param use_proxies] is [code]false[/code], ignores the [LayeredTileSet]'s tile proxies, returning the raw alternative identifier. See [method LayeredTileSet.map_tile_proxy].
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -99,7 +99,7 @@
<param index="1" name="coords" type="Vector2i" />
<param index="2" name="use_proxies" type="bool" default="false" />
<description>
Returns the tile atlas coordinates ID of the cell on layer [param layer] at coordinates [param coords]. If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
Returns the tile atlas coordinates ID of the cell on layer [param layer] at coordinates [param coords]. If [param use_proxies] is [code]false[/code], ignores the [LayeredTileSet]'s tile proxies, returning the raw alternative identifier. See [method LayeredTileSet.map_tile_proxy].
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -110,7 +110,7 @@
<param index="2" name="use_proxies" type="bool" default="false" />
<description>
Returns the tile source ID of the cell on layer [param layer] at coordinates [param coords]. Returns [code]-1[/code] if the cell does not exist.
If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
If [param use_proxies] is [code]false[/code], ignores the [LayeredTileSet]'s tile proxies, returning the raw alternative identifier. See [method LayeredTileSet.map_tile_proxy].
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -120,9 +120,9 @@
<param index="1" name="coords" type="Vector2i" />
<param index="2" name="use_proxies" type="bool" default="false" />
<description>
Returns the [TileData] object associated with the given cell, or [code]null[/code] if the cell does not exist or is not a [TileSetAtlasSource].
Returns the [TileData] object associated with the given cell, or [code]null[/code] if the cell does not exist or is not a [LayeredTileSetAtlasSource].
If [param layer] is negative, the layers are accessed from the last one.
If [param use_proxies] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
If [param use_proxies] is [code]false[/code], ignores the [LayeredTileSet]'s tile proxies, returning the raw alternative identifier. See [method LayeredTileSet.map_tile_proxy].
[codeblock]
func get_clicked_tile_power():
var clicked_cell = tile_map.local_to_map(tile_map.get_local_mouse_position())
@ -152,7 +152,7 @@
<return type="Color" />
<param index="0" name="layer" type="int" />
<description>
Returns a TileMap layer's modulate.
Returns a LayeredTileMap layer's modulate.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -160,7 +160,7 @@
<return type="String" />
<param index="0" name="layer" type="int" />
<description>
Returns a TileMap layer's name.
Returns a LayeredTileMap layer's name.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -168,9 +168,9 @@
<return type="RID" />
<param index="0" name="layer" type="int" />
<description>
Returns the [RID] of the [NavigationServer2D] navigation map assigned to the specified TileMap layer [param layer].
By default the TileMap uses the default [World2D] navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer.
In order to make [NavigationAgent2D] switch between TileMap layer navigation maps use [method NavigationAgent2D.set_navigation_map] with the navigation map received from [method get_layer_navigation_map].
Returns the [RID] of the [NavigationServer2D] navigation map assigned to the specified LayeredTileMap layer [param layer].
By default the LayeredTileMap uses the default [World2D] navigation map for the first LayeredTileMap layer. For each additional LayeredTileMap layer a new navigation map is created for the additional layer.
In order to make [NavigationAgent2D] switch between LayeredTileMap layer navigation maps use [method NavigationAgent2D.set_navigation_map] with the navigation map received from [method get_layer_navigation_map].
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -178,7 +178,7 @@
<return type="int" />
<param index="0" name="layer" type="int" />
<description>
Returns a TileMap layer's Y sort origin.
Returns a LayeredTileMap layer's Y sort origin.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -186,37 +186,37 @@
<return type="int" />
<param index="0" name="layer" type="int" />
<description>
Returns a TileMap layer's Z-index value.
Returns a LayeredTileMap layer's Z-index value.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="get_layers_count" qualifiers="const">
<return type="int" />
<description>
Returns the number of layers in the TileMap.
Returns the number of layers in the LayeredTileMap.
</description>
</method>
<method name="get_navigation_map" qualifiers="const" deprecated="Use [method get_layer_navigation_map] instead.">
<return type="RID" />
<param index="0" name="layer" type="int" />
<description>
Returns the [RID] of the [NavigationServer2D] navigation map assigned to the specified TileMap layer [param layer].
Returns the [RID] of the [NavigationServer2D] navigation map assigned to the specified LayeredTileMap layer [param layer].
</description>
</method>
<method name="get_neighbor_cell" qualifiers="const">
<return type="Vector2i" />
<param index="0" name="coords" type="Vector2i" />
<param index="1" name="neighbor" type="int" enum="TileSet.CellNeighbor" />
<param index="1" name="neighbor" type="int" enum="LayeredTileSet.CellNeighbor" />
<description>
Returns the neighboring cell to the one at coordinates [param coords], identified by the [param neighbor] direction. This method takes into account the different layouts a TileMap can take.
Returns the neighboring cell to the one at coordinates [param coords], identified by the [param neighbor] direction. This method takes into account the different layouts a LayeredTileMap can take.
</description>
</method>
<method name="get_pattern">
<return type="TileMapPattern" />
<return type="LayeredTileMapPattern" />
<param index="0" name="layer" type="int" />
<param index="1" name="coords_array" type="Vector2i[]" />
<description>
Creates a new [TileMapPattern] from the given layer and set of cells.
Creates a new [LayeredTileMapPattern] from the given layer and set of cells.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -288,16 +288,16 @@
<return type="Vector2i" />
<param index="0" name="position_in_tilemap" type="Vector2i" />
<param index="1" name="coords_in_pattern" type="Vector2i" />
<param index="2" name="pattern" type="TileMapPattern" />
<param index="2" name="pattern" type="LayeredTileMapPattern" />
<description>
Returns for the given coordinate [param coords_in_pattern] in a [TileMapPattern] the corresponding cell coordinates if the pattern was pasted at the [param position_in_tilemap] coordinates (see [method set_pattern]). This mapping is required as in half-offset tile shapes, the mapping might not work by calculating [code]position_in_tile_map + coords_in_pattern[/code].
Returns for the given coordinate [param coords_in_pattern] in a [LayeredTileMapPattern] the corresponding cell coordinates if the pattern was pasted at the [param position_in_tilemap] coordinates (see [method set_pattern]). This mapping is required as in half-offset tile shapes, the mapping might not work by calculating [code]position_in_tile_map + coords_in_pattern[/code].
</description>
</method>
<method name="map_to_local" qualifiers="const">
<return type="Vector2" />
<param index="0" name="map_position" type="Vector2i" />
<description>
Returns the centered position of a cell in the TileMap's local coordinate space. To convert the returned value into global coordinates, use [method Node2D.to_global]. See also [method local_to_map].
Returns the centered position of a cell in the LayeredTileMap's local coordinate space. To convert the returned value into global coordinates, use [method Node2D.to_global]. See also [method local_to_map].
[b]Note:[/b] This may not correspond to the visual position of the tile, i.e. it ignores the [member TileData.texture_origin] property of individual tiles.
</description>
</method>
@ -313,10 +313,10 @@
<return type="void" />
<param index="0" name="layer" type="int" default="-1" />
<description>
Notifies the TileMap node that calls to [method _use_tile_data_runtime_update] or [method _tile_data_runtime_update] will lead to different results. This will thus trigger a TileMap update.
Notifies the LayeredTileMap node that calls to [method _use_tile_data_runtime_update] or [method _tile_data_runtime_update] will lead to different results. This will thus trigger a LayeredTileMap update.
If [param layer] is provided, only notifies changes for the given layer. Providing the [param layer] argument (when applicable) is usually preferred for performance reasons.
[b]Warning:[/b] Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of calls to this function to avoid unnecessary update.
[b]Note:[/b] This does not trigger a direct update of the TileMap, the update will be done at the end of the frame as usual (unless you call [method update_internals]).
[b]Warning:[/b] Updating the LayeredTileMap is computationally expensive and may impact performance. Try to limit the number of calls to this function to avoid unnecessary update.
[b]Note:[/b] This does not trigger a direct update of the LayeredTileMap, the update will be done at the end of the frame as usual (unless you call [method update_internals]).
</description>
</method>
<method name="remove_layer">
@ -334,10 +334,10 @@
<param index="3" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<param index="4" name="alternative_tile" type="int" default="0" />
<description>
Sets the tile identifiers for the cell on layer [param layer] at coordinates [param coords]. Each tile of the [TileSet] is identified using three parts:
- The source identifier [param source_id] identifies a [TileSetSource] identifier. See [method TileSet.set_source_id],
- The atlas coordinates identifier [param atlas_coords] identifies a tile coordinates in the atlas (if the source is a [TileSetAtlasSource]). For [TileSetScenesCollectionSource] it should always be [code]Vector2i(0, 0)[/code]),
- The alternative tile identifier [param alternative_tile] identifies a tile alternative in the atlas (if the source is a [TileSetAtlasSource]), and the scene for a [TileSetScenesCollectionSource].
Sets the tile identifiers for the cell on layer [param layer] at coordinates [param coords]. Each tile of the [LayeredTileSet] is identified using three parts:
- The source identifier [param source_id] identifies a [LayeredTileSetSource] identifier. See [method LayeredTileSet.set_source_id],
- The atlas coordinates identifier [param atlas_coords] identifies a tile coordinates in the atlas (if the source is a [LayeredTileSetAtlasSource]). For [LayeredTileSetScenesCollectionSource] it should always be [code]Vector2i(0, 0)[/code]),
- The alternative tile identifier [param alternative_tile] identifies a tile alternative in the atlas (if the source is a [LayeredTileSetAtlasSource]), and the scene for a [LayeredTileSetScenesCollectionSource].
If [param source_id] is set to [code]-1[/code], [param atlas_coords] to [code]Vector2i(-1, -1)[/code] or [param alternative_tile] to [code]-1[/code], the cell will be erased. An erased cell gets [b]all[/b] its identifiers automatically set to their respective invalid values, namely [code]-1[/code], [code]Vector2i(-1, -1)[/code] and [code]-1[/code].
If [param layer] is negative, the layers are accessed from the last one.
</description>
@ -353,7 +353,7 @@
Update all the cells in the [param cells] coordinates array so that they use the given [param terrain] for the given [param terrain_set]. If an updated cell has the same terrain as one of its neighboring cells, this function tries to join the two. This function might update neighboring tiles if needed to create correct terrain transitions.
If [param ignore_empty_terrains] is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
If [param layer] is negative, the layers are accessed from the last one.
[b]Note:[/b] To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
[b]Note:[/b] To work correctly, this method requires the LayeredTileMap's LayeredTileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
</description>
</method>
<method name="set_cells_terrain_path">
@ -367,7 +367,7 @@
Update all the cells in the [param path] coordinates array so that they use the given [param terrain] for the given [param terrain_set]. The function will also connect two successive cell in the path with the same terrain. This function might update neighboring tiles if needed to create correct terrain transitions.
If [param ignore_empty_terrains] is true, empty terrains will be ignored when trying to find the best fitting tile for the given terrain constraints.
If [param layer] is negative, the layers are accessed from the last one.
[b]Note:[/b] To work correctly, this method requires the TileMap's TileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
[b]Note:[/b] To work correctly, this method requires the LayeredTileMap's LayeredTileSet to have terrains set up with all required terrain combinations. Otherwise, it may produce unexpected results.
</description>
</method>
<method name="set_layer_enabled">
@ -384,7 +384,7 @@
<param index="0" name="layer" type="int" />
<param index="1" name="modulate" type="Color" />
<description>
Sets a layer's color. It will be multiplied by tile's color and TileMap's modulate.
Sets a layer's color. It will be multiplied by tile's color and LayeredTileMap's modulate.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -402,7 +402,7 @@
<param index="0" name="layer" type="int" />
<param index="1" name="enabled" type="bool" />
<description>
Enables or disables a layer's built-in navigation regions generation. Disable this if you need to bake navigation regions from a TileMap using a [NavigationRegion2D] node.
Enables or disables a layer's built-in navigation regions generation. Disable this if you need to bake navigation regions from a LayeredTileMap using a [NavigationRegion2D] node.
</description>
</method>
<method name="set_layer_navigation_map">
@ -410,9 +410,9 @@
<param index="0" name="layer" type="int" />
<param index="1" name="map" type="RID" />
<description>
Assigns [param map] as a [NavigationServer2D] navigation map for the specified TileMap layer [param layer].
By default the TileMap uses the default [World2D] navigation map for the first TileMap layer. For each additional TileMap layer a new navigation map is created for the additional layer.
In order to make [NavigationAgent2D] switch between TileMap layer navigation maps use [method NavigationAgent2D.set_navigation_map] with the navigation map received from [method get_layer_navigation_map].
Assigns [param map] as a [NavigationServer2D] navigation map for the specified LayeredTileMap layer [param layer].
By default the LayeredTileMap uses the default [World2D] navigation map for the first LayeredTileMap layer. For each additional LayeredTileMap layer a new navigation map is created for the additional layer.
In order to make [NavigationAgent2D] switch between LayeredTileMap layer navigation maps use [method NavigationAgent2D.set_navigation_map] with the navigation map received from [method get_layer_navigation_map].
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
@ -450,49 +450,49 @@
<param index="0" name="layer" type="int" />
<param index="1" name="map" type="RID" />
<description>
Assigns [param map] as a [NavigationServer2D] navigation map for the specified TileMap layer [param layer].
Assigns [param map] as a [NavigationServer2D] navigation map for the specified LayeredTileMap layer [param layer].
</description>
</method>
<method name="set_pattern">
<return type="void" />
<param index="0" name="layer" type="int" />
<param index="1" name="position" type="Vector2i" />
<param index="2" name="pattern" type="TileMapPattern" />
<param index="2" name="pattern" type="LayeredTileMapPattern" />
<description>
Paste the given [TileMapPattern] at the given [param position] and [param layer] in the tile map.
Paste the given [LayeredTileMapPattern] at the given [param position] and [param layer] in the tile map.
If [param layer] is negative, the layers are accessed from the last one.
</description>
</method>
<method name="update_internals">
<return type="void" />
<description>
Triggers a direct update of the TileMap. Usually, calling this function is not needed, as TileMap node updates automatically when one of its properties or cells is modified.
However, for performance reasons, those updates are batched and delayed to the end of the frame. Calling this function will force the TileMap to update right away instead.
[b]Warning:[/b] Updating the TileMap is computationally expensive and may impact performance. Try to limit the number of updates and how many tiles they impact.
Triggers a direct update of the LayeredTileMap. Usually, calling this function is not needed, as LayeredTileMap node updates automatically when one of its properties or cells is modified.
However, for performance reasons, those updates are batched and delayed to the end of the frame. Calling this function will force the LayeredTileMap to update right away instead.
[b]Warning:[/b] Updating the LayeredTileMap is computationally expensive and may impact performance. Try to limit the number of updates and how many tiles they impact.
</description>
</method>
</methods>
<members>
<member name="collision_animatable" type="bool" setter="set_collision_animatable" getter="is_collision_animatable" default="false">
If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform.
[b]Note:[/b] Enabling [member collision_animatable] may have a small performance impact, only do it if the TileMap is moving and has colliding tiles.
If enabled, the LayeredTileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create LayeredTileMap-based moving platform.
[b]Note:[/b] Enabling [member collision_animatable] may have a small performance impact, only do it if the LayeredTileMap is moving and has colliding tiles.
</member>
<member name="collision_visibility_mode" type="int" setter="set_collision_visibility_mode" getter="get_collision_visibility_mode" enum="TileMap.VisibilityMode" default="0">
Show or hide the TileMap's collision shapes. If set to [constant VISIBILITY_MODE_DEFAULT], this depends on the show collision debug settings.
<member name="collision_visibility_mode" type="int" setter="set_collision_visibility_mode" getter="get_collision_visibility_mode" enum="LayeredTileMap.VisibilityMode" default="0">
Show or hide the LayeredTileMap's collision shapes. If set to [constant VISIBILITY_MODE_DEFAULT], this depends on the show collision debug settings.
</member>
<member name="navigation_visibility_mode" type="int" setter="set_navigation_visibility_mode" getter="get_navigation_visibility_mode" enum="TileMap.VisibilityMode" default="0">
Show or hide the TileMap's navigation meshes. If set to [constant VISIBILITY_MODE_DEFAULT], this depends on the show navigation debug settings.
<member name="navigation_visibility_mode" type="int" setter="set_navigation_visibility_mode" getter="get_navigation_visibility_mode" enum="LayeredTileMap.VisibilityMode" default="0">
Show or hide the LayeredTileMap's navigation meshes. If set to [constant VISIBILITY_MODE_DEFAULT], this depends on the show navigation debug settings.
</member>
<member name="rendering_quadrant_size" type="int" setter="set_rendering_quadrant_size" getter="get_rendering_quadrant_size" default="16">
The TileMap's quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes. [member rendering_quadrant_size] defines the length of a square's side, in the map's coordinate system, that forms the quadrant. Thus, the default quandrant size groups together [code]16 * 16 = 256[/code] tiles.
The LayeredTileMap's quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes. [member rendering_quadrant_size] defines the length of a square's side, in the map's coordinate system, that forms the quadrant. Thus, the default quandrant size groups together [code]16 * 16 = 256[/code] tiles.
The quadrant size does not apply on Y-sorted layers, as tiles are be grouped by Y position instead in that case.
[b]Note:[/b] As quadrants are created according to the map's coordinate system, the quadrant's "square shape" might not look like square in the TileMap's local coordinate system.
[b]Note:[/b] As quadrants are created according to the map's coordinate system, the quadrant's "square shape" might not look like square in the LayeredTileMap's local coordinate system.
</member>
</members>
<signals>
<signal name="changed">
<description>
Emitted when the [TileSet] of this TileMap changes.
Emitted when the [LayeredTileSet] of this LayeredTileMap changes.
</description>
</signal>
</signals>

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileMapLayerGroup" inherits="Node2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileMapLayerGroup" inherits="Node2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Groups a set of tile map layers together, allowing them to share a provided [TileSet].
Groups a set of tile map layers together, allowing them to share a provided [LayeredTileSet].
</brief_description>
<description>
Groups together tile map layers as part or the same map, replacing the [TileMap] node. Child layers will use this node's [member tile_set].
The editor also uses [TileMapLayerGroup] as a way to store which layers are selected in a given group. This allows highlighting the currently selected layers.
Groups together tile map layers as part or the same map, replacing the [LayeredTileMap] node. Child layers will use this node's [member tile_set].
The editor also uses [LayeredTileMapLayerGroup] as a way to store which layers are selected in a given group. This allows highlighting the currently selected layers.
</description>
<tutorials>
</tutorials>
<members>
<member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset">
The assigned [TileSet]. This TileSet will be applied to all child layers.
<member name="tile_set" type="LayeredTileSet" setter="set_tileset" getter="get_tileset">
The assigned [LayeredTileSet]. This LayeredTileSet will be applied to all child layers.
</member>
</members>
</class>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileMapPattern" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileMapPattern" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Holds a pattern to be copied from or pasted into [TileMap]s.
Holds a pattern to be copied from or pasted into [LayeredTileMap]s.
</brief_description>
<description>
This resource holds a set of cells to help bulk manipulations of [TileMap].
This resource holds a set of cells to help bulk manipulations of [LayeredTileMap].
A pattern always start at the [code](0,0)[/code] coordinates and cannot have cells with negative coordinates.
</description>
<tutorials>
@ -71,7 +71,7 @@
<param index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" />
<param index="3" name="alternative_tile" type="int" default="-1" />
<description>
Sets the tile identifiers for the cell at coordinates [param coords]. See [method TileMap.set_cell].
Sets the tile identifiers for the cell at coordinates [param coords]. See [method LayeredTileMap.set_cell].
</description>
</method>
<method name="set_size">

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSet" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileSet" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Tile library for tilemaps.
</brief_description>
<description>
A TileSet is a library of tiles for a [TileMap]. A TileSet handles a list of [TileSetSource], each of them storing a set of tiles.
Tiles can either be from a [TileSetAtlasSource], which renders tiles out of a texture with support for physics, navigation, etc., or from a [TileSetScenesCollectionSource], which exposes scene-based tiles.
A LayeredTileSet is a library of tiles for a [LayeredTileMap]. A LayeredTileSet handles a list of [LayeredTileSetSource], each of them storing a set of tiles.
Tiles can either be from a [LayeredTileSetAtlasSource], which renders tiles out of a texture with support for physics, navigation, etc., or from a [LayeredTileSetScenesCollectionSource], which exposes scene-based tiles.
Tiles are referenced by using three IDs: their source ID, their atlas coordinates ID, and their alternative tile ID.
A TileSet can be configured so that its tiles expose more or fewer properties. To do so, the TileSet resources use property layers, which you can add or remove depending on your needs.
For example, adding a physics layer allows giving collision shapes to your tiles. Each layer has dedicated properties (physics layer and mask), so you may add several TileSet physics layers for each type of collision you need.
A LayeredTileSet can be configured so that its tiles expose more or fewer properties. To do so, the LayeredTileSet resources use property layers, which you can add or remove depending on your needs.
For example, adding a physics layer allows giving collision shapes to your tiles. Each layer has dedicated properties (physics layer and mask), so you may add several LayeredTileSet physics layers for each type of collision you need.
See the functions to add new layers for more information.
</description>
<tutorials>
@ -25,7 +25,7 @@
<return type="void" />
<param index="0" name="to_position" type="int" default="-1" />
<description>
Adds a custom data layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Adds a custom data layer to the LayeredTileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Custom data layers allow assigning custom properties to atlas tiles.
</description>
</method>
@ -33,7 +33,7 @@
<return type="void" />
<param index="0" name="to_position" type="int" default="-1" />
<description>
Adds a navigation layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Adds a navigation layer to the LayeredTileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Navigation layers allow assigning a navigable area to atlas tiles.
</description>
</method>
@ -41,34 +41,34 @@
<return type="void" />
<param index="0" name="to_position" type="int" default="-1" />
<description>
Adds an occlusion layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Adds an occlusion layer to the LayeredTileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Occlusion layers allow assigning occlusion polygons to atlas tiles.
</description>
</method>
<method name="add_pattern">
<return type="int" />
<param index="0" name="pattern" type="TileMapPattern" />
<param index="0" name="pattern" type="LayeredTileMapPattern" />
<param index="1" name="index" type="int" default="-1" />
<description>
Adds a [TileMapPattern] to be stored in the TileSet resource. If provided, insert it at the given [param index].
Adds a [LayeredTileMapPattern] to be stored in the LayeredTileSet resource. If provided, insert it at the given [param index].
</description>
</method>
<method name="add_physics_layer">
<return type="void" />
<param index="0" name="to_position" type="int" default="-1" />
<description>
Adds a physics layer to the TileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Adds a physics layer to the LayeredTileSet at the given position [param to_position] in the array. If [param to_position] is -1, adds it at the end of the array.
Physics layers allow assigning collision polygons to atlas tiles.
</description>
</method>
<method name="add_source">
<return type="int" />
<param index="0" name="source" type="TileSetSource" />
<param index="0" name="source" type="LayeredTileSetSource" />
<param index="1" name="atlas_source_id_override" type="int" default="-1" />
<description>
Adds a [TileSetSource] to the TileSet. If [param atlas_source_id_override] is not -1, also set its source ID. Otherwise, a unique identifier is automatically generated.
Adds a [LayeredTileSetSource] to the LayeredTileSet. If [param atlas_source_id_override] is not -1, also set its source ID. Otherwise, a unique identifier is automatically generated.
The function returns the added source ID or -1 if the source could not be added.
[b]Warning:[/b] A source cannot belong to two TileSets at the same time. If the added source was attached to another [TileSet], it will be removed from that one.
[b]Warning:[/b] A source cannot belong to two LayeredTileSets at the same time. If the added source was attached to another [LayeredTileSet], it will be removed from that one.
</description>
</method>
<method name="add_terrain">
@ -105,7 +105,7 @@
<param index="2" name="alternative_from" type="int" />
<description>
Returns the alternative-level proxy for the given identifiers. The returned array contains the three proxie's target identifiers (source ID, atlas coords ID and alternative tile ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
If the LayeredTileSet has no proxy for the given identifiers, returns an empty Array.
</description>
</method>
<method name="get_coords_level_tile_proxy">
@ -114,7 +114,7 @@
<param index="1" name="coords_from" type="Vector2i" />
<description>
Returns the coordinate-level proxy for the given identifiers. The returned array contains the two target identifiers of the proxy (source ID and atlas coordinates ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
If the LayeredTileSet has no proxy for the given identifiers, returns an empty Array.
</description>
</method>
<method name="get_custom_data_layer_by_name" qualifiers="const">
@ -149,14 +149,14 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="layer_number" type="int" />
<description>
Returns whether or not the specified navigation layer of the TileSet navigation data layer identified by the given [param layer_index] is enabled, given a navigation_layers [param layer_number] between 1 and 32.
Returns whether or not the specified navigation layer of the LayeredTileSet navigation data layer identified by the given [param layer_index] is enabled, given a navigation_layers [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_navigation_layer_layers" qualifiers="const">
<return type="int" />
<param index="0" name="layer_index" type="int" />
<description>
Returns the navigation layers (as in the Navigation server) of the given TileSet navigation layer.
Returns the navigation layers (as in the Navigation server) of the given LayeredTileSet navigation layer.
</description>
</method>
<method name="get_navigation_layers_count" qualifiers="const">
@ -192,37 +192,37 @@
</description>
</method>
<method name="get_pattern">
<return type="TileMapPattern" />
<return type="LayeredTileMapPattern" />
<param index="0" name="index" type="int" default="-1" />
<description>
Returns the [TileMapPattern] at the given [param index].
Returns the [LayeredTileMapPattern] at the given [param index].
</description>
</method>
<method name="get_patterns_count">
<return type="int" />
<description>
Returns the number of [TileMapPattern] this tile set handles.
Returns the number of [LayeredTileMapPattern] this tile set handles.
</description>
</method>
<method name="get_physics_layer_collision_layer" qualifiers="const">
<return type="int" />
<param index="0" name="layer_index" type="int" />
<description>
Returns the collision layer (as in the physics server) bodies on the given TileSet's physics layer are in.
Returns the collision layer (as in the physics server) bodies on the given LayeredTileSet's physics layer are in.
</description>
</method>
<method name="get_physics_layer_collision_mask" qualifiers="const">
<return type="int" />
<param index="0" name="layer_index" type="int" />
<description>
Returns the collision mask of bodies on the given TileSet's physics layer.
Returns the collision mask of bodies on the given LayeredTileSet's physics layer.
</description>
</method>
<method name="get_physics_layer_physics_material" qualifiers="const">
<return type="PhysicsMaterial" />
<param index="0" name="layer_index" type="int" />
<description>
Returns the physics material of bodies on the given TileSet's physics layer.
Returns the physics material of bodies on the given LayeredTileSet's physics layer.
</description>
</method>
<method name="get_physics_layers_count" qualifiers="const">
@ -232,16 +232,16 @@
</description>
</method>
<method name="get_source" qualifiers="const">
<return type="TileSetSource" />
<return type="LayeredTileSetSource" />
<param index="0" name="source_id" type="int" />
<description>
Returns the [TileSetSource] with ID [param source_id].
Returns the [LayeredTileSetSource] with ID [param source_id].
</description>
</method>
<method name="get_source_count" qualifiers="const">
<return type="int" />
<description>
Returns the number of [TileSetSource] in this TileSet.
Returns the number of [LayeredTileSetSource] in this LayeredTileSet.
</description>
</method>
<method name="get_source_id" qualifiers="const">
@ -256,7 +256,7 @@
<param index="0" name="source_from" type="int" />
<description>
Returns the source-level proxy for the given source identifier.
If the TileSet has no proxy for the given identifier, returns -1.
If the LayeredTileSet has no proxy for the given identifier, returns -1.
</description>
</method>
<method name="get_terrain_color" qualifiers="const">
@ -276,7 +276,7 @@
</description>
</method>
<method name="get_terrain_set_mode" qualifiers="const">
<return type="int" enum="TileSet.TerrainMode" />
<return type="int" enum="LayeredTileSet.TerrainMode" />
<param index="0" name="terrain_set" type="int" />
<description>
Returns a terrain set mode.
@ -316,7 +316,7 @@
<return type="bool" />
<param index="0" name="source_id" type="int" />
<description>
Returns if this TileSet has a source for the given source ID.
Returns if this LayeredTileSet has a source for the given source ID.
</description>
</method>
<method name="has_source_level_tile_proxy">
@ -428,7 +428,7 @@
<return type="void" />
<param index="0" name="index" type="int" />
<description>
Remove the [TileMapPattern] at the given index.
Remove the [LayeredTileMapPattern] at the given index.
</description>
</method>
<method name="remove_physics_layer">
@ -477,8 +477,8 @@
<param index="5" name="alternative_to" type="int" />
<description>
Create an alternative-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers.
This can be used to replace a tile in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
This can be used to replace a tile in all LayeredTileMaps using this LayeredTileSet, as LayeredTileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in LayeredTileMap nodes using the editor.
</description>
</method>
<method name="set_coords_level_tile_proxy">
@ -489,8 +489,8 @@
<param index="3" name="coords_to" type="Vector2i" />
<description>
Creates a coordinates-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers. The alternative tile ID is kept the same when using coordinates-level proxies.
This can be used to replace a tile in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
This can be used to replace a tile in all LayeredTileMaps using this LayeredTileSet, as LayeredTileMap nodes will find and use the proxy's target tile when one is available.
Proxied tiles can be automatically replaced in LayeredTileMap nodes using the editor.
</description>
</method>
<method name="set_custom_data_layer_name">
@ -515,7 +515,7 @@
<param index="1" name="layer_number" type="int" />
<param index="2" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified navigation layer of the TileSet navigation data layer identified by the given [param layer_index], given a navigation_layers [param layer_number] between 1 and 32.
Based on [param value], enables or disables the specified navigation layer of the LayeredTileSet navigation data layer identified by the given [param layer_index], given a navigation_layers [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_navigation_layer_layers">
@ -523,7 +523,7 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="layers" type="int" />
<description>
Sets the navigation layers (as in the navigation server) for navigation regions in the given TileSet navigation layer.
Sets the navigation layers (as in the navigation server) for navigation regions in the given LayeredTileSet navigation layer.
</description>
</method>
<method name="set_occlusion_layer_light_mask">
@ -531,7 +531,7 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="light_mask" type="int" />
<description>
Sets the occlusion layer (as in the rendering server) for occluders in the given TileSet occlusion layer.
Sets the occlusion layer (as in the rendering server) for occluders in the given LayeredTileSet occlusion layer.
</description>
</method>
<method name="set_occlusion_layer_sdf_collision">
@ -539,7 +539,7 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="sdf_collision" type="bool" />
<description>
Enables or disables SDF collision for occluders in the given TileSet occlusion layer.
Enables or disables SDF collision for occluders in the given LayeredTileSet occlusion layer.
</description>
</method>
<method name="set_physics_layer_collision_layer">
@ -547,7 +547,7 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="layer" type="int" />
<description>
Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer.
Sets the physics layer (as in the physics server) for bodies in the given LayeredTileSet physics layer.
</description>
</method>
<method name="set_physics_layer_collision_mask">
@ -555,7 +555,7 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="mask" type="int" />
<description>
Sets the physics layer (as in the physics server) for bodies in the given TileSet physics layer.
Sets the physics layer (as in the physics server) for bodies in the given LayeredTileSet physics layer.
</description>
</method>
<method name="set_physics_layer_physics_material">
@ -563,7 +563,7 @@
<param index="0" name="layer_index" type="int" />
<param index="1" name="physics_material" type="PhysicsMaterial" />
<description>
Sets the physics material for bodies in the given TileSet physics layer.
Sets the physics material for bodies in the given LayeredTileSet physics layer.
</description>
</method>
<method name="set_source_id">
@ -580,8 +580,8 @@
<param index="1" name="source_to" type="int" />
<description>
Creates a source-level proxy for the given source ID. A proxy will map set of tile identifiers to another set of identifiers. Both the atlas coordinates ID and the alternative tile ID are kept the same when using source-level proxies.
This can be used to replace a source in all TileMaps using this TileSet, as TileMap nodes will find and use the proxy's target source when one is available.
Proxied tiles can be automatically replaced in TileMap nodes using the editor.
This can be used to replace a source in all LayeredTileMaps using this LayeredTileSet, as LayeredTileMap nodes will find and use the proxy's target source when one is available.
Proxied tiles can be automatically replaced in LayeredTileMap nodes using the editor.
</description>
</method>
<method name="set_terrain_color">
@ -590,7 +590,7 @@
<param index="1" name="terrain_index" type="int" />
<param index="2" name="color" type="Color" />
<description>
Sets a terrain's color. This color is used for identifying the different terrains in the TileSet editor.
Sets a terrain's color. This color is used for identifying the different terrains in the LayeredTileSet editor.
</description>
</method>
<method name="set_terrain_name">
@ -605,20 +605,20 @@
<method name="set_terrain_set_mode">
<return type="void" />
<param index="0" name="terrain_set" type="int" />
<param index="1" name="mode" type="int" enum="TileSet.TerrainMode" />
<param index="1" name="mode" type="int" enum="LayeredTileSet.TerrainMode" />
<description>
Sets a terrain mode. Each mode determines which bits of a tile shape is used to match the neighboring tiles' terrains.
</description>
</method>
</methods>
<members>
<member name="tile_layout" type="int" setter="set_tile_layout" getter="get_tile_layout" enum="TileSet.TileLayout" default="0">
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the TileMap grid.
<member name="tile_layout" type="int" setter="set_tile_layout" getter="get_tile_layout" enum="LayeredTileSet.TileLayout" default="0">
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the LayeredTileMap grid.
</member>
<member name="tile_offset_axis" type="int" setter="set_tile_offset_axis" getter="get_tile_offset_axis" enum="TileSet.TileOffsetAxis" default="0">
<member name="tile_offset_axis" type="int" setter="set_tile_offset_axis" getter="get_tile_offset_axis" enum="LayeredTileSet.TileOffsetAxis" default="0">
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), determines the offset axis.
</member>
<member name="tile_shape" type="int" setter="set_tile_shape" getter="get_tile_shape" enum="TileSet.TileShape" default="0">
<member name="tile_shape" type="int" setter="set_tile_shape" getter="get_tile_shape" enum="LayeredTileSet.TileShape" default="0">
The tile shape.
</member>
<member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i(16, 16)">
@ -634,7 +634,7 @@
</constant>
<constant name="TILE_SHAPE_ISOMETRIC" value="1" enum="TileShape">
Diamond tile shape (for isometric look).
[b]Note:[/b] Isometric [TileSet] works best if [TileMap] and all its layers have Y-sort enabled.
[b]Note:[/b] Isometric [LayeredTileSet] works best if [LayeredTileMap] and all its layers have Y-sort enabled.
</constant>
<constant name="TILE_SHAPE_HALF_OFFSET_SQUARE" value="2" enum="TileShape">
Rectangular tile shape with one row/column out of two offset by half a tile.

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSetAtlasSource" inherits="TileSetSource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileSetAtlasSource" inherits="LayeredTileSetSource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Exposes a 2D atlas texture as a set of tiles for a [TileSet] resource.
Exposes a 2D atlas texture as a set of tiles for a [LayeredTileSet] resource.
</brief_description>
<description>
An atlas is a grid of tiles laid out on a texture. Each tile in the grid must be exposed using [method create_tile]. Those tiles are then indexed using their coordinates in the grid.
Each tile can also have a size in the grid coordinates, making it more or less cells in the atlas.
Alternatives version of a tile can be created using [method create_alternative_tile], which are then indexed using an alternative ID. The main tile (the one in the grid), is accessed with an alternative ID equal to 0.
Each tile alternate has a set of properties that is defined by the source's [TileSet] layers. Those properties are stored in a TileData object that can be accessed and modified using [method get_tile_data].
As TileData properties are stored directly in the TileSetAtlasSource resource, their properties might also be set using [code]TileSetAtlasSource.set("&lt;coords_x&gt;:&lt;coords_y&gt;/&lt;alternative_id&gt;/&lt;tile_data_property&gt;")[/code].
Each tile alternate has a set of properties that is defined by the source's [LayeredTileSet] layers. Those properties are stored in a TileData object that can be accessed and modified using [method get_tile_data].
As TileData properties are stored directly in the LayeredTileSetAtlasSource resource, their properties might also be set using [code]LayeredTileSetAtlasSource.set("&lt;coords_x&gt;:&lt;coords_y&gt;/&lt;alternative_id&gt;/&lt;tile_data_property&gt;")[/code].
</description>
<tutorials>
</tutorials>
@ -87,7 +87,7 @@
</description>
</method>
<method name="get_tile_animation_mode" qualifiers="const">
<return type="int" enum="TileSetAtlasSource.TileAnimationMode" />
<return type="int" enum="LayeredTileSetAtlasSource.TileAnimationMode" />
<param index="0" name="atlas_coords" type="Vector2i" />
<description>
Returns the tile animation mode of the tile at [param atlas_coords]. See also [method set_tile_animation_mode].
@ -237,7 +237,7 @@
<method name="set_tile_animation_mode">
<return type="void" />
<param index="0" name="atlas_coords" type="Vector2i" />
<param index="1" name="mode" type="int" enum="TileSetAtlasSource.TileAnimationMode" />
<param index="1" name="mode" type="int" enum="LayeredTileSetAtlasSource.TileAnimationMode" />
<description>
Sets the tile animation mode of the tile at [param atlas_coords] to [param mode]. See also [method get_tile_animation_mode].
</description>
@ -270,11 +270,11 @@
The atlas texture.
</member>
<member name="texture_region_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)">
The base tile size in the texture (in pixel). This size must be bigger than the TileSet's [code]tile_size[/code] value.
The base tile size in the texture (in pixel). This size must be bigger than the LayeredTileSet's [code]tile_size[/code] value.
</member>
<member name="use_texture_padding" type="bool" setter="set_use_texture_padding" getter="get_use_texture_padding" default="true">
If [code]true[/code], generates an internal texture with an additional one pixel padding around each tile. Texture padding avoids a common artifact where lines appear between tiles.
Disabling this setting might lead a small performance improvement, as generating the internal texture requires both memory and processing time when the TileSetAtlasSource resource is modified.
Disabling this setting might lead a small performance improvement, as generating the internal texture requires both memory and processing time when the LayeredTileSetAtlasSource resource is modified.
</member>
</members>
<constants>
@ -288,12 +288,12 @@
Represents the size of the [enum TileAnimationMode] enum.
</constant>
<constant name="TRANSFORM_FLIP_H" value="4096">
Represents cell's horizontal flip flag. Should be used directly with [TileMap] to flip placed tiles by altering their alternative IDs.
Represents cell's horizontal flip flag. Should be used directly with [LayeredTileMap] to flip placed tiles by altering their alternative IDs.
[codeblock]
var alternate_id = $TileMap.get_cell_alternative_tile(0, Vector2i(2, 2))
if not alternate_id &amp; TileSetAtlasSource.TRANSFORM_FLIP_H:
var alternate_id = $LayeredTileMap.get_cell_alternative_tile(0, Vector2i(2, 2))
if not alternate_id &amp; LayeredTileSetAtlasSource.TRANSFORM_FLIP_H:
# If tile is not already flipped, flip it.
$TileMap.set_cell(0, Vector2i(2, 2), source_id, atlas_coords, alternate_id | TileSetAtlasSource.TRANSFORM_FLIP_H)
$LayeredTileMap.set_cell(0, Vector2i(2, 2), source_id, atlas_coords, alternate_id | LayeredTileSetAtlasSource.TRANSFORM_FLIP_H)
[/codeblock]
</constant>
<constant name="TRANSFORM_FLIP_V" value="8192">

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSetScenesCollectionSource" inherits="TileSetSource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileSetScenesCollectionSource" inherits="LayeredTileSetSource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Exposes a set of scenes as tiles for a [TileSet] resource.
Exposes a set of scenes as tiles for a [LayeredTileSet] resource.
</brief_description>
<description>
When placed on a [TileMap], tiles from [TileSetScenesCollectionSource] will automatically instantiate an associated scene at the cell's position in the TileMap.
Scenes are instantiated as children of the [TileMap] when it enters the tree. If you add/remove a scene tile in the [TileMap] that is already inside the tree, the [TileMap] will automatically instantiate/free the scene accordingly.
When placed on a [LayeredTileMap], tiles from [LayeredTileSetScenesCollectionSource] will automatically instantiate an associated scene at the cell's position in the LayeredTileMap.
Scenes are instantiated as children of the [LayeredTileMap] when it enters the tree. If you add/remove a scene tile in the [LayeredTileMap] that is already inside the tree, the [LayeredTileMap] will automatically instantiate/free the scene accordingly.
</description>
<tutorials>
</tutorials>
@ -49,14 +49,14 @@
<method name="get_scene_tiles_count">
<return type="int" />
<description>
Returns the number or scene tiles this TileSet source has.
Returns the number or scene tiles this LayeredTileSet source has.
</description>
</method>
<method name="has_scene_tile_id">
<return type="bool" />
<param index="0" name="id" type="int" />
<description>
Returns whether this TileSet source has a scene tile with [param id].
Returns whether this LayeredTileSet source has a scene tile with [param id].
</description>
</method>
<method name="remove_scene_tile">
@ -87,7 +87,7 @@
<param index="0" name="id" type="int" />
<param index="1" name="packed_scene" type="PackedScene" />
<description>
Assigns a [PackedScene] resource to the scene tile with [param id]. This will fail if the scene does not extend CanvasItem, as positioning properties are needed to place the scene on the TileMap.
Assigns a [PackedScene] resource to the scene tile with [param id]. This will fail if the scene does not extend CanvasItem, as positioning properties are needed to place the scene on the LayeredTileMap.
</description>
</method>
</methods>

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TileSetSource" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="LayeredTileSetSource" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Exposes a set of tiles for a [TileSet] resource.
Exposes a set of tiles for a [LayeredTileSet] resource.
</brief_description>
<description>
Exposes a set of tiles for a [TileSet] resource.
Tiles in a source are indexed with two IDs, coordinates ID (of type Vector2i) and an alternative ID (of type int), named according to their use in the [TileSetAtlasSource] class.
Depending on the TileSet source type, those IDs might have restrictions on their values, this is why the base [TileSetSource] class only exposes getters for them.
You can iterate over all tiles exposed by a TileSetSource by first iterating over coordinates IDs using [method get_tiles_count] and [method get_tile_id], then over alternative IDs using [method get_alternative_tiles_count] and [method get_alternative_tile_id].
[b]Warning:[/b] [TileSetSource] can only be added to one TileSet at the same time. Calling [method TileSet.add_source] on a second [TileSet] will remove the source from the first one.
Exposes a set of tiles for a [LayeredTileSet] resource.
Tiles in a source are indexed with two IDs, coordinates ID (of type Vector2i) and an alternative ID (of type int), named according to their use in the [LayeredTileSetAtlasSource] class.
Depending on the LayeredTileSet source type, those IDs might have restrictions on their values, this is why the base [LayeredTileSetSource] class only exposes getters for them.
You can iterate over all tiles exposed by a LayeredTileSetSource by first iterating over coordinates IDs using [method get_tiles_count] and [method get_tile_id], then over alternative IDs using [method get_alternative_tiles_count] and [method get_alternative_tile_id].
[b]Warning:[/b] [LayeredTileSetSource] can only be added to one LayeredTileSet at the same time. Calling [method LayeredTileSet.add_source] on a second [LayeredTileSet] will remove the source from the first one.
</description>
<tutorials>
</tutorials>
@ -26,7 +26,7 @@
<param index="0" name="atlas_coords" type="Vector2i" />
<description>
Returns the number of alternatives tiles for the coordinates ID [param atlas_coords].
For [TileSetAtlasSource], this always return at least 1, as the base tile with ID 0 is always part of the alternatives list.
For [LayeredTileSetAtlasSource], this always return at least 1, as the base tile with ID 0 is always part of the alternatives list.
Returns -1 if there is not tile at the given coords.
</description>
</method>

View File

@ -43,7 +43,7 @@ void AtlasMergingDialog::_property_changed(const StringName &p_property, const V
_set(p_property, p_value);
}
void AtlasMergingDialog::_generate_merged(const Vector<Ref<TileSetAtlasSource>> &p_atlas_sources, int p_max_columns) {
void AtlasMergingDialog::_generate_merged(const Vector<Ref<LayeredTileSetAtlasSource>> &p_atlas_sources, int p_max_columns) {
merged.instantiate();
merged_mapping.clear();
@ -53,7 +53,7 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<TileSetAtlasSource>>
// Compute the new texture region size.
Vector2i new_texture_region_size;
for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) {
const Ref<TileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
const Ref<LayeredTileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
new_texture_region_size = new_texture_region_size.max(atlas_source->get_texture_region_size());
}
@ -61,7 +61,7 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<TileSetAtlasSource>>
Vector2i atlas_offset;
int line_height = 0;
for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) {
const Ref<TileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
const Ref<LayeredTileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
Ref<Image> input_image = atlas_source->get_texture()->get_image();
if (input_image->get_format() != Image::FORMAT_RGBA8) {
input_image->convert(Image::FORMAT_RGBA8);
@ -110,9 +110,9 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<TileSetAtlasSource>>
merged->set_texture(ImageTexture::create_from_image(output_image));
merged->set_texture_region_size(new_texture_region_size);
// Copy the tiles to the merged TileSetAtlasSource.
// Copy the tiles to the merged LayeredTileSetAtlasSource.
for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) {
const Ref<TileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
const Ref<LayeredTileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
for (KeyValue<Vector2i, Vector2i> tile_mapping : merged_mapping[source_index]) {
// Create tiles and alternatives, then copy their properties.
for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_mapping.key); alternative_index++) {
@ -157,7 +157,7 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<TileSetAtlasSource>>
void AtlasMergingDialog::_update_texture() {
Vector<int> selected = atlas_merging_atlases_list->get_selected_items();
if (selected.size() >= 2) {
Vector<Ref<TileSetAtlasSource>> to_merge;
Vector<Ref<LayeredTileSetAtlasSource>> to_merge;
for (int i = 0; i < selected.size(); i++) {
int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]);
to_merge.push_back(tile_set->get_source(source_id));
@ -169,7 +169,7 @@ void AtlasMergingDialog::_update_texture() {
get_ok_button()->set_disabled(false);
merge_button->set_disabled(false);
} else {
_generate_merged(Vector<Ref<TileSetAtlasSource>>(), next_line_after_column);
_generate_merged(Vector<Ref<LayeredTileSetAtlasSource>>(), next_line_after_column);
preview->set_texture(Ref<Texture2D>());
preview->hide();
select_2_atlases_label->show();
@ -190,7 +190,7 @@ void AtlasMergingDialog::_merge_confirmed(const String &p_path) {
merged->set_texture(new_texture_resource);
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Merge TileSetAtlasSource"));
undo_redo->create_action(TTR("Merge LayeredTileSetAtlasSource"));
int next_id = tile_set->get_next_source_id();
undo_redo->add_do_method(*tile_set, "add_source", merged, next_id);
undo_redo->add_undo_method(*tile_set, "remove_source", next_id);
@ -200,7 +200,7 @@ void AtlasMergingDialog::_merge_confirmed(const String &p_path) {
Vector<int> selected = atlas_merging_atlases_list->get_selected_items();
for (int i = 0; i < selected.size(); i++) {
int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]);
Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id);
Ref<LayeredTileSetAtlasSource> tas = tile_set->get_source(source_id);
undo_redo->add_do_method(*tile_set, "remove_source", source_id);
undo_redo->add_undo_method(*tile_set, "add_source", tas, source_id);
@ -270,14 +270,14 @@ void AtlasMergingDialog::_notification(int p_what) {
}
}
void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) {
void AtlasMergingDialog::update_tile_set(Ref<LayeredTileSet> p_tile_set) {
ERR_FAIL_COND(!p_tile_set.is_valid());
tile_set = p_tile_set;
atlas_merging_atlases_list->clear();
for (int i = 0; i < p_tile_set->get_source_count(); i++) {
int source_id = p_tile_set->get_source_id(i);
Ref<TileSetAtlasSource> atlas_source = p_tile_set->get_source(source_id);
Ref<LayeredTileSetAtlasSource> atlas_source = p_tile_set->get_source(source_id);
if (atlas_source.is_valid()) {
Ref<Texture2D> texture = atlas_source->get_texture();
if (texture.is_valid()) {

View File

@ -47,9 +47,9 @@ class AtlasMergingDialog : public ConfirmationDialog {
private:
int commited_actions_count = 0;
bool delete_original_atlases = true;
Ref<TileSetAtlasSource> merged;
Ref<LayeredTileSetAtlasSource> merged;
LocalVector<HashMap<Vector2i, Vector2i>> merged_mapping;
Ref<TileSet> tile_set;
Ref<LayeredTileSet> tile_set;
// Settings.
int next_line_after_column = 30;
@ -65,7 +65,7 @@ private:
void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing);
void _generate_merged(const Vector<Ref<TileSetAtlasSource>> &p_atlas_sources, int p_max_columns);
void _generate_merged(const Vector<Ref<LayeredTileSetAtlasSource>> &p_atlas_sources, int p_max_columns);
void _update_texture();
void _merge_confirmed(const String &p_path);
@ -80,7 +80,7 @@ protected:
void _notification(int p_what);
public:
void update_tile_set(Ref<TileSet> p_tile_set);
void update_tile_set(Ref<LayeredTileSet> p_tile_set);
AtlasMergingDialog();
};

View File

@ -41,25 +41,25 @@
#include "scene/gui/panel.h"
#include "scene/gui/view_panner.h"
void TileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
void LayeredTileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
if (panner->gui_input(p_event)) {
accept_event();
}
}
void TileAtlasView::_pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event) {
void LayeredTileAtlasView::_pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event) {
panning += p_scroll_vec;
_update_zoom_and_panning(true);
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
}
void TileAtlasView::_zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event) {
void LayeredTileAtlasView::_zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event) {
zoom_widget->set_zoom(zoom_widget->get_zoom() * p_zoom_factor);
_update_zoom_and_panning(true);
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
}
Size2i TileAtlasView::_compute_base_tiles_control_size() {
Size2i LayeredTileAtlasView::_compute_base_tiles_control_size() {
// Update the texture.
Vector2i size;
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
@ -69,7 +69,7 @@ Size2i TileAtlasView::_compute_base_tiles_control_size() {
return size;
}
Size2i TileAtlasView::_compute_alternative_tiles_control_size() {
Size2i LayeredTileAtlasView::_compute_alternative_tiles_control_size() {
Vector2i size;
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
Vector2i tile_id = tile_set_atlas_source->get_tile_id(i);
@ -89,7 +89,7 @@ Size2i TileAtlasView::_compute_alternative_tiles_control_size() {
return size;
}
void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
void LayeredTileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
float zoom = zoom_widget->get_zoom();
// Compute the minimum sizes.
@ -141,35 +141,35 @@ void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
center_container->set_size(center_container->get_minimum_size());
}
void TileAtlasView::_zoom_widget_changed() {
void LayeredTileAtlasView::_zoom_widget_changed() {
_update_zoom_and_panning();
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
}
void TileAtlasView::_center_view() {
void LayeredTileAtlasView::_center_view() {
panning = Vector2();
button_center_view->set_disabled(true);
_update_zoom_and_panning();
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
}
void TileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
void LayeredTileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
base_tiles_root_control->set_tooltip_text("");
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
Transform2D xform = base_tiles_drawing_root->get_transform().affine_inverse();
Vector2i coords = get_atlas_tile_coords_at_pos(xform.xform(mm->get_position()));
if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
coords = tile_set_atlas_source->get_tile_at_coords(coords);
if (coords != TileSetSource::INVALID_ATLAS_COORDS) {
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
base_tiles_root_control->set_tooltip_text(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: 0"), source_id, coords));
}
}
}
}
void TileAtlasView::_draw_base_tiles() {
void LayeredTileAtlasView::_draw_base_tiles() {
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
if (texture.is_valid()) {
Vector2i margins = tile_set_atlas_source->get_margins();
@ -181,7 +181,7 @@ void TileAtlasView::_draw_base_tiles() {
for (int x = 0; x < grid_size.x; x++) {
for (int y = 0; y < grid_size.y; y++) {
Vector2i coords = Vector2i(x, y);
if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
if (tile_set_atlas_source->get_tile_at_coords(coords) == LayeredTileSetSource::INVALID_ATLAS_COORDS) {
Rect2i rect = Rect2i((texture_region_size + separation) * coords + margins, texture_region_size + separation);
rect = rect.intersection(Rect2i(Vector2(), texture->get_size()));
if (rect.size.x > 0 && rect.size.y > 0) {
@ -195,7 +195,7 @@ void TileAtlasView::_draw_base_tiles() {
for (int x = 0; x < grid_size.x; x++) {
for (int y = 0; y < grid_size.y; y++) {
Vector2i coords = Vector2i(x, y);
if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) {
if (tile_set_atlas_source->get_tile_at_coords(coords) == LayeredTileSetSource::INVALID_ATLAS_COORDS) {
Rect2i rect = Rect2i((texture_region_size + separation) * coords + margins, texture_region_size + separation);
rect = rect.intersection(Rect2i(Vector2(), texture->get_size()));
if (rect.size.x > 0 && rect.size.y > 0) {
@ -251,7 +251,7 @@ void TileAtlasView::_draw_base_tiles() {
Vector2 offset_pos = Rect2(base_frame_rect).get_center() + Vector2(tile_set_atlas_source->get_tile_data(atlas_coords, 0)->get_texture_origin());
// Draw the tile.
TileMap::draw_tile(ci_rid, offset_pos, tile_set, source_id, atlas_coords, 0, frame);
LayeredTileMap::draw_tile(ci_rid, offset_pos, tile_set, source_id, atlas_coords, 0, frame);
}
}
@ -287,7 +287,7 @@ void TileAtlasView::_draw_base_tiles() {
}
}
RID TileAtlasView::_get_canvas_item_to_draw(const TileData *p_for_data, const CanvasItem *p_base_item, HashMap<Ref<Material>, RID> &p_material_map) {
RID LayeredTileAtlasView::_get_canvas_item_to_draw(const TileData *p_for_data, const CanvasItem *p_base_item, HashMap<Ref<Material>, RID> &p_material_map) {
Ref<Material> mat = p_for_data->get_material();
if (mat.is_null()) {
return p_base_item->get_canvas_item();
@ -302,7 +302,7 @@ RID TileAtlasView::_get_canvas_item_to_draw(const TileData *p_for_data, const Ca
}
}
void TileAtlasView::_clear_material_canvas_items() {
void LayeredTileAtlasView::_clear_material_canvas_items() {
for (KeyValue<Ref<Material>, RID> kv : material_tiles_draw) {
RS::get_singleton()->free(kv.value);
}
@ -314,7 +314,7 @@ void TileAtlasView::_clear_material_canvas_items() {
material_alternatives_draw.clear();
}
void TileAtlasView::_draw_base_tiles_texture_grid() {
void LayeredTileAtlasView::_draw_base_tiles_texture_grid() {
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
if (texture.is_valid()) {
Vector2i margins = tile_set_atlas_source->get_margins();
@ -328,7 +328,7 @@ void TileAtlasView::_draw_base_tiles_texture_grid() {
for (int y = 0; y < grid_size.y; y++) {
Vector2i origin = margins + (Vector2i(x, y) * (texture_region_size + separation));
Vector2i base_tile_coords = tile_set_atlas_source->get_tile_at_coords(Vector2i(x, y));
if (base_tile_coords != TileSetSource::INVALID_ATLAS_COORDS) {
if (base_tile_coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
if (base_tile_coords == Vector2i(x, y)) {
// Draw existing tile.
Vector2i size_in_atlas = tile_set_atlas_source->get_tile_size_in_atlas(base_tile_coords);
@ -344,7 +344,7 @@ void TileAtlasView::_draw_base_tiles_texture_grid() {
}
}
void TileAtlasView::_draw_base_tiles_shape_grid() {
void LayeredTileAtlasView::_draw_base_tiles_shape_grid() {
// Draw the shapes.
Color grid_color = EDITOR_GET("editors/tiles_editor/grid_color");
Vector2i tile_shape_size = tile_set->get_tile_size();
@ -367,7 +367,7 @@ void TileAtlasView::_draw_base_tiles_shape_grid() {
}
}
void TileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
void LayeredTileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
alternative_tiles_root_control->set_tooltip_text("");
Ref<InputEventMouseMotion> mm = p_event;
@ -376,13 +376,13 @@ void TileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEve
Vector3i coords3 = get_alternative_tile_at_pos(xform.xform(mm->get_position()));
Vector2i coords = Vector2i(coords3.x, coords3.y);
int alternative_id = coords3.z;
if (coords != TileSetSource::INVALID_ATLAS_COORDS && alternative_id != TileSetSource::INVALID_TILE_ALTERNATIVE) {
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS && alternative_id != LayeredTileSetSource::INVALID_TILE_ALTERNATIVE) {
alternative_tiles_root_control->set_tooltip_text(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: %d"), source_id, coords, alternative_id));
}
}
}
void TileAtlasView::_draw_alternatives() {
void LayeredTileAtlasView::_draw_alternatives() {
// Draw the alternative tiles.
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
if (texture.is_valid()) {
@ -412,7 +412,7 @@ void TileAtlasView::_draw_alternatives() {
}
// Draw the tile.
TileMap::draw_tile(ci_rid, offset_pos, tile_set, source_id, atlas_coords, alternative_id);
LayeredTileMap::draw_tile(ci_rid, offset_pos, tile_set, source_id, atlas_coords, alternative_id);
// Increment the x position.
current_pos.x += transposed ? texture_region_size.y : texture_region_size.x;
@ -424,15 +424,15 @@ void TileAtlasView::_draw_alternatives() {
}
}
void TileAtlasView::_draw_background_left() {
void LayeredTileAtlasView::_draw_background_left() {
background_left->draw_texture_rect(theme_cache.checkerboard, Rect2(Vector2(), background_left->get_size()), true);
}
void TileAtlasView::_draw_background_right() {
void LayeredTileAtlasView::_draw_background_right() {
background_right->draw_texture_rect(theme_cache.checkerboard, Rect2(Vector2(), background_right->get_size()), true);
}
void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
void LayeredTileAtlasView::set_atlas_source(LayeredTileSet *p_tile_set, LayeredTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
tile_set = p_tile_set;
tile_set_atlas_source = p_tile_set_atlas_source;
@ -470,25 +470,25 @@ void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_
background_right->queue_redraw();
}
float TileAtlasView::get_zoom() const {
float LayeredTileAtlasView::get_zoom() const {
return zoom_widget->get_zoom();
};
void TileAtlasView::set_transform(float p_zoom, Vector2i p_panning) {
void LayeredTileAtlasView::set_transform(float p_zoom, Vector2i p_panning) {
zoom_widget->set_zoom(p_zoom);
panning = p_panning;
_update_zoom_and_panning();
};
void TileAtlasView::set_padding(Side p_side, int p_padding) {
void LayeredTileAtlasView::set_padding(Side p_side, int p_padding) {
ERR_FAIL_COND(p_padding < 0);
margin_container_paddings[p_side] = p_padding;
}
Vector2i TileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos, bool p_clamp) const {
Vector2i LayeredTileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos, bool p_clamp) const {
Ref<Texture2D> texture = tile_set_atlas_source->get_texture();
if (!texture.is_valid()) {
return TileSetSource::INVALID_ATLAS_COORDS;
return LayeredTileSetSource::INVALID_ATLAS_COORDS;
}
Vector2i margins = tile_set_atlas_source->get_margins();
@ -509,7 +509,7 @@ Vector2i TileAtlasView::get_atlas_tile_coords_at_pos(const Vector2 p_pos, bool p
return ret;
}
void TileAtlasView::_update_alternative_tiles_rect_cache() {
void LayeredTileAtlasView::_update_alternative_tiles_rect_cache() {
alternative_tiles_rect_cache.clear();
Rect2i current;
@ -539,7 +539,7 @@ void TileAtlasView::_update_alternative_tiles_rect_cache() {
}
}
Vector3i TileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
Vector3i LayeredTileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
for (const KeyValue<Vector2, HashMap<int, Rect2i>> &E_coords : alternative_tiles_rect_cache) {
for (const KeyValue<int, Rect2i> &E_alternative : E_coords.value) {
if (E_alternative.value.has_point(p_pos)) {
@ -548,17 +548,17 @@ Vector3i TileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
}
}
return Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE);
return Vector3i(LayeredTileSetSource::INVALID_ATLAS_COORDS.x, LayeredTileSetSource::INVALID_ATLAS_COORDS.y, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
}
Rect2i TileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_alternative_tile) {
Rect2i LayeredTileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_alternative_tile) {
ERR_FAIL_COND_V_MSG(!alternative_tiles_rect_cache.has(p_coords), Rect2i(), vformat("No cached rect for tile coords:%s", p_coords));
ERR_FAIL_COND_V_MSG(!alternative_tiles_rect_cache[p_coords].has(p_alternative_tile), Rect2i(), vformat("No cached rect for tile coords:%s alternative_id:%d", p_coords, p_alternative_tile));
return alternative_tiles_rect_cache[p_coords][p_alternative_tile];
}
void TileAtlasView::queue_redraw() {
void LayeredTileAtlasView::queue_redraw() {
base_tiles_draw->queue_redraw();
base_tiles_texture_grid->queue_redraw();
base_tiles_shape_grid->queue_redraw();
@ -567,14 +567,14 @@ void TileAtlasView::queue_redraw() {
background_right->queue_redraw();
}
void TileAtlasView::_update_theme_item_cache() {
void LayeredTileAtlasView::_update_theme_item_cache() {
Control::_update_theme_item_cache();
theme_cache.center_view_icon = get_editor_theme_icon(SNAME("CenterView"));
theme_cache.checkerboard = get_editor_theme_icon(SNAME("Checkerboard"));
}
void TileAtlasView::_notification(int p_what) {
void LayeredTileAtlasView::_notification(int p_what) {
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (!EditorSettings::get_singleton()->check_changed_settings_in_group("editors/panning")) {
@ -592,11 +592,11 @@ void TileAtlasView::_notification(int p_what) {
}
}
void TileAtlasView::_bind_methods() {
void LayeredTileAtlasView::_bind_methods() {
ADD_SIGNAL(MethodInfo("transform_changed", PropertyInfo(Variant::FLOAT, "zoom"), PropertyInfo(Variant::VECTOR2, "scroll")));
}
TileAtlasView::TileAtlasView() {
LayeredTileAtlasView::LayeredTileAtlasView() {
set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
Panel *panel = memnew(Panel);
@ -610,32 +610,32 @@ TileAtlasView::TileAtlasView() {
zoom_widget = memnew(EditorZoomWidget);
add_child(zoom_widget);
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1));
zoom_widget->connect("zoom_changed", callable_mp(this, &LayeredTileAtlasView::_zoom_widget_changed).unbind(1));
zoom_widget->set_shortcut_context(this);
button_center_view = memnew(Button);
button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
button_center_view->set_grow_direction_preset(Control::PRESET_TOP_RIGHT);
button_center_view->connect("pressed", callable_mp(this, &TileAtlasView::_center_view));
button_center_view->connect("pressed", callable_mp(this, &LayeredTileAtlasView::_center_view));
button_center_view->set_flat(true);
button_center_view->set_disabled(true);
button_center_view->set_tooltip_text(TTR("Center View"));
add_child(button_center_view);
panner.instantiate();
panner->set_callbacks(callable_mp(this, &TileAtlasView::_pan_callback), callable_mp(this, &TileAtlasView::_zoom_callback));
panner->set_callbacks(callable_mp(this, &LayeredTileAtlasView::_pan_callback), callable_mp(this, &LayeredTileAtlasView::_zoom_callback));
panner->set_enable_rmb(true);
center_container = memnew(CenterContainer);
center_container->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
center_container->set_anchors_preset(Control::PRESET_CENTER);
center_container->connect("gui_input", callable_mp(this, &TileAtlasView::gui_input));
center_container->connect("gui_input", callable_mp(this, &LayeredTileAtlasView::gui_input));
center_container->connect("focus_exited", callable_mp(panner.ptr(), &ViewPanner::release_pan_key));
center_container->set_focus_mode(FOCUS_CLICK);
panel->add_child(center_container);
missing_source_label = memnew(Label);
missing_source_label->set_text(TTR("The selected atlas source has no valid texture. Assign a texture in the TileSet bottom tab."));
missing_source_label->set_text(TTR("The selected atlas source has no valid texture. Assign a texture in the LayeredTileSet bottom tab."));
center_container->add_child(missing_source_label);
margin_container = memnew(MarginContainer);
@ -666,14 +666,14 @@ TileAtlasView::TileAtlasView() {
base_tiles_root_control = memnew(Control);
base_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
base_tiles_root_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
base_tiles_root_control->connect("gui_input", callable_mp(this, &TileAtlasView::_base_tiles_root_control_gui_input));
base_tiles_root_control->connect("gui_input", callable_mp(this, &LayeredTileAtlasView::_base_tiles_root_control_gui_input));
left_vbox->add_child(base_tiles_root_control);
background_left = memnew(Control);
background_left->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_left->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT);
background_left->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
background_left->connect("draw", callable_mp(this, &TileAtlasView::_draw_background_left));
background_left->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_background_left));
base_tiles_root_control->add_child(background_left);
base_tiles_drawing_root = memnew(Control);
@ -684,19 +684,19 @@ TileAtlasView::TileAtlasView() {
base_tiles_draw = memnew(Control);
base_tiles_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_draw->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_tiles_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles));
base_tiles_draw->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_base_tiles));
base_tiles_drawing_root->add_child(base_tiles_draw);
base_tiles_texture_grid = memnew(Control);
base_tiles_texture_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_texture_grid->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_tiles_texture_grid->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_texture_grid));
base_tiles_texture_grid->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_base_tiles_texture_grid));
base_tiles_drawing_root->add_child(base_tiles_texture_grid);
base_tiles_shape_grid = memnew(Control);
base_tiles_shape_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_shape_grid->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_tiles_shape_grid->connect("draw", callable_mp(this, &TileAtlasView::_draw_base_tiles_shape_grid));
base_tiles_shape_grid->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_base_tiles_shape_grid));
base_tiles_drawing_root->add_child(base_tiles_shape_grid);
// Alternative tiles.
@ -709,14 +709,14 @@ TileAtlasView::TileAtlasView() {
alternative_tiles_root_control = memnew(Control);
alternative_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
alternative_tiles_root_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
alternative_tiles_root_control->connect("gui_input", callable_mp(this, &TileAtlasView::_alternative_tiles_root_control_gui_input));
alternative_tiles_root_control->connect("gui_input", callable_mp(this, &LayeredTileAtlasView::_alternative_tiles_root_control_gui_input));
right_vbox->add_child(alternative_tiles_root_control);
background_right = memnew(Control);
background_right->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_right->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT);
background_right->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
background_right->connect("draw", callable_mp(this, &TileAtlasView::_draw_background_right));
background_right->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_background_right));
alternative_tiles_root_control->add_child(background_right);
alternative_tiles_drawing_root = memnew(Control);
@ -727,10 +727,10 @@ TileAtlasView::TileAtlasView() {
alternatives_draw = memnew(Control);
alternatives_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
alternatives_draw->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
alternatives_draw->connect("draw", callable_mp(this, &TileAtlasView::_draw_alternatives));
alternatives_draw->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_alternatives));
alternative_tiles_drawing_root->add_child(alternatives_draw);
}
TileAtlasView::~TileAtlasView() {
LayeredTileAtlasView::~LayeredTileAtlasView() {
_clear_material_canvas_items();
}

View File

@ -42,13 +42,13 @@
class ViewPanner;
class TileAtlasView : public Control {
GDCLASS(TileAtlasView, Control);
class LayeredTileAtlasView : public Control {
GDCLASS(LayeredTileAtlasView, Control);
private:
TileSet *tile_set = nullptr;
TileSetAtlasSource *tile_set_atlas_source = nullptr;
int source_id = TileSet::INVALID_SOURCE;
LayeredTileSet *tile_set = nullptr;
LayeredTileSetAtlasSource *tile_set_atlas_source = nullptr;
int source_id = LayeredTileSet::INVALID_SOURCE;
enum DragType {
DRAG_TYPE_NONE,
@ -128,7 +128,7 @@ protected:
public:
// Global.
void set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id);
void set_atlas_source(LayeredTileSet *p_tile_set, LayeredTileSetAtlasSource *p_tile_set_atlas_source, int p_source_id);
float get_zoom() const;
void set_transform(float p_zoom, Vector2i p_panning);
@ -168,8 +168,8 @@ public:
// Redraw everything.
void queue_redraw();
TileAtlasView();
~TileAtlasView();
LayeredTileAtlasView();
~LayeredTileAtlasView();
};
#endif // TILE_ATLAS_VIEW_H

File diff suppressed because it is too large Load Diff

View File

@ -44,8 +44,8 @@ class MenuButton;
class SpinBox;
class EditorUndoRedoManager;
class TileDataEditor : public VBoxContainer {
GDCLASS(TileDataEditor, VBoxContainer);
class LayeredTileDataEditor : public VBoxContainer {
GDCLASS(LayeredTileDataEditor, VBoxContainer);
private:
bool _tile_set_changed_update_needed = false;
@ -53,24 +53,24 @@ private:
void _tile_set_changed_deferred_update();
protected:
Ref<TileSet> tile_set;
TileData *_get_tile_data(TileMapCell p_cell);
Ref<LayeredTileSet> tile_set;
TileData *_get_tile_data(LayeredTileMapCell p_cell);
virtual void _tile_set_changed(){};
static void _bind_methods();
public:
void set_tile_set(Ref<TileSet> p_tile_set);
void set_tile_set(Ref<LayeredTileSet> p_tile_set);
// Input to handle painting.
virtual Control *get_toolbar() { return nullptr; };
virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
virtual void forward_draw_over_atlas(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
virtual void forward_draw_over_alternatives(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform){};
virtual void forward_painting_atlas_gui_input(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
virtual void forward_painting_alternatives_gui_input(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event){};
// Used to draw the tile data property value over a tile.
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false){};
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false){};
};
class DummyObject : public Object {
@ -93,7 +93,7 @@ class GenericTilePolygonEditor : public VBoxContainer {
GDCLASS(GenericTilePolygonEditor, VBoxContainer);
private:
Ref<TileSet> tile_set;
Ref<LayeredTileSet> tile_set;
LocalVector<Vector<Point2>> polygons;
bool multiple_polygon_mode = false;
@ -182,7 +182,7 @@ protected:
public:
void set_use_undo_redo(bool p_use_undo_redo);
void set_tile_set(Ref<TileSet> p_tile_set);
void set_tile_set(Ref<LayeredTileSet> p_tile_set);
void set_background(Ref<Texture2D> p_texture, Rect2 p_region = Rect2(), Vector2 p_offset = Vector2(), bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false, Color p_modulate = Color(1.0, 1.0, 1.0, 0.0));
int get_polygon_count();
@ -198,8 +198,8 @@ public:
GenericTilePolygonEditor();
};
class TileDataDefaultEditor : public TileDataEditor {
GDCLASS(TileDataDefaultEditor, TileDataEditor);
class TileDataDefaultEditor : public LayeredTileDataEditor {
GDCLASS(TileDataDefaultEditor, LayeredTileDataEditor);
private:
// Toolbar
@ -222,7 +222,7 @@ private:
DragType drag_type = DRAG_TYPE_NONE;
Vector2 drag_start_pos;
Vector2 drag_last_pos;
HashMap<TileMapCell, Variant, TileMapCell> drag_modified;
HashMap<LayeredTileMapCell, Variant, LayeredTileMapCell> drag_modified;
Variant drag_painted_value;
void _property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field);
@ -236,18 +236,18 @@ protected:
void _notification(int p_what);
virtual Variant _get_painted_value();
virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile);
virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value);
virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile);
virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value);
virtual void _set_painted_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile);
virtual void _set_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value);
virtual Variant _get_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile);
virtual void _setup_undo_redo_action(LayeredTileSetAtlasSource *p_tile_set_atlas_source, const HashMap<LayeredTileMapCell, Variant, LayeredTileMapCell> &p_previous_values, const Variant &p_new_value);
public:
virtual Control *get_toolbar() override { return toolbar; };
virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void forward_draw_over_atlas(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_draw_over_alternatives(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_painting_atlas_gui_input(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
void setup_property_editor(Variant::Type p_type, const String &p_property, const String &p_label = "", const Variant &p_default_value = Variant());
Variant::Type get_property_type();
@ -260,21 +260,21 @@ class TileDataTextureOriginEditor : public TileDataDefaultEditor {
GDCLASS(TileDataTextureOriginEditor, TileDataDefaultEditor);
public:
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
};
class TileDataPositionEditor : public TileDataDefaultEditor {
GDCLASS(TileDataPositionEditor, TileDataDefaultEditor);
public:
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
};
class TileDataYSortEditor : public TileDataDefaultEditor {
GDCLASS(TileDataYSortEditor, TileDataDefaultEditor);
public:
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
};
class TileDataOcclusionShapeEditor : public TileDataDefaultEditor {
@ -289,10 +289,10 @@ private:
void _polygon_changed(const PackedVector2Array &p_polygon);
virtual Variant _get_painted_value() override;
virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override;
virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) override;
virtual void _set_painted_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _set_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override;
virtual Variant _get_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _setup_undo_redo_action(LayeredTileSetAtlasSource *p_tile_set_atlas_source, const HashMap<LayeredTileMapCell, Variant, LayeredTileMapCell> &p_previous_values, const Variant &p_new_value) override;
protected:
virtual void _tile_set_changed() override;
@ -300,7 +300,7 @@ protected:
void _notification(int p_what);
public:
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
void set_occlusion_layer(int p_occlusion_layer) { occlusion_layer = p_occlusion_layer; }
@ -322,10 +322,10 @@ class TileDataCollisionEditor : public TileDataDefaultEditor {
void _polygons_changed();
virtual Variant _get_painted_value() override;
virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override;
virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) override;
virtual void _set_painted_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _set_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override;
virtual Variant _get_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _setup_undo_redo_action(LayeredTileSetAtlasSource *p_tile_set_atlas_source, const HashMap<LayeredTileMapCell, Variant, LayeredTileMapCell> &p_previous_values, const Variant &p_new_value) override;
protected:
virtual void _tile_set_changed() override;
@ -333,7 +333,7 @@ protected:
void _notification(int p_what);
public:
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
void set_physics_layer(int p_physics_layer) { physics_layer = p_physics_layer; }
@ -341,8 +341,8 @@ public:
~TileDataCollisionEditor();
};
class TileDataTerrainsEditor : public TileDataEditor {
GDCLASS(TileDataTerrainsEditor, TileDataEditor);
class TileDataTerrainsEditor : public LayeredTileDataEditor {
GDCLASS(TileDataTerrainsEditor, LayeredTileDataEditor);
private:
// Toolbar
@ -360,7 +360,7 @@ private:
DragType drag_type = DRAG_TYPE_NONE;
Vector2 drag_start_pos;
Vector2 drag_last_pos;
HashMap<TileMapCell, Variant, TileMapCell> drag_modified;
HashMap<LayeredTileMapCell, Variant, LayeredTileMapCell> drag_modified;
Variant drag_painted_value;
// UI
@ -380,11 +380,11 @@ protected:
public:
virtual Control *get_toolbar() override { return toolbar; };
virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void forward_draw_over_atlas(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_draw_over_alternatives(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override;
virtual void forward_painting_atlas_gui_input(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void forward_painting_alternatives_gui_input(LayeredTileAtlasView *p_tile_atlas_view, LayeredTileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
TileDataTerrainsEditor();
~TileDataTerrainsEditor();
@ -403,10 +403,10 @@ private:
void _polygon_changed(const PackedVector2Array &p_polygon);
virtual Variant _get_painted_value() override;
virtual void _set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override;
virtual Variant _get_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value) override;
virtual void _set_painted_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _set_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, const Variant &p_value) override;
virtual Variant _get_value(LayeredTileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) override;
virtual void _setup_undo_redo_action(LayeredTileSetAtlasSource *p_tile_set_atlas_source, const HashMap<LayeredTileMapCell, Variant, LayeredTileMapCell> &p_previous_values, const Variant &p_new_value) override;
protected:
virtual void _tile_set_changed() override;
@ -414,7 +414,7 @@ protected:
void _notification(int p_what);
public:
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, TileMapCell p_cell, bool p_selected = false) override;
virtual void draw_over_tile(CanvasItem *p_canvas_item, Transform2D p_transform, LayeredTileMapCell p_cell, bool p_selected = false) override;
void set_navigation_layer(int p_navigation_layer) { navigation_layer = p_navigation_layer; }

View File

@ -49,12 +49,12 @@
#include "scene/gui/tab_bar.h"
#include "scene/gui/tree.h"
class TileMapLayerEditor;
class LayeredTileMapLayerEditor;
class TileMapLayerSubEditorPlugin : public Object {
class LayeredTileMapLayerSubEditorPlugin : public Object {
protected:
ObjectID edited_tile_map_layer_id;
TileMapLayer *_get_edited_layer() const;
LayeredTileMapLayer *_get_edited_layer() const;
public:
struct TabData {
@ -72,8 +72,8 @@ public:
virtual void edit(ObjectID p_tile_map_layer_id){};
};
class TileMapLayerEditorTilesPlugin : public TileMapLayerSubEditorPlugin {
GDCLASS(TileMapLayerEditorTilesPlugin, TileMapLayerSubEditorPlugin);
class LayeredTileMapLayerEditorTilesPlugin : public LayeredTileMapLayerSubEditorPlugin {
GDCLASS(LayeredTileMapLayerEditorTilesPlugin, LayeredTileMapLayerSubEditorPlugin);
public:
enum {
@ -140,12 +140,12 @@ private:
bool drag_erasing = false;
Vector2 drag_start_mouse_pos;
Vector2 drag_last_mouse_pos;
HashMap<Vector2i, TileMapCell> drag_modified;
HashMap<Vector2i, LayeredTileMapCell> drag_modified;
TileMapCell _pick_random_tile(Ref<TileMapPattern> p_pattern);
HashMap<Vector2i, TileMapCell> _draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase);
HashMap<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
HashMap<Vector2i, TileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase);
LayeredTileMapCell _pick_random_tile(Ref<LayeredTileMapPattern> p_pattern);
HashMap<Vector2i, LayeredTileMapCell> _draw_line(Vector2 p_start_drag_mouse_pos, Vector2 p_from_mouse_pos, Vector2 p_to_mouse_pos, bool p_erase);
HashMap<Vector2i, LayeredTileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
HashMap<Vector2i, LayeredTileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase);
void _stop_dragging();
void _apply_transform(int p_type);
@ -153,12 +153,12 @@ private:
///// Selection system. /////
RBSet<Vector2i> tile_map_selection;
Ref<TileMapPattern> tile_map_clipboard;
Ref<TileMapPattern> selection_pattern;
Ref<LayeredTileMapPattern> tile_map_clipboard;
Ref<LayeredTileMapPattern> selection_pattern;
void _set_tile_map_selection(const TypedArray<Vector2i> &p_selection);
TypedArray<Vector2i> _get_tile_map_selection() const;
RBSet<TileMapCell> tile_set_selection;
RBSet<LayeredTileMapCell> tile_set_selection;
void _update_selection_pattern_from_tilemap_selection();
void _update_selection_pattern_from_tileset_tiles_selection();
@ -186,8 +186,8 @@ private:
void _update_source_display();
// Atlas sources.
TileMapCell hovered_tile;
TileAtlasView *tile_atlas_view = nullptr;
LayeredTileMapCell hovered_tile;
LayeredTileAtlasView *tile_atlas_view = nullptr;
HSplitContainer *atlas_sources_split_container = nullptr;
bool tile_set_dragging_selection = false;
@ -219,7 +219,7 @@ private:
ItemList *patterns_item_list = nullptr;
Label *patterns_help_label = nullptr;
void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);
void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture);
void _pattern_preview_done(Ref<LayeredTileMapPattern> p_pattern, Ref<Texture2D> p_texture);
bool select_last_pattern = false;
void _update_patterns_list();
@ -240,12 +240,12 @@ public:
virtual void edit(ObjectID p_tile_map_layer_id) override;
TileMapLayerEditorTilesPlugin();
~TileMapLayerEditorTilesPlugin();
LayeredTileMapLayerEditorTilesPlugin();
~LayeredTileMapLayerEditorTilesPlugin();
};
class TileMapLayerEditorTerrainsPlugin : public TileMapLayerSubEditorPlugin {
GDCLASS(TileMapLayerEditorTerrainsPlugin, TileMapLayerSubEditorPlugin);
class LayeredTileMapLayerEditorTerrainsPlugin : public LayeredTileMapLayerSubEditorPlugin {
GDCLASS(LayeredTileMapLayerEditorTerrainsPlugin, LayeredTileMapLayerSubEditorPlugin);
private:
// Toolbar.
@ -270,7 +270,7 @@ private:
// Main vbox.
VBoxContainer *main_vbox_container = nullptr;
// TileMap editing.
// LayeredTileMap editing.
bool has_mouse = false;
void _mouse_exited_viewport();
@ -286,15 +286,15 @@ private:
bool drag_erasing = false;
Vector2 drag_start_mouse_pos;
Vector2 drag_last_mouse_pos;
HashMap<Vector2i, TileMapCell> drag_modified;
HashMap<Vector2i, LayeredTileMapCell> drag_modified;
// Painting
HashMap<Vector2i, TileMapCell> _draw_terrain_path_or_connect(const Vector<Vector2i> &p_to_paint, int p_terrain_set, int p_terrain, bool p_connect) const;
HashMap<Vector2i, TileMapCell> _draw_terrain_pattern(const Vector<Vector2i> &p_to_paint, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern) const;
HashMap<Vector2i, TileMapCell> _draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
HashMap<Vector2i, TileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
HashMap<Vector2i, LayeredTileMapCell> _draw_terrain_path_or_connect(const Vector<Vector2i> &p_to_paint, int p_terrain_set, int p_terrain, bool p_connect) const;
HashMap<Vector2i, LayeredTileMapCell> _draw_terrain_pattern(const Vector<Vector2i> &p_to_paint, int p_terrain_set, LayeredTileSet::TerrainsPattern p_terrains_pattern) const;
HashMap<Vector2i, LayeredTileMapCell> _draw_line(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
HashMap<Vector2i, LayeredTileMapCell> _draw_rect(Vector2i p_start_cell, Vector2i p_end_cell, bool p_erase);
RBSet<Vector2i> _get_cells_for_bucket_fill(Vector2i p_coords, bool p_contiguous);
HashMap<Vector2i, TileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase);
HashMap<Vector2i, LayeredTileMapCell> _draw_bucket_fill(Vector2i p_coords, bool p_contiguous, bool p_erase);
void _stop_dragging();
enum SelectedType {
@ -305,7 +305,7 @@ private:
SelectedType selected_type;
int selected_terrain_set = -1;
int selected_terrain = -1;
TileSet::TerrainsPattern selected_terrains_pattern;
LayeredTileSet::TerrainsPattern selected_terrains_pattern;
void _update_selection();
// Bottom panel.
@ -313,7 +313,7 @@ private:
ItemList *terrains_tile_list = nullptr;
// Cache.
LocalVector<LocalVector<RBSet<TileSet::TerrainsPattern>>> per_terrain_terrains_patterns;
LocalVector<LocalVector<RBSet<LayeredTileSet::TerrainsPattern>>> per_terrain_terrains_patterns;
List<BaseButton *> viewport_shortcut_buttons;
// Update functions.
@ -332,21 +332,21 @@ public:
virtual void edit(ObjectID p_tile_map_layer_id) override;
TileMapLayerEditorTerrainsPlugin();
~TileMapLayerEditorTerrainsPlugin();
LayeredTileMapLayerEditorTerrainsPlugin();
~LayeredTileMapLayerEditorTerrainsPlugin();
};
class TileMapLayerEditor : public VBoxContainer {
GDCLASS(TileMapLayerEditor, VBoxContainer);
class LayeredTileMapLayerEditor : public VBoxContainer {
GDCLASS(LayeredTileMapLayerEditor, VBoxContainer);
private:
bool tileset_changed_needs_update = false;
ObjectID edited_tile_map_layer_id;
TileMapLayer *_get_edited_layer() const;
LayeredTileMapLayer *_get_edited_layer() const;
// Vector to keep plugins.
Vector<TileMapLayerSubEditorPlugin *> tile_map_editor_plugins;
Vector<LayeredTileMapLayerSubEditorPlugin *> tile_map_editor_plugins;
// Toolbar.
HFlowContainer *tile_map_toolbar = nullptr;
@ -366,11 +366,11 @@ private:
// Bottom panel.
Label *missing_tileset_label = nullptr;
TabBar *tabs_bar = nullptr;
LocalVector<TileMapLayerSubEditorPlugin::TabData> tabs_data;
LocalVector<TileMapLayerSubEditorPlugin *> tabs_plugins;
LocalVector<LayeredTileMapLayerSubEditorPlugin::TabData> tabs_data;
LocalVector<LayeredTileMapLayerSubEditorPlugin *> tabs_plugins;
void _update_bottom_panel();
// TileMap.
// LayeredTileMap.
Ref<Texture2D> missing_tile_texture;
Ref<Texture2D> warning_pattern_texture;
@ -388,20 +388,20 @@ private:
protected:
void _notification(int p_what);
static void _bind_methods();
void _draw_shape(Control *p_control, Rect2 p_region, TileSet::TileShape p_shape, TileSet::TileOffsetAxis p_offset_axis, Color p_color);
void _draw_shape(Control *p_control, Rect2 p_region, LayeredTileSet::TileShape p_shape, LayeredTileSet::TileOffsetAxis p_offset_axis, Color p_color);
public:
bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
void edit(TileMapLayer *p_tile_map_layer);
void edit(LayeredTileMapLayer *p_tile_map_layer);
void update_layers_selector();
TileMapLayerEditor();
~TileMapLayerEditor();
LayeredTileMapLayerEditor();
~LayeredTileMapLayerEditor();
// Static functions.
static Vector<Vector2i> get_line(const TileMapLayer *p_tile_map_layer, Vector2i p_from_cell, Vector2i p_to_cell);
static Vector<Vector2i> get_line(const LayeredTileMapLayer *p_tile_map_layer, Vector2i p_from_cell, Vector2i p_to_cell);
};
#endif // TILE_MAP_LAYER_EDITOR_H

View File

@ -39,7 +39,7 @@
#include "scene/gui/popup_menu.h"
#include "scene/gui/separator.h"
void TileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index, Object *p_item_list) {
void LayeredTileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index, Object *p_item_list) {
if (p_mouse_button_index != MouseButton::RIGHT) {
return;
}
@ -50,14 +50,14 @@ void TileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_
popup_menu->popup();
}
void TileProxiesManagerDialog::_menu_id_pressed(int p_id) {
void LayeredTileProxiesManagerDialog::_menu_id_pressed(int p_id) {
if (p_id == 0) {
// Delete.
_delete_selected_bindings();
}
}
void TileProxiesManagerDialog::_delete_selected_bindings() {
void LayeredTileProxiesManagerDialog::_delete_selected_bindings() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Remove Tile Proxies"));
@ -91,7 +91,7 @@ void TileProxiesManagerDialog::_delete_selected_bindings() {
commited_actions_count += 1;
}
void TileProxiesManagerDialog::_update_lists() {
void LayeredTileProxiesManagerDialog::_update_lists() {
source_level_list->clear();
coords_level_list->clear();
alternative_level_list->clear();
@ -121,19 +121,19 @@ void TileProxiesManagerDialog::_update_lists() {
}
}
void TileProxiesManagerDialog::_update_enabled_property_editors() {
if (from.source_id == TileSet::INVALID_SOURCE) {
from.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
to.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
void LayeredTileProxiesManagerDialog::_update_enabled_property_editors() {
if (from.source_id == LayeredTileSet::INVALID_SOURCE) {
from.set_atlas_coords(LayeredTileSetSource::INVALID_ATLAS_COORDS);
to.set_atlas_coords(LayeredTileSetSource::INVALID_ATLAS_COORDS);
from.alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
to.alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
coords_from_property_editor->hide();
coords_to_property_editor->hide();
alternative_from_property_editor->hide();
alternative_to_property_editor->hide();
} else if (from.get_atlas_coords().x == -1 || from.get_atlas_coords().y == -1) {
from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
from.alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
to.alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
coords_from_property_editor->show();
coords_to_property_editor->show();
alternative_from_property_editor->hide();
@ -153,17 +153,17 @@ void TileProxiesManagerDialog::_update_enabled_property_editors() {
alternative_to_property_editor->update_property();
}
void TileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
void LayeredTileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
_set(p_path, p_value);
}
void TileProxiesManagerDialog::_add_button_pressed() {
void LayeredTileProxiesManagerDialog::_add_button_pressed() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
if (from.source_id != TileSet::INVALID_SOURCE && to.source_id != TileSet::INVALID_SOURCE) {
if (from.source_id != LayeredTileSet::INVALID_SOURCE && to.source_id != LayeredTileSet::INVALID_SOURCE) {
Vector2i from_coords = from.get_atlas_coords();
Vector2i to_coords = to.get_atlas_coords();
if (from_coords.x >= 0 && from_coords.y >= 0 && to_coords.x >= 0 && to_coords.y >= 0) {
if (from.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE) {
if (from.alternative_tile != LayeredTileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != LayeredTileSetSource::INVALID_TILE_ALTERNATIVE) {
undo_redo->create_action(TTR("Create Alternative-level Tile Proxy"));
undo_redo->add_do_method(*tile_set, "set_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile, to.source_id, to.get_atlas_coords(), to.alternative_tile);
if (tile_set->has_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile)) {
@ -198,7 +198,7 @@ void TileProxiesManagerDialog::_add_button_pressed() {
}
}
void TileProxiesManagerDialog::_clear_invalid_button_pressed() {
void LayeredTileProxiesManagerDialog::_clear_invalid_button_pressed() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Delete All Invalid Tile Proxies"));
@ -226,7 +226,7 @@ void TileProxiesManagerDialog::_clear_invalid_button_pressed() {
undo_redo->commit_action();
}
void TileProxiesManagerDialog::_clear_all_button_pressed() {
void LayeredTileProxiesManagerDialog::_clear_all_button_pressed() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Delete All Tile Proxies"));
@ -254,7 +254,7 @@ void TileProxiesManagerDialog::_clear_all_button_pressed() {
undo_redo->commit_action();
}
bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) {
bool LayeredTileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "from_source") {
from.source_id = MAX(int(p_value), -1);
} else if (p_name == "from_coords") {
@ -274,7 +274,7 @@ bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_v
return true;
}
bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const {
bool LayeredTileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "from_source") {
r_ret = from.source_id;
} else if (p_name == "from_coords") {
@ -293,7 +293,7 @@ bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) co
return true;
}
void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
void LayeredTileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
@ -307,7 +307,7 @@ void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
}
}
void TileProxiesManagerDialog::cancel_pressed() {
void LayeredTileProxiesManagerDialog::cancel_pressed() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
for (int i = 0; i < commited_actions_count; i++) {
undo_redo->undo();
@ -315,19 +315,19 @@ void TileProxiesManagerDialog::cancel_pressed() {
commited_actions_count = 0;
}
void TileProxiesManagerDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_lists"), &TileProxiesManagerDialog::_update_lists);
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &TileProxiesManagerDialog::_unhandled_key_input);
void LayeredTileProxiesManagerDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_lists"), &LayeredTileProxiesManagerDialog::_update_lists);
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &LayeredTileProxiesManagerDialog::_unhandled_key_input);
}
void TileProxiesManagerDialog::update_tile_set(Ref<TileSet> p_tile_set) {
void LayeredTileProxiesManagerDialog::update_tile_set(Ref<LayeredTileSet> p_tile_set) {
ERR_FAIL_COND(!p_tile_set.is_valid());
tile_set = p_tile_set;
commited_actions_count = 0;
_update_lists();
}
TileProxiesManagerDialog::TileProxiesManagerDialog() {
LayeredTileProxiesManagerDialog::LayeredTileProxiesManagerDialog() {
// Tile proxy management window.
set_title(TTR("Tile Proxies Management"));
set_process_unhandled_key_input(true);
@ -350,7 +350,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
source_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
source_level_list->set_select_mode(ItemList::SELECT_MULTI);
source_level_list->set_allow_rmb_select(true);
source_level_list->connect("item_clicked", callable_mp(this, &TileProxiesManagerDialog::_right_clicked).bind(source_level_list));
source_level_list->connect("item_clicked", callable_mp(this, &LayeredTileProxiesManagerDialog::_right_clicked).bind(source_level_list));
vbox_container->add_child(source_level_list);
Label *coords_level_label = memnew(Label);
@ -362,7 +362,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
coords_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
coords_level_list->set_select_mode(ItemList::SELECT_MULTI);
coords_level_list->set_allow_rmb_select(true);
coords_level_list->connect("item_clicked", callable_mp(this, &TileProxiesManagerDialog::_right_clicked).bind(coords_level_list));
coords_level_list->connect("item_clicked", callable_mp(this, &LayeredTileProxiesManagerDialog::_right_clicked).bind(coords_level_list));
vbox_container->add_child(coords_level_list);
Label *alternative_level_label = memnew(Label);
@ -374,12 +374,12 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
alternative_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
alternative_level_list->set_select_mode(ItemList::SELECT_MULTI);
alternative_level_list->set_allow_rmb_select(true);
alternative_level_list->connect("item_clicked", callable_mp(this, &TileProxiesManagerDialog::_right_clicked).bind(alternative_level_list));
alternative_level_list->connect("item_clicked", callable_mp(this, &LayeredTileProxiesManagerDialog::_right_clicked).bind(alternative_level_list));
vbox_container->add_child(alternative_level_list);
popup_menu = memnew(PopupMenu);
popup_menu->add_shortcut(ED_GET_SHORTCUT("ui_text_delete"));
popup_menu->connect("id_pressed", callable_mp(this, &TileProxiesManagerDialog::_menu_id_pressed));
popup_menu->connect("id_pressed", callable_mp(this, &LayeredTileProxiesManagerDialog::_menu_id_pressed));
add_child(popup_menu);
// Add proxy panel.
@ -401,7 +401,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
source_from_property_editor = memnew(EditorPropertyInteger);
source_from_property_editor->set_label(TTR("From Source"));
source_from_property_editor->set_object_and_property(this, "from_source");
source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
source_from_property_editor->connect("property_changed", callable_mp(this, &LayeredTileProxiesManagerDialog::_property_changed));
source_from_property_editor->set_selectable(false);
source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
source_from_property_editor->setup(-1, 99999, 1, false, true, false);
@ -410,7 +410,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
coords_from_property_editor = memnew(EditorPropertyVector2i);
coords_from_property_editor->set_label(TTR("From Coords"));
coords_from_property_editor->set_object_and_property(this, "from_coords");
coords_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
coords_from_property_editor->connect("property_changed", callable_mp(this, &LayeredTileProxiesManagerDialog::_property_changed));
coords_from_property_editor->set_selectable(false);
coords_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
coords_from_property_editor->setup(-1, 99999, true);
@ -420,7 +420,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
alternative_from_property_editor = memnew(EditorPropertyInteger);
alternative_from_property_editor->set_label(TTR("From Alternative"));
alternative_from_property_editor->set_object_and_property(this, "from_alternative");
alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
alternative_from_property_editor->connect("property_changed", callable_mp(this, &LayeredTileProxiesManagerDialog::_property_changed));
alternative_from_property_editor->set_selectable(false);
alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
alternative_from_property_editor->setup(-1, 99999, 1, false, true, false);
@ -435,7 +435,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
source_to_property_editor = memnew(EditorPropertyInteger);
source_to_property_editor->set_label(TTR("To Source"));
source_to_property_editor->set_object_and_property(this, "to_source");
source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
source_to_property_editor->connect("property_changed", callable_mp(this, &LayeredTileProxiesManagerDialog::_property_changed));
source_to_property_editor->set_selectable(false);
source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
source_to_property_editor->setup(-1, 99999, 1, false, true, false);
@ -444,7 +444,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
coords_to_property_editor = memnew(EditorPropertyVector2i);
coords_to_property_editor->set_label(TTR("To Coords"));
coords_to_property_editor->set_object_and_property(this, "to_coords");
coords_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
coords_to_property_editor->connect("property_changed", callable_mp(this, &LayeredTileProxiesManagerDialog::_property_changed));
coords_to_property_editor->set_selectable(false);
coords_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
coords_to_property_editor->setup(-1, 99999, true);
@ -454,7 +454,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
alternative_to_property_editor = memnew(EditorPropertyInteger);
alternative_to_property_editor->set_label(TTR("To Alternative"));
alternative_to_property_editor->set_object_and_property(this, "to_alternative");
alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
alternative_to_property_editor->connect("property_changed", callable_mp(this, &LayeredTileProxiesManagerDialog::_property_changed));
alternative_to_property_editor->set_selectable(false);
alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
alternative_to_property_editor->setup(-1, 99999, 1, false, true, false);
@ -464,7 +464,7 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
Button *add_button = memnew(Button);
add_button->set_text(TTR("Add"));
add_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
add_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_add_button_pressed));
add_button->connect("pressed", callable_mp(this, &LayeredTileProxiesManagerDialog::_add_button_pressed));
vbox_container->add_child(add_button);
h_separator = memnew(HSeparator);
@ -481,13 +481,13 @@ TileProxiesManagerDialog::TileProxiesManagerDialog() {
Button *clear_invalid_button = memnew(Button);
clear_invalid_button->set_text(TTR("Clear Invalid"));
clear_invalid_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
clear_invalid_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_invalid_button_pressed));
clear_invalid_button->connect("pressed", callable_mp(this, &LayeredTileProxiesManagerDialog::_clear_invalid_button_pressed));
hboxcontainer->add_child(clear_invalid_button);
Button *clear_all_button = memnew(Button);
clear_all_button->set_text(TTR("Clear All"));
clear_all_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
clear_all_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_all_button_pressed));
clear_all_button->connect("pressed", callable_mp(this, &LayeredTileProxiesManagerDialog::_clear_all_button_pressed));
hboxcontainer->add_child(clear_all_button);
h_separator = memnew(HSeparator);

View File

@ -40,15 +40,15 @@
class EditorPropertyVector2i;
class EditorUndoRedoManager;
class TileProxiesManagerDialog : public ConfirmationDialog {
GDCLASS(TileProxiesManagerDialog, ConfirmationDialog);
class LayeredTileProxiesManagerDialog : public ConfirmationDialog {
GDCLASS(LayeredTileProxiesManagerDialog, ConfirmationDialog);
private:
int commited_actions_count = 0;
Ref<TileSet> tile_set;
Ref<LayeredTileSet> tile_set;
TileMapCell from;
TileMapCell to;
LayeredTileMapCell from;
LayeredTileMapCell to;
// GUI
ItemList *source_level_list = nullptr;
@ -82,9 +82,9 @@ protected:
static void _bind_methods();
public:
void update_tile_set(Ref<TileSet> p_tile_set);
void update_tile_set(Ref<LayeredTileSet> p_tile_set);
TileProxiesManagerDialog();
LayeredTileProxiesManagerDialog();
};
#endif // TILE_PROXIES_MANAGER_DIALOG_H

View File

@ -39,18 +39,18 @@
#include "scene/resources/2d/tile_set.h"
class Popup;
class TileSet;
class LayeredTileSet;
class Tree;
class VSeparator;
class TileSetAtlasSourceEditor : public HSplitContainer {
GDCLASS(TileSetAtlasSourceEditor, HSplitContainer);
class LayeredTileSetAtlasSourceEditor : public HSplitContainer {
GDCLASS(LayeredTileSetAtlasSourceEditor, HSplitContainer);
public:
// A class to store which tiles are selected.
struct TileSelection {
Vector2i tile = TileSetSource::INVALID_ATLAS_COORDS;
int alternative = TileSetSource::INVALID_TILE_ALTERNATIVE;
Vector2i tile = LayeredTileSetSource::INVALID_ATLAS_COORDS;
int alternative = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
bool operator<(const TileSelection &p_other) const {
if (tile == p_other.tile) {
@ -62,13 +62,13 @@ public:
};
// -- Proxy object for an atlas source, needed by the inspector --
class TileSetAtlasSourceProxyObject : public Object {
GDCLASS(TileSetAtlasSourceProxyObject, Object);
class LayeredTileSetAtlasSourceProxyObject : public Object {
GDCLASS(LayeredTileSetAtlasSourceProxyObject, Object);
private:
Ref<TileSet> tile_set;
Ref<TileSetAtlasSource> tile_set_atlas_source;
int source_id = TileSet::INVALID_SOURCE;
Ref<LayeredTileSet> tile_set;
Ref<LayeredTileSetAtlasSource> tile_set_atlas_source;
int source_id = LayeredTileSet::INVALID_SOURCE;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@ -80,18 +80,18 @@ public:
void set_id(int p_id);
int get_id() const;
void edit(Ref<TileSet> p_tile_set, Ref<TileSetAtlasSource> p_tile_set_atlas_source, int p_source_id);
Ref<TileSetAtlasSource> get_edited() { return tile_set_atlas_source; };
void edit(Ref<LayeredTileSet> p_tile_set, Ref<LayeredTileSetAtlasSource> p_tile_set_atlas_source, int p_source_id);
Ref<LayeredTileSetAtlasSource> get_edited() { return tile_set_atlas_source; };
};
// -- Proxy object for a tile, needed by the inspector --
class AtlasTileProxyObject : public Object {
GDCLASS(AtlasTileProxyObject, Object);
class LayeredAtlasTileProxyObject : public Object {
GDCLASS(LayeredAtlasTileProxyObject, Object);
private:
TileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr;
LayeredTileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr;
Ref<TileSetAtlasSource> tile_set_atlas_source;
Ref<LayeredTileSetAtlasSource> tile_set_atlas_source;
RBSet<TileSelection> tiles = RBSet<TileSelection>();
protected:
@ -102,32 +102,32 @@ public:
static void _bind_methods();
public:
Ref<TileSetAtlasSource> get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; };
Ref<LayeredTileSetAtlasSource> get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; };
RBSet<TileSelection> get_edited_tiles() const { return tiles; };
// Update the proxyed object.
void edit(Ref<TileSetAtlasSource> p_tile_set_atlas_source, const RBSet<TileSelection> &p_tiles = RBSet<TileSelection>());
void edit(Ref<LayeredTileSetAtlasSource> p_tile_set_atlas_source, const RBSet<TileSelection> &p_tiles = RBSet<TileSelection>());
AtlasTileProxyObject(TileSetAtlasSourceEditor *p_tiles_set_atlas_source_editor) {
LayeredAtlasTileProxyObject(LayeredTileSetAtlasSourceEditor *p_tiles_set_atlas_source_editor) {
tiles_set_atlas_source_editor = p_tiles_set_atlas_source_editor;
}
};
class TileAtlasControl : public Control {
TileSetAtlasSourceEditor *editor = nullptr;
class LayeredTileAtlasControl : public Control {
LayeredTileSetAtlasSourceEditor *editor = nullptr;
public:
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
TileAtlasControl(TileSetAtlasSourceEditor *p_editor) { editor = p_editor; }
LayeredTileAtlasControl(LayeredTileSetAtlasSourceEditor *p_editor) { editor = p_editor; }
};
friend class TileAtlasControl;
friend class LayeredTileAtlasControl;
private:
bool read_only = false;
Ref<TileSet> tile_set;
TileSetAtlasSource *tile_set_atlas_source = nullptr;
int tile_set_atlas_source_id = TileSet::INVALID_SOURCE;
Ref<LayeredTileSet> tile_set;
LayeredTileSetAtlasSource *tile_set_atlas_source = nullptr;
int tile_set_atlas_source_id = LayeredTileSet::INVALID_SOURCE;
Ref<Texture2D> atlas_source_texture;
bool tile_set_changed_needs_update = false;
@ -145,22 +145,22 @@ private:
// -- Tile data editors --
String current_property;
Control *current_tile_data_editor_toolbar = nullptr;
HashMap<String, TileDataEditor *> tile_data_editors;
TileDataEditor *current_tile_data_editor = nullptr;
HashMap<String, LayeredTileDataEditor *> tile_data_editors;
LayeredTileDataEditor *current_tile_data_editor = nullptr;
void _tile_data_editors_tree_selected();
// -- Inspector --
AtlasTileProxyObject *tile_proxy_object = nullptr;
LayeredAtlasTileProxyObject *tile_proxy_object = nullptr;
EditorInspector *tile_inspector = nullptr;
Label *tile_inspector_no_tile_selected_label = nullptr;
String selected_property;
void _inspector_property_selected(const String &p_property);
TileSetAtlasSourceProxyObject *atlas_source_proxy_object = nullptr;
LayeredTileSetAtlasSourceProxyObject *atlas_source_proxy_object = nullptr;
EditorInspector *atlas_source_inspector = nullptr;
// -- Atlas view --
TileAtlasView *tile_atlas_view = nullptr;
LayeredTileAtlasView *tile_atlas_view = nullptr;
VBoxContainer *tile_create_help = nullptr;
// Dragging
@ -197,7 +197,7 @@ private:
RBSet<Vector2i> drag_modified_tiles;
void _end_dragging();
HashMap<Vector2i, List<const PropertyInfo *>> _group_properties_per_tiles(const List<PropertyInfo> &r_list, const TileSetAtlasSource *p_atlas);
HashMap<Vector2i, List<const PropertyInfo *>> _group_properties_per_tiles(const List<PropertyInfo> &r_list, const LayeredTileSetAtlasSource *p_atlas);
// Popup functions.
enum MenuOptions {
@ -210,7 +210,7 @@ private:
ADVANCED_CLEANUP_TILES,
};
Vector2i menu_option_coords;
int menu_option_alternative = TileSetSource::INVALID_TILE_ALTERNATIVE;
int menu_option_alternative = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
void _menu_option(int p_option);
// Tool buttons.
@ -234,7 +234,7 @@ private:
Array _get_selection_as_array();
// A control on the tile atlas to draw and handle input events.
Vector2i hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS;
Vector2i hovered_base_tile_coords = LayeredTileSetSource::INVALID_ATLAS_COORDS;
PopupMenu *base_tile_popup_menu = nullptr;
PopupMenu *empty_base_tile_popup_menu = nullptr;
@ -249,7 +249,7 @@ private:
void _tile_atlas_view_transform_changed();
// A control over the alternative tiles.
Vector3i hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE);
Vector3i hovered_alternative_tile_coords = Vector3i(LayeredTileSetSource::INVALID_ATLAS_COORDS.x, LayeredTileSetSource::INVALID_ATLAS_COORDS.y, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
PopupMenu *alternative_tile_popup_menu = nullptr;
Control *alternative_tiles_control = nullptr;
@ -276,7 +276,7 @@ private:
void _auto_remove_tiles();
void _cancel_auto_create_tiles();
AcceptDialog *confirm_auto_create_tiles = nullptr;
Vector<Ref<TileSetAtlasSource>> atlases_to_auto_create_tiles;
Vector<Ref<LayeredTileSetAtlasSource>> atlases_to_auto_create_tiles;
Vector2i _get_drag_offset_tile_coords(const Vector2i &p_offset) const;
void _update_source_texture();
@ -297,11 +297,11 @@ protected:
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
public:
void edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_source, int p_source_id);
void init_new_atlases(const Vector<Ref<TileSetAtlasSource>> &p_atlases);
void edit(Ref<LayeredTileSet> p_tile_set, LayeredTileSetAtlasSource *p_tile_set_source, int p_source_id);
void init_new_atlases(const Vector<Ref<LayeredTileSetAtlasSource>> &p_atlases);
TileSetAtlasSourceEditor();
~TileSetAtlasSourceEditor();
LayeredTileSetAtlasSourceEditor();
~LayeredTileSetAtlasSourceEditor();
};
class EditorPropertyTilePolygon : public EditorProperty {

View File

@ -47,9 +47,9 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/tab_container.h"
TileSetEditor *TileSetEditor::singleton = nullptr;
LayeredTileSetEditor *LayeredTileSetEditor::singleton = nullptr;
void TileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
void LayeredTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
ERR_FAIL_COND(!tile_set.is_valid());
if (!_can_drop_data_fw(p_point, p_data, p_from)) {
@ -64,7 +64,7 @@ void TileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
}
bool TileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
bool LayeredTileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
ERR_FAIL_COND_V(!tile_set.is_valid(), false);
if (read_only) {
@ -100,9 +100,9 @@ bool TileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_da
return false;
}
void TileSetEditor::_load_texture_files(const Vector<String> &p_paths) {
int source_id = TileSet::INVALID_SOURCE;
Vector<Ref<TileSetAtlasSource>> atlases;
void LayeredTileSetEditor::_load_texture_files(const Vector<String> &p_paths) {
int source_id = LayeredTileSet::INVALID_SOURCE;
Vector<Ref<LayeredTileSetAtlasSource>> atlases;
for (const String &p_path : p_paths) {
Ref<Texture2D> texture = ResourceLoader::load(p_path);
@ -116,7 +116,7 @@ void TileSetEditor::_load_texture_files(const Vector<String> &p_paths) {
source_id = tile_set->get_next_source_id();
// Actually create the new source.
Ref<TileSetAtlasSource> atlas_source = memnew(TileSetAtlasSource);
Ref<LayeredTileSetAtlasSource> atlas_source = memnew(LayeredTileSetAtlasSource);
atlas_source->set_texture(texture);
atlas_source->set_texture_region_size(tile_set->get_tile_size());
@ -137,13 +137,13 @@ void TileSetEditor::_load_texture_files(const Vector<String> &p_paths) {
_update_sources_list(source_id);
}
void TileSetEditor::_update_sources_list(int force_selected_id) {
void LayeredTileSetEditor::_update_sources_list(int force_selected_id) {
if (tile_set.is_null()) {
return;
}
// Get the previously selected id.
int old_selected = TileSet::INVALID_SOURCE;
int old_selected = LayeredTileSet::INVALID_SOURCE;
if (sources_list->get_current() >= 0) {
int source_id = sources_list->get_item_metadata(sources_list->get_current());
if (tile_set->has_source(source_id)) {
@ -151,7 +151,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) {
}
}
int to_select = TileSet::INVALID_SOURCE;
int to_select = LayeredTileSet::INVALID_SOURCE;
if (force_selected_id >= 0) {
to_select = force_selected_id;
} else if (old_selected >= 0) {
@ -162,9 +162,9 @@ void TileSetEditor::_update_sources_list(int force_selected_id) {
sources_list->clear();
// Update the atlas sources.
List<int> source_ids = TilesEditorUtils::get_singleton()->get_sorted_sources(tile_set);
List<int> source_ids = LayeredTilesEditorUtils::get_singleton()->get_sorted_sources(tile_set);
for (const int &source_id : source_ids) {
TileSetSource *source = *tile_set->get_source(source_id);
LayeredTileSetSource *source = *tile_set->get_source(source_id);
Ref<Texture2D> texture;
String item_text;
@ -175,7 +175,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) {
}
// Atlas source.
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
if (atlas_source) {
texture = atlas_source->get_texture();
if (item_text.is_empty()) {
@ -188,7 +188,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) {
}
// Scene collection source.
TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source);
LayeredTileSetScenesCollectionSource *scene_collection_source = Object::cast_to<LayeredTileSetScenesCollectionSource>(source);
if (scene_collection_source) {
texture = get_editor_theme_icon(SNAME("PackedScene"));
if (item_text.is_empty()) {
@ -238,10 +238,10 @@ void TileSetEditor::_update_sources_list(int force_selected_id) {
_source_selected(sources_list->get_current());
// Synchronize the lists.
TilesEditorUtils::get_singleton()->set_sources_lists_current(sources_list->get_current());
LayeredTilesEditorUtils::get_singleton()->set_sources_lists_current(sources_list->get_current());
}
void TileSetEditor::_source_selected(int p_source_index) {
void LayeredTileSetEditor::_source_selected(int p_source_index) {
ERR_FAIL_COND(!tile_set.is_valid());
// Update the selected source.
@ -249,8 +249,8 @@ void TileSetEditor::_source_selected(int p_source_index) {
if (p_source_index >= 0) {
int source_id = sources_list->get_item_metadata(p_source_index);
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(*tile_set->get_source(source_id));
TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to<TileSetScenesCollectionSource>(*tile_set->get_source(source_id));
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(*tile_set->get_source(source_id));
LayeredTileSetScenesCollectionSource *scenes_collection_source = Object::cast_to<LayeredTileSetScenesCollectionSource>(*tile_set->get_source(source_id));
if (atlas_source) {
no_source_selected_label->hide();
tile_set_atlas_source_editor->edit(*tile_set, atlas_source, source_id);
@ -273,13 +273,13 @@ void TileSetEditor::_source_selected(int p_source_index) {
}
}
void TileSetEditor::_source_delete_pressed() {
void LayeredTileSetEditor::_source_delete_pressed() {
ERR_FAIL_COND(!tile_set.is_valid());
// Update the selected source.
int to_delete = sources_list->get_item_metadata(sources_list->get_current());
Ref<TileSetSource> source = tile_set->get_source(to_delete);
Ref<LayeredTileSetSource> source = tile_set->get_source(to_delete);
// Remove the source.
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
@ -291,7 +291,7 @@ void TileSetEditor::_source_delete_pressed() {
_update_sources_list();
}
void TileSetEditor::_source_add_id_pressed(int p_id_pressed) {
void LayeredTileSetEditor::_source_add_id_pressed(int p_id_pressed) {
ERR_FAIL_COND(!tile_set.is_valid());
switch (p_id_pressed) {
@ -300,7 +300,7 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) {
texture_file_dialog = memnew(EditorFileDialog);
add_child(texture_file_dialog);
texture_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
texture_file_dialog->connect("files_selected", callable_mp(this, &TileSetEditor::_load_texture_files));
texture_file_dialog->connect("files_selected", callable_mp(this, &LayeredTileSetEditor::_load_texture_files));
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
@ -313,7 +313,7 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) {
case 1: {
int source_id = tile_set->get_next_source_id();
Ref<TileSetScenesCollectionSource> scene_collection_source = memnew(TileSetScenesCollectionSource);
Ref<LayeredTileSetScenesCollectionSource> scene_collection_source = memnew(LayeredTileSetScenesCollectionSource);
// Add a new source.
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
@ -329,7 +329,7 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) {
}
}
void TileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) {
void LayeredTileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) {
ERR_FAIL_COND(!tile_set.is_valid());
switch (p_id_pressed) {
@ -344,13 +344,13 @@ void TileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) {
}
}
void TileSetEditor::_set_source_sort(int p_sort) {
TilesEditorUtils::get_singleton()->set_sorting_option(p_sort);
for (int i = 0; i != TilesEditorUtils::SOURCE_SORT_MAX; i++) {
void LayeredTileSetEditor::_set_source_sort(int p_sort) {
LayeredTilesEditorUtils::get_singleton()->set_sorting_option(p_sort);
for (int i = 0; i != LayeredTilesEditorUtils::SOURCE_SORT_MAX; i++) {
source_sort_button->get_popup()->set_item_checked(i, (i == (int)p_sort));
}
int old_selected = TileSet::INVALID_SOURCE;
int old_selected = LayeredTileSet::INVALID_SOURCE;
if (sources_list->get_current() >= 0) {
int source_id = sources_list->get_item_metadata(sources_list->get_current());
if (tile_set->has_source(source_id)) {
@ -361,14 +361,14 @@ void TileSetEditor::_set_source_sort(int p_sort) {
EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "tile_source_sort", p_sort);
}
void TileSetEditor::_notification(int p_what) {
void LayeredTileSetEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
sources_delete_button->set_icon(get_editor_theme_icon(SNAME("Remove")));
sources_add_button->set_icon(get_editor_theme_icon(SNAME("Add")));
source_sort_button->set_icon(get_editor_theme_icon(SNAME("Sort")));
sources_advanced_menu_button->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
missing_texture_texture = get_editor_theme_icon(SNAME("TileSet"));
missing_texture_texture = get_editor_theme_icon(SNAME("LayeredTileSet"));
expanded_area->add_theme_style_override("panel", get_theme_stylebox("panel", "Tree"));
_update_sources_list();
} break;
@ -403,7 +403,7 @@ void TileSetEditor::_notification(int p_what) {
}
}
void TileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event) {
void LayeredTileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(!tile_set.is_valid());
if (EditorNode::get_singleton()->is_resource_read_only(tile_set)) {
@ -413,7 +413,7 @@ void TileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event
if (ED_IS_SHORTCUT("tiles_editor/delete", p_event) && p_event->is_pressed() && !p_event->is_echo()) {
Vector<int> selected = patterns_item_list->get_selected_items();
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Remove TileSet patterns"));
undo_redo->create_action(TTR("Remove LayeredTileSet patterns"));
for (int i = 0; i < selected.size(); i++) {
int pattern_index = selected[i];
undo_redo->add_do_method(*tile_set, "remove_pattern", pattern_index);
@ -424,7 +424,7 @@ void TileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_event
}
}
void TileSetEditor::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture) {
void LayeredTileSetEditor::_pattern_preview_done(Ref<LayeredTileMapPattern> p_pattern, Ref<Texture2D> p_texture) {
// TODO optimize ?
for (int i = 0; i < patterns_item_list->get_item_count(); i++) {
if (patterns_item_list->get_item_metadata(i) == p_pattern) {
@ -434,7 +434,7 @@ void TileSetEditor::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Tex
}
}
void TileSetEditor::_update_patterns_list() {
void LayeredTileSetEditor::_update_patterns_list() {
ERR_FAIL_COND(!tile_set.is_valid());
// Recreate the items.
@ -443,27 +443,27 @@ void TileSetEditor::_update_patterns_list() {
int id = patterns_item_list->add_item("");
patterns_item_list->set_item_metadata(id, tile_set->get_pattern(i));
patterns_item_list->set_item_tooltip(id, vformat(TTR("Index: %d"), i));
TilesEditorUtils::get_singleton()->queue_pattern_preview(tile_set, tile_set->get_pattern(i), callable_mp(this, &TileSetEditor::_pattern_preview_done));
LayeredTilesEditorUtils::get_singleton()->queue_pattern_preview(tile_set, tile_set->get_pattern(i), callable_mp(this, &LayeredTileSetEditor::_pattern_preview_done));
}
// Update the label visibility.
patterns_help_label->set_visible(patterns_item_list->get_item_count() == 0);
}
void TileSetEditor::_tile_set_changed() {
void LayeredTileSetEditor::_tile_set_changed() {
tile_set_changed_needs_update = true;
}
void TileSetEditor::_tab_changed(int p_tab_changed) {
void LayeredTileSetEditor::_tab_changed(int p_tab_changed) {
split_container->set_visible(p_tab_changed == 0);
patterns_item_list->set_visible(p_tab_changed == 1);
}
void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos) {
void LayeredTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, const String &p_array_prefix, int p_from_index, int p_to_pos) {
EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
ERR_FAIL_NULL(undo_redo_man);
TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited);
LayeredTileSet *ed_tile_set = Object::cast_to<LayeredTileSet>(p_edited);
if (!ed_tile_set) {
return;
}
@ -487,7 +487,7 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
} else if (p_array_prefix == "custom_data_layer_") {
end = ed_tile_set->get_custom_data_layers_count();
} else {
ERR_FAIL_MSG("Invalid array prefix for TileSet.");
ERR_FAIL_MSG("Invalid array prefix for LayeredTileSet.");
}
if (p_from_index < 0) {
// Adding new.
@ -557,11 +557,11 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
}
}
// Save properties for TileSetAtlasSources tile data
// Save properties for LayeredTileSetAtlasSources tile data
for (int i = 0; i < ed_tile_set->get_source_count(); i++) {
int source_id = ed_tile_set->get_source_id(i);
Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id);
Ref<LayeredTileSetAtlasSource> tas = ed_tile_set->get_source(source_id);
if (tas.is_valid()) {
for (int j = 0; j < tas->get_tiles_count(); j++) {
Vector2i tile_id = tas->get_tile_id(j);
@ -587,18 +587,18 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
} else if (p_array_prefix == "terrain_set_") {
ADD_UNDO(tile_data, "terrain_set");
for (int terrain_set_index = begin; terrain_set_index < end; terrain_set_index++) {
for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(l);
for (int l = 0; l < LayeredTileSet::CELL_NEIGHBOR_MAX; l++) {
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(l);
if (tile_data->is_valid_terrain_peering_bit(bit)) {
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(LayeredTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
}
}
}
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
for (int terrain_index = 0; terrain_index < TileSet::CELL_NEIGHBOR_MAX; terrain_index++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(terrain_index);
for (int terrain_index = 0; terrain_index < LayeredTileSet::CELL_NEIGHBOR_MAX; terrain_index++) {
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(terrain_index);
if (tile_data->is_valid_terrain_peering_bit(bit)) {
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[terrain_index]));
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(LayeredTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[terrain_index]));
}
}
} else if (p_array_prefix == "navigation_layer_") {
@ -669,18 +669,18 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_
}
}
void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value) {
void LayeredTileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, const String &p_property, const Variant &p_new_value) {
EditorUndoRedoManager *undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
ERR_FAIL_NULL(undo_redo_man);
#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited);
LayeredTileSet *ed_tile_set = Object::cast_to<LayeredTileSet>(p_edited);
if (ed_tile_set) {
Vector<String> components = p_property.split("/", true, 3);
for (int i = 0; i < ed_tile_set->get_source_count(); i++) {
int source_id = ed_tile_set->get_source_id(i);
Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id);
Ref<LayeredTileSetAtlasSource> tas = ed_tile_set->get_source(source_id);
if (tas.is_valid()) {
for (int j = 0; j < tas->get_tiles_count(); j++) {
Vector2i tile_id = tas->get_tile_id(j);
@ -692,10 +692,10 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") {
ADD_UNDO(tile_data, "terrain_set");
ADD_UNDO(tile_data, "terrain");
for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(l);
for (int l = 0; l < LayeredTileSet::CELL_NEIGHBOR_MAX; l++) {
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(l);
if (tile_data->is_valid_terrain_peering_bit(bit)) {
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(LayeredTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
}
}
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") {
@ -710,7 +710,7 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p
#undef ADD_UNDO
}
void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
void LayeredTileSetEditor::edit(Ref<LayeredTileSet> p_tile_set) {
bool new_read_only_state = false;
if (p_tile_set.is_valid()) {
new_read_only_state = EditorNode::get_singleton()->is_resource_read_only(p_tile_set);
@ -722,7 +722,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
// Remove listener.
if (tile_set.is_valid()) {
tile_set->disconnect_changed(callable_mp(this, &TileSetEditor::_tile_set_changed));
tile_set->disconnect_changed(callable_mp(this, &LayeredTileSetEditor::_tile_set_changed));
}
// Change the edited object.
@ -737,7 +737,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
sources_advanced_menu_button->set_disabled(read_only);
source_sort_button->set_disabled(read_only);
tile_set->connect_changed(callable_mp(this, &TileSetEditor::_tile_set_changed));
tile_set->connect_changed(callable_mp(this, &LayeredTileSetEditor::_tile_set_changed));
if (first_edit) {
first_edit = false;
_set_source_sort(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_source_sort", 0));
@ -748,7 +748,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) {
}
}
void TileSetEditor::add_expanded_editor(Control *p_editor) {
void LayeredTileSetEditor::add_expanded_editor(Control *p_editor) {
expanded_editor = p_editor;
expanded_editor_parent = p_editor->get_parent()->get_instance_id();
@ -778,7 +778,7 @@ void TileSetEditor::add_expanded_editor(Control *p_editor) {
}
}
void TileSetEditor::remove_expanded_editor() {
void LayeredTileSetEditor::remove_expanded_editor() {
if (!expanded_editor) {
return;
}
@ -799,11 +799,11 @@ void TileSetEditor::remove_expanded_editor() {
}
}
void TileSetEditor::register_split(SplitContainer *p_split) {
void LayeredTileSetEditor::register_split(SplitContainer *p_split) {
disable_on_expand.push_back(p_split);
}
TileSetEditor::TileSetEditor() {
LayeredTileSetEditor::LayeredTileSetEditor() {
singleton = this;
set_process_internal(true);
@ -818,7 +818,7 @@ TileSetEditor::TileSetEditor() {
tabs_bar->set_clip_tabs(false);
tabs_bar->add_tab(TTR("Tiles"));
tabs_bar->add_tab(TTR("Patterns"));
tabs_bar->connect("tab_changed", callable_mp(this, &TileSetEditor::_tab_changed));
tabs_bar->connect("tab_changed", callable_mp(this, &LayeredTileSetEditor::_tab_changed));
tile_set_toolbar = memnew(HBoxContainer);
tile_set_toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
@ -847,25 +847,25 @@ TileSetEditor::TileSetEditor() {
source_sort_button->set_tooltip_text(TTR("Sort Sources"));
PopupMenu *p = source_sort_button->get_popup();
p->connect("id_pressed", callable_mp(this, &TileSetEditor::_set_source_sort));
p->add_radio_check_item(TTR("Sort by ID (Ascending)"), TilesEditorUtils::SOURCE_SORT_ID);
p->add_radio_check_item(TTR("Sort by ID (Descending)"), TilesEditorUtils::SOURCE_SORT_ID_REVERSE);
p->add_radio_check_item(TTR("Sort by Name (Ascending)"), TilesEditorUtils::SOURCE_SORT_NAME);
p->add_radio_check_item(TTR("Sort by Name (Descending)"), TilesEditorUtils::SOURCE_SORT_NAME_REVERSE);
p->set_item_checked(TilesEditorUtils::SOURCE_SORT_ID, true);
p->connect("id_pressed", callable_mp(this, &LayeredTileSetEditor::_set_source_sort));
p->add_radio_check_item(TTR("Sort by ID (Ascending)"), LayeredTilesEditorUtils::SOURCE_SORT_ID);
p->add_radio_check_item(TTR("Sort by ID (Descending)"), LayeredTilesEditorUtils::SOURCE_SORT_ID_REVERSE);
p->add_radio_check_item(TTR("Sort by Name (Ascending)"), LayeredTilesEditorUtils::SOURCE_SORT_NAME);
p->add_radio_check_item(TTR("Sort by Name (Descending)"), LayeredTilesEditorUtils::SOURCE_SORT_NAME_REVERSE);
p->set_item_checked(LayeredTilesEditorUtils::SOURCE_SORT_ID, true);
sources_list = memnew(ItemList);
sources_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
sources_list->set_fixed_icon_size(Size2(60, 60) * EDSCALE);
sources_list->set_h_size_flags(SIZE_EXPAND_FILL);
sources_list->set_v_size_flags(SIZE_EXPAND_FILL);
sources_list->connect("item_selected", callable_mp(this, &TileSetEditor::_source_selected));
sources_list->connect("item_selected", callable_mp(TilesEditorUtils::get_singleton(), &TilesEditorUtils::set_sources_lists_current));
sources_list->connect("visibility_changed", callable_mp(TilesEditorUtils::get_singleton(), &TilesEditorUtils::synchronize_sources_list).bind(sources_list, source_sort_button));
sources_list->connect("item_selected", callable_mp(this, &LayeredTileSetEditor::_source_selected));
sources_list->connect("item_selected", callable_mp(LayeredTilesEditorUtils::get_singleton(), &LayeredTilesEditorUtils::set_sources_lists_current));
sources_list->connect("visibility_changed", callable_mp(LayeredTilesEditorUtils::get_singleton(), &LayeredTilesEditorUtils::synchronize_sources_list).bind(sources_list, source_sort_button));
sources_list->add_user_signal(MethodInfo("sort_request"));
sources_list->connect("sort_request", callable_mp(this, &TileSetEditor::_update_sources_list).bind(-1));
sources_list->connect("sort_request", callable_mp(this, &LayeredTileSetEditor::_update_sources_list).bind(-1));
sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
SET_DRAG_FORWARDING_CDU(sources_list, TileSetEditor);
SET_DRAG_FORWARDING_CDU(sources_list, LayeredTileSetEditor);
split_container_left_side->add_child(sources_list);
HBoxContainer *sources_bottom_actions = memnew(HBoxContainer);
@ -875,7 +875,7 @@ TileSetEditor::TileSetEditor() {
sources_delete_button = memnew(Button);
sources_delete_button->set_theme_type_variation("FlatButton");
sources_delete_button->set_disabled(true);
sources_delete_button->connect("pressed", callable_mp(this, &TileSetEditor::_source_delete_pressed));
sources_delete_button->connect("pressed", callable_mp(this, &LayeredTileSetEditor::_source_delete_pressed));
sources_bottom_actions->add_child(sources_delete_button);
sources_add_button = memnew(MenuButton);
@ -883,7 +883,7 @@ TileSetEditor::TileSetEditor() {
sources_add_button->set_theme_type_variation("FlatButton");
sources_add_button->get_popup()->add_item(TTR("Atlas"));
sources_add_button->get_popup()->add_item(TTR("Scenes Collection"));
sources_add_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_source_add_id_pressed));
sources_add_button->get_popup()->connect("id_pressed", callable_mp(this, &LayeredTileSetEditor::_source_add_id_pressed));
sources_bottom_actions->add_child(sources_add_button);
sources_advanced_menu_button = memnew(MenuButton);
@ -891,14 +891,14 @@ TileSetEditor::TileSetEditor() {
sources_advanced_menu_button->set_theme_type_variation("FlatButton");
sources_advanced_menu_button->get_popup()->add_item(TTR("Open Atlas Merging Tool"));
sources_advanced_menu_button->get_popup()->add_item(TTR("Manage Tile Proxies"));
sources_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_sources_advanced_menu_id_pressed));
sources_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &LayeredTileSetEditor::_sources_advanced_menu_id_pressed));
sources_bottom_actions->add_child(sources_advanced_menu_button);
sources_bottom_actions->add_child(source_sort_button);
atlas_merging_dialog = memnew(AtlasMergingDialog);
add_child(atlas_merging_dialog);
tile_proxies_manager_dialog = memnew(TileProxiesManagerDialog);
tile_proxies_manager_dialog = memnew(LayeredTileProxiesManagerDialog);
add_child(tile_proxies_manager_dialog);
// Right side container.
@ -909,7 +909,7 @@ TileSetEditor::TileSetEditor() {
// No source selected.
no_source_selected_label = memnew(Label);
no_source_selected_label->set_text(TTR("No TileSet source selected. Select or create a TileSet source.\nYou can create a new source by using the Add button on the left or by dropping a tileset texture onto the source list."));
no_source_selected_label->set_text(TTR("No LayeredTileSet source selected. Select or create a LayeredTileSet source.\nYou can create a new source by using the Add button on the left or by dropping a tileset texture onto the source list."));
no_source_selected_label->set_h_size_flags(SIZE_EXPAND_FILL);
no_source_selected_label->set_v_size_flags(SIZE_EXPAND_FILL);
no_source_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@ -917,18 +917,18 @@ TileSetEditor::TileSetEditor() {
split_container_right_side->add_child(no_source_selected_label);
// Atlases editor.
tile_set_atlas_source_editor = memnew(TileSetAtlasSourceEditor);
tile_set_atlas_source_editor = memnew(LayeredTileSetAtlasSourceEditor);
tile_set_atlas_source_editor->set_h_size_flags(SIZE_EXPAND_FILL);
tile_set_atlas_source_editor->set_v_size_flags(SIZE_EXPAND_FILL);
tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list));
tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &LayeredTileSetEditor::_update_sources_list));
split_container_right_side->add_child(tile_set_atlas_source_editor);
tile_set_atlas_source_editor->hide();
// Scenes collection editor.
tile_set_scenes_collection_source_editor = memnew(TileSetScenesCollectionSourceEditor);
tile_set_scenes_collection_source_editor = memnew(LayeredTileSetScenesCollectionSourceEditor);
tile_set_scenes_collection_source_editor->set_h_size_flags(SIZE_EXPAND_FILL);
tile_set_scenes_collection_source_editor->set_v_size_flags(SIZE_EXPAND_FILL);
tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list));
tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &LayeredTileSetEditor::_update_sources_list));
split_container_right_side->add_child(tile_set_scenes_collection_source_editor);
tile_set_scenes_collection_source_editor->hide();
@ -942,12 +942,12 @@ TileSetEditor::TileSetEditor() {
patterns_item_list->set_max_text_lines(2);
patterns_item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
patterns_item_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
patterns_item_list->connect("gui_input", callable_mp(this, &TileSetEditor::_patterns_item_list_gui_input));
patterns_item_list->connect("gui_input", callable_mp(this, &LayeredTileSetEditor::_patterns_item_list_gui_input));
main_vb->add_child(patterns_item_list);
patterns_item_list->hide();
patterns_help_label = memnew(Label);
patterns_help_label->set_text(TTR("Add new patterns in the TileMap editing mode."));
patterns_help_label->set_text(TTR("Add new patterns in the LayeredTileMap editing mode."));
patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER);
patterns_item_list->add_child(patterns_help_label);
@ -959,19 +959,19 @@ TileSetEditor::TileSetEditor() {
expanded_area->hide();
// Registers UndoRedo inspector callback.
EditorNode::get_editor_data().add_move_array_element_function(SNAME("TileSet"), callable_mp(this, &TileSetEditor::_move_tile_set_array_element));
EditorNode::get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &TileSetEditor::_undo_redo_inspector_callback));
EditorNode::get_editor_data().add_move_array_element_function(SNAME("LayeredTileSet"), callable_mp(this, &LayeredTileSetEditor::_move_tile_set_array_element));
EditorNode::get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &LayeredTileSetEditor::_undo_redo_inspector_callback));
}
void TileSourceInspectorPlugin::_show_id_edit_dialog(Object *p_for_source) {
void LayeredTileSourceInspectorPlugin::_show_id_edit_dialog(Object *p_for_source) {
if (!id_edit_dialog) {
id_edit_dialog = memnew(ConfirmationDialog);
TileSetEditor::get_singleton()->add_child(id_edit_dialog);
LayeredTileSetEditor::get_singleton()->add_child(id_edit_dialog);
VBoxContainer *vbox = memnew(VBoxContainer);
id_edit_dialog->add_child(vbox);
Label *label = memnew(Label(TTR("Warning: Modifying a source ID will result in all TileMaps using that source to reference an invalid source instead. This may result in unexpected data loss. Change this ID carefully.")));
Label *label = memnew(Label(TTR("Warning: Modifying a source ID will result in all LayeredTileMaps using that source to reference an invalid source instead. This may result in unexpected data loss. Change this ID carefully.")));
label->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
vbox->add_child(label);
@ -979,7 +979,7 @@ void TileSourceInspectorPlugin::_show_id_edit_dialog(Object *p_for_source) {
vbox->add_child(id_input);
id_input->set_max(INT_MAX);
id_edit_dialog->connect("confirmed", callable_mp(this, &TileSourceInspectorPlugin::_confirm_change_id));
id_edit_dialog->connect("confirmed", callable_mp(this, &LayeredTileSourceInspectorPlugin::_confirm_change_id));
}
edited_source = p_for_source;
id_input->set_value(p_for_source->get("id"));
@ -987,16 +987,16 @@ void TileSourceInspectorPlugin::_show_id_edit_dialog(Object *p_for_source) {
callable_mp((Control *)id_input->get_line_edit(), &Control::grab_focus).call_deferred();
}
void TileSourceInspectorPlugin::_confirm_change_id() {
void LayeredTileSourceInspectorPlugin::_confirm_change_id() {
edited_source->set("id", id_input->get_value());
id_label->set_text(itos(edited_source->get("id"))); // Use get(), because the provided ID might've been invalid.
}
bool TileSourceInspectorPlugin::can_handle(Object *p_object) {
return p_object->is_class("TileSetAtlasSourceProxyObject") || p_object->is_class("TileSetScenesCollectionProxyObject");
bool LayeredTileSourceInspectorPlugin::can_handle(Object *p_object) {
return p_object->is_class("LayeredTileSetAtlasSourceProxyObject") || p_object->is_class("LayeredTileSetScenesCollectionProxyObject");
}
bool TileSourceInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {
bool LayeredTileSourceInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {
if (p_path == "id") {
const Variant value = p_object->get("id");
if (value.get_type() == Variant::NIL) { // May happen if the object is not yet initialized.
@ -1015,7 +1015,7 @@ bool TileSourceInspectorPlugin::parse_property(Object *p_object, const Variant::
Button *button = memnew(Button(TTR("Edit")));
button->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbox->add_child(button);
button->connect("pressed", callable_mp(this, &TileSourceInspectorPlugin::_show_id_edit_dialog).bind(p_object));
button->connect("pressed", callable_mp(this, &LayeredTileSourceInspectorPlugin::_show_id_edit_dialog).bind(p_object));
ep->add_child(hbox);
add_property_editor(p_path, ep);

View File

@ -46,15 +46,15 @@ class SplitContainer;
class EditorFileDialog;
class EditorInspectorPlugin;
class TileSetEditor : public Control {
GDCLASS(TileSetEditor, Control);
class LayeredTileSetEditor : public Control {
GDCLASS(LayeredTileSetEditor, Control);
static TileSetEditor *singleton;
static LayeredTileSetEditor *singleton;
private:
bool read_only = false;
Ref<TileSet> tile_set;
Ref<LayeredTileSet> tile_set;
bool tile_set_changed_needs_update = false;
HSplitContainer *split_container = nullptr;
@ -64,8 +64,8 @@ private:
// Tiles.
Label *no_source_selected_label = nullptr;
TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr;
TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
LayeredTileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr;
LayeredTileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
@ -88,7 +88,7 @@ private:
EditorFileDialog *texture_file_dialog = nullptr;
AtlasMergingDialog *atlas_merging_dialog = nullptr;
TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr;
LayeredTileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr;
bool first_edit = true;
@ -96,7 +96,7 @@ private:
ItemList *patterns_item_list = nullptr;
Label *patterns_help_label = nullptr;
void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);
void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture);
void _pattern_preview_done(Ref<LayeredTileMapPattern> p_pattern, Ref<Texture2D> p_texture);
bool select_last_pattern = false;
void _update_patterns_list();
@ -116,19 +116,19 @@ protected:
void _notification(int p_what);
public:
_FORCE_INLINE_ static TileSetEditor *get_singleton() { return singleton; }
_FORCE_INLINE_ static LayeredTileSetEditor *get_singleton() { return singleton; }
void edit(Ref<TileSet> p_tile_set);
void edit(Ref<LayeredTileSet> p_tile_set);
void add_expanded_editor(Control *p_editor);
void remove_expanded_editor();
void register_split(SplitContainer *p_split);
TileSetEditor();
LayeredTileSetEditor();
};
class TileSourceInspectorPlugin : public EditorInspectorPlugin {
GDCLASS(TileSourceInspectorPlugin, EditorInspectorPlugin);
class LayeredTileSourceInspectorPlugin : public EditorInspectorPlugin {
GDCLASS(LayeredTileSourceInspectorPlugin, EditorInspectorPlugin);
AcceptDialog *id_edit_dialog = nullptr;
Label *id_label = nullptr;

View File

@ -47,12 +47,12 @@
#include "core/core_string_names.h"
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id(int p_id) {
void LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::set_id(int p_id) {
ERR_FAIL_COND(p_id < 0);
if (source_id == p_id) {
return;
}
ERR_FAIL_COND_MSG(tile_set->has_source(p_id), vformat("Cannot change TileSet Scenes Collection source ID. Another TileSet source exists with id %d.", p_id));
ERR_FAIL_COND_MSG(tile_set->has_source(p_id), vformat("Cannot change LayeredTileSet Scenes Collection source ID. Another LayeredTileSet source exists with id %d.", p_id));
int previous_source = source_id;
source_id = p_id; // source_id must be updated before, because it's used by the source list update.
@ -60,11 +60,11 @@ void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::se
emit_signal(SNAME("changed"), "id");
}
int TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id() {
int LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::get_id() {
return source_id;
}
bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_set(const StringName &p_name, const Variant &p_value) {
bool LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
if (name == "name") {
// Use the resource_name property to store the source's name.
@ -78,7 +78,7 @@ bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_s
return valid;
}
bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
bool LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
if (!tile_set_scenes_collection_source) {
return false;
}
@ -92,21 +92,21 @@ bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_g
return valid;
}
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
void LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, ""));
}
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_bind_methods() {
void LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::_bind_methods() {
// -- Shape and layout --
ClassDB::bind_method(D_METHOD("set_id", "id"), &TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::set_id);
ClassDB::bind_method(D_METHOD("get_id"), &TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id);
ClassDB::bind_method(D_METHOD("set_id", "id"), &LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::set_id);
ClassDB::bind_method(D_METHOD("get_id"), &LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::get_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what")));
}
void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
void LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionProxyObject::edit(Ref<LayeredTileSet> p_tile_set, LayeredTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
ERR_FAIL_COND(!p_tile_set.is_valid());
ERR_FAIL_NULL(p_tile_set_scenes_collection_source);
ERR_FAIL_COND(p_source_id < 0);
@ -136,7 +136,7 @@ void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::ed
}
// -- Proxy object used by the tile inspector --
bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const StringName &p_name, const Variant &p_value) {
bool LayeredTileSetScenesCollectionSourceEditor::LayeredSceneTileProxyObject::_set(const StringName &p_name, const Variant &p_value) {
if (!tile_set_scenes_collection_source) {
return false;
}
@ -168,7 +168,7 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const Strin
return false;
}
bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
bool LayeredTileSetScenesCollectionSourceEditor::LayeredSceneTileProxyObject::_get(const StringName &p_name, Variant &r_ret) const {
if (!tile_set_scenes_collection_source) {
return false;
}
@ -187,7 +187,7 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get(const Strin
return false;
}
void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
void LayeredTileSetScenesCollectionSourceEditor::LayeredSceneTileProxyObject::_get_property_list(List<PropertyInfo> *p_list) const {
if (!tile_set_scenes_collection_source) {
return;
}
@ -197,7 +197,7 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_get_property_li
p_list->push_back(PropertyInfo(Variant::BOOL, "display_placeholder", PROPERTY_HINT_NONE, ""));
}
void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_scene_id) {
void LayeredTileSetScenesCollectionSourceEditor::LayeredSceneTileProxyObject::edit(LayeredTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_scene_id) {
ERR_FAIL_NULL(p_tile_set_scenes_collection_source);
ERR_FAIL_COND(!p_tile_set_scenes_collection_source->has_scene_tile_id(p_scene_id));
@ -211,21 +211,21 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::edit(TileSetScen
notify_property_list_changed();
}
void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_bind_methods() {
void LayeredTileSetScenesCollectionSourceEditor::LayeredSceneTileProxyObject::_bind_methods() {
ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what")));
}
void TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(const String &p_what) {
void LayeredTileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(const String &p_what) {
if (p_what == "id") {
emit_signal(SNAME("source_id_changed"), scenes_collection_source_proxy_object->get_id());
}
}
void TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed() {
void LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed() {
tile_set_scenes_collection_source_changed_needs_update = true;
}
void TileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_ud) {
void LayeredTileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_ud) {
int index = p_ud;
if (index >= 0 && index < scene_tiles_list->get_item_count()) {
@ -233,19 +233,19 @@ void TileSetScenesCollectionSourceEditor::_scene_thumbnail_done(const String &p_
}
}
void TileSetScenesCollectionSourceEditor::_scenes_list_item_activated(int p_index) {
void LayeredTileSetScenesCollectionSourceEditor::_scenes_list_item_activated(int p_index) {
Ref<PackedScene> packed_scene = tile_set_scenes_collection_source->get_scene_tile_scene(scene_tiles_list->get_item_metadata(p_index));
if (packed_scene.is_valid()) {
EditorNode::get_singleton()->open_request(packed_scene->get_path());
}
}
void TileSetScenesCollectionSourceEditor::_source_add_pressed() {
void LayeredTileSetScenesCollectionSourceEditor::_source_add_pressed() {
if (!scene_select_dialog) {
scene_select_dialog = memnew(EditorFileDialog);
add_child(scene_select_dialog);
scene_select_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
scene_select_dialog->connect("file_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_scene_file_selected));
scene_select_dialog->connect("file_selected", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_scene_file_selected));
for (const String &E : Vector<String>{ "tscn", "scn" }) {
scene_select_dialog->add_filter("*." + E, E.to_upper());
@ -254,7 +254,7 @@ void TileSetScenesCollectionSourceEditor::_source_add_pressed() {
scene_select_dialog->popup_file_dialog();
}
void TileSetScenesCollectionSourceEditor::_scene_file_selected(const String &p_path) {
void LayeredTileSetScenesCollectionSourceEditor::_scene_file_selected(const String &p_path) {
Ref<PackedScene> scene = ResourceLoader::load(p_path);
int scene_id = tile_set_scenes_collection_source->get_next_scene_tile_id();
@ -268,7 +268,7 @@ void TileSetScenesCollectionSourceEditor::_scene_file_selected(const String &p_p
_update_tile_inspector();
}
void TileSetScenesCollectionSourceEditor::_source_delete_pressed() {
void LayeredTileSetScenesCollectionSourceEditor::_source_delete_pressed() {
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
ERR_FAIL_COND(selected_indices.is_empty());
int scene_id = scene_tiles_list->get_item_metadata(selected_indices[0]);
@ -283,12 +283,12 @@ void TileSetScenesCollectionSourceEditor::_source_delete_pressed() {
_update_tile_inspector();
}
void TileSetScenesCollectionSourceEditor::_update_source_inspector() {
void LayeredTileSetScenesCollectionSourceEditor::_update_source_inspector() {
// Update the proxy object.
scenes_collection_source_proxy_object->edit(tile_set, tile_set_scenes_collection_source, tile_set_source_id);
}
void TileSetScenesCollectionSourceEditor::_update_tile_inspector() {
void LayeredTileSetScenesCollectionSourceEditor::_update_tile_inspector() {
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
bool has_atlas_tile_selected = (selected_indices.size() > 0);
@ -303,12 +303,12 @@ void TileSetScenesCollectionSourceEditor::_update_tile_inspector() {
tile_inspector->set_visible(has_atlas_tile_selected);
}
void TileSetScenesCollectionSourceEditor::_update_action_buttons() {
void LayeredTileSetScenesCollectionSourceEditor::_update_action_buttons() {
Vector<int> selected_indices = scene_tiles_list->get_selected_items();
scene_tile_delete_button->set_disabled(selected_indices.size() <= 0 || read_only);
}
void TileSetScenesCollectionSourceEditor::_update_scenes_list() {
void LayeredTileSetScenesCollectionSourceEditor::_update_scenes_list() {
if (!tile_set_scenes_collection_source) {
return;
}
@ -356,17 +356,17 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() {
scene_tiles_list->set_fixed_icon_size(Vector2(int_size, int_size));
}
void TileSetScenesCollectionSourceEditor::_notification(int p_what) {
void LayeredTileSetScenesCollectionSourceEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
scenes_collection_source_inspector->edit(scenes_collection_source_proxy_object);
scenes_collection_source_inspector->add_custom_property_description("TileSetScenesCollectionProxyObject", "id", TTR("The tile's unique identifier within this TileSet. Each tile stores its source ID, so changing one may make tiles invalid."));
scenes_collection_source_inspector->add_custom_property_description("TileSetScenesCollectionProxyObject", "name", TTR("The human-readable name for the scene collection. Use a descriptive name here for organizational purposes (such as \"obstacles\", \"decoration\", etc.)."));
scenes_collection_source_inspector->add_custom_property_description("LayeredTileSetScenesCollectionProxyObject", "id", TTR("The tile's unique identifier within this LayeredTileSet. Each tile stores its source ID, so changing one may make tiles invalid."));
scenes_collection_source_inspector->add_custom_property_description("LayeredTileSetScenesCollectionProxyObject", "name", TTR("The human-readable name for the scene collection. Use a descriptive name here for organizational purposes (such as \"obstacles\", \"decoration\", etc.)."));
tile_inspector->edit(tile_proxy_object);
tile_inspector->add_custom_property_description("SceneTileProxyObject", "id", TTR("ID of the scene tile in the collection. Each painted tile has associated ID, so changing this property may cause your TileMaps to not display properly."));
tile_inspector->add_custom_property_description("SceneTileProxyObject", "scene", TTR("Absolute path to the scene associated with this tile."));
tile_inspector->add_custom_property_description("SceneTileProxyObject", "display_placeholder", TTR("If [code]true[/code], a placeholder marker will be displayed on top of the scene's preview. The marker is displayed anyway if the scene has no valid preview."));
tile_inspector->add_custom_property_description("LayeredSceneTileProxyObject", "id", TTR("ID of the scene tile in the collection. Each painted tile has associated ID, so changing this property may cause your LayeredTileMaps to not display properly."));
tile_inspector->add_custom_property_description("LayeredSceneTileProxyObject", "scene", TTR("Absolute path to the scene associated with this tile."));
tile_inspector->add_custom_property_description("LayeredSceneTileProxyObject", "display_placeholder", TTR("If [code]true[/code], a placeholder marker will be displayed on top of the scene's preview. The marker is displayed anyway if the scene has no valid preview."));
} break;
case NOTIFICATION_THEME_CHANGED: {
@ -400,7 +400,7 @@ void TileSetScenesCollectionSourceEditor::_notification(int p_what) {
}
}
void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
void LayeredTileSetScenesCollectionSourceEditor::edit(Ref<LayeredTileSet> p_tile_set, LayeredTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id) {
ERR_FAIL_COND(!p_tile_set.is_valid());
ERR_FAIL_NULL(p_tile_set_scenes_collection_source);
ERR_FAIL_COND(p_source_id < 0);
@ -417,7 +417,7 @@ void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetS
// Remove listener for old objects.
if (tile_set_scenes_collection_source) {
tile_set_scenes_collection_source->disconnect_changed(callable_mp(this, &TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
tile_set_scenes_collection_source->disconnect_changed(callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
}
// Change the edited object.
@ -437,7 +437,7 @@ void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetS
// Add the listener again.
if (tile_set_scenes_collection_source) {
tile_set_scenes_collection_source->connect_changed(callable_mp(this, &TileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
tile_set_scenes_collection_source->connect_changed(callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
}
// Update everything.
@ -447,7 +447,7 @@ void TileSetScenesCollectionSourceEditor::edit(Ref<TileSet> p_tile_set, TileSetS
_update_tile_inspector();
}
void TileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
void LayeredTileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
if (!_can_drop_data_fw(p_point, p_data, p_from)) {
return;
}
@ -474,7 +474,7 @@ void TileSetScenesCollectionSourceEditor::_drop_data_fw(const Point2 &p_point, c
}
}
bool TileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
bool LayeredTileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
if (p_from == scene_tiles_list) {
Dictionary d = p_data;
@ -504,13 +504,13 @@ bool TileSetScenesCollectionSourceEditor::_can_drop_data_fw(const Point2 &p_poin
return false;
}
void TileSetScenesCollectionSourceEditor::_bind_methods() {
void LayeredTileSetScenesCollectionSourceEditor::_bind_methods() {
ADD_SIGNAL(MethodInfo("source_id_changed", PropertyInfo(Variant::INT, "source_id")));
ClassDB::bind_method(D_METHOD("_scene_thumbnail_done"), &TileSetScenesCollectionSourceEditor::_scene_thumbnail_done);
ClassDB::bind_method(D_METHOD("_scene_thumbnail_done"), &LayeredTileSetScenesCollectionSourceEditor::_scene_thumbnail_done);
}
TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
LayeredTileSetScenesCollectionSourceEditor::LayeredTileSetScenesCollectionSourceEditor() {
// -- Right side --
HSplitContainer *split_container_right_side = memnew(HSplitContainer);
split_container_right_side->set_h_size_flags(SIZE_EXPAND_FILL);
@ -531,13 +531,13 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
scenes_collection_source_inspector_label->set_text(TTR("Scenes collection properties:"));
middle_vbox_container->add_child(scenes_collection_source_inspector_label);
scenes_collection_source_proxy_object = memnew(TileSetScenesCollectionProxyObject());
scenes_collection_source_proxy_object->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed));
scenes_collection_source_proxy_object = memnew(LayeredTileSetScenesCollectionProxyObject());
scenes_collection_source_proxy_object->connect("changed", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed));
scenes_collection_source_inspector = memnew(EditorInspector);
scenes_collection_source_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
scenes_collection_source_inspector->set_use_doc_hints(true);
scenes_collection_source_inspector->add_inspector_plugin(memnew(TileSourceInspectorPlugin));
scenes_collection_source_inspector->add_inspector_plugin(memnew(LayeredTileSourceInspectorPlugin));
middle_vbox_container->add_child(scenes_collection_source_inspector);
// Tile inspector.
@ -546,9 +546,9 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
tile_inspector_label->hide();
middle_vbox_container->add_child(tile_inspector_label);
tile_proxy_object = memnew(SceneTileProxyObject(this));
tile_proxy_object->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_scenes_list).unbind(1));
tile_proxy_object->connect("changed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
tile_proxy_object = memnew(LayeredSceneTileProxyObject(this));
tile_proxy_object->connect("changed", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_update_scenes_list).unbind(1));
tile_proxy_object->connect("changed", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
tile_inspector = memnew(EditorInspector);
tile_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
@ -564,10 +564,10 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
scene_tiles_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
scene_tiles_list->set_h_size_flags(SIZE_EXPAND_FILL);
scene_tiles_list->set_v_size_flags(SIZE_EXPAND_FILL);
SET_DRAG_FORWARDING_CDU(scene_tiles_list, TileSetScenesCollectionSourceEditor);
scene_tiles_list->connect("item_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_tile_inspector).unbind(1));
scene_tiles_list->connect("item_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
scene_tiles_list->connect("item_activated", callable_mp(this, &TileSetScenesCollectionSourceEditor::_scenes_list_item_activated));
SET_DRAG_FORWARDING_CDU(scene_tiles_list, LayeredTileSetScenesCollectionSourceEditor);
scene_tiles_list->connect("item_selected", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_update_tile_inspector).unbind(1));
scene_tiles_list->connect("item_selected", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1));
scene_tiles_list->connect("item_activated", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_scenes_list_item_activated));
scene_tiles_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
right_vbox_container->add_child(scene_tiles_list);
@ -576,17 +576,17 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() {
scene_tile_add_button = memnew(Button);
scene_tile_add_button->set_theme_type_variation("FlatButton");
scene_tile_add_button->connect("pressed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_source_add_pressed));
scene_tile_add_button->connect("pressed", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_source_add_pressed));
scenes_bottom_actions->add_child(scene_tile_add_button);
scene_tile_delete_button = memnew(Button);
scene_tile_delete_button->set_theme_type_variation("FlatButton");
scene_tile_delete_button->set_disabled(true);
scene_tile_delete_button->connect("pressed", callable_mp(this, &TileSetScenesCollectionSourceEditor::_source_delete_pressed));
scene_tile_delete_button->connect("pressed", callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_source_delete_pressed));
scenes_bottom_actions->add_child(scene_tile_delete_button);
}
TileSetScenesCollectionSourceEditor::~TileSetScenesCollectionSourceEditor() {
LayeredTileSetScenesCollectionSourceEditor::~LayeredTileSetScenesCollectionSourceEditor() {
memdelete(scenes_collection_source_proxy_object);
memdelete(tile_proxy_object);
}

View File

@ -41,17 +41,17 @@ class ItemList;
class Label;
class EditorFileDialog;
class TileSetScenesCollectionSourceEditor : public HBoxContainer {
GDCLASS(TileSetScenesCollectionSourceEditor, HBoxContainer);
class LayeredTileSetScenesCollectionSourceEditor : public HBoxContainer {
GDCLASS(LayeredTileSetScenesCollectionSourceEditor, HBoxContainer);
private:
// -- Proxy object for an atlas source, needed by the inspector --
class TileSetScenesCollectionProxyObject : public Object {
GDCLASS(TileSetScenesCollectionProxyObject, Object);
class LayeredTileSetScenesCollectionProxyObject : public Object {
GDCLASS(LayeredTileSetScenesCollectionProxyObject, Object);
private:
Ref<TileSet> tile_set;
TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
Ref<LayeredTileSet> tile_set;
LayeredTileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
int source_id = -1;
protected:
@ -64,17 +64,17 @@ private:
void set_id(int p_id);
int get_id();
void edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
void edit(Ref<LayeredTileSet> p_tile_set, LayeredTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
};
// -- Proxy object for a tile, needed by the inspector --
class SceneTileProxyObject : public Object {
GDCLASS(SceneTileProxyObject, Object);
class LayeredSceneTileProxyObject : public Object {
GDCLASS(LayeredSceneTileProxyObject, Object);
private:
TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
LayeredTileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr;
TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
LayeredTileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
int source_id;
int scene_id;
@ -87,9 +87,9 @@ private:
public:
// Update the proxyed object.
void edit(TileSetScenesCollectionSource *p_tile_set_atlas_source, int p_scene_id);
void edit(LayeredTileSetScenesCollectionSource *p_tile_set_atlas_source, int p_scene_id);
SceneTileProxyObject(TileSetScenesCollectionSourceEditor *p_tiles_set_scenes_collection_source_editor) {
LayeredSceneTileProxyObject(LayeredTileSetScenesCollectionSourceEditor *p_tiles_set_scenes_collection_source_editor) {
tile_set_scenes_collection_source_editor = p_tiles_set_scenes_collection_source_editor;
}
};
@ -97,19 +97,19 @@ private:
private:
bool read_only = false;
Ref<TileSet> tile_set;
TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
Ref<LayeredTileSet> tile_set;
LayeredTileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr;
int tile_set_source_id = -1;
bool tile_set_scenes_collection_source_changed_needs_update = false;
// Source inspector.
TileSetScenesCollectionProxyObject *scenes_collection_source_proxy_object = nullptr;
LayeredTileSetScenesCollectionProxyObject *scenes_collection_source_proxy_object = nullptr;
Label *scenes_collection_source_inspector_label = nullptr;
EditorInspector *scenes_collection_source_inspector = nullptr;
// Tile inspector.
SceneTileProxyObject *tile_proxy_object = nullptr;
LayeredSceneTileProxyObject *tile_proxy_object = nullptr;
Label *tile_inspector_label = nullptr;
EditorInspector *tile_inspector = nullptr;
@ -141,9 +141,9 @@ protected:
static void _bind_methods();
public:
void edit(Ref<TileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
TileSetScenesCollectionSourceEditor();
~TileSetScenesCollectionSourceEditor();
void edit(Ref<LayeredTileSet> p_tile_set, LayeredTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
LayeredTileSetScenesCollectionSourceEditor();
~LayeredTileSetScenesCollectionSourceEditor();
};
#endif // TILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H

View File

@ -51,25 +51,25 @@
#include "scene/resources/2d/tile_set.h"
#include "scene/resources/image_texture.h"
TilesEditorUtils *TilesEditorUtils::singleton = nullptr;
TileMapEditorPlugin *tile_map_plugin_singleton = nullptr;
TileSetEditorPlugin *tile_set_plugin_singleton = nullptr;
LayeredTilesEditorUtils *LayeredTilesEditorUtils::singleton = nullptr;
LayeredTileMapEditorPlugin *tile_map_plugin_singleton = nullptr;
LayeredTileSetEditorPlugin *tile_set_plugin_singleton = nullptr;
void TilesEditorUtils::_preview_frame_started() {
RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<TilesEditorUtils *>(this), &TilesEditorUtils::_pattern_preview_done));
void LayeredTilesEditorUtils::_preview_frame_started() {
RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<LayeredTilesEditorUtils *>(this), &LayeredTilesEditorUtils::_pattern_preview_done));
}
void TilesEditorUtils::_pattern_preview_done() {
void LayeredTilesEditorUtils::_pattern_preview_done() {
pattern_preview_done.post();
}
void TilesEditorUtils::_thread_func(void *ud) {
TilesEditorUtils *te = static_cast<TilesEditorUtils *>(ud);
void LayeredTilesEditorUtils::_thread_func(void *ud) {
LayeredTilesEditorUtils *te = static_cast<LayeredTilesEditorUtils *>(ud);
set_current_thread_safe_for_nodes(true);
te->_thread();
}
void TilesEditorUtils::_thread() {
void LayeredTilesEditorUtils::_thread() {
pattern_thread_exited.clear();
while (!pattern_thread_exit.is_set()) {
pattern_preview_sem.wait();
@ -94,7 +94,7 @@ void TilesEditorUtils::_thread() {
viewport->set_transparent_background(true);
viewport->set_update_mode(SubViewport::UPDATE_ONCE);
TileMap *tile_map = memnew(TileMap);
LayeredTileMap *tile_map = memnew(LayeredTileMap);
tile_map->set_tileset(item.tile_set);
tile_map->set_pattern(0, Vector2(), item.pattern);
viewport->add_child(tile_map);
@ -109,7 +109,7 @@ void TilesEditorUtils::_thread() {
encompassing_rect.expand_to(world_pos);
// Texture.
Ref<TileSetAtlasSource> atlas_source = item.tile_set->get_source(tile_map->get_cell_source_id(0, cell));
Ref<LayeredTileSetAtlasSource> atlas_source = item.tile_set->get_source(tile_map->get_cell_source_id(0, cell));
if (atlas_source.is_valid()) {
Vector2i coords = tile_map->get_cell_atlas_coords(0, cell);
int alternative = tile_map->get_cell_alternative_tile(0, cell);
@ -129,7 +129,7 @@ void TilesEditorUtils::_thread() {
// Add the viewport at the last moment to avoid rendering too early.
callable_mp((Node *)EditorNode::get_singleton(), &Node::add_child).call_deferred(viewport, false, Node::INTERNAL_MODE_DISABLED);
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorUtils *>(this), &TilesEditorUtils::_preview_frame_started), Object::CONNECT_ONE_SHOT);
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<LayeredTilesEditorUtils *>(this), &LayeredTilesEditorUtils::_preview_frame_started), Object::CONNECT_ONE_SHOT);
pattern_preview_done.wait();
@ -145,7 +145,7 @@ void TilesEditorUtils::_thread() {
pattern_thread_exited.set();
}
void TilesEditorUtils::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback) {
void LayeredTilesEditorUtils::queue_pattern_preview(Ref<LayeredTileSet> p_tile_set, Ref<LayeredTileMapPattern> p_pattern, Callable p_callback) {
ERR_FAIL_COND(!p_tile_set.is_valid());
ERR_FAIL_COND(!p_pattern.is_valid());
{
@ -155,11 +155,11 @@ void TilesEditorUtils::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMa
pattern_preview_sem.post();
}
void TilesEditorUtils::set_sources_lists_current(int p_current) {
void LayeredTilesEditorUtils::set_sources_lists_current(int p_current) {
atlas_sources_lists_current = p_current;
}
void TilesEditorUtils::synchronize_sources_list(Object *p_current_list, Object *p_current_sort_button) {
void LayeredTilesEditorUtils::synchronize_sources_list(Object *p_current_list, Object *p_current_sort_button) {
ItemList *item_list = Object::cast_to<ItemList>(p_current_list);
MenuButton *sorting_button = Object::cast_to<MenuButton>(p_current_sort_button);
ERR_FAIL_NULL(item_list);
@ -187,13 +187,13 @@ void TilesEditorUtils::synchronize_sources_list(Object *p_current_list, Object *
}
}
void TilesEditorUtils::set_atlas_view_transform(float p_zoom, Vector2 p_scroll) {
void LayeredTilesEditorUtils::set_atlas_view_transform(float p_zoom, Vector2 p_scroll) {
atlas_view_zoom = p_zoom;
atlas_view_scroll = p_scroll;
}
void TilesEditorUtils::synchronize_atlas_view(Object *p_current) {
TileAtlasView *tile_atlas_view = Object::cast_to<TileAtlasView>(p_current);
void LayeredTilesEditorUtils::synchronize_atlas_view(Object *p_current) {
LayeredTileAtlasView *tile_atlas_view = Object::cast_to<LayeredTileAtlasView>(p_current);
ERR_FAIL_NULL(tile_atlas_view);
if (tile_atlas_view->is_visible_in_tree()) {
@ -201,11 +201,11 @@ void TilesEditorUtils::synchronize_atlas_view(Object *p_current) {
}
}
void TilesEditorUtils::set_sorting_option(int p_option) {
void LayeredTilesEditorUtils::set_sorting_option(int p_option) {
source_sort = p_option;
}
List<int> TilesEditorUtils::get_sorted_sources(const Ref<TileSet> p_tile_set) const {
List<int> LayeredTilesEditorUtils::get_sorted_sources(const Ref<LayeredTileSet> p_tile_set) const {
SourceNameComparator::tile_set = p_tile_set;
List<int> source_ids;
@ -233,20 +233,20 @@ List<int> TilesEditorUtils::get_sorted_sources(const Ref<TileSet> p_tile_set) co
return source_ids;
}
Ref<TileSet> TilesEditorUtils::SourceNameComparator::tile_set;
Ref<LayeredTileSet> LayeredTilesEditorUtils::SourceNameComparator::tile_set;
bool TilesEditorUtils::SourceNameComparator::operator()(const int &p_a, const int &p_b) const {
bool LayeredTilesEditorUtils::SourceNameComparator::operator()(const int &p_a, const int &p_b) const {
String name_a;
String name_b;
{
TileSetSource *source = *tile_set->get_source(p_a);
LayeredTileSetSource *source = *tile_set->get_source(p_a);
if (!source->get_name().is_empty()) {
name_a = source->get_name();
}
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
if (atlas_source) {
Ref<Texture2D> texture = atlas_source->get_texture();
if (name_a.is_empty() && texture.is_valid()) {
@ -260,13 +260,13 @@ bool TilesEditorUtils::SourceNameComparator::operator()(const int &p_a, const in
}
{
TileSetSource *source = *tile_set->get_source(p_b);
LayeredTileSetSource *source = *tile_set->get_source(p_b);
if (!source->get_name().is_empty()) {
name_b = source->get_name();
}
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
if (atlas_source) {
Ref<Texture2D> texture = atlas_source->get_texture();
if (name_b.is_empty() && texture.is_valid()) {
@ -282,12 +282,12 @@ bool TilesEditorUtils::SourceNameComparator::operator()(const int &p_a, const in
return NaturalNoCaseComparator()(name_a, name_b);
}
void TilesEditorUtils::display_tile_set_editor_panel() {
void LayeredTilesEditorUtils::display_tile_set_editor_panel() {
tile_map_plugin_singleton->hide_editor();
tile_set_plugin_singleton->make_visible(true);
}
void TilesEditorUtils::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect, const Color &p_color) {
void LayeredTilesEditorUtils::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect, const Color &p_color) {
Ref<Texture2D> selection_texture = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("TileSelection"), EditorStringName(EditorIcons));
real_t scale = p_ci->get_global_transform().get_scale().x * 0.5;
@ -298,13 +298,13 @@ void TilesEditorUtils::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect
p_ci->draw_set_transform_matrix(Transform2D());
}
TilesEditorUtils::TilesEditorUtils() {
LayeredTilesEditorUtils::LayeredTilesEditorUtils() {
singleton = this;
// Pattern preview generation thread.
pattern_preview_thread.start(_thread_func, this);
}
TilesEditorUtils::~TilesEditorUtils() {
LayeredTilesEditorUtils::~LayeredTilesEditorUtils() {
if (pattern_preview_thread.is_started()) {
pattern_thread_exit.set();
pattern_preview_sem.post();
@ -317,26 +317,26 @@ TilesEditorUtils::~TilesEditorUtils() {
singleton = nullptr;
}
void TileMapEditorPlugin::_tile_map_layer_changed() {
void LayeredTileMapEditorPlugin::_tile_map_layer_changed() {
if (tile_map_changed_needs_update) {
return;
}
tile_map_changed_needs_update = true;
callable_mp(this, &TileMapEditorPlugin::_update_tile_map).call_deferred();
callable_mp(this, &LayeredTileMapEditorPlugin::_update_tile_map).call_deferred();
}
void TileMapEditorPlugin::_tile_map_layer_removed() {
// Workaround for TileMap, making sure the editor stays open when you delete the currently edited layer.
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_group_id));
void LayeredTileMapEditorPlugin::_tile_map_layer_removed() {
// Workaround for LayeredTileMap, making sure the editor stays open when you delete the currently edited layer.
LayeredTileMap *tile_map = Object::cast_to<LayeredTileMap>(ObjectDB::get_instance(tile_map_group_id));
if (tile_map) {
edit(tile_map);
}
}
void TileMapEditorPlugin::_update_tile_map() {
TileMapLayer *edited_layer = Object::cast_to<TileMapLayer>(ObjectDB::get_instance(tile_map_layer_id));
void LayeredTileMapEditorPlugin::_update_tile_map() {
LayeredTileMapLayer *edited_layer = Object::cast_to<LayeredTileMapLayer>(ObjectDB::get_instance(tile_map_layer_id));
if (edited_layer) {
Ref<TileSet> tile_set = edited_layer->get_effective_tile_set();
Ref<LayeredTileSet> tile_set = edited_layer->get_effective_tile_set();
if (tile_set.is_valid() && tile_set_id != tile_set->get_instance_id()) {
tile_set_plugin_singleton->edit(tile_set.ptr());
tile_set_plugin_singleton->make_visible(true);
@ -350,24 +350,24 @@ void TileMapEditorPlugin::_update_tile_map() {
tile_map_changed_needs_update = false;
}
void TileMapEditorPlugin::_select_layer(const StringName &p_name) {
TileMapLayer *edited_layer = Object::cast_to<TileMapLayer>(ObjectDB::get_instance(tile_map_layer_id));
void LayeredTileMapEditorPlugin::_select_layer(const StringName &p_name) {
LayeredTileMapLayer *edited_layer = Object::cast_to<LayeredTileMapLayer>(ObjectDB::get_instance(tile_map_layer_id));
ERR_FAIL_NULL(edited_layer);
Node *parent = edited_layer->get_parent();
ERR_FAIL_NULL(parent);
TileMapLayer *new_layer = Object::cast_to<TileMapLayer>(parent->get_node_or_null(String(p_name)));
LayeredTileMapLayer *new_layer = Object::cast_to<LayeredTileMapLayer>(parent->get_node_or_null(String(p_name)));
edit(new_layer);
}
void TileMapEditorPlugin::_edit_tile_map_layer(TileMapLayer *p_tile_map_layer) {
void LayeredTileMapEditorPlugin::_edit_tile_map_layer(LayeredTileMapLayer *p_tile_map_layer) {
ERR_FAIL_NULL(p_tile_map_layer);
editor->edit(p_tile_map_layer);
// Update the selected layers in the TileMapLayerGroup parent node.
TileMapLayerGroup *tile_map_layer_group = Object::cast_to<TileMapLayerGroup>(p_tile_map_layer->get_parent());
// Update the selected layers in the LayeredTileMapLayerGroup parent node.
LayeredTileMapLayerGroup *tile_map_layer_group = Object::cast_to<LayeredTileMapLayerGroup>(p_tile_map_layer->get_parent());
if (tile_map_layer_group) {
Vector<StringName> selected;
selected.push_back(p_tile_map_layer->get_name());
@ -376,17 +376,17 @@ void TileMapEditorPlugin::_edit_tile_map_layer(TileMapLayer *p_tile_map_layer) {
// Update the object IDs.
tile_map_layer_id = p_tile_map_layer->get_instance_id();
p_tile_map_layer->connect("changed", callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_changed));
p_tile_map_layer->connect("tree_exited", callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_removed));
p_tile_map_layer->connect("changed", callable_mp(this, &LayeredTileMapEditorPlugin::_tile_map_layer_changed));
p_tile_map_layer->connect("tree_exited", callable_mp(this, &LayeredTileMapEditorPlugin::_tile_map_layer_removed));
if (tile_map_layer_group) {
tile_map_group_id = tile_map_layer_group->get_instance_id();
tile_map_layer_group->connect("child_entered_tree", callable_mp(editor, &TileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_layer_group->connect("child_exiting_tree", callable_mp(editor, &TileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_layer_group->connect("child_order_changed", callable_mp(editor, &TileMapLayerEditor::update_layers_selector));
tile_map_layer_group->connect("child_entered_tree", callable_mp(editor, &LayeredTileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_layer_group->connect("child_exiting_tree", callable_mp(editor, &LayeredTileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_layer_group->connect("child_order_changed", callable_mp(editor, &LayeredTileMapLayerEditor::update_layers_selector));
}
// Update the edited tileset.
Ref<TileSet> tile_set = p_tile_map_layer->get_effective_tile_set();
Ref<LayeredTileSet> tile_set = p_tile_map_layer->get_effective_tile_set();
if (tile_set.is_valid()) {
tile_set_plugin_singleton->edit(tile_set.ptr());
tile_set_plugin_singleton->make_visible(true);
@ -397,20 +397,20 @@ void TileMapEditorPlugin::_edit_tile_map_layer(TileMapLayer *p_tile_map_layer) {
}
}
void TileMapEditorPlugin::_edit_tile_map_layer_group(TileMapLayerGroup *p_tile_map_layer_group) {
void LayeredTileMapEditorPlugin::_edit_tile_map_layer_group(LayeredTileMapLayerGroup *p_tile_map_layer_group) {
ERR_FAIL_NULL(p_tile_map_layer_group);
Vector<StringName> selected_layers = p_tile_map_layer_group->get_selected_layers();
TileMapLayer *selected_layer = nullptr;
LayeredTileMapLayer *selected_layer = nullptr;
if (selected_layers.size() > 0) {
// Edit the selected layer.
selected_layer = Object::cast_to<TileMapLayer>(p_tile_map_layer_group->get_node_or_null(String(selected_layers[0])));
selected_layer = Object::cast_to<LayeredTileMapLayer>(p_tile_map_layer_group->get_node_or_null(String(selected_layers[0])));
}
if (!selected_layer) {
// Edit the first layer found.
for (int i = 0; i < p_tile_map_layer_group->get_child_count(); i++) {
selected_layer = Object::cast_to<TileMapLayer>(p_tile_map_layer_group->get_child(i));
selected_layer = Object::cast_to<LayeredTileMapLayer>(p_tile_map_layer_group->get_child(i));
if (selected_layer) {
break;
}
@ -424,32 +424,32 @@ void TileMapEditorPlugin::_edit_tile_map_layer_group(TileMapLayerGroup *p_tile_m
}
}
void TileMapEditorPlugin::_notification(int p_notification) {
void LayeredTileMapEditorPlugin::_notification(int p_notification) {
if (p_notification == NOTIFICATION_EXIT_TREE) {
get_tree()->queue_delete(TilesEditorUtils::get_singleton());
get_tree()->queue_delete(LayeredTilesEditorUtils::get_singleton());
}
}
void TileMapEditorPlugin::edit(Object *p_object) {
TileMapLayer *edited_layer = Object::cast_to<TileMapLayer>(ObjectDB::get_instance(tile_map_layer_id));
void LayeredTileMapEditorPlugin::edit(Object *p_object) {
LayeredTileMapLayer *edited_layer = Object::cast_to<LayeredTileMapLayer>(ObjectDB::get_instance(tile_map_layer_id));
if (edited_layer) {
edited_layer->disconnect("changed", callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_changed));
edited_layer->disconnect("tree_exited", callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_removed));
edited_layer->disconnect("changed", callable_mp(this, &LayeredTileMapEditorPlugin::_tile_map_layer_changed));
edited_layer->disconnect("tree_exited", callable_mp(this, &LayeredTileMapEditorPlugin::_tile_map_layer_removed));
}
TileMapLayerGroup *tile_map_group = Object::cast_to<TileMapLayerGroup>(ObjectDB::get_instance(tile_map_group_id));
LayeredTileMapLayerGroup *tile_map_group = Object::cast_to<LayeredTileMapLayerGroup>(ObjectDB::get_instance(tile_map_group_id));
if (tile_map_group) {
tile_map_group->disconnect("child_entered_tree", callable_mp(editor, &TileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_group->disconnect("child_exiting_tree", callable_mp(editor, &TileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_group->disconnect("child_order_changed", callable_mp(editor, &TileMapLayerEditor::update_layers_selector));
tile_map_group->disconnect("child_entered_tree", callable_mp(editor, &LayeredTileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_group->disconnect("child_exiting_tree", callable_mp(editor, &LayeredTileMapLayerEditor::update_layers_selector).unbind(1));
tile_map_group->disconnect("child_order_changed", callable_mp(editor, &LayeredTileMapLayerEditor::update_layers_selector));
}
tile_map_group_id = ObjectID();
tile_map_layer_id = ObjectID();
tile_set_id = ObjectID();
TileMapLayerGroup *tile_map_layer_group = Object::cast_to<TileMap>(p_object);
TileMapLayer *tile_map_layer = Object::cast_to<TileMapLayer>(p_object);
LayeredTileMapLayerGroup *tile_map_layer_group = Object::cast_to<LayeredTileMap>(p_object);
LayeredTileMapLayer *tile_map_layer = Object::cast_to<LayeredTileMapLayer>(p_object);
if (tile_map_layer_group) {
_edit_tile_map_layer_group(tile_map_layer_group);
} else if (tile_map_layer) {
@ -457,7 +457,7 @@ void TileMapEditorPlugin::edit(Object *p_object) {
} else {
// Deselect the layer in the group.
if (edited_layer) {
tile_map_layer_group = Object::cast_to<TileMapLayerGroup>(edited_layer->get_parent());
tile_map_layer_group = Object::cast_to<LayeredTileMapLayerGroup>(edited_layer->get_parent());
if (tile_map_layer_group) {
tile_map_layer_group->set_selected_layers(Vector<StringName>());
}
@ -465,11 +465,11 @@ void TileMapEditorPlugin::edit(Object *p_object) {
}
}
bool TileMapEditorPlugin::handles(Object *p_object) const {
return Object::cast_to<TileMapLayer>(p_object) != nullptr || Object::cast_to<TileMapLayerGroup>(p_object) != nullptr;
bool LayeredTileMapEditorPlugin::handles(Object *p_object) const {
return Object::cast_to<LayeredTileMapLayer>(p_object) != nullptr || Object::cast_to<LayeredTileMapLayerGroup>(p_object) != nullptr;
}
void TileMapEditorPlugin::make_visible(bool p_visible) {
void LayeredTileMapEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
button->show();
EditorNode::get_bottom_panel()->make_item_visible(editor);
@ -481,47 +481,47 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
}
}
bool TileMapEditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
bool LayeredTileMapEditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
return editor->forward_canvas_gui_input(p_event);
}
void TileMapEditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
void LayeredTileMapEditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
editor->forward_canvas_draw_over_viewport(p_overlay);
}
void TileMapEditorPlugin::hide_editor() {
void LayeredTileMapEditorPlugin::hide_editor() {
if (editor->is_visible_in_tree()) {
EditorNode::get_bottom_panel()->hide_bottom_panel();
}
}
bool TileMapEditorPlugin::is_editor_visible() const {
bool LayeredTileMapEditorPlugin::is_editor_visible() const {
return editor->is_visible_in_tree();
}
TileMapEditorPlugin::TileMapEditorPlugin() {
if (!TilesEditorUtils::get_singleton()) {
memnew(TilesEditorUtils);
LayeredTileMapEditorPlugin::LayeredTileMapEditorPlugin() {
if (!LayeredTilesEditorUtils::get_singleton()) {
memnew(LayeredTilesEditorUtils);
}
tile_map_plugin_singleton = this;
editor = memnew(TileMapLayerEditor);
editor = memnew(LayeredTileMapLayerEditor);
editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
editor->connect("change_selected_layer_request", callable_mp(this, &TileMapEditorPlugin::_select_layer));
editor->connect("change_selected_layer_request", callable_mp(this, &LayeredTileMapEditorPlugin::_select_layer));
editor->hide();
button = EditorNode::get_bottom_panel()->add_item(TTR("TileMap"), editor);
button = EditorNode::get_bottom_panel()->add_item(TTR("LayeredTileMap"), editor);
button->hide();
}
TileMapEditorPlugin::~TileMapEditorPlugin() {
LayeredTileMapEditorPlugin::~LayeredTileMapEditorPlugin() {
tile_map_plugin_singleton = nullptr;
}
void TileSetEditorPlugin::edit(Object *p_object) {
editor->edit(Ref<TileSet>(p_object));
void LayeredTileSetEditorPlugin::edit(Object *p_object) {
editor->edit(Ref<LayeredTileSet>(p_object));
if (p_object) {
edited_tileset = p_object->get_instance_id();
} else {
@ -529,11 +529,11 @@ void TileSetEditorPlugin::edit(Object *p_object) {
}
}
bool TileSetEditorPlugin::handles(Object *p_object) const {
return Object::cast_to<TileSet>(p_object) != nullptr;
bool LayeredTileSetEditorPlugin::handles(Object *p_object) const {
return Object::cast_to<LayeredTileSet>(p_object) != nullptr;
}
void TileSetEditorPlugin::make_visible(bool p_visible) {
void LayeredTileSetEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
button->show();
if (!tile_map_plugin_singleton->is_editor_visible()) {
@ -547,26 +547,26 @@ void TileSetEditorPlugin::make_visible(bool p_visible) {
}
}
ObjectID TileSetEditorPlugin::get_edited_tileset() const {
ObjectID LayeredTileSetEditorPlugin::get_edited_tileset() const {
return edited_tileset;
}
TileSetEditorPlugin::TileSetEditorPlugin() {
if (!TilesEditorUtils::get_singleton()) {
memnew(TilesEditorUtils);
LayeredTileSetEditorPlugin::LayeredTileSetEditorPlugin() {
if (!LayeredTilesEditorUtils::get_singleton()) {
memnew(LayeredTilesEditorUtils);
}
tile_set_plugin_singleton = this;
editor = memnew(TileSetEditor);
editor = memnew(LayeredTileSetEditor);
editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
editor->hide();
button = EditorNode::get_bottom_panel()->add_item(TTR("TileSet"), editor);
button = EditorNode::get_bottom_panel()->add_item(TTR("LayeredTileSet"), editor);
button->hide();
}
TileSetEditorPlugin::~TileSetEditorPlugin() {
LayeredTileSetEditorPlugin::~LayeredTileSetEditorPlugin() {
tile_set_plugin_singleton = nullptr;
}

View File

@ -39,10 +39,10 @@
#include "tile_map_layer_editor.h"
#include "tile_set_editor.h"
class TilesEditorUtils : public Object {
GDCLASS(TilesEditorUtils, Object);
class LayeredTilesEditorUtils : public Object {
GDCLASS(LayeredTilesEditorUtils, Object);
static TilesEditorUtils *singleton;
static LayeredTilesEditorUtils *singleton;
public:
enum SourceSortOption {
@ -63,14 +63,14 @@ private:
int source_sort = SOURCE_SORT_ID;
struct SourceNameComparator {
static Ref<TileSet> tile_set;
static Ref<LayeredTileSet> tile_set;
bool operator()(const int &p_a, const int &p_b) const;
};
// Patterns preview generation.
struct QueueItem {
Ref<TileSet> tile_set;
Ref<TileMapPattern> pattern;
Ref<LayeredTileSet> tile_set;
Ref<LayeredTileMapPattern> pattern;
Callable callback;
};
List<QueueItem> pattern_preview_queue;
@ -86,10 +86,10 @@ private:
void _thread();
public:
_FORCE_INLINE_ static TilesEditorUtils *get_singleton() { return singleton; }
_FORCE_INLINE_ static LayeredTilesEditorUtils *get_singleton() { return singleton; }
// Pattern preview API.
void queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback);
void queue_pattern_preview(Ref<LayeredTileSet> p_tile_set, Ref<LayeredTileMapPattern> p_pattern, Callable p_callback);
// To synchronize the atlas sources lists.
void set_sources_lists_current(int p_current);
@ -100,35 +100,35 @@ public:
// Sorting.
void set_sorting_option(int p_option);
List<int> get_sorted_sources(const Ref<TileSet> p_tile_set) const;
List<int> get_sorted_sources(const Ref<LayeredTileSet> p_tile_set) const;
// Misc.
void display_tile_set_editor_panel();
static void draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect, const Color &p_color = Color(1.0, 1.0, 1.0));
TilesEditorUtils();
~TilesEditorUtils();
LayeredTilesEditorUtils();
~LayeredTilesEditorUtils();
};
class TileMapEditorPlugin : public EditorPlugin {
GDCLASS(TileMapEditorPlugin, EditorPlugin);
class LayeredTileMapEditorPlugin : public EditorPlugin {
GDCLASS(LayeredTileMapEditorPlugin, EditorPlugin);
TileMapLayerEditor *editor = nullptr;
LayeredTileMapLayerEditor *editor = nullptr;
Button *button = nullptr;
ObjectID tile_map_layer_id;
ObjectID tile_map_group_id; // Allow keeping the layer selector up to date.
bool tile_map_changed_needs_update = false;
ObjectID tile_set_id; // The TileSet associated with the TileMap.
ObjectID tile_set_id; // The LayeredTileSet associated with the LayeredTileMap.
void _tile_map_layer_changed();
void _tile_map_layer_removed();
void _update_tile_map();
void _select_layer(const StringName &p_name);
void _edit_tile_map_layer(TileMapLayer *p_tile_map_layer);
void _edit_tile_map_layer_group(TileMapLayerGroup *p_tile_map_layer_group);
void _edit_tile_map_layer(LayeredTileMapLayer *p_tile_map_layer);
void _edit_tile_map_layer_group(LayeredTileMapLayerGroup *p_tile_map_layer_group);
protected:
void _notification(int p_notification);
@ -144,14 +144,14 @@ public:
void hide_editor();
bool is_editor_visible() const;
TileMapEditorPlugin();
~TileMapEditorPlugin();
LayeredTileMapEditorPlugin();
~LayeredTileMapEditorPlugin();
};
class TileSetEditorPlugin : public EditorPlugin {
GDCLASS(TileSetEditorPlugin, EditorPlugin);
class LayeredTileSetEditorPlugin : public EditorPlugin {
GDCLASS(LayeredTileSetEditorPlugin, EditorPlugin);
TileSetEditor *editor = nullptr;
LayeredTileSetEditor *editor = nullptr;
Button *button = nullptr;
ObjectID edited_tileset;
@ -163,8 +163,8 @@ public:
ObjectID get_edited_tileset() const;
TileSetEditorPlugin();
~TileSetEditorPlugin();
LayeredTileSetEditorPlugin();
~LayeredTileSetEditorPlugin();
};
#endif // TILES_EDITOR_PLUGIN_H

View File

@ -40,17 +40,17 @@
#include "modules/modules_enabled.gen.h"
bool TileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) {
return (Object::cast_to<TileMap>(p_node) != nullptr);
bool LayeredTileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) {
return (Object::cast_to<LayeredTileMap>(p_node) != nullptr);
}
void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
TileMap *tilemap = Object::cast_to<TileMap>(p_node);
void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
LayeredTileMap *tilemap = Object::cast_to<LayeredTileMap>(p_node);
//NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type();
//uint32_t navigation_polygon_collision_mask = p_navigation_polygon->get_collision_mask();
if (tilemap) {
Ref<TileSet> tile_set = tilemap->get_tileset();
Ref<LayeredTileSet> tile_set = tilemap->get_tileset();
if (!tile_set.is_valid()) {
return;
}
@ -102,13 +102,13 @@ void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<Navig
}
}
bool TileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) {
return (Object::cast_to<TileMap>(p_node) != nullptr);
bool LayeredTileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) {
return (Object::cast_to<LayeredTileMap>(p_node) != nullptr);
}
void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
#ifdef CLIPPER_ENABLED
TileMap *tilemap = Object::cast_to<TileMap>(p_node);
LayeredTileMap *tilemap = Object::cast_to<LayeredTileMap>(p_node);
NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type();
uint32_t navigation_polygon_collision_mask = p_navigation_polygon->get_collision_mask();
@ -119,7 +119,7 @@ void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<Navig
int tilemap_layer = 0; // only main tile map layer is supported
Ref<TileSet> tile_set = tilemap->get_tileset();
Ref<LayeredTileSet> tile_set = tilemap->get_tileset();
if (!tile_set.is_valid()) {
return;
}

View File

@ -34,7 +34,7 @@
#include "scene/2d/navigation_geometry_parser_2d.h"
class TileMap2DNavigationGeometryParser2D : public NavigationGeometryParser2D {
class LayeredTileMap2DNavigationGeometryParser2D : public NavigationGeometryParser2D {
public:
virtual bool parses_node(Node *p_node);

View File

@ -50,13 +50,13 @@
ERR_FAIL_INDEX_V(layer, (int)layers.size(), err_value); \
return layers[layer]->function(__VA_ARGS__);
void TileMap::_emit_changed() {
void LayeredTileMap::_emit_changed() {
emit_signal(CoreStringNames::get_singleton()->changed);
}
void TileMap::_notification(int p_what) {
void LayeredTileMap::_notification(int p_what) {
switch (p_what) {
case TileMap::NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
case LayeredTileMap::NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
// This is only executed when collision_animatable is enabled.
bool in_editor = false;
@ -72,7 +72,7 @@ void TileMap::_notification(int p_what) {
}
} break;
case TileMap::NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
case LayeredTileMap::NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
// This is only executed when collision_animatable is enabled.
bool in_editor = false;
@ -95,33 +95,33 @@ void TileMap::_notification(int p_what) {
#ifndef DISABLE_DEPRECATED
// Deprecated methods.
void TileMap::force_update(int p_layer) {
void LayeredTileMap::force_update(int p_layer) {
notify_runtime_tile_data_update(p_layer);
update_internals();
}
#endif
void TileMap::set_rendering_quadrant_size(int p_size) {
ERR_FAIL_COND_MSG(p_size < 1, "TileMapQuadrant size cannot be smaller than 1.");
void LayeredTileMap::set_rendering_quadrant_size(int p_size) {
ERR_FAIL_COND_MSG(p_size < 1, "LayeredTileMapQuadrant size cannot be smaller than 1.");
rendering_quadrant_size = p_size;
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_rendering_quadrant_size(p_size);
}
_emit_changed();
}
int TileMap::get_rendering_quadrant_size() const {
int LayeredTileMap::get_rendering_quadrant_size() const {
return rendering_quadrant_size;
}
void TileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<TileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const TileData *p_tile_data_override, real_t p_normalized_animation_offset) {
void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<LayeredTileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const TileData *p_tile_data_override, real_t p_normalized_animation_offset) {
ERR_FAIL_COND(!p_tile_set.is_valid());
ERR_FAIL_COND(!p_tile_set->has_source(p_atlas_source_id));
ERR_FAIL_COND(!p_tile_set->get_source(p_atlas_source_id)->has_tile(p_atlas_coords));
ERR_FAIL_COND(!p_tile_set->get_source(p_atlas_source_id)->has_alternative_tile(p_atlas_coords, p_alternative_tile));
TileSetSource *source = *p_tile_set->get_source(p_atlas_source_id);
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
LayeredTileSetSource *source = *p_tile_set->get_source(p_atlas_source_id);
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
if (atlas_source) {
// Check for the frame.
if (p_frame >= 0) {
@ -155,18 +155,18 @@ void TileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<
dest_rect.size.x += FP_ADJUST;
dest_rect.size.y += FP_ADJUST;
bool transpose = tile_data->get_transpose() ^ bool(p_alternative_tile & TileSetAtlasSource::TRANSFORM_TRANSPOSE);
bool transpose = tile_data->get_transpose() ^ bool(p_alternative_tile & LayeredTileSetAtlasSource::TRANSFORM_TRANSPOSE);
if (transpose) {
dest_rect.position = (p_position - Vector2(dest_rect.size.y, dest_rect.size.x) / 2 - tile_offset);
} else {
dest_rect.position = (p_position - dest_rect.size / 2 - tile_offset);
}
if (tile_data->get_flip_h() ^ bool(p_alternative_tile & TileSetAtlasSource::TRANSFORM_FLIP_H)) {
if (tile_data->get_flip_h() ^ bool(p_alternative_tile & LayeredTileSetAtlasSource::TRANSFORM_FLIP_H)) {
dest_rect.size.x = -dest_rect.size.x;
}
if (tile_data->get_flip_v() ^ bool(p_alternative_tile & TileSetAtlasSource::TRANSFORM_FLIP_V)) {
if (tile_data->get_flip_v() ^ bool(p_alternative_tile & LayeredTileSetAtlasSource::TRANSFORM_FLIP_V)) {
dest_rect.size.y = -dest_rect.size.y;
}
@ -200,11 +200,11 @@ void TileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<
}
}
int TileMap::get_layers_count() const {
int LayeredTileMap::get_layers_count() const {
return layers.size();
}
void TileMap::add_layer(int p_to_pos) {
void LayeredTileMap::add_layer(int p_to_pos) {
if (p_to_pos < 0) {
p_to_pos = layers.size() + p_to_pos + 1;
}
@ -212,7 +212,7 @@ void TileMap::add_layer(int p_to_pos) {
ERR_FAIL_INDEX(p_to_pos, (int)layers.size() + 1);
// Must clear before adding the layer.
TileMapLayer *new_layer = memnew(TileMapLayer);
LayeredTileMapLayer *new_layer = memnew(LayeredTileMapLayer);
layers.insert(p_to_pos, new_layer);
add_child(new_layer, false, INTERNAL_MODE_FRONT);
new_layer->set_name(vformat("Layer%d", p_to_pos));
@ -220,7 +220,7 @@ void TileMap::add_layer(int p_to_pos) {
for (uint32_t i = 0; i < layers.size(); i++) {
layers[i]->set_as_tile_map_internal_node(i);
}
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TileMap::_emit_changed));
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMap::_emit_changed));
notify_property_list_changed();
@ -229,12 +229,12 @@ void TileMap::add_layer(int p_to_pos) {
update_configuration_warnings();
}
void TileMap::move_layer(int p_layer, int p_to_pos) {
void LayeredTileMap::move_layer(int p_layer, int p_to_pos) {
ERR_FAIL_INDEX(p_layer, (int)layers.size());
ERR_FAIL_INDEX(p_to_pos, (int)layers.size() + 1);
// Clear before shuffling layers.
TileMapLayer *layer = layers[p_layer];
LayeredTileMapLayer *layer = layers[p_layer];
layers.insert(p_to_pos, layer);
layers.remove_at(p_to_pos < p_layer ? p_layer + 1 : p_layer);
for (uint32_t i = 0; i < layers.size(); i++) {
@ -248,7 +248,7 @@ void TileMap::move_layer(int p_layer, int p_to_pos) {
update_configuration_warnings();
}
void TileMap::remove_layer(int p_layer) {
void LayeredTileMap::remove_layer(int p_layer) {
ERR_FAIL_INDEX(p_layer, (int)layers.size());
// Clear before removing the layer.
@ -264,199 +264,199 @@ void TileMap::remove_layer(int p_layer) {
update_configuration_warnings();
}
void TileMap::set_layer_name(int p_layer, String p_name) {
void LayeredTileMap::set_layer_name(int p_layer, String p_name) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_name, p_name);
}
String TileMap::get_layer_name(int p_layer) const {
String LayeredTileMap::get_layer_name(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, "", get_name);
}
void TileMap::set_layer_enabled(int p_layer, bool p_enabled) {
void LayeredTileMap::set_layer_enabled(int p_layer, bool p_enabled) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_enabled, p_enabled);
}
bool TileMap::is_layer_enabled(int p_layer) const {
bool LayeredTileMap::is_layer_enabled(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, false, is_enabled);
}
void TileMap::set_layer_modulate(int p_layer, Color p_modulate) {
void LayeredTileMap::set_layer_modulate(int p_layer, Color p_modulate) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_modulate, p_modulate);
}
Color TileMap::get_layer_modulate(int p_layer) const {
Color LayeredTileMap::get_layer_modulate(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, Color(), get_modulate);
}
void TileMap::set_layer_y_sort_enabled(int p_layer, bool p_y_sort_enabled) {
void LayeredTileMap::set_layer_y_sort_enabled(int p_layer, bool p_y_sort_enabled) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_y_sort_enabled, p_y_sort_enabled);
}
bool TileMap::is_layer_y_sort_enabled(int p_layer) const {
bool LayeredTileMap::is_layer_y_sort_enabled(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, false, is_y_sort_enabled);
}
void TileMap::set_layer_y_sort_origin(int p_layer, int p_y_sort_origin) {
void LayeredTileMap::set_layer_y_sort_origin(int p_layer, int p_y_sort_origin) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_y_sort_origin, p_y_sort_origin);
}
int TileMap::get_layer_y_sort_origin(int p_layer) const {
int LayeredTileMap::get_layer_y_sort_origin(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, 0, get_y_sort_origin);
}
void TileMap::set_layer_z_index(int p_layer, int p_z_index) {
void LayeredTileMap::set_layer_z_index(int p_layer, int p_z_index) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_z_index, p_z_index);
}
int TileMap::get_layer_z_index(int p_layer) const {
int LayeredTileMap::get_layer_z_index(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, 0, get_z_index);
}
void TileMap::set_layer_navigation_enabled(int p_layer, bool p_enabled) {
void LayeredTileMap::set_layer_navigation_enabled(int p_layer, bool p_enabled) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_navigation_enabled, p_enabled);
}
bool TileMap::is_layer_navigation_enabled(int p_layer) const {
bool LayeredTileMap::is_layer_navigation_enabled(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, false, is_navigation_enabled);
}
void TileMap::set_layer_navigation_map(int p_layer, RID p_map) {
void LayeredTileMap::set_layer_navigation_map(int p_layer, RID p_map) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_navigation_map, p_map);
}
RID TileMap::get_layer_navigation_map(int p_layer) const {
RID LayeredTileMap::get_layer_navigation_map(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, RID(), get_navigation_map);
}
void TileMap::set_collision_animatable(bool p_collision_animatable) {
void LayeredTileMap::set_collision_animatable(bool p_collision_animatable) {
if (collision_animatable == p_collision_animatable) {
return;
}
collision_animatable = p_collision_animatable;
set_notify_local_transform(p_collision_animatable);
set_physics_process_internal(p_collision_animatable);
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_use_kinematic_bodies(layer);
}
}
bool TileMap::is_collision_animatable() const {
bool LayeredTileMap::is_collision_animatable() const {
return collision_animatable;
}
void TileMap::set_collision_visibility_mode(TileMap::VisibilityMode p_show_collision) {
void LayeredTileMap::set_collision_visibility_mode(LayeredTileMap::VisibilityMode p_show_collision) {
if (collision_visibility_mode == p_show_collision) {
return;
}
collision_visibility_mode = p_show_collision;
for (TileMapLayer *layer : layers) {
layer->set_collision_visibility_mode(TileMapLayer::VisibilityMode(p_show_collision));
for (LayeredTileMapLayer *layer : layers) {
layer->set_collision_visibility_mode(LayeredTileMapLayer::VisibilityMode(p_show_collision));
}
_emit_changed();
}
TileMap::VisibilityMode TileMap::get_collision_visibility_mode() const {
LayeredTileMap::VisibilityMode LayeredTileMap::get_collision_visibility_mode() const {
return collision_visibility_mode;
}
void TileMap::set_navigation_visibility_mode(TileMap::VisibilityMode p_show_navigation) {
void LayeredTileMap::set_navigation_visibility_mode(LayeredTileMap::VisibilityMode p_show_navigation) {
if (navigation_visibility_mode == p_show_navigation) {
return;
}
navigation_visibility_mode = p_show_navigation;
for (TileMapLayer *layer : layers) {
layer->set_navigation_visibility_mode(TileMapLayer::VisibilityMode(p_show_navigation));
for (LayeredTileMapLayer *layer : layers) {
layer->set_navigation_visibility_mode(LayeredTileMapLayer::VisibilityMode(p_show_navigation));
}
_emit_changed();
}
TileMap::VisibilityMode TileMap::get_navigation_visibility_mode() const {
LayeredTileMap::VisibilityMode LayeredTileMap::get_navigation_visibility_mode() const {
return navigation_visibility_mode;
}
void TileMap::set_y_sort_enabled(bool p_enable) {
void LayeredTileMap::set_y_sort_enabled(bool p_enable) {
if (is_y_sort_enabled() == p_enable) {
return;
}
Node2D::set_y_sort_enabled(p_enable);
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_y_sort_enabled(p_enable);
}
_emit_changed();
update_configuration_warnings();
}
void TileMap::set_cell(int p_layer, const Vector2i &p_coords, int p_source_id, const Vector2i p_atlas_coords, int p_alternative_tile) {
void LayeredTileMap::set_cell(int p_layer, const Vector2i &p_coords, int p_source_id, const Vector2i p_atlas_coords, int p_alternative_tile) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_cell, p_coords, p_source_id, p_atlas_coords, p_alternative_tile);
}
void TileMap::erase_cell(int p_layer, const Vector2i &p_coords) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_cell, p_coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE);
void LayeredTileMap::erase_cell(int p_layer, const Vector2i &p_coords) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_cell, p_coords, LayeredTileSet::INVALID_SOURCE, LayeredTileSetSource::INVALID_ATLAS_COORDS, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
}
int TileMap::get_cell_source_id(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, TileSet::INVALID_SOURCE, get_cell_source_id, p_coords, p_use_proxies);
int LayeredTileMap::get_cell_source_id(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileSet::INVALID_SOURCE, get_cell_source_id, p_coords, p_use_proxies);
}
Vector2i TileMap::get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, TileSetSource::INVALID_ATLAS_COORDS, get_cell_atlas_coords, p_coords, p_use_proxies);
Vector2i LayeredTileMap::get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileSetSource::INVALID_ATLAS_COORDS, get_cell_atlas_coords, p_coords, p_use_proxies);
}
int TileMap::get_cell_alternative_tile(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, TileSetSource::INVALID_TILE_ALTERNATIVE, get_cell_alternative_tile, p_coords, p_use_proxies);
int LayeredTileMap::get_cell_alternative_tile(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE, get_cell_alternative_tile, p_coords, p_use_proxies);
}
TileData *TileMap::get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TileData *LayeredTileMap::get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, nullptr, get_cell_tile_data, p_coords, p_use_proxies);
}
Ref<TileMapPattern> TileMap::get_pattern(int p_layer, TypedArray<Vector2i> p_coords_array) {
TILEMAP_CALL_FOR_LAYER_V(p_layer, Ref<TileMapPattern>(), get_pattern, p_coords_array);
Ref<LayeredTileMapPattern> LayeredTileMap::get_pattern(int p_layer, TypedArray<Vector2i> p_coords_array) {
TILEMAP_CALL_FOR_LAYER_V(p_layer, Ref<LayeredTileMapPattern>(), get_pattern, p_coords_array);
}
Vector2i TileMap::map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref<TileMapPattern> p_pattern) {
Vector2i LayeredTileMap::map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref<LayeredTileMapPattern> p_pattern) {
ERR_FAIL_COND_V(!tile_set.is_valid(), Vector2i());
return tile_set->map_pattern(p_position_in_tilemap, p_coords_in_pattern, p_pattern);
}
void TileMap::set_pattern(int p_layer, const Vector2i &p_position, const Ref<TileMapPattern> p_pattern) {
void LayeredTileMap::set_pattern(int p_layer, const Vector2i &p_position, const Ref<LayeredTileMapPattern> p_pattern) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_pattern, p_position, p_pattern);
}
HashMap<Vector2i, TileSet::TerrainsPattern> TileMap::terrain_fill_constraints(int p_layer, const Vector<Vector2i> &p_to_replace, int p_terrain_set, const RBSet<TerrainConstraint> &p_constraints) {
HashMap<Vector2i, TileSet::TerrainsPattern> err_value;
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> LayeredTileMap::terrain_fill_constraints(int p_layer, const Vector<Vector2i> &p_to_replace, int p_terrain_set, const RBSet<TerrainConstraint> &p_constraints) {
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> err_value;
TILEMAP_CALL_FOR_LAYER_V(p_layer, err_value, terrain_fill_constraints, p_to_replace, p_terrain_set, p_constraints);
}
HashMap<Vector2i, TileSet::TerrainsPattern> TileMap::terrain_fill_connect(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
HashMap<Vector2i, TileSet::TerrainsPattern> err_value;
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> LayeredTileMap::terrain_fill_connect(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> err_value;
TILEMAP_CALL_FOR_LAYER_V(p_layer, err_value, terrain_fill_connect, p_coords_array, p_terrain_set, p_terrain, p_ignore_empty_terrains);
}
HashMap<Vector2i, TileSet::TerrainsPattern> TileMap::terrain_fill_path(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
HashMap<Vector2i, TileSet::TerrainsPattern> err_value;
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> LayeredTileMap::terrain_fill_path(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> err_value;
TILEMAP_CALL_FOR_LAYER_V(p_layer, err_value, terrain_fill_path, p_coords_array, p_terrain_set, p_terrain, p_ignore_empty_terrains);
}
HashMap<Vector2i, TileSet::TerrainsPattern> TileMap::terrain_fill_pattern(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains) {
HashMap<Vector2i, TileSet::TerrainsPattern> err_value;
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> LayeredTileMap::terrain_fill_pattern(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, LayeredTileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains) {
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> err_value;
TILEMAP_CALL_FOR_LAYER_V(p_layer, err_value, terrain_fill_pattern, p_coords_array, p_terrain_set, p_terrains_pattern, p_ignore_empty_terrains);
}
void TileMap::set_cells_terrain_connect(int p_layer, TypedArray<Vector2i> p_cells, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
void LayeredTileMap::set_cells_terrain_connect(int p_layer, TypedArray<Vector2i> p_cells, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_cells_terrain_connect, p_cells, p_terrain_set, p_terrain, p_ignore_empty_terrains);
}
void TileMap::set_cells_terrain_path(int p_layer, TypedArray<Vector2i> p_path, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
void LayeredTileMap::set_cells_terrain_path(int p_layer, TypedArray<Vector2i> p_path, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_cells_terrain_path, p_path, p_terrain_set, p_terrain, p_ignore_empty_terrains);
}
TileMapCell TileMap::get_cell(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, TileMapCell(), get_cell, p_coords, p_use_proxies);
LayeredTileMapCell LayeredTileMap::get_cell(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileMapCell(), get_cell, p_coords, p_use_proxies);
}
Vector2i TileMap::get_coords_for_body_rid(RID p_physics_body) {
for (const TileMapLayer *layer : layers) {
Vector2i LayeredTileMap::get_coords_for_body_rid(RID p_physics_body) {
for (const LayeredTileMapLayer *layer : layers) {
if (layer->has_body_rid(p_physics_body)) {
return layer->get_coords_for_body_rid(p_physics_body);
}
@ -464,7 +464,7 @@ Vector2i TileMap::get_coords_for_body_rid(RID p_physics_body) {
ERR_FAIL_V_MSG(Vector2i(), vformat("No tiles for the given body RID %d.", p_physics_body.get_id()));
}
int TileMap::get_layer_for_body_rid(RID p_physics_body) {
int LayeredTileMap::get_layer_for_body_rid(RID p_physics_body) {
for (uint32_t i = 0; i < layers.size(); i++) {
if (layers[i]->has_body_rid(p_physics_body)) {
return i;
@ -473,40 +473,40 @@ int TileMap::get_layer_for_body_rid(RID p_physics_body) {
ERR_FAIL_V_MSG(-1, vformat("No tiles for the given body RID %d.", p_physics_body.get_id()));
}
void TileMap::fix_invalid_tiles() {
for (TileMapLayer *layer : layers) {
void LayeredTileMap::fix_invalid_tiles() {
for (LayeredTileMapLayer *layer : layers) {
layer->fix_invalid_tiles();
}
}
void TileMap::clear_layer(int p_layer) {
void LayeredTileMap::clear_layer(int p_layer) {
TILEMAP_CALL_FOR_LAYER(p_layer, clear)
}
void TileMap::clear() {
for (TileMapLayer *layer : layers) {
void LayeredTileMap::clear() {
for (LayeredTileMapLayer *layer : layers) {
layer->clear();
}
}
void TileMap::update_internals() {
for (TileMapLayer *layer : layers) {
void LayeredTileMap::update_internals() {
for (LayeredTileMapLayer *layer : layers) {
layer->update_internals();
}
}
void TileMap::notify_runtime_tile_data_update(int p_layer) {
void LayeredTileMap::notify_runtime_tile_data_update(int p_layer) {
if (p_layer >= 0) {
TILEMAP_CALL_FOR_LAYER(p_layer, notify_runtime_tile_data_update);
} else {
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->notify_runtime_tile_data_update();
}
}
}
#ifdef TOOLS_ENABLED
Rect2 TileMap::_edit_get_rect() const {
Rect2 LayeredTileMap::_edit_get_rect() const {
// Return the visible rect of the tilemap.
if (layers.is_empty()) {
return Rect2();
@ -520,16 +520,16 @@ Rect2 TileMap::_edit_get_rect() const {
rect = rect.merge(layers[i]->get_rect(changed));
any_changed |= changed;
}
const_cast<TileMap *>(this)->item_rect_changed(any_changed);
const_cast<LayeredTileMap *>(this)->item_rect_changed(any_changed);
return rect;
}
#endif
bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
bool LayeredTileMap::_set(const StringName &p_name, const Variant &p_value) {
Vector<String> components = String(p_name).split("/", true, 2);
if (p_name == "format") {
if (p_value.get_type() == Variant::INT) {
format = (TileMapDataFormat)(p_value.operator int64_t()); // Set format used for loading.
format = (LayeredTileMapDataFormat)(p_value.operator int64_t()); // Set format used for loading.
return true;
}
}
@ -537,11 +537,11 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
else if (p_name == "tile_data") { // Kept for compatibility reasons.
if (p_value.is_array()) {
if (layers.size() == 0) {
TileMapLayer *new_layer = memnew(TileMapLayer);
LayeredTileMapLayer *new_layer = memnew(LayeredTileMapLayer);
add_child(new_layer, false, INTERNAL_MODE_FRONT);
new_layer->set_as_tile_map_internal_node(0);
new_layer->set_name("Layer0");
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TileMap::_emit_changed));
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMap::_emit_changed));
layers.push_back(new_layer);
}
layers[0]->set_tile_data(format, p_value);
@ -562,11 +562,11 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
if (index >= (int)layers.size()) {
while (index >= (int)layers.size()) {
TileMapLayer *new_layer = memnew(TileMapLayer);
LayeredTileMapLayer *new_layer = memnew(LayeredTileMapLayer);
add_child(new_layer, false, INTERNAL_MODE_FRONT);
new_layer->set_as_tile_map_internal_node(index);
new_layer->set_name(vformat("Layer%d", index));
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TileMap::_emit_changed));
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMap::_emit_changed));
layers.push_back(new_layer);
}
@ -607,10 +607,10 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
return false;
}
bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {
bool LayeredTileMap::_get(const StringName &p_name, Variant &r_ret) const {
Vector<String> components = String(p_name).split("/", true, 2);
if (p_name == "format") {
r_ret = TileMapDataFormat::FORMAT_MAX - 1; // When saving, always save highest format.
r_ret = LayeredTileMapDataFormat::FORMAT_MAX - 1; // When saving, always save highest format.
return true;
}
#ifndef DISABLE_DEPRECATED
@ -656,7 +656,7 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
void TileMap::_get_property_list(List<PropertyInfo> *p_list) const {
void LayeredTileMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::NIL, "Layers", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
@ -680,7 +680,7 @@ void TileMap::_get_property_list(List<PropertyInfo> *p_list) const {
#undef MAKE_LAYER_PROPERTY
}
bool TileMap::_property_can_revert(const StringName &p_name) const {
bool LayeredTileMap::_property_can_revert(const StringName &p_name) const {
Vector<String> components = String(p_name).split("/", true, 2);
if (components.size() == 2 && components[0].begins_with("layer_")) {
int index = components[0].trim_prefix("layer_").to_int();
@ -708,7 +708,7 @@ bool TileMap::_property_can_revert(const StringName &p_name) const {
return false;
}
bool TileMap::_property_get_revert(const StringName &p_name, Variant &r_property) const {
bool LayeredTileMap::_property_get_revert(const StringName &p_name, Variant &r_property) const {
Vector<String> components = String(p_name).split("/", true, 2);
if (components.size() == 2 && components[0].begins_with("layer_")) {
int index = components[0].trim_prefix("layer_").to_int();
@ -743,39 +743,39 @@ bool TileMap::_property_get_revert(const StringName &p_name, Variant &r_property
return false;
}
Vector2 TileMap::map_to_local(const Vector2i &p_pos) const {
Vector2 LayeredTileMap::map_to_local(const Vector2i &p_pos) const {
ERR_FAIL_COND_V(!tile_set.is_valid(), Vector2());
return tile_set->map_to_local(p_pos);
}
Vector2i TileMap::local_to_map(const Vector2 &p_pos) const {
Vector2i LayeredTileMap::local_to_map(const Vector2 &p_pos) const {
ERR_FAIL_COND_V(!tile_set.is_valid(), Vector2i());
return tile_set->local_to_map(p_pos);
}
bool TileMap::is_existing_neighbor(TileSet::CellNeighbor p_cell_neighbor) const {
bool LayeredTileMap::is_existing_neighbor(LayeredTileSet::CellNeighbor p_cell_neighbor) const {
ERR_FAIL_COND_V(!tile_set.is_valid(), false);
return tile_set->is_existing_neighbor(p_cell_neighbor);
}
Vector2i TileMap::get_neighbor_cell(const Vector2i &p_coords, TileSet::CellNeighbor p_cell_neighbor) const {
Vector2i LayeredTileMap::get_neighbor_cell(const Vector2i &p_coords, LayeredTileSet::CellNeighbor p_cell_neighbor) const {
ERR_FAIL_COND_V(!tile_set.is_valid(), Vector2i());
return tile_set->get_neighbor_cell(p_coords, p_cell_neighbor);
}
TypedArray<Vector2i> TileMap::get_used_cells(int p_layer) const {
TypedArray<Vector2i> LayeredTileMap::get_used_cells(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, TypedArray<Vector2i>(), get_used_cells);
}
TypedArray<Vector2i> TileMap::get_used_cells_by_id(int p_layer, int p_source_id, const Vector2i p_atlas_coords, int p_alternative_tile) const {
TypedArray<Vector2i> LayeredTileMap::get_used_cells_by_id(int p_layer, int p_source_id, const Vector2i p_atlas_coords, int p_alternative_tile) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, TypedArray<Vector2i>(), get_used_cells_by_id, p_source_id, p_atlas_coords, p_alternative_tile);
}
Rect2i TileMap::get_used_rect() const {
Rect2i LayeredTileMap::get_used_rect() const {
// Return the visible rect of the tilemap.
bool first = true;
Rect2i rect = Rect2i();
for (const TileMapLayer *layer : layers) {
for (const LayeredTileMapLayer *layer : layers) {
Rect2i layer_rect = layer->get_used_rect();
if (layer_rect == Rect2i()) {
continue;
@ -792,39 +792,39 @@ Rect2i TileMap::get_used_rect() const {
// --- Override some methods of the CanvasItem class to pass the changes to the quadrants CanvasItems ---
void TileMap::set_light_mask(int p_light_mask) {
void LayeredTileMap::set_light_mask(int p_light_mask) {
// Set light mask for occlusion and applies it to all layers too.
CanvasItem::set_light_mask(p_light_mask);
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_light_mask(p_light_mask);
}
}
void TileMap::set_self_modulate(const Color &p_self_modulate) {
void LayeredTileMap::set_self_modulate(const Color &p_self_modulate) {
// Set self_modulation and applies it to all layers too.
CanvasItem::set_self_modulate(p_self_modulate);
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_self_modulate(p_self_modulate);
}
}
void TileMap::set_texture_filter(TextureFilter p_texture_filter) {
void LayeredTileMap::set_texture_filter(TextureFilter p_texture_filter) {
// Set a default texture filter and applies it to all layers too.
CanvasItem::set_texture_filter(p_texture_filter);
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_texture_filter(p_texture_filter);
}
}
void TileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) {
void LayeredTileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) {
// Set a default texture repeat and applies it to all layers too.
CanvasItem::set_texture_repeat(p_texture_repeat);
for (TileMapLayer *layer : layers) {
for (LayeredTileMapLayer *layer : layers) {
layer->set_texture_repeat(p_texture_repeat);
}
}
TypedArray<Vector2i> TileMap::get_surrounding_cells(const Vector2i &p_coords) {
TypedArray<Vector2i> LayeredTileMap::get_surrounding_cells(const Vector2i &p_coords) {
if (!tile_set.is_valid()) {
return TypedArray<Vector2i>();
}
@ -832,19 +832,19 @@ TypedArray<Vector2i> TileMap::get_surrounding_cells(const Vector2i &p_coords) {
return tile_set->get_surrounding_cells(p_coords);
}
PackedStringArray TileMap::get_configuration_warnings() const {
PackedStringArray LayeredTileMap::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
// Retrieve the set of Z index values with a Y-sorted layer.
RBSet<int> y_sorted_z_index;
for (const TileMapLayer *layer : layers) {
for (const LayeredTileMapLayer *layer : layers) {
if (layer->is_y_sort_enabled()) {
y_sorted_z_index.insert(layer->get_z_index());
}
}
// Check if we have a non-sorted layer in a Z-index with a Y-sorted layer.
for (const TileMapLayer *layer : layers) {
for (const LayeredTileMapLayer *layer : layers) {
if (!layer->is_y_sort_enabled() && y_sorted_z_index.has(layer->get_z_index())) {
warnings.push_back(RTR("A Y-sorted layer has the same Z-index value as a not Y-sorted layer.\nThis may lead to unwanted behaviors, as a layer that is not Y-sorted will be Y-sorted as a whole with tiles from Y-sorted layers."));
break;
@ -853,31 +853,31 @@ PackedStringArray TileMap::get_configuration_warnings() const {
if (!is_y_sort_enabled()) {
// Check if Y-sort is enabled on a layer but not on the node.
for (const TileMapLayer *layer : layers) {
for (const LayeredTileMapLayer *layer : layers) {
if (layer->is_y_sort_enabled()) {
warnings.push_back(RTR("A TileMap layer is set as Y-sorted, but Y-sort is not enabled on the TileMap node itself."));
warnings.push_back(RTR("A LayeredTileMap layer is set as Y-sorted, but Y-sort is not enabled on the LayeredTileMap node itself."));
break;
}
}
} else {
// Check if Y-sort is enabled on the node, but not on any of the layers.
bool need_warning = true;
for (const TileMapLayer *layer : layers) {
for (const LayeredTileMapLayer *layer : layers) {
if (layer->is_y_sort_enabled()) {
need_warning = false;
break;
}
}
if (need_warning) {
warnings.push_back(RTR("The TileMap node is set as Y-sorted, but Y-sort is not enabled on any of the TileMap's layers.\nThis may lead to unwanted behaviors, as a layer that is not Y-sorted will be Y-sorted as a whole."));
warnings.push_back(RTR("The LayeredTileMap node is set as Y-sorted, but Y-sort is not enabled on any of the LayeredTileMap's layers.\nThis may lead to unwanted behaviors, as a layer that is not Y-sorted will be Y-sorted as a whole."));
}
}
// Check if we are in isometric mode without Y-sort enabled.
if (tile_set.is_valid() && tile_set->get_tile_shape() == TileSet::TILE_SHAPE_ISOMETRIC) {
if (tile_set.is_valid() && tile_set->get_tile_shape() == LayeredTileSet::TILE_SHAPE_ISOMETRIC) {
bool warn = !is_y_sort_enabled();
if (!warn) {
for (const TileMapLayer *layer : layers) {
for (const LayeredTileMapLayer *layer : layers) {
if (!layer->is_y_sort_enabled()) {
warn = true;
break;
@ -886,86 +886,86 @@ PackedStringArray TileMap::get_configuration_warnings() const {
}
if (warn) {
warnings.push_back(RTR("Isometric TileSet will likely not look as intended without Y-sort enabled for the TileMap and all of its layers."));
warnings.push_back(RTR("Isometric LayeredTileSet will likely not look as intended without Y-sort enabled for the LayeredTileMap and all of its layers."));
}
}
return warnings;
}
void TileMap::_bind_methods() {
void LayeredTileMap::_bind_methods() {
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_navigation_map", "layer", "map"), &TileMap::set_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map", "layer"), &TileMap::get_layer_navigation_map);
ClassDB::bind_method(D_METHOD("force_update", "layer"), &TileMap::force_update, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_navigation_map", "layer", "map"), &LayeredTileMap::set_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map", "layer"), &LayeredTileMap::get_layer_navigation_map);
ClassDB::bind_method(D_METHOD("force_update", "layer"), &LayeredTileMap::force_update, DEFVAL(-1));
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_rendering_quadrant_size", "size"), &TileMap::set_rendering_quadrant_size);
ClassDB::bind_method(D_METHOD("get_rendering_quadrant_size"), &TileMap::get_rendering_quadrant_size);
ClassDB::bind_method(D_METHOD("set_rendering_quadrant_size", "size"), &LayeredTileMap::set_rendering_quadrant_size);
ClassDB::bind_method(D_METHOD("get_rendering_quadrant_size"), &LayeredTileMap::get_rendering_quadrant_size);
ClassDB::bind_method(D_METHOD("get_layers_count"), &TileMap::get_layers_count);
ClassDB::bind_method(D_METHOD("add_layer", "to_position"), &TileMap::add_layer);
ClassDB::bind_method(D_METHOD("move_layer", "layer", "to_position"), &TileMap::move_layer);
ClassDB::bind_method(D_METHOD("remove_layer", "layer"), &TileMap::remove_layer);
ClassDB::bind_method(D_METHOD("set_layer_name", "layer", "name"), &TileMap::set_layer_name);
ClassDB::bind_method(D_METHOD("get_layer_name", "layer"), &TileMap::get_layer_name);
ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &TileMap::set_layer_enabled);
ClassDB::bind_method(D_METHOD("is_layer_enabled", "layer"), &TileMap::is_layer_enabled);
ClassDB::bind_method(D_METHOD("set_layer_modulate", "layer", "modulate"), &TileMap::set_layer_modulate);
ClassDB::bind_method(D_METHOD("get_layer_modulate", "layer"), &TileMap::get_layer_modulate);
ClassDB::bind_method(D_METHOD("set_layer_y_sort_enabled", "layer", "y_sort_enabled"), &TileMap::set_layer_y_sort_enabled);
ClassDB::bind_method(D_METHOD("is_layer_y_sort_enabled", "layer"), &TileMap::is_layer_y_sort_enabled);
ClassDB::bind_method(D_METHOD("set_layer_y_sort_origin", "layer", "y_sort_origin"), &TileMap::set_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("get_layer_y_sort_origin", "layer"), &TileMap::get_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &TileMap::set_layer_z_index);
ClassDB::bind_method(D_METHOD("get_layer_z_index", "layer"), &TileMap::get_layer_z_index);
ClassDB::bind_method(D_METHOD("set_layer_navigation_enabled", "layer", "enabled"), &TileMap::set_layer_navigation_enabled);
ClassDB::bind_method(D_METHOD("is_layer_navigation_enabled", "layer"), &TileMap::is_layer_navigation_enabled);
ClassDB::bind_method(D_METHOD("set_layer_navigation_map", "layer", "map"), &TileMap::set_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_layer_navigation_map", "layer"), &TileMap::get_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_layers_count"), &LayeredTileMap::get_layers_count);
ClassDB::bind_method(D_METHOD("add_layer", "to_position"), &LayeredTileMap::add_layer);
ClassDB::bind_method(D_METHOD("move_layer", "layer", "to_position"), &LayeredTileMap::move_layer);
ClassDB::bind_method(D_METHOD("remove_layer", "layer"), &LayeredTileMap::remove_layer);
ClassDB::bind_method(D_METHOD("set_layer_name", "layer", "name"), &LayeredTileMap::set_layer_name);
ClassDB::bind_method(D_METHOD("get_layer_name", "layer"), &LayeredTileMap::get_layer_name);
ClassDB::bind_method(D_METHOD("set_layer_enabled", "layer", "enabled"), &LayeredTileMap::set_layer_enabled);
ClassDB::bind_method(D_METHOD("is_layer_enabled", "layer"), &LayeredTileMap::is_layer_enabled);
ClassDB::bind_method(D_METHOD("set_layer_modulate", "layer", "modulate"), &LayeredTileMap::set_layer_modulate);
ClassDB::bind_method(D_METHOD("get_layer_modulate", "layer"), &LayeredTileMap::get_layer_modulate);
ClassDB::bind_method(D_METHOD("set_layer_y_sort_enabled", "layer", "y_sort_enabled"), &LayeredTileMap::set_layer_y_sort_enabled);
ClassDB::bind_method(D_METHOD("is_layer_y_sort_enabled", "layer"), &LayeredTileMap::is_layer_y_sort_enabled);
ClassDB::bind_method(D_METHOD("set_layer_y_sort_origin", "layer", "y_sort_origin"), &LayeredTileMap::set_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("get_layer_y_sort_origin", "layer"), &LayeredTileMap::get_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &LayeredTileMap::set_layer_z_index);
ClassDB::bind_method(D_METHOD("get_layer_z_index", "layer"), &LayeredTileMap::get_layer_z_index);
ClassDB::bind_method(D_METHOD("set_layer_navigation_enabled", "layer", "enabled"), &LayeredTileMap::set_layer_navigation_enabled);
ClassDB::bind_method(D_METHOD("is_layer_navigation_enabled", "layer"), &LayeredTileMap::is_layer_navigation_enabled);
ClassDB::bind_method(D_METHOD("set_layer_navigation_map", "layer", "map"), &LayeredTileMap::set_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_layer_navigation_map", "layer"), &LayeredTileMap::get_layer_navigation_map);
ClassDB::bind_method(D_METHOD("set_collision_animatable", "enabled"), &TileMap::set_collision_animatable);
ClassDB::bind_method(D_METHOD("is_collision_animatable"), &TileMap::is_collision_animatable);
ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &TileMap::set_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMap::get_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("set_collision_animatable", "enabled"), &LayeredTileMap::set_collision_animatable);
ClassDB::bind_method(D_METHOD("is_collision_animatable"), &LayeredTileMap::is_collision_animatable);
ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &LayeredTileMap::set_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &LayeredTileMap::get_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "navigation_visibility_mode"), &TileMap::set_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &TileMap::get_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "navigation_visibility_mode"), &LayeredTileMap::set_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &LayeredTileMap::get_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("set_cell", "layer", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(0));
ClassDB::bind_method(D_METHOD("erase_cell", "layer", "coords"), &TileMap::erase_cell);
ClassDB::bind_method(D_METHOD("get_cell_source_id", "layer", "coords", "use_proxies"), &TileMap::get_cell_source_id, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "layer", "coords", "use_proxies"), &TileMap::get_cell_atlas_coords, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "layer", "coords", "use_proxies"), &TileMap::get_cell_alternative_tile, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_cell_tile_data", "layer", "coords", "use_proxies"), &TileMap::get_cell_tile_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_cell", "layer", "coords", "source_id", "atlas_coords", "alternative_tile"), &LayeredTileMap::set_cell, DEFVAL(LayeredTileSet::INVALID_SOURCE), DEFVAL(LayeredTileSetSource::INVALID_ATLAS_COORDS), DEFVAL(0));
ClassDB::bind_method(D_METHOD("erase_cell", "layer", "coords"), &LayeredTileMap::erase_cell);
ClassDB::bind_method(D_METHOD("get_cell_source_id", "layer", "coords", "use_proxies"), &LayeredTileMap::get_cell_source_id, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "layer", "coords", "use_proxies"), &LayeredTileMap::get_cell_atlas_coords, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "layer", "coords", "use_proxies"), &LayeredTileMap::get_cell_alternative_tile, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_cell_tile_data", "layer", "coords", "use_proxies"), &LayeredTileMap::get_cell_tile_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_coords_for_body_rid", "body"), &TileMap::get_coords_for_body_rid);
ClassDB::bind_method(D_METHOD("get_layer_for_body_rid", "body"), &TileMap::get_layer_for_body_rid);
ClassDB::bind_method(D_METHOD("get_coords_for_body_rid", "body"), &LayeredTileMap::get_coords_for_body_rid);
ClassDB::bind_method(D_METHOD("get_layer_for_body_rid", "body"), &LayeredTileMap::get_layer_for_body_rid);
ClassDB::bind_method(D_METHOD("get_pattern", "layer", "coords_array"), &TileMap::get_pattern);
ClassDB::bind_method(D_METHOD("map_pattern", "position_in_tilemap", "coords_in_pattern", "pattern"), &TileMap::map_pattern);
ClassDB::bind_method(D_METHOD("set_pattern", "layer", "position", "pattern"), &TileMap::set_pattern);
ClassDB::bind_method(D_METHOD("get_pattern", "layer", "coords_array"), &LayeredTileMap::get_pattern);
ClassDB::bind_method(D_METHOD("map_pattern", "position_in_tilemap", "coords_in_pattern", "pattern"), &LayeredTileMap::map_pattern);
ClassDB::bind_method(D_METHOD("set_pattern", "layer", "position", "pattern"), &LayeredTileMap::set_pattern);
ClassDB::bind_method(D_METHOD("set_cells_terrain_connect", "layer", "cells", "terrain_set", "terrain", "ignore_empty_terrains"), &TileMap::set_cells_terrain_connect, DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_cells_terrain_path", "layer", "path", "terrain_set", "terrain", "ignore_empty_terrains"), &TileMap::set_cells_terrain_path, DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_cells_terrain_connect", "layer", "cells", "terrain_set", "terrain", "ignore_empty_terrains"), &LayeredTileMap::set_cells_terrain_connect, DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_cells_terrain_path", "layer", "path", "terrain_set", "terrain", "ignore_empty_terrains"), &LayeredTileMap::set_cells_terrain_path, DEFVAL(true));
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles);
ClassDB::bind_method(D_METHOD("clear_layer", "layer"), &TileMap::clear_layer);
ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear);
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &LayeredTileMap::fix_invalid_tiles);
ClassDB::bind_method(D_METHOD("clear_layer", "layer"), &LayeredTileMap::clear_layer);
ClassDB::bind_method(D_METHOD("clear"), &LayeredTileMap::clear);
ClassDB::bind_method(D_METHOD("update_internals"), &TileMap::update_internals);
ClassDB::bind_method(D_METHOD("notify_runtime_tile_data_update", "layer"), &TileMap::notify_runtime_tile_data_update, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("update_internals"), &LayeredTileMap::update_internals);
ClassDB::bind_method(D_METHOD("notify_runtime_tile_data_update", "layer"), &LayeredTileMap::notify_runtime_tile_data_update, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_surrounding_cells", "coords"), &TileMap::get_surrounding_cells);
ClassDB::bind_method(D_METHOD("get_surrounding_cells", "coords"), &LayeredTileMap::get_surrounding_cells);
ClassDB::bind_method(D_METHOD("get_used_cells", "layer"), &TileMap::get_used_cells);
ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "layer", "source_id", "atlas_coords", "alternative_tile"), &TileMap::get_used_cells_by_id, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE));
ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect);
ClassDB::bind_method(D_METHOD("get_used_cells", "layer"), &LayeredTileMap::get_used_cells);
ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "layer", "source_id", "atlas_coords", "alternative_tile"), &LayeredTileMap::get_used_cells_by_id, DEFVAL(LayeredTileSet::INVALID_SOURCE), DEFVAL(LayeredTileSetSource::INVALID_ATLAS_COORDS), DEFVAL(LayeredTileSetSource::INVALID_TILE_ALTERNATIVE));
ClassDB::bind_method(D_METHOD("get_used_rect"), &LayeredTileMap::get_used_rect);
ClassDB::bind_method(D_METHOD("map_to_local", "map_position"), &TileMap::map_to_local);
ClassDB::bind_method(D_METHOD("local_to_map", "local_position"), &TileMap::local_to_map);
ClassDB::bind_method(D_METHOD("map_to_local", "map_position"), &LayeredTileMap::map_to_local);
ClassDB::bind_method(D_METHOD("local_to_map", "local_position"), &LayeredTileMap::local_to_map);
ClassDB::bind_method(D_METHOD("get_neighbor_cell", "coords", "neighbor"), &TileMap::get_neighbor_cell);
ClassDB::bind_method(D_METHOD("get_neighbor_cell", "coords", "neighbor"), &LayeredTileMap::get_neighbor_cell);
GDVIRTUAL_BIND(_use_tile_data_runtime_update, "layer", "coords");
GDVIRTUAL_BIND(_tile_data_runtime_update, "layer", "coords", "tile_data");
@ -977,7 +977,7 @@ void TileMap::_bind_methods() {
ADD_ARRAY("layers", "layer_");
ADD_PROPERTY_DEFAULT("format", TileMapDataFormat::FORMAT_1);
ADD_PROPERTY_DEFAULT("format", LayeredTileMapDataFormat::FORMAT_1);
ADD_SIGNAL(MethodInfo(CoreStringNames::get_singleton()->changed));
@ -986,17 +986,17 @@ void TileMap::_bind_methods() {
BIND_ENUM_CONSTANT(VISIBILITY_MODE_FORCE_SHOW);
}
TileMap::TileMap() {
TileMapLayer *new_layer = memnew(TileMapLayer);
LayeredTileMap::LayeredTileMap() {
LayeredTileMapLayer *new_layer = memnew(LayeredTileMapLayer);
add_child(new_layer, false, INTERNAL_MODE_FRONT);
new_layer->set_as_tile_map_internal_node(0);
new_layer->set_name("Layer0");
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TileMap::_emit_changed));
new_layer->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMap::_emit_changed));
layers.push_back(new_layer);
default_layer = memnew(TileMapLayer);
default_layer = memnew(LayeredTileMapLayer);
}
TileMap::~TileMap() {
LayeredTileMap::~LayeredTileMap() {
memdelete(default_layer);
}

View File

@ -36,21 +36,21 @@
#include "scene/resources/2d/tile_set.h"
class Control;
class TileMapLayer;
class LayeredTileMapLayer;
class TerrainConstraint;
enum TileMapDataFormat {
enum LayeredTileMapDataFormat {
FORMAT_1 = 0,
FORMAT_2,
FORMAT_3,
FORMAT_MAX,
};
class TileMap : public TileMapLayerGroup {
GDCLASS(TileMap, TileMapLayerGroup)
class LayeredTileMap : public LayeredTileMapLayerGroup {
GDCLASS(LayeredTileMap, LayeredTileMapLayerGroup)
public:
// Kept for compatibility, but should use TileMapLayer::VisibilityMode instead.
// Kept for compatibility, but should use LayeredTileMapLayer::VisibilityMode instead.
enum VisibilityMode {
VISIBILITY_MODE_DEFAULT,
VISIBILITY_MODE_FORCE_SHOW,
@ -58,10 +58,10 @@ public:
};
private:
friend class TileSetPlugin;
friend class LayeredTileSetPlugin;
// A compatibility enum to specify how is the data if formatted.
mutable TileMapDataFormat format = TileMapDataFormat::FORMAT_3;
mutable LayeredTileMapDataFormat format = LayeredTileMapDataFormat::FORMAT_3;
static constexpr float FP_ADJUST = 0.00001;
@ -72,8 +72,8 @@ private:
VisibilityMode navigation_visibility_mode = VISIBILITY_MODE_DEFAULT;
// Layers.
LocalVector<TileMapLayer *> layers;
TileMapLayer *default_layer; // Dummy layer to fetch default values.
LocalVector<LayeredTileMapLayer *> layers;
LayeredTileMapLayer *default_layer; // Dummy layer to fetch default values.
// Transforms for collision_animatable.
Transform2D last_valid_transform;
@ -113,7 +113,7 @@ public:
void set_rendering_quadrant_size(int p_size);
int get_rendering_quadrant_size() const;
static void draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<TileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame = -1, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0), const TileData *p_tile_data_override = nullptr, real_t p_normalized_animation_offset = 0.0);
static void draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<LayeredTileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame = -1, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0), const TileData *p_tile_data_override = nullptr, real_t p_normalized_animation_offset = 0.0);
// Layers management.
int get_layers_count() const;
@ -149,7 +149,7 @@ public:
VisibilityMode get_navigation_visibility_mode() const;
// Cells accessors.
void set_cell(int p_layer, const Vector2i &p_coords, int p_source_id = TileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void set_cell(int p_layer, const Vector2i &p_coords, int p_source_id = LayeredTileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = LayeredTileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void erase_cell(int p_layer, const Vector2i &p_coords);
int get_cell_source_id(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
Vector2i get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
@ -158,33 +158,33 @@ public:
TileData *get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
// Patterns.
Ref<TileMapPattern> get_pattern(int p_layer, TypedArray<Vector2i> p_coords_array);
Vector2i map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref<TileMapPattern> p_pattern);
void set_pattern(int p_layer, const Vector2i &p_position, const Ref<TileMapPattern> p_pattern);
Ref<LayeredTileMapPattern> get_pattern(int p_layer, TypedArray<Vector2i> p_coords_array);
Vector2i map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref<LayeredTileMapPattern> p_pattern);
void set_pattern(int p_layer, const Vector2i &p_position, const Ref<LayeredTileMapPattern> p_pattern);
// Terrains (Not exposed).
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_constraints(int p_layer, const Vector<Vector2i> &p_to_replace, int p_terrain_set, const RBSet<TerrainConstraint> &p_constraints);
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_connect(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_path(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_pattern(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains = true);
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_constraints(int p_layer, const Vector<Vector2i> &p_to_replace, int p_terrain_set, const RBSet<TerrainConstraint> &p_constraints);
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_connect(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_path(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_pattern(int p_layer, const Vector<Vector2i> &p_coords_array, int p_terrain_set, LayeredTileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains = true);
// Terrains (exposed).
void set_cells_terrain_connect(int p_layer, TypedArray<Vector2i> p_cells, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
void set_cells_terrain_path(int p_layer, TypedArray<Vector2i> p_path, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
// Not exposed to users.
TileMapCell get_cell(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
LayeredTileMapCell get_cell(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
int get_effective_quadrant_size(int p_layer) const;
virtual void set_y_sort_enabled(bool p_enable) override;
Vector2 map_to_local(const Vector2i &p_pos) const;
Vector2i local_to_map(const Vector2 &p_pos) const;
bool is_existing_neighbor(TileSet::CellNeighbor p_cell_neighbor) const;
Vector2i get_neighbor_cell(const Vector2i &p_coords, TileSet::CellNeighbor p_cell_neighbor) const;
bool is_existing_neighbor(LayeredTileSet::CellNeighbor p_cell_neighbor) const;
Vector2i get_neighbor_cell(const Vector2i &p_coords, LayeredTileSet::CellNeighbor p_cell_neighbor) const;
TypedArray<Vector2i> get_used_cells(int p_layer) const;
TypedArray<Vector2i> get_used_cells_by_id(int p_layer, int p_source_id = TileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE) const;
TypedArray<Vector2i> get_used_cells_by_id(int p_layer, int p_source_id = LayeredTileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = LayeredTileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE) const;
Rect2i get_used_rect() const;
// Override some methods of the CanvasItem class to pass the changes to the quadrants CanvasItems.
@ -205,7 +205,7 @@ public:
void clear_layer(int p_layer);
void clear();
// Force a TileMap update.
// Force a LayeredTileMap update.
void update_internals();
void notify_runtime_tile_data_update(int p_layer = -1);
@ -219,10 +219,10 @@ public:
// Configuration warnings.
PackedStringArray get_configuration_warnings() const override;
TileMap();
~TileMap();
LayeredTileMap();
~LayeredTileMap();
};
VARIANT_ENUM_CAST(TileMap::VisibilityMode);
VARIANT_ENUM_CAST(LayeredTileMap::VisibilityMode);
#endif // TILE_MAP_H

File diff suppressed because it is too large Load Diff

View File

@ -35,11 +35,11 @@
#include "scene/2d/tile_map.h"
#include "scene/resources/2d/tile_set.h"
class TileSetAtlasSource;
class LayeredTileSetAtlasSource;
class TerrainConstraint {
private:
Ref<TileSet> tile_set;
Ref<LayeredTileSet> tile_set;
Vector2i base_cell_coords;
int bit = -1;
int terrain = -1;
@ -66,7 +66,7 @@ public:
return bit == 0;
}
HashMap<Vector2i, TileSet::CellNeighbor> get_overlapping_coords_and_peering_bits() const;
HashMap<Vector2i, LayeredTileSet::CellNeighbor> get_overlapping_coords_and_peering_bits() const;
void set_terrain(int p_terrain) {
terrain = p_terrain;
@ -84,8 +84,8 @@ public:
return priority;
}
TerrainConstraint(Ref<TileSet> p_tile_set, const Vector2i &p_position, int p_terrain); // For the center terrain bit
TerrainConstraint(Ref<TileSet> p_tile_set, const Vector2i &p_position, const TileSet::CellNeighbor &p_bit, int p_terrain); // For peering bits
TerrainConstraint(Ref<LayeredTileSet> p_tile_set, const Vector2i &p_position, int p_terrain); // For the center terrain bit
TerrainConstraint(Ref<LayeredTileSet> p_tile_set, const Vector2i &p_position, const LayeredTileSet::CellNeighbor &p_bit, int p_terrain); // For peering bits
TerrainConstraint(){};
};
@ -96,7 +96,7 @@ class RenderingQuadrant;
struct CellData {
Vector2i coords;
TileMapCell cell;
LayeredTileMapCell cell;
// Debug.
SelfList<CellData> debug_quadrant_list_element;
@ -215,8 +215,8 @@ public:
}
};
class TileMapLayer : public Node2D {
GDCLASS(TileMapLayer, Node2D);
class LayeredTileMapLayer : public Node2D {
GDCLASS(LayeredTileMapLayer, Node2D);
public:
enum VisibilityMode {
@ -272,8 +272,8 @@ private:
HashMap<Vector2i, CellData> tile_map;
bool pending_update = false;
// For keeping compatibility with TileMap.
TileMap *tile_map_node = nullptr;
// For keeping compatibility with LayeredTileMap.
LayeredTileMap *tile_map_node = nullptr;
int layer_index_in_tile_map_node = -1;
// Dirty flag. Allows knowing what was modified since the last update.
@ -345,8 +345,8 @@ private:
#endif // DEBUG_ENABLED
// Terrains.
TileSet::TerrainsPattern _get_best_terrain_pattern_for_constraints(int p_terrain_set, const Vector2i &p_position, const RBSet<TerrainConstraint> &p_constraints, TileSet::TerrainsPattern p_current_pattern) const;
RBSet<TerrainConstraint> _get_terrain_constraints_from_added_pattern(const Vector2i &p_position, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern) const;
LayeredTileSet::TerrainsPattern _get_best_terrain_pattern_for_constraints(int p_terrain_set, const Vector2i &p_position, const RBSet<TerrainConstraint> &p_constraints, LayeredTileSet::TerrainsPattern p_current_pattern) const;
RBSet<TerrainConstraint> _get_terrain_constraints_from_added_pattern(const Vector2i &p_position, int p_terrain_set, LayeredTileSet::TerrainsPattern p_terrains_pattern) const;
RBSet<TerrainConstraint> _get_terrain_constraints_from_painted_cells_list(const RBSet<Vector2i> &p_painted, int p_terrain_set, bool p_ignore_empty_terrains) const;
void _renamed();
@ -362,32 +362,32 @@ protected:
static void _bind_methods();
public:
// TileMap node.
// LayeredTileMap node.
void set_as_tile_map_internal_node(int p_index);
// Rect caching.
Rect2 get_rect(bool &r_changed) const;
// Terrains.
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_constraints(const Vector<Vector2i> &p_to_replace, int p_terrain_set, const RBSet<TerrainConstraint> &p_constraints) const; // Not exposed.
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_connect(const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true) const; // Not exposed.
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_path(const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true) const; // Not exposed.
HashMap<Vector2i, TileSet::TerrainsPattern> terrain_fill_pattern(const Vector<Vector2i> &p_coords_array, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains = true) const; // Not exposed.
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_constraints(const Vector<Vector2i> &p_to_replace, int p_terrain_set, const RBSet<TerrainConstraint> &p_constraints) const; // Not exposed.
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_connect(const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true) const; // Not exposed.
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_path(const Vector<Vector2i> &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true) const; // Not exposed.
HashMap<Vector2i, LayeredTileSet::TerrainsPattern> terrain_fill_pattern(const Vector<Vector2i> &p_coords_array, int p_terrain_set, LayeredTileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains = true) const; // Not exposed.
// Not exposed to users.
TileMapCell get_cell(const Vector2i &p_coords, bool p_use_proxies = false) const;
LayeredTileMapCell get_cell(const Vector2i &p_coords, bool p_use_proxies = false) const;
// For TileMap node's use.
void set_tile_data(TileMapDataFormat p_format, const Vector<int> &p_data);
// For LayeredTileMap node's use.
void set_tile_data(LayeredTileMapDataFormat p_format, const Vector<int> &p_data);
Vector<int> get_tile_data() const;
void notify_tile_map_layer_group_change(DirtyFlags p_what);
void update_internals();
void notify_runtime_tile_data_update();
// --- Exposed in TileMap ---
// --- Exposed in LayeredTileMap ---
// Cells manipulation.
void set_cell(const Vector2i &p_coords, int p_source_id = TileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void set_cell(const Vector2i &p_coords, int p_source_id = LayeredTileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = LayeredTileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
void erase_cell(const Vector2i &p_coords);
int get_cell_source_id(const Vector2i &p_coords, bool p_use_proxies = false) const;
@ -397,8 +397,8 @@ public:
void clear();
// Patterns.
Ref<TileMapPattern> get_pattern(TypedArray<Vector2i> p_coords_array);
void set_pattern(const Vector2i &p_position, const Ref<TileMapPattern> p_pattern);
Ref<LayeredTileMapPattern> get_pattern(TypedArray<Vector2i> p_coords_array);
void set_pattern(const Vector2i &p_position, const Ref<LayeredTileMapPattern> p_pattern);
// Terrains.
void set_cells_terrain_connect(TypedArray<Vector2i> p_cells, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true);
@ -406,7 +406,7 @@ public:
// Cells usage.
TypedArray<Vector2i> get_used_cells() const;
TypedArray<Vector2i> get_used_cells_by_id(int p_source_id = TileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE) const;
TypedArray<Vector2i> get_used_cells_by_id(int p_source_id = LayeredTileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = LayeredTileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE) const;
Rect2i get_used_rect() const;
// Layer properties.
@ -443,15 +443,15 @@ public:
Vector2i get_coords_for_body_rid(RID p_physics_body) const; // For finding tiles from collision.
// Helper.
Ref<TileSet> get_effective_tile_set() const;
Ref<LayeredTileSet> get_effective_tile_set() const;
// Virtual function to modify the TileData at runtime.
GDVIRTUAL1R(bool, _use_tile_data_runtime_update, Vector2i);
GDVIRTUAL2(_tile_data_runtime_update, Vector2i, TileData *);
// ---
TileMapLayer();
~TileMapLayer();
LayeredTileMapLayer();
~LayeredTileMapLayer();
};
#endif // TILE_MAP_LAYER_H

View File

@ -37,10 +37,10 @@
#ifdef TOOLS_ENABLED
void TileMapLayerGroup::_cleanup_selected_layers() {
void LayeredTileMapLayerGroup::_cleanup_selected_layers() {
for (int i = 0; i < selected_layers.size(); i++) {
const String name = selected_layers[i];
TileMapLayer *layer = Object::cast_to<TileMapLayer>(get_node_or_null(name));
LayeredTileMapLayer *layer = Object::cast_to<LayeredTileMapLayer>(get_node_or_null(name));
if (!layer) {
selected_layers.remove_at(i);
i--;
@ -50,11 +50,11 @@ void TileMapLayerGroup::_cleanup_selected_layers() {
#endif // TOOLS_ENABLED
void TileMapLayerGroup::_tile_set_changed() {
void LayeredTileMapLayerGroup::_tile_set_changed() {
for (int i = 0; i < get_child_count(); i++) {
TileMapLayer *layer = Object::cast_to<TileMapLayer>(get_child(i));
LayeredTileMapLayer *layer = Object::cast_to<LayeredTileMapLayer>(get_child(i));
if (layer) {
layer->notify_tile_map_layer_group_change(TileMapLayer::DIRTY_FLAGS_LAYER_GROUP_TILE_SET);
layer->notify_tile_map_layer_group_change(LayeredTileMapLayer::DIRTY_FLAGS_LAYER_GROUP_TILE_SET);
}
}
@ -63,24 +63,24 @@ void TileMapLayerGroup::_tile_set_changed() {
#ifdef TOOLS_ENABLED
void TileMapLayerGroup::set_selected_layers(Vector<StringName> p_layer_names) {
void LayeredTileMapLayerGroup::set_selected_layers(Vector<StringName> p_layer_names) {
selected_layers = p_layer_names;
_cleanup_selected_layers();
// Update the layers modulation.
for (int i = 0; i < get_child_count(); i++) {
TileMapLayer *layer = Object::cast_to<TileMapLayer>(get_child(i));
LayeredTileMapLayer *layer = Object::cast_to<LayeredTileMapLayer>(get_child(i));
if (layer) {
layer->notify_tile_map_layer_group_change(TileMapLayer::DIRTY_FLAGS_LAYER_GROUP_SELECTED_LAYERS);
layer->notify_tile_map_layer_group_change(LayeredTileMapLayer::DIRTY_FLAGS_LAYER_GROUP_SELECTED_LAYERS);
}
}
}
Vector<StringName> TileMapLayerGroup::get_selected_layers() const {
Vector<StringName> LayeredTileMapLayerGroup::get_selected_layers() const {
return selected_layers;
}
void TileMapLayerGroup::set_highlight_selected_layer(bool p_highlight_selected_layer) {
void LayeredTileMapLayerGroup::set_highlight_selected_layer(bool p_highlight_selected_layer) {
if (highlight_selected_layer == p_highlight_selected_layer) {
return;
}
@ -88,62 +88,62 @@ void TileMapLayerGroup::set_highlight_selected_layer(bool p_highlight_selected_l
highlight_selected_layer = p_highlight_selected_layer;
for (int i = 0; i < get_child_count(); i++) {
TileMapLayer *layer = Object::cast_to<TileMapLayer>(get_child(i));
LayeredTileMapLayer *layer = Object::cast_to<LayeredTileMapLayer>(get_child(i));
if (layer) {
layer->notify_tile_map_layer_group_change(TileMapLayer::DIRTY_FLAGS_LAYER_GROUP_HIGHLIGHT_SELECTED);
layer->notify_tile_map_layer_group_change(LayeredTileMapLayer::DIRTY_FLAGS_LAYER_GROUP_HIGHLIGHT_SELECTED);
}
}
}
bool TileMapLayerGroup::is_highlighting_selected_layer() const {
bool LayeredTileMapLayerGroup::is_highlighting_selected_layer() const {
return highlight_selected_layer;
}
#endif // TOOLS_ENABLED
void TileMapLayerGroup::remove_child_notify(Node *p_child) {
void LayeredTileMapLayerGroup::remove_child_notify(Node *p_child) {
#ifdef TOOLS_ENABLED
_cleanup_selected_layers();
#endif // TOOLS_ENABLED
}
void TileMapLayerGroup::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMapLayerGroup::set_tileset);
ClassDB::bind_method(D_METHOD("get_tileset"), &TileMapLayerGroup::get_tileset);
void LayeredTileMapLayerGroup::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &LayeredTileMapLayerGroup::set_tileset);
ClassDB::bind_method(D_METHOD("get_tileset"), &LayeredTileMapLayerGroup::get_tileset);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_set", PROPERTY_HINT_RESOURCE_TYPE, "TileSet"), "set_tileset", "get_tileset");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_set", PROPERTY_HINT_RESOURCE_TYPE, "LayeredTileSet"), "set_tileset", "get_tileset");
}
void TileMapLayerGroup::set_tileset(const Ref<TileSet> &p_tileset) {
void LayeredTileMapLayerGroup::set_tileset(const Ref<LayeredTileSet> &p_tileset) {
if (p_tileset == tile_set) {
return;
}
// Set the tileset, registering to its changes.
if (tile_set.is_valid()) {
tile_set->disconnect_changed(callable_mp(this, &TileMapLayerGroup::_tile_set_changed));
tile_set->disconnect_changed(callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
}
tile_set = p_tileset;
if (tile_set.is_valid()) {
tile_set->connect_changed(callable_mp(this, &TileMapLayerGroup::_tile_set_changed));
tile_set->connect_changed(callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
}
for (int i = 0; i < get_child_count(); i++) {
TileMapLayer *layer = Object::cast_to<TileMapLayer>(get_child(i));
LayeredTileMapLayer *layer = Object::cast_to<LayeredTileMapLayer>(get_child(i));
if (layer) {
layer->notify_tile_map_layer_group_change(TileMapLayer::DIRTY_FLAGS_LAYER_GROUP_TILE_SET);
layer->notify_tile_map_layer_group_change(LayeredTileMapLayer::DIRTY_FLAGS_LAYER_GROUP_TILE_SET);
}
}
}
Ref<TileSet> TileMapLayerGroup::get_tileset() const {
Ref<LayeredTileSet> LayeredTileMapLayerGroup::get_tileset() const {
return tile_set;
}
TileMapLayerGroup::~TileMapLayerGroup() {
LayeredTileMapLayerGroup::~LayeredTileMapLayerGroup() {
if (tile_set.is_valid()) {
tile_set->disconnect_changed(callable_mp(this, &TileMapLayerGroup::_tile_set_changed));
tile_set->disconnect_changed(callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
}
}

View File

@ -34,10 +34,10 @@
#include "scene/2d/node_2d.h"
class TileSet;
class LayeredTileSet;
class TileMapLayerGroup : public Node2D {
GDCLASS(TileMapLayerGroup, Node2D);
class LayeredTileMapLayerGroup : public Node2D {
GDCLASS(LayeredTileMapLayerGroup, Node2D);
private:
mutable Vector<StringName> selected_layers;
@ -49,7 +49,7 @@ private:
void _tile_set_changed();
protected:
Ref<TileSet> tile_set;
Ref<LayeredTileSet> tile_set;
virtual void remove_child_notify(Node *p_child) override;
@ -65,10 +65,10 @@ public:
#endif
// Accessors.
void set_tileset(const Ref<TileSet> &p_tileset);
Ref<TileSet> get_tileset() const;
void set_tileset(const Ref<LayeredTileSet> &p_tileset);
Ref<LayeredTileSet> get_tileset() const;
~TileMapLayerGroup();
~LayeredTileMapLayerGroup();
};
#endif // TILE_MAP_LAYER_GROUP_H

File diff suppressed because it is too large Load Diff

View File

@ -48,18 +48,18 @@
#include "scene/resources/shader.h"
#endif
class TileMap;
class TileSetSource;
class TileSetAtlasSource;
class LayeredTileMap;
class LayeredTileSetSource;
class LayeredTileSetAtlasSource;
class TileData;
// Forward-declare the plugins.
class TileSetPlugin;
class TileSetPluginAtlasRendering;
class TileSetPluginAtlasPhysics;
class TileSetPluginAtlasNavigation;
class LayeredTileSetPlugin;
class LayeredTileSetPluginAtlasRendering;
class LayeredTileSetPluginAtlasPhysics;
class LayeredTileSetPluginAtlasNavigation;
union TileMapCell {
union LayeredTileMapCell {
struct {
int16_t source_id;
int16_t coord_x;
@ -69,11 +69,11 @@ union TileMapCell {
uint64_t _u64t;
static uint32_t hash(const TileMapCell &p_hash) {
static uint32_t hash(const LayeredTileMapCell &p_hash) {
return hash_one_uint64(p_hash._u64t);
}
TileMapCell(int p_source_id = -1, Vector2i p_atlas_coords = Vector2i(-1, -1), int p_alternative_tile = -1) { // default are INVALID_SOURCE, INVALID_ATLAS_COORDS, INVALID_TILE_ALTERNATIVE
LayeredTileMapCell(int p_source_id = -1, Vector2i p_atlas_coords = Vector2i(-1, -1), int p_alternative_tile = -1) { // default are INVALID_SOURCE, INVALID_ATLAS_COORDS, INVALID_TILE_ALTERNATIVE
source_id = p_source_id;
set_atlas_coords(p_atlas_coords);
alternative_tile = p_alternative_tile;
@ -88,7 +88,7 @@ union TileMapCell {
coord_y = r_coords.y;
}
bool operator<(const TileMapCell &p_other) const {
bool operator<(const LayeredTileMapCell &p_other) const {
if (source_id == p_other.source_id) {
if (coord_x == p_other.coord_x) {
if (coord_y == p_other.coord_y) {
@ -104,19 +104,19 @@ union TileMapCell {
}
}
bool operator!=(const TileMapCell &p_other) const {
bool operator!=(const LayeredTileMapCell &p_other) const {
return !(source_id == p_other.source_id && coord_x == p_other.coord_x && coord_y == p_other.coord_y && alternative_tile == p_other.alternative_tile);
}
bool operator==(const TileMapCell &p_other) const {
bool operator==(const LayeredTileMapCell &p_other) const {
return source_id == p_other.source_id && coord_x == p_other.coord_x && coord_y == p_other.coord_y && alternative_tile == p_other.alternative_tile;
}
};
class TileMapPattern : public Resource {
GDCLASS(TileMapPattern, Resource);
class LayeredTileMapPattern : public Resource {
GDCLASS(LayeredTileMapPattern, Resource);
Size2i size;
HashMap<Vector2i, TileMapCell> pattern;
HashMap<Vector2i, LayeredTileMapCell> pattern;
void _set_tile_data(const Vector<int> &p_data);
Vector<int> _get_tile_data() const;
@ -136,7 +136,7 @@ public:
Vector2i get_cell_atlas_coords(const Vector2i &p_coords) const;
int get_cell_alternative_tile(const Vector2i &p_coords) const;
const HashMap<Vector2i, TileMapCell> &get_pattern() const { return pattern; }
const HashMap<Vector2i, LayeredTileMapCell> &get_pattern() const { return pattern; }
TypedArray<Vector2i> get_used_cells() const;
Size2i get_size() const;
@ -146,8 +146,8 @@ public:
void clear();
};
class TileSet : public Resource {
GDCLASS(TileSet, Resource);
class LayeredTileSet : public Resource {
GDCLASS(LayeredTileSet, Resource);
#ifndef DISABLE_DEPRECATED
private:
@ -266,8 +266,8 @@ public:
class TerrainsPattern {
bool valid = false;
int terrain = -1;
int bits[TileSet::CELL_NEIGHBOR_MAX];
bool is_valid_bit[TileSet::CELL_NEIGHBOR_MAX];
int bits[LayeredTileSet::CELL_NEIGHBOR_MAX];
bool is_valid_bit[LayeredTileSet::CELL_NEIGHBOR_MAX];
int not_empty_terrains_count = 0;
@ -284,13 +284,13 @@ public:
void set_terrain(int p_terrain);
int get_terrain() const;
void set_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit, int p_terrain);
int get_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit) const;
void set_terrain_peering_bit(LayeredTileSet::CellNeighbor p_peering_bit, int p_terrain);
int get_terrain_peering_bit(LayeredTileSet::CellNeighbor p_peering_bit) const;
void from_array(Array p_terrains);
Array as_array() const;
TerrainsPattern(const TileSet *p_tile_set, int p_terrain_set);
TerrainsPattern(const LayeredTileSet *p_tile_set, int p_terrain_set);
TerrainsPattern() {}
};
@ -301,7 +301,7 @@ protected:
void _validate_property(PropertyInfo &p_property) const;
private:
// --- TileSet data ---
// --- LayeredTileSet data ---
// Basic shape and layout.
TileShape tile_shape = TILE_SHAPE_SQUARE;
TileLayout tile_layout = TILE_LAYOUT_STACKED;
@ -343,7 +343,7 @@ private:
HashMap<TerrainMode, HashMap<CellNeighbor, Ref<ArrayMesh>>> terrain_peering_bits_meshes;
bool terrain_bits_meshes_dirty = true;
LocalVector<RBMap<TileSet::TerrainsPattern, RBSet<TileMapCell>>> per_terrain_pattern_tiles; // Cached data.
LocalVector<RBMap<LayeredTileSet::TerrainsPattern, RBSet<LayeredTileMapCell>>> per_terrain_pattern_tiles; // Cached data.
bool terrains_cache_dirty = true;
void _update_terrains_cache();
@ -362,12 +362,12 @@ private:
HashMap<String, int> custom_data_layers_by_name;
// Per Atlas source data.
HashMap<int, Ref<TileSetSource>> sources;
HashMap<int, Ref<LayeredTileSetSource>> sources;
Vector<int> source_ids;
int next_source_id = 0;
// ---------------------
LocalVector<Ref<TileMapPattern>> patterns;
LocalVector<Ref<LayeredTileMapPattern>> patterns;
void _compute_next_source_id();
void _source_changed();
@ -379,28 +379,28 @@ private:
// Helpers
Vector<Point2> _get_square_terrain_polygon(Vector2i p_size);
Vector<Point2> _get_square_corner_or_side_terrain_peering_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_square_corner_terrain_peering_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_square_side_terrain_peering_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_square_corner_or_side_terrain_peering_bit_polygon(Vector2i p_size, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_square_corner_terrain_peering_bit_polygon(Vector2i p_size, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_square_side_terrain_peering_bit_polygon(Vector2i p_size, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_isometric_terrain_polygon(Vector2i p_size);
Vector<Point2> _get_isometric_corner_or_side_terrain_peering_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_isometric_corner_terrain_peering_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_isometric_side_terrain_peering_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_isometric_corner_or_side_terrain_peering_bit_polygon(Vector2i p_size, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_isometric_corner_terrain_peering_bit_polygon(Vector2i p_size, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_isometric_side_terrain_peering_bit_polygon(Vector2i p_size, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_half_offset_terrain_polygon(Vector2i p_size, float p_overlap, TileSet::TileOffsetAxis p_offset_axis);
Vector<Point2> _get_half_offset_corner_or_side_terrain_peering_bit_polygon(Vector2i p_size, float p_overlap, TileSet::TileOffsetAxis p_offset_axis, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_half_offset_corner_terrain_peering_bit_polygon(Vector2i p_size, float p_overlap, TileSet::TileOffsetAxis p_offset_axis, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_half_offset_side_terrain_peering_bit_polygon(Vector2i p_size, float p_overlap, TileSet::TileOffsetAxis p_offset_axis, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_half_offset_terrain_polygon(Vector2i p_size, float p_overlap, LayeredTileSet::TileOffsetAxis p_offset_axis);
Vector<Point2> _get_half_offset_corner_or_side_terrain_peering_bit_polygon(Vector2i p_size, float p_overlap, LayeredTileSet::TileOffsetAxis p_offset_axis, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_half_offset_corner_terrain_peering_bit_polygon(Vector2i p_size, float p_overlap, LayeredTileSet::TileOffsetAxis p_offset_axis, LayeredTileSet::CellNeighbor p_bit);
Vector<Point2> _get_half_offset_side_terrain_peering_bit_polygon(Vector2i p_size, float p_overlap, LayeredTileSet::TileOffsetAxis p_offset_axis, LayeredTileSet::CellNeighbor p_bit);
protected:
static void _bind_methods();
public:
// --- Plugins ---
Vector<TileSetPlugin *> get_tile_set_atlas_plugins() const;
Vector<LayeredTileSetPlugin *> get_tile_set_atlas_plugins() const;
// --- Accessors for TileSet data ---
// --- Accessors for LayeredTileSet data ---
// -- Shape and layout --
void set_tile_shape(TileShape p_shape);
@ -416,12 +416,12 @@ public:
int get_next_source_id() const;
int get_source_count() const;
int get_source_id(int p_index) const;
int add_source(Ref<TileSetSource> p_tile_set_source, int p_source_id_override = -1);
int add_source(Ref<LayeredTileSetSource> p_tile_set_source, int p_source_id_override = -1);
void set_source_id(int p_source_id, int p_new_id);
void remove_source(int p_source_id);
void remove_source_ptr(TileSetSource *p_tile_set_source); // Not exposed
void remove_source_ptr(LayeredTileSetSource *p_tile_set_source); // Not exposed
bool has_source(int p_source_id) const;
Ref<TileSetSource> get_source(int p_source_id) const;
Ref<LayeredTileSetSource> get_source(int p_source_id) const;
// Rendering
void set_uv_clipping(bool p_uv_clipping);
@ -465,8 +465,8 @@ public:
String get_terrain_name(int p_terrain_set, int p_terrain_index) const;
void set_terrain_color(int p_terrain_set, int p_terrain_index, Color p_color);
Color get_terrain_color(int p_terrain_set, int p_terrain_index) const;
bool is_valid_terrain_peering_bit_for_mode(TileSet::TerrainMode p_terrain_mode, TileSet::CellNeighbor p_peering_bit) const;
bool is_valid_terrain_peering_bit(int p_terrain_set, TileSet::CellNeighbor p_peering_bit) const;
bool is_valid_terrain_peering_bit_for_mode(LayeredTileSet::TerrainMode p_terrain_mode, LayeredTileSet::CellNeighbor p_peering_bit) const;
bool is_valid_terrain_peering_bit(int p_terrain_set, LayeredTileSet::CellNeighbor p_peering_bit) const;
// Navigation
int get_navigation_layers_count() const;
@ -515,31 +515,31 @@ public:
void clear_tile_proxies();
// Patterns.
int add_pattern(Ref<TileMapPattern> p_pattern, int p_index = -1);
Ref<TileMapPattern> get_pattern(int p_index);
int add_pattern(Ref<LayeredTileMapPattern> p_pattern, int p_index = -1);
Ref<LayeredTileMapPattern> get_pattern(int p_index);
void remove_pattern(int p_index);
int get_patterns_count();
// Terrains.
RBSet<TerrainsPattern> get_terrains_pattern_set(int p_terrain_set);
RBSet<TileMapCell> get_tiles_for_terrains_pattern(int p_terrain_set, TerrainsPattern p_terrain_tile_pattern);
TileMapCell get_random_tile_from_terrains_pattern(int p_terrain_set, TerrainsPattern p_terrain_tile_pattern);
RBSet<LayeredTileMapCell> get_tiles_for_terrains_pattern(int p_terrain_set, TerrainsPattern p_terrain_tile_pattern);
LayeredTileMapCell get_random_tile_from_terrains_pattern(int p_terrain_set, TerrainsPattern p_terrain_tile_pattern);
// Helpers
Vector<Vector2> get_tile_shape_polygon() const;
void draw_tile_shape(CanvasItem *p_canvas_item, Transform2D p_transform, Color p_color, bool p_filled = false, Ref<Texture2D> p_texture = Ref<Texture2D>()) const;
// Used by TileMap/TileMapLayer
// Used by LayeredTileMap/LayeredTileMapLayer
Vector2 map_to_local(const Vector2i &p_pos) const;
Vector2i local_to_map(const Vector2 &p_pos) const;
bool is_existing_neighbor(TileSet::CellNeighbor p_cell_neighbor) const;
Vector2i get_neighbor_cell(const Vector2i &p_coords, TileSet::CellNeighbor p_cell_neighbor) const;
bool is_existing_neighbor(LayeredTileSet::CellNeighbor p_cell_neighbor) const;
Vector2i get_neighbor_cell(const Vector2i &p_coords, LayeredTileSet::CellNeighbor p_cell_neighbor) const;
TypedArray<Vector2i> get_surrounding_cells(const Vector2i &p_coords) const;
Vector2i map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref<TileMapPattern> p_pattern) const;
Vector2i map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref<LayeredTileMapPattern> p_pattern) const;
void draw_cells_outline(CanvasItem *p_canvas_item, const RBSet<Vector2i> &p_cells, Color p_color, Transform2D p_transform = Transform2D()) const;
Vector<Point2> get_terrain_polygon(int p_terrain_set);
Vector<Point2> get_terrain_peering_bit_polygon(int p_terrain_set, TileSet::CellNeighbor p_bit);
Vector<Point2> get_terrain_peering_bit_polygon(int p_terrain_set, LayeredTileSet::CellNeighbor p_bit);
void draw_terrains(CanvasItem *p_canvas_item, Transform2D p_transform, const TileData *p_tile_data);
Vector<Vector<Ref<Texture2D>>> generate_terrains_icons(Size2i p_size);
@ -547,17 +547,17 @@ public:
virtual void reset_state() override;
// Helpers.
static Vector2i transform_coords_layout(const Vector2i &p_coords, TileSet::TileOffsetAxis p_offset_axis, TileSet::TileLayout p_from_layout, TileSet::TileLayout p_to_layout);
static Vector2i transform_coords_layout(const Vector2i &p_coords, LayeredTileSet::TileOffsetAxis p_offset_axis, LayeredTileSet::TileLayout p_from_layout, LayeredTileSet::TileLayout p_to_layout);
TileSet();
~TileSet();
LayeredTileSet();
~LayeredTileSet();
};
class TileSetSource : public Resource {
GDCLASS(TileSetSource, Resource);
class LayeredTileSetSource : public Resource {
GDCLASS(LayeredTileSetSource, Resource);
protected:
const TileSet *tile_set = nullptr;
const LayeredTileSet *tile_set = nullptr;
static void _bind_methods();
@ -566,8 +566,8 @@ public:
static const int INVALID_TILE_ALTERNATIVE; // -1;
// Not exposed.
virtual void set_tile_set(const TileSet *p_tile_set);
TileSet *get_tile_set() const;
virtual void set_tile_set(const LayeredTileSet *p_tile_set);
LayeredTileSet *get_tile_set() const;
virtual void notify_tile_data_properties_should_change(){};
virtual void add_occlusion_layer(int p_index){};
virtual void move_occlusion_layer(int p_from_index, int p_to_pos){};
@ -600,8 +600,8 @@ public:
virtual bool has_alternative_tile(const Vector2i p_atlas_coords, int p_alternative_tile) const = 0;
};
class TileSetAtlasSource : public TileSetSource {
GDCLASS(TileSetAtlasSource, TileSetSource);
class LayeredTileSetAtlasSource : public LayeredTileSetSource {
GDCLASS(LayeredTileSetAtlasSource, LayeredTileSetSource);
public:
enum TileAnimationMode {
@ -625,7 +625,7 @@ private:
int animation_columns = 0;
Vector2i animation_separation;
real_t animation_speed = 1.0;
TileSetAtlasSource::TileAnimationMode animation_mode = TILE_ANIMATION_MODE_DEFAULT;
LayeredTileSetAtlasSource::TileAnimationMode animation_mode = TILE_ANIMATION_MODE_DEFAULT;
LocalVector<real_t> animation_frames_durations;
// Alternatives
@ -667,8 +667,8 @@ protected:
public:
// Not exposed.
virtual void set_tile_set(const TileSet *p_tile_set) override;
const TileSet *get_tile_set() const;
virtual void set_tile_set(const LayeredTileSet *p_tile_set) override;
const LayeredTileSet *get_tile_set() const;
virtual void notify_tile_data_properties_should_change() override;
virtual void add_occlusion_layer(int p_index) override;
virtual void move_occlusion_layer(int p_from_index, int p_to_pos) override;
@ -729,8 +729,8 @@ public:
Vector2i get_tile_animation_separation(const Vector2i p_atlas_coords) const;
void set_tile_animation_speed(const Vector2i p_atlas_coords, real_t p_speed);
real_t get_tile_animation_speed(const Vector2i p_atlas_coords) const;
void set_tile_animation_mode(const Vector2i p_atlas_coords, const TileSetAtlasSource::TileAnimationMode p_mode);
TileSetAtlasSource::TileAnimationMode get_tile_animation_mode(const Vector2i p_atlas_coords) const;
void set_tile_animation_mode(const Vector2i p_atlas_coords, const LayeredTileSetAtlasSource::TileAnimationMode p_mode);
LayeredTileSetAtlasSource::TileAnimationMode get_tile_animation_mode(const Vector2i p_atlas_coords) const;
void set_tile_animation_frames_count(const Vector2i p_atlas_coords, int p_frames_count);
int get_tile_animation_frames_count(const Vector2i p_atlas_coords) const;
void set_tile_animation_frame_duration(const Vector2i p_atlas_coords, int p_frame_index, real_t p_duration);
@ -761,11 +761,11 @@ public:
Ref<Texture2D> get_runtime_texture() const;
Rect2i get_runtime_tile_texture_region(Vector2i p_atlas_coords, int p_frame = 0) const;
~TileSetAtlasSource();
~LayeredTileSetAtlasSource();
};
class TileSetScenesCollectionSource : public TileSetSource {
GDCLASS(TileSetScenesCollectionSource, TileSetSource);
class LayeredTileSetScenesCollectionSource : public LayeredTileSetSource {
GDCLASS(LayeredTileSetScenesCollectionSource, LayeredTileSetSource);
private:
struct SceneData {
@ -814,7 +814,7 @@ class TileData : public Object {
GDCLASS(TileData, Object);
private:
const TileSet *tile_set = nullptr;
const LayeredTileSet *tile_set = nullptr;
bool allow_transform = true;
// Rendering
@ -882,7 +882,7 @@ protected:
public:
// Not exposed.
void set_tile_set(const TileSet *p_tile_set);
void set_tile_set(const LayeredTileSet *p_tile_set);
void notify_tile_data_properties_should_change();
void add_occlusion_layer(int p_index);
void move_occlusion_layer(int p_from_index, int p_to_pos);
@ -953,11 +953,11 @@ public:
int get_terrain_set() const;
void set_terrain(int p_terrain_id);
int get_terrain() const;
void set_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit, int p_terrain_id);
int get_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit) const;
bool is_valid_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit) const;
void set_terrain_peering_bit(LayeredTileSet::CellNeighbor p_peering_bit, int p_terrain_id);
int get_terrain_peering_bit(LayeredTileSet::CellNeighbor p_peering_bit) const;
bool is_valid_terrain_peering_bit(LayeredTileSet::CellNeighbor p_peering_bit) const;
TileSet::TerrainsPattern get_terrains_pattern() const; // Not exposed.
LayeredTileSet::TerrainsPattern get_terrains_pattern() const; // Not exposed.
// Navigation
void set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon);
@ -977,12 +977,12 @@ public:
static PackedVector2Array get_transformed_vertices(const PackedVector2Array &p_vertices, bool p_flip_h, bool p_flip_v, bool p_transpose);
};
VARIANT_ENUM_CAST(TileSet::CellNeighbor);
VARIANT_ENUM_CAST(TileSet::TerrainMode);
VARIANT_ENUM_CAST(TileSet::TileShape);
VARIANT_ENUM_CAST(TileSet::TileLayout);
VARIANT_ENUM_CAST(TileSet::TileOffsetAxis);
VARIANT_ENUM_CAST(LayeredTileSet::CellNeighbor);
VARIANT_ENUM_CAST(LayeredTileSet::TerrainMode);
VARIANT_ENUM_CAST(LayeredTileSet::TileShape);
VARIANT_ENUM_CAST(LayeredTileSet::TileLayout);
VARIANT_ENUM_CAST(LayeredTileSet::TileOffsetAxis);
VARIANT_ENUM_CAST(TileSetAtlasSource::TileAnimationMode);
VARIANT_ENUM_CAST(LayeredTileSetAtlasSource::TileAnimationMode);
#endif // TILE_SET_H

View File

@ -44,16 +44,16 @@
void register_tile_map_types(ModuleRegistrationLevel p_level) {
if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) {
ClassDB::register_class<TileMap>();
ClassDB::register_class<TileSet>();
ClassDB::register_class<LayeredTileMap>();
ClassDB::register_class<LayeredTileSet>();
NavigationMeshGenerator::get_singleton()->register_geometry_parser_2d(memnew(TileMap2DNavigationGeometryParser2D));
NavigationMeshGenerator::get_singleton()->register_geometry_parser_2d(memnew(LayeredTileMap2DNavigationGeometryParser2D));
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_REGISTRATION_LEVEL_EDITOR) {
EditorPlugins::add_by_type<TileMapEditorPlugin>();
EditorPlugins::add_by_type<TileSetEditorPlugin>();
EditorPlugins::add_by_type<LayeredTileMapEditorPlugin>();
EditorPlugins::add_by_type<LayeredTileSetEditorPlugin>();
}
#endif
}