From b7582227611925ad4ce216d894dfb8cdfbad3524 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 16 May 2024 15:47:23 +0200 Subject: [PATCH] Allow selecting TileMapLayers by clicking them --- scene/2d/tile_map_layer.cpp | 6 ++++++ scene/2d/tile_map_layer.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/scene/2d/tile_map_layer.cpp b/scene/2d/tile_map_layer.cpp index 03fd7364c00..105790916be 100644 --- a/scene/2d/tile_map_layer.cpp +++ b/scene/2d/tile_map_layer.cpp @@ -1829,6 +1829,12 @@ void TileMapLayer::_update_self_texture_repeat(RS::CanvasItemTextureRepeat p_tex emit_signal(CoreStringName(changed)); } +#ifdef TOOLS_ENABLED +bool TileMapLayer::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { + return get_cell_source_id(local_to_map(p_point)) != TileSet::INVALID_SOURCE; +} +#endif + void TileMapLayer::set_as_tile_map_internal_node(int p_index) { // Compatibility with TileMap. ERR_FAIL_NULL(get_parent()); diff --git a/scene/2d/tile_map_layer.h b/scene/2d/tile_map_layer.h index 5861433c8ad..56b04a495ea 100644 --- a/scene/2d/tile_map_layer.h +++ b/scene/2d/tile_map_layer.h @@ -386,6 +386,10 @@ protected: virtual void _update_self_texture_repeat(RS::CanvasItemTextureRepeat p_texture_repeat) override; public: +#ifdef TOOLS_ENABLED + virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override; +#endif + // TileMap node. void set_as_tile_map_internal_node(int p_index); int get_index_in_tile_map() const {