Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TileMap selection pattern being needlessly reorganized #91905

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading