diff options
author | kobewi <kobewi4e@gmail.com> | 2022-10-07 22:27:31 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-10-26 14:27:58 +0200 |
commit | 64fc443e2416a9c27b15010e8e0bfeb424c5436c (patch) | |
tree | eb75b68dd0586390fe7fc1a82e80bea227bfecb9 | |
parent | 2b505b74b9b0a7005586ecaa9aa1236e86b18437 (diff) |
Warn if isometric TileMap is not Y-sorted
-rw-r--r-- | doc/classes/TileSet.xml | 1 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml index 7ced16d1af..1cf3d4bf21 100644 --- a/doc/classes/TileSet.xml +++ b/doc/classes/TileSet.xml @@ -617,6 +617,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. </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. diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index e865806a7f..c3b6de985b 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -755,6 +755,7 @@ void TileMap::set_y_sort_enabled(bool p_enable) { _clear_internals(); _recreate_internals(); emit_signal(SNAME("changed")); + update_configuration_warnings(); } Vector2i TileMap::_coords_to_quadrant_coords(int p_layer, const Vector2i &p_coords) const { @@ -3943,6 +3944,22 @@ PackedStringArray TileMap::get_configuration_warnings() const { } } + if (tile_set.is_valid() && tile_set->get_tile_shape() == TileSet::TILE_SHAPE_ISOMETRIC) { + bool warn = !is_y_sort_enabled(); + if (!warn) { + for (int layer = 0; layer < (int)layers.size(); layer++) { + if (!layers[layer].y_sort_enabled) { + warn = true; + break; + } + } + } + + 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.")); + } + } + return warnings; } @@ -4038,6 +4055,7 @@ void TileMap::_tile_set_changed() { emit_signal(SNAME("changed")); _tile_set_changed_deferred_update_needed = true; call_deferred(SNAME("_tile_set_changed_deferred_update")); + update_configuration_warnings(); } void TileMap::_tile_set_changed_deferred_update() { |