Skip to content

Commit

Permalink
Merge pull request #91905 from groud/fix_patterns_being_needlessly_re…
Browse files Browse the repository at this point in the history
…organized

Fix TileMap selection pattern being needlessly reorganized
  • Loading branch information
akien-mga committed May 14, 2024
2 parents a8c6eb3 + b0cd6ed commit e58eb6a
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions editor/plugins/tiles/tile_map_layer_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ void TileMapLayerEditorTilesPlugin::_update_fix_selected_and_hovered() {
hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
}

// Selection if needed.
// Cleanup tile set selection.
for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E;) {
RBSet<TileMapCell>::Element *N = E->next();
const TileMapCell *selected = &(E->get());
Expand All @@ -1640,12 +1640,15 @@ void TileMapLayerEditorTilesPlugin::_update_fix_selected_and_hovered() {
E = N;
}

if (!tile_map_selection.is_empty()) {
_update_selection_pattern_from_tilemap_selection();
} else if (tiles_bottom_panel->is_visible_in_tree()) {
_update_selection_pattern_from_tileset_tiles_selection();
} else {
_update_selection_pattern_from_tileset_pattern_selection();
// Cleanup selection.
for (const KeyValue<Vector2i, TileMapCell> &E : selection_pattern->get_pattern()) {
const Vector2i key = E.key;
const TileMapCell &selected = E.value;
if (!tile_set->has_source(selected.source_id) ||
!tile_set->get_source(selected.source_id)->has_tile(selected.get_atlas_coords()) ||
!tile_set->get_source(selected.source_id)->has_alternative_tile(selected.get_atlas_coords(), selected.alternative_tile)) {
selection_pattern->remove_cell(key);
}
}
}

Expand Down Expand Up @@ -2409,7 +2412,6 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() {
sources_list->set_stretch_ratio(0.25);
sources_list->set_custom_minimum_size(Size2(70, 0) * EDSCALE);
sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
sources_list->connect("item_selected", callable_mp(this, &TileMapLayerEditorTilesPlugin::_update_fix_selected_and_hovered).unbind(1));
sources_list->connect("item_selected", callable_mp(this, &TileMapLayerEditorTilesPlugin::_update_source_display).unbind(1));
sources_list->connect("item_selected", callable_mp(TilesEditorUtils::get_singleton(), &TilesEditorUtils::set_sources_lists_current));
sources_list->connect("item_activated", callable_mp(TilesEditorUtils::get_singleton(), &TilesEditorUtils::display_tile_set_editor_panel).unbind(1));
Expand Down Expand Up @@ -3980,10 +3982,14 @@ void TileMapLayerEditor::_update_bottom_panel() {
}

// Update tabs visibility.
for (TileMapLayerSubEditorPlugin::TabData &tab_data : tabs_data) {
tab_data.panel->hide();
for (int i = 0; i < int(tabs_data.size()); i++) {
TileMapLayerSubEditorPlugin::TabData &tab_data = tabs_data[i];
if (i == tabs_bar->get_current_tab()) {
tab_data.panel->set_visible(!cant_edit_label->is_visible());
} else {
tab_data.panel->hide();
}
}
tabs_data[tabs_bar->get_current_tab()].panel->set_visible(!cant_edit_label->is_visible());
}

Vector<Vector2i> TileMapLayerEditor::get_line(const TileMapLayer *p_tile_map_layer, Vector2i p_from_cell, Vector2i p_to_cell) {
Expand Down

0 comments on commit e58eb6a

Please sign in to comment.