From b8d5c3b0037e16336aa1259849e46f7f4535db0a Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 29 Apr 2022 17:47:47 +0800 Subject: [PATCH] Fix issues when skipping l10n for script variables --- editor/editor_inspector.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 981c0d3e2c7..32a64f64e87 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1465,8 +1465,6 @@ void EditorInspector::update_tree() { _parse_added_editors(main_vbox, ped); } - bool in_script_variables = false; - for (List::Element *I = plist.front(); I; I = I->next()) { PropertyInfo &p = I->get(); @@ -1507,8 +1505,6 @@ void EditorInspector::update_tree() { main_vbox->add_child(category); category_vbox = nullptr; //reset - in_script_variables = p.name == "Script Variables"; - String type = p.name; category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object"); category->label = type; @@ -1577,9 +1573,9 @@ void EditorInspector::update_tree() { } } - // Don't localize properties in Script Variables category. + // Don't localize script variables. EditorPropertyNameProcessor::Style name_style = property_name_style; - if (in_script_variables && name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) { + if ((p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) && name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) { name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED; } name = EditorPropertyNameProcessor::get_singleton()->process_name(name_override, name_style) + feature_tag; @@ -1617,9 +1613,15 @@ void EditorInspector::update_tree() { String label; String tooltip; + // Don't localize groups for script variables. + EditorPropertyNameProcessor::Style section_name_style = property_name_style; + if ((p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) && section_name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) { + section_name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED; + } + // Only process group label if this is not the group or subgroup. if ((i == 0 && path_name == group)) { - if (property_name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) { + if (section_name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) { label = TTRGET(path_name); tooltip = path_name; } else { @@ -1627,8 +1629,8 @@ void EditorInspector::update_tree() { tooltip = TTRGET(path_name); } } else { - label = EditorPropertyNameProcessor::get_singleton()->process_name(path_name, property_name_style); - tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(path_name, EditorPropertyNameProcessor::get_tooltip_style(property_name_style)); + label = EditorPropertyNameProcessor::get_singleton()->process_name(path_name, section_name_style); + tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(path_name, EditorPropertyNameProcessor::get_tooltip_style(section_name_style)); } Color c = sscolor;