mirror of
https://github.com/godotengine/godot.git
synced 2024-12-13 14:44:23 +00:00
Let TileSet editor sanitize out tiles with wrong textures
This commit is contained in:
parent
d2b0f69a64
commit
d856ec611a
@ -2111,13 +2111,24 @@ void TileSetEditor::update_texture_list() {
|
|||||||
|
|
||||||
List<int> ids;
|
List<int> ids;
|
||||||
tileset->get_tile_list(&ids);
|
tileset->get_tile_list(&ids);
|
||||||
|
Vector<int> ids_to_remove;
|
||||||
for (List<int>::Element *E = ids.front(); E; E = E->next()) {
|
for (List<int>::Element *E = ids.front(); E; E = E->next()) {
|
||||||
|
// Clear tiles referencing gone textures (user has been already given the chance to fix broken deps)
|
||||||
|
if (!tileset->tile_get_texture(E->get()).is_valid()) {
|
||||||
|
ids_to_remove.push_back(E->get());
|
||||||
|
ERR_CONTINUE(!tileset->tile_get_texture(E->get()).is_valid());
|
||||||
|
}
|
||||||
|
|
||||||
if (!texture_map.has(tileset->tile_get_texture(E->get())->get_rid())) {
|
if (!texture_map.has(tileset->tile_get_texture(E->get())->get_rid())) {
|
||||||
texture_list->add_item(tileset->tile_get_texture(E->get())->get_path().get_file());
|
texture_list->add_item(tileset->tile_get_texture(E->get())->get_path().get_file());
|
||||||
texture_map.insert(tileset->tile_get_texture(E->get())->get_rid(), tileset->tile_get_texture(E->get()));
|
texture_map.insert(tileset->tile_get_texture(E->get())->get_rid(), tileset->tile_get_texture(E->get()));
|
||||||
texture_list->set_item_metadata(texture_list->get_item_count() - 1, tileset->tile_get_texture(E->get())->get_rid());
|
texture_list->set_item_metadata(texture_list->get_item_count() - 1, tileset->tile_get_texture(E->get())->get_rid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < ids_to_remove.size(); i++) {
|
||||||
|
tileset->remove_tile(ids_to_remove[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (texture_list->get_item_count() > 0 && selected_texture.is_valid()) {
|
if (texture_list->get_item_count() > 0 && selected_texture.is_valid()) {
|
||||||
texture_list->select(texture_list->find_metadata(selected_texture->get_rid()));
|
texture_list->select(texture_list->find_metadata(selected_texture->get_rid()));
|
||||||
if (texture_list->get_selected_items().size() > 0)
|
if (texture_list->get_selected_items().size() > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user