From d4ac65bc48aeda1e22a78c017110951a6aa4444b Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Thu, 7 Sep 2023 19:04:28 +0800 Subject: [PATCH] Fix property array tooltip shows wrong ID on later pages Also do some cleanup, use`element_position` instead of `begin_array_index + i` --- editor/editor_inspector.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index db61700c001..87a5fdfe9ef 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2089,8 +2089,10 @@ void EditorInspectorArray::_setup() { ae.panel->set_focus_mode(FOCUS_ALL); ae.panel->set_mouse_filter(MOUSE_FILTER_PASS); SET_DRAG_FORWARDING_GCD(ae.panel, EditorInspectorArray); - ae.panel->set_meta("index", begin_array_index + i); - ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), i, array_element_prefix, i)); + + int element_position = begin_array_index + i; + ae.panel->set_meta("index", element_position); + ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), element_position, array_element_prefix, element_position)); ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); ae.panel->connect("draw", callable_mp(this, &EditorInspectorArray::_panel_draw).bind(i)); @@ -2116,7 +2118,6 @@ void EditorInspectorArray::_setup() { // Move button. if (movable) { - int element_position = begin_array_index + i; VBoxContainer *move_vbox = memnew(VBoxContainer); move_vbox->set_v_size_flags(SIZE_EXPAND_FILL); move_vbox->set_alignment(BoxContainer::ALIGNMENT_CENTER); @@ -2152,7 +2153,7 @@ void EditorInspectorArray::_setup() { ae.number->set_custom_minimum_size(Size2(numbers_min_w, 0)); ae.number->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT); ae.number->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); - ae.number->set_text(itos(begin_array_index + i)); + ae.number->set_text(itos(element_position)); ae.hbox->add_child(ae.number); } @@ -2165,7 +2166,7 @@ void EditorInspectorArray::_setup() { ae.erase = memnew(Button); ae.erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); ae.erase->set_v_size_flags(SIZE_SHRINK_CENTER); - ae.erase->connect("pressed", callable_mp(this, &EditorInspectorArray::_remove_item).bind(begin_array_index + i)); + ae.erase->connect("pressed", callable_mp(this, &EditorInspectorArray::_remove_item).bind(element_position)); ae.hbox->add_child(ae.erase); }