Przeglądaj źródła

Remember selected subtile when updating the TileMap editor

Fixes #29444.

(cherry picked from commit 0a03ed7544893038f17445df536366ee863f2f36)
Michael Alexsander Silva Dias 6 lat temu
rodzic
commit
02ccd4d78c
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6 3
      editor/plugins/tile_map_editor_plugin.cpp

+ 6 - 3
editor/plugins/tile_map_editor_plugin.cpp

@@ -363,6 +363,8 @@ void TileMapEditor::_update_palette() {
 
 	// Update the palette
 	Vector<int> selected = get_selected_tiles();
+	int selected_single = palette->get_current();
+	int selected_manual = manual_palette->get_current();
 	palette->clear();
 	manual_palette->clear();
 	manual_palette->hide();
@@ -511,9 +513,10 @@ void TileMapEditor::_update_palette() {
 
 	if (manual_palette->get_item_count() > 0) {
 		// Only show the manual palette if at least tile exists in it
-		int selected2 = manual_palette->get_current();
-		if (selected2 == -1) selected2 = 0;
-		manual_palette->set_current(selected2);
+		if (selected_manual == -1 || selected_single != palette->get_current())
+			selected_manual = 0;
+		if (selected_manual < manual_palette->get_item_count())
+			manual_palette->set_current(selected_manual);
 		manual_palette->show();
 	}