diff --git a/modules/layered_tile_map/editor/atlas_merging_dialog.cpp b/modules/layered_tile_map/editor/atlas_merging_dialog.cpp index d45399ee6..8ff945b44 100644 --- a/modules/layered_tile_map/editor/atlas_merging_dialog.cpp +++ b/modules/layered_tile_map/editor/atlas_merging_dialog.cpp @@ -309,7 +309,7 @@ void AtlasMergingDialog::update_tile_set(Ref p_tile_set) { if (texture.is_valid()) { String item_text = vformat(TTR("%s (ID: %d)"), texture->get_path().get_file(), source_id); atlas_merging_atlases_list->add_item(item_text, texture); - atlas_merging_atlases_list->set_item_metadata(-1, source_id); + atlas_merging_atlases_list->set_item_metadata(atlas_merging_atlases_list->get_item_count() - 1, source_id); } } } diff --git a/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp b/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp index aa01983e7..1db985479 100644 --- a/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp +++ b/modules/layered_tile_map/editor/layered_tile_map_layer_editor.cpp @@ -246,7 +246,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_tile_set_sources_list() { } sources_list->add_item(item_text, texture); - sources_list->set_item_metadata(-1, source_id); + sources_list->set_item_metadata(sources_list->get_item_count() - 1, source_id); } if (sources_list->get_item_count() > 0) { @@ -466,7 +466,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_scenes_collection_view() { } if (scene_tiles_list->get_item_count() == 0) { scene_tiles_list->add_item(TTR("The selected scene collection source has no scenes. Add scenes in the LayeredTileSet bottom tab.")); - scene_tiles_list->set_item_disabled(-1, true); + scene_tiles_list->set_item_disabled(scene_tiles_list->get_item_count() - 1, true); } // Icon size update. diff --git a/modules/layered_tile_map/editor/layered_tile_set_editor.cpp b/modules/layered_tile_map/editor/layered_tile_set_editor.cpp index 11638b289..6a9736bea 100644 --- a/modules/layered_tile_map/editor/layered_tile_set_editor.cpp +++ b/modules/layered_tile_map/editor/layered_tile_set_editor.cpp @@ -220,7 +220,7 @@ void LayeredTileSetEditor::_update_sources_list(int force_selected_id) { } sources_list->add_item(item_text, texture); - sources_list->set_item_metadata(-1, source_id); + sources_list->set_item_metadata(sources_list->get_item_count() - 1, source_id); } // Set again the current selected item if needed. diff --git a/modules/layered_tile_map/editor/layered_tile_set_scenes_collection_source_editor.cpp b/modules/layered_tile_map/editor/layered_tile_set_scenes_collection_source_editor.cpp index a2f5d3572..cbcea42ff 100644 --- a/modules/layered_tile_map/editor/layered_tile_set_scenes_collection_source_editor.cpp +++ b/modules/layered_tile_map/editor/layered_tile_set_scenes_collection_source_editor.cpp @@ -351,7 +351,7 @@ void LayeredTileSetScenesCollectionSourceEditor::_update_scenes_list() { } if (scene_tiles_list->get_item_count() == 0) { scene_tiles_list->add_item(TTR("Drag and drop scenes here or use the Add button.")); - scene_tiles_list->set_item_disabled(-1, true); + scene_tiles_list->set_item_disabled(scene_tiles_list->get_item_count() - 1, true); } // Reselect if needed.