1
0
Fork 0

Preview Dictionary and Array values in the inspector instead of showing size.

This commit is contained in:
Pāvels Nadtočajevs 2025-01-09 10:18:46 +02:00
parent 0e3a5eda86
commit 97167ee7ee
2 changed files with 4 additions and 12 deletions

View File

@ -412,7 +412,7 @@ void EditorPropertyArray::update_property() {
edit->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); edit->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
edit->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT); edit->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
edit->set_button_icon(get_editor_theme_icon(array_type_name)); edit->set_button_icon(get_editor_theme_icon(array_type_name));
edit->set_text(vformat("%s%s", array_sub_type_name, ctr_str)); edit->set_text(vformat("%s(%d) - %s", array_sub_type_name, size, ctr_str));
edit->set_tooltip_text(vformat(TTR("%s%s (size %d)"), array_type_name, array_sub_type_name, size)); edit->set_tooltip_text(vformat(TTR("%s%s (size %d)"), array_type_name, array_sub_type_name, size));
} else { } else {
edit->set_text_alignment(HORIZONTAL_ALIGNMENT_CENTER); edit->set_text_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@ -1184,7 +1184,7 @@ void EditorPropertyDictionary::update_property() {
edit->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); edit->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
edit->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT); edit->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
edit->set_button_icon(get_editor_theme_icon(dict_type_name)); edit->set_button_icon(get_editor_theme_icon(dict_type_name));
edit->set_text(vformat("%s%s", dict_sub_type_name, ctr_str)); edit->set_text(vformat("%s(%d) - %s", dict_sub_type_name, dict.size(), ctr_str));
edit->set_tooltip_text(vformat(TTR("%s%s (size %d)"), dict_type_name, dict_sub_type_name, dict.size())); edit->set_tooltip_text(vformat(TTR("%s%s (size %d)"), dict_type_name, dict_sub_type_name, dict.size()));
} else { } else {
edit->set_text_alignment(HORIZONTAL_ALIGNMENT_CENTER); edit->set_text_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@ -1282,14 +1282,6 @@ void EditorPropertyDictionary::update_property() {
new_prop->set_use_folding(is_using_folding()); new_prop->set_use_folding(is_using_folding());
new_prop->set_h_size_flags(SIZE_EXPAND_FILL); new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
new_prop->set_draw_label(false); new_prop->set_draw_label(false);
EditorPropertyArray *arr_prop = Object::cast_to<EditorPropertyArray>(new_prop);
if (arr_prop) {
arr_prop->set_preview_value(true);
}
EditorPropertyDictionary *dict_prop = Object::cast_to<EditorPropertyDictionary>(new_prop);
if (dict_prop) {
dict_prop->set_preview_value(true);
}
slot.set_key_prop(new_prop); slot.set_key_prop(new_prop);
} }
} }

View File

@ -115,7 +115,7 @@ class EditorPropertyArray : public EditorProperty {
PopupMenu *change_type = nullptr; PopupMenu *change_type = nullptr;
bool preview_value = false; bool preview_value = true;
int page_length = 20; int page_length = 20;
int page_index = 0; int page_index = 0;
int changing_type_index = EditorPropertyArrayObject::NOT_CHANGING_TYPE; int changing_type_index = EditorPropertyArrayObject::NOT_CHANGING_TYPE;
@ -228,7 +228,7 @@ class EditorPropertyDictionary : public EditorProperty {
PopupMenu *change_type = nullptr; PopupMenu *change_type = nullptr;
bool updating = false; bool updating = false;
bool preview_value = false; bool preview_value = true;
Ref<EditorPropertyDictionaryObject> object; Ref<EditorPropertyDictionaryObject> object;
int page_length = 20; int page_length = 20;
int page_index = 0; int page_index = 0;