diff options
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r-- | editor/editor_inspector.cpp | 320 |
1 files changed, 157 insertions, 163 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 4dd57cb1a8..3db03c0276 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -41,8 +41,8 @@ Size2 EditorProperty::get_minimum_size() const { Size2 ms; - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); ms.height = font->get_height(font_size); for (int i = 0; i < get_child_count(); i++) { @@ -66,22 +66,22 @@ Size2 EditorProperty::get_minimum_size() const { } if (keying) { - Ref<Texture2D> key = get_theme_icon("Key", "EditorIcons"); - ms.width += key->get_width() + get_theme_constant("hseparator", "Tree"); + Ref<Texture2D> key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); + ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (deletable) { - Ref<Texture2D> key = get_theme_icon("Close", "EditorIcons"); - ms.width += key->get_width() + get_theme_constant("hseparator", "Tree"); + Ref<Texture2D> key = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); + ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (checkable) { - Ref<Texture2D> check = get_theme_icon("checked", "CheckBox"); - ms.width += check->get_width() + get_theme_constant("hseparation", "CheckBox") + get_theme_constant("hseparator", "Tree"); + Ref<Texture2D> check = get_theme_icon(SNAME("checked"), SNAME("CheckBox")); + ms.width += check->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox")) + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (bottom_editor != nullptr && bottom_editor->is_visible()) { - ms.height += get_theme_constant("vseparation"); + ms.height += get_theme_constant(SNAME("vseparation")); Size2 bems = bottom_editor->get_combined_minimum_size(); //bems.width += get_constant("item_margin", "Tree"); ms.height += bems.height; @@ -96,7 +96,7 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p const Variant *argptrs[4] = { &args[0], &args[1], &args[2], &args[3] }; cache[p_property] = p_value; - emit_signal("property_changed", (const Variant **)argptrs, 4); + emit_signal(SNAME("property_changed"), (const Variant **)argptrs, 4); } void EditorProperty::_notification(int p_what) { @@ -110,8 +110,8 @@ void EditorProperty::_notification(int p_what) { { int child_room = size.width * (1.0 - split_ratio); - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); int height = font->get_height(font_size); bool no_children = true; @@ -149,21 +149,21 @@ void EditorProperty::_notification(int p_what) { if (bottom_editor) { int m = 0; //get_constant("item_margin", "Tree"); - bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation"), size.width - m, bottom_editor->get_combined_minimum_size().height); + bottom_rect = Rect2(m, rect.size.height + get_theme_constant(SNAME("vseparation")), size.width - m, bottom_editor->get_combined_minimum_size().height); } if (keying) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_theme_icon("KeyNext", "EditorIcons"); + key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons")); } else { - key = get_theme_icon("Key", "EditorIcons"); + key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); } - rect.size.x -= key->get_width() + get_theme_constant("hseparator", "Tree"); + rect.size.x -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); if (is_layout_rtl()) { - rect.position.x += key->get_width() + get_theme_constant("hseparator", "Tree"); + rect.position.x += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (no_children) { @@ -174,12 +174,12 @@ void EditorProperty::_notification(int p_what) { if (deletable) { Ref<Texture2D> close; - close = get_theme_icon("Close", "EditorIcons"); + close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); - rect.size.x -= close->get_width() + get_theme_constant("hseparator", "Tree"); + rect.size.x -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); if (is_layout_rtl()) { - rect.position.x += close->get_width() + get_theme_constant("hseparator", "Tree"); + rect.position.x += close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (no_children) { @@ -214,9 +214,9 @@ void EditorProperty::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); - Color dark_color = get_theme_color("dark_color_2", "Editor"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); + Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); bool rtl = is_layout_rtl(); Size2 size = get_size(); @@ -228,9 +228,9 @@ void EditorProperty::_notification(int p_what) { Ref<StyleBox> sb; if (selected) { - sb = get_theme_stylebox("bg_selected"); + sb = get_theme_stylebox(SNAME("bg_selected")); } else { - sb = get_theme_stylebox("bg"); + sb = get_theme_stylebox(SNAME("bg")); } draw_style_box(sb, Rect2(Vector2(), size)); @@ -244,23 +244,23 @@ void EditorProperty::_notification(int p_what) { Color color; if (draw_red) { - color = get_theme_color("error_color"); + color = get_theme_color(SNAME("error_color")); } else { - color = get_theme_color("property_color"); + color = get_theme_color(SNAME("property_color")); } if (label.find(".") != -1) { color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides } - int ofs = get_theme_constant("font_offset"); + int ofs = get_theme_constant(SNAME("font_offset")); int text_limit = text_size; if (checkable) { Ref<Texture2D> checkbox; if (checked) { - checkbox = get_theme_icon("GuiChecked", "EditorIcons"); + checkbox = get_theme_icon(SNAME("GuiChecked"), SNAME("EditorIcons")); } else { - checkbox = get_theme_icon("GuiUnchecked", "EditorIcons"); + checkbox = get_theme_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")); } Color color2(1, 1, 1); @@ -275,16 +275,16 @@ void EditorProperty::_notification(int p_what) { } else { draw_texture(checkbox, check_rect.position, color2); } - ofs += get_theme_constant("hseparator", "Tree") + checkbox->get_width() + get_theme_constant("hseparation", "CheckBox"); + ofs += get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox")); text_limit -= ofs; } else { check_rect = Rect2(); } if (can_revert) { - Ref<Texture2D> reload_icon = get_theme_icon("ReloadSmall", "EditorIcons"); - text_limit -= reload_icon->get_width() + get_theme_constant("hseparator", "Tree") * 2; - revert_rect = Rect2(text_limit + get_theme_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); + Ref<Texture2D> reload_icon = get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons")); + text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2; + revert_rect = Rect2(text_limit + get_theme_constant(SNAME("hseparator"), SNAME("Tree")), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); Color color2(1, 1, 1); if (revert_hover) { @@ -312,12 +312,12 @@ void EditorProperty::_notification(int p_what) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_theme_icon("KeyNext", "EditorIcons"); + key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons")); } else { - key = get_theme_icon("Key", "EditorIcons"); + key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); } - ofs = size.width - key->get_width() - get_theme_constant("hseparator", "Tree"); + ofs = size.width - key->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree")); Color color2(1, 1, 1); if (keying_hover) { @@ -339,9 +339,9 @@ void EditorProperty::_notification(int p_what) { if (deletable) { Ref<Texture2D> close; - close = get_theme_icon("Close", "EditorIcons"); + close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); - ofs = size.width - close->get_width() - get_theme_constant("hseparator", "Tree"); + ofs = size.width - close->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree")); Color color2(1, 1, 1); if (delete_hover) { @@ -646,7 +646,7 @@ void EditorProperty::_focusable_focused(int p_index) { selected_focusable = p_index; update(); if (!already_selected && selected) { - emit_signal("selected", property, selected_focusable); + emit_signal(SNAME("selected"), property, selected_focusable); } } @@ -667,7 +667,7 @@ void EditorProperty::select(int p_focusable) { } if (!already_selected && selected) { - emit_signal("selected", property, selected_focusable); + emit_signal(SNAME("selected"), property, selected_focusable); } } @@ -732,12 +732,12 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { if (!selected && selectable) { selected = true; - emit_signal("selected", property, -1); + emit_signal(SNAME("selected"), property, -1); update(); } if (keying_rect.has_point(mpos)) { - emit_signal("property_keyed", property, use_keying_next()); + emit_signal(SNAME("property_keyed"), property, use_keying_next()); if (use_keying_next()) { if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) { @@ -748,16 +748,16 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { new_coords.y++; } - call_deferred("emit_changed", property, new_coords, "", false); + call_deferred(SNAME("emit_changed"), property, new_coords, "", false); } else { - call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false); + call_deferred(SNAME("emit_changed"), property, object->get(property).operator int64_t() + 1, "", false); } - call_deferred("_update_property"); + call_deferred(SNAME("_update_property")); } } if (delete_rect.has_point(mpos)) { - emit_signal("property_deleted", property); + emit_signal(SNAME("property_deleted"), property); } if (revert_rect.has_point(mpos)) { @@ -799,7 +799,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { if (check_rect.has_point(mpos)) { checked = !checked; update(); - emit_signal("property_checked", property, checked); + emit_signal(SNAME("property_checked"), property, checked); } } } @@ -889,7 +889,7 @@ void EditorProperty::set_object_and_property(Object *p_object, const StringName Control *EditorProperty::make_custom_tooltip(const String &p_text) const { tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); - //help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + //help_bit->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); String text; @@ -1076,14 +1076,14 @@ void EditorInspectorPlugin::_bind_methods() { void EditorInspectorCategory::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> sb = get_theme_stylebox("prop_category_style", "Editor"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("prop_category_style"), SNAME("Editor")); draw_style_box(sb, Rect2(Vector2(), get_size())); - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); - int hs = get_theme_constant("hseparation", "Tree"); + int hs = get_theme_constant(SNAME("hseparation"), SNAME("Tree")); int w = font->get_string_size(label, font_size).width; if (icon.is_valid()) { @@ -1097,7 +1097,7 @@ void EditorInspectorCategory::_notification(int p_what) { ofs += hs + icon->get_width(); } - Color color = get_theme_color("font_color", "Tree"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Tree")); draw_string(font, Point2(ofs, font->get_ascent(font_size) + (get_size().height - font->get_height(font_size)) / 2).floor(), label, HALIGN_LEFT, get_size().width, font_size, color); } } @@ -1105,7 +1105,7 @@ void EditorInspectorCategory::_notification(int p_what) { Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const { tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + help_bit->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); PackedStringArray slices = p_text.split("::", false); @@ -1126,8 +1126,8 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons } Size2 EditorInspectorCategory::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); Size2 ms; ms.width = 1; @@ -1135,7 +1135,7 @@ Size2 EditorInspectorCategory::get_minimum_size() const { if (icon.is_valid()) { ms.height = MAX(icon->get_height(), ms.height); } - ms.height += get_theme_constant("vseparation", "Tree"); + ms.height += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); return ms; } @@ -1163,19 +1163,19 @@ void EditorInspectorSection::_test_unfold() { void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { - arrow = get_theme_icon("arrow", "Tree"); + arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree")); } else { if (is_layout_rtl()) { - arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree")); } else { - arrow = get_theme_icon("arrow_collapsed", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree")); } } } @@ -1188,11 +1188,11 @@ void EditorInspectorSection::_notification(int p_what) { offset.y = MAX(offset.y, arrow->get_height()); } - offset.y += get_theme_constant("vseparation", "Tree"); + offset.y += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); if (is_layout_rtl()) { - rect = Rect2(offset, size - offset - Vector2(get_theme_constant("inspector_margin", "Editor"), 0)); + rect = Rect2(offset, size - offset - Vector2(get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")), 0)); } else { - offset.x += get_theme_constant("inspector_margin", "Editor"); + offset.x += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); rect = Rect2(offset, size - offset); } @@ -1221,24 +1221,24 @@ void EditorInspectorSection::_notification(int p_what) { if (foldable) { if (object->editor_is_section_unfolded(section)) { - arrow = get_theme_icon("arrow", "Tree"); + arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree")); } else { if (is_layout_rtl()) { - arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree")); } else { - arrow = get_theme_icon("arrow_collapsed", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree")); } } } - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); int h = font->get_height(font_size); if (arrow.is_valid()) { h = MAX(h, arrow->get_height()); } - h += get_theme_constant("vseparation", "Tree"); + h += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); Color c = bg_color; c.a *= 0.4; @@ -1246,7 +1246,7 @@ void EditorInspectorSection::_notification(int p_what) { const int arrow_margin = 2; const int arrow_width = arrow.is_valid() ? arrow->get_width() : 0; - Color color = get_theme_color("font_color"); + Color color = get_theme_color(SNAME("font_color")); float text_width = get_size().width - Math::round(arrow_width + arrow_margin * EDSCALE); draw_string(font, Point2(rtl ? 0 : Math::round(arrow_width + arrow_margin * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color); @@ -1259,7 +1259,7 @@ void EditorInspectorSection::_notification(int p_what) { } if (dropping && !vbox->is_visible_in_tree()) { - Color accent_color = get_theme_color("accent_color", "Editor"); + Color accent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(Rect2(Point2(), get_size()), accent_color, false); } } @@ -1319,10 +1319,10 @@ Size2 EditorInspectorSection::get_minimum_size() const { ms.height = MAX(ms.height, minsize.height); } - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); - ms.height += font->get_height(font_size) + get_theme_constant("vseparation", "Tree"); - ms.width += get_theme_constant("inspector_margin", "Editor"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); + ms.height += font->get_height(font_size) + get_theme_constant(SNAME("vseparation"), SNAME("Tree")); + ms.width += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); return ms; } @@ -1358,8 +1358,8 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); if (mb->get_position().y > font->get_height(font_size)) { //clicked outside return; } @@ -1508,9 +1508,9 @@ String EditorInspector::get_selected_path() const { } void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped) { - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); - current_vbox->add_child(F->get().property_editor); + for (const EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { + EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->object = object; @@ -1524,19 +1524,19 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit ep->connect("resource_selected", callable_mp(this, &EditorInspector::_resource_selected), varray(), CONNECT_DEFERRED); ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED); - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = 0; } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List<EditorProperty *>(); @@ -1646,10 +1646,9 @@ void EditorInspector::update_tree() { item_path[""] = main_vbox; - Color sscolor = get_theme_color("prop_subsection", "Editor"); + Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_begin(object); _parse_added_editors(main_vbox, ped); } @@ -1720,8 +1719,8 @@ void EditorInspector::update_tree() { } s = s->get_base_script(); } - if (category->icon.is_null() && has_theme_icon(base_type, "EditorIcons")) { - category->icon = get_theme_icon(base_type, "EditorIcons"); + if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) { + category->icon = get_theme_icon(base_type, SNAME("EditorIcons")); } } if (category->icon.is_null()) { @@ -1746,8 +1745,7 @@ void EditorInspector::update_tree() { category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_category(object, p.name); _parse_added_editors(main_vbox, ped); } @@ -1948,36 +1946,35 @@ void EditorInspector::update_tree() { doc_hint = descr; } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors); List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector ped->added_editors.clear(); - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); + for (const EditorInspectorPlugin::AddedEditor &F : editors) { + EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); if (ep) { //set all this before the control gets the ENTER_TREE notification ep->object = object; - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = p.usage; //and set label? } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } else { - //use existin one + // Use the existing one. ep->set_label(name); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List<EditorProperty *>(); @@ -1995,7 +1992,7 @@ void EditorInspector::update_tree() { ep->set_deletable(deletable_properties); } - current_vbox->add_child(F->get().property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed)); @@ -2031,8 +2028,7 @@ void EditorInspector::update_tree() { } } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_end(); _parse_added_editors(main_vbox, ped); } @@ -2045,10 +2041,10 @@ void EditorInspector::update_property(const String &p_prop) { return; } - for (List<EditorProperty *>::Element *E = editor_property_map[p_prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } @@ -2157,24 +2153,24 @@ bool EditorInspector::is_using_folding() { } void EditorInspector::collapse_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { - E->get()->fold(); + for (EditorInspectorSection *E : sections) { + E->fold(); } for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - E->get()->collapse_all_folding(); + for (EditorProperty *E : F->get()) { + E->collapse_all_folding(); } } } void EditorInspector::expand_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { - E->get()->unfold(); + for (EditorInspectorSection *E : sections) { + E->unfold(); } for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - E->get()->expand_all_folding(); + for (EditorProperty *E : F->get()) { + E->expand_all_folding(); } } } @@ -2205,7 +2201,7 @@ void EditorInspector::_update_inspector_bg() { count_subinspectors = MIN(15, count_subinspectors); add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), "Editor")); } else { - add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } } void EditorInspector::set_sub_inspector(bool p_enable) { @@ -2239,9 +2235,9 @@ void EditorInspector::_edit_request_change(Object *p_object, const String &p_pro void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { if (autoclear && editor_property_map.has(p_name)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - if (E->get()->is_checkable()) { - E->get()->set_checked(true); + for (EditorProperty *E : editor_property_map[p_name]) { + if (E->is_checkable()) { + E->set_checked(true); } } } @@ -2261,7 +2257,7 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo _edit_request_change(object, p_name); emit_signal(_prop_edited, p_name); } else { - undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS); + undo_redo->create_action(vformat(TTR("Set %s"), p_name), UndoRedo::MERGE_ENDS); undo_redo->add_do_property(object, p_name, p_value); undo_redo->add_undo_property(object, p_name, object->get(p_name)); @@ -2308,8 +2304,8 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } if (editor_property_map.has(p_name)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - E->get()->update_reload_status(); + for (EditorProperty *E : editor_property_map[p_name]) { + E->update_reload_status(); } } } @@ -2328,7 +2324,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v } if (restart_request_props.has(p_path)) { - emit_signal("restart_requested"); + emit_signal(SNAME("restart_requested")); } } @@ -2350,7 +2346,7 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array for (int i = 0; i < p_paths.size(); i++) { _edit_set(p_paths[i], p_values[i], false, ""); if (restart_request_props.has(p_paths[i])) { - emit_signal("restart_requested"); + emit_signal(SNAME("restart_requested")); } } changing++; @@ -2363,16 +2359,15 @@ void EditorInspector::_property_keyed(const String &p_path, bool p_advance) { return; } - emit_signal("property_keyed", p_path, object->get(p_path), p_advance); //second param is deprecated + emit_signal(SNAME("property_keyed"), p_path, object->get(p_path), p_advance); //second param is deprecated } void EditorInspector::_property_deleted(const String &p_path) { - print_line("deleted pressed?"); if (!object) { return; } - emit_signal("property_deleted", p_path); //second param is deprecated + emit_signal(SNAME("property_deleted"), p_path); //second param is deprecated } void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance) { @@ -2380,7 +2375,7 @@ void EditorInspector::_property_keyed_with_value(const String &p_path, const Var return; } - emit_signal("property_keyed", p_path, p_value, p_advance); //second param is deprecated + emit_signal(SNAME("property_keyed"), p_path, p_value, p_advance); //second param is deprecated } void EditorInspector::_property_checked(const String &p_path, bool p_checked) { @@ -2396,10 +2391,10 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { Variant to_create; List<PropertyInfo> pinfo; object->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == p_path) { + for (const PropertyInfo &E : pinfo) { + if (E.name == p_path) { Callable::CallError ce; - Variant::construct(E->get().type, to_create, nullptr, 0, ce); + Variant::construct(E.type, to_create, nullptr, 0, ce); break; } } @@ -2407,15 +2402,15 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { } if (editor_property_map.has(p_path)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_path].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_path]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } } else { - emit_signal("property_toggled", p_path, p_checked); + emit_signal(SNAME("property_toggled"), p_path, p_checked); } } @@ -2427,22 +2422,22 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) if (F->key() == property_selected) { continue; } - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - if (E->get()->is_selected()) { - E->get()->deselect(); + for (EditorProperty *E : F->get()) { + if (E->is_selected()) { + E->deselect(); } } } - emit_signal("property_selected", p_path); + emit_signal(SNAME("property_selected"), p_path); } void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) { - emit_signal("object_id_selected", p_id); + emit_signal(SNAME("object_id_selected"), p_id); } void EditorInspector::_resource_selected(const String &p_path, RES p_resource) { - emit_signal("resource_selected", p_resource, p_path); + emit_signal(SNAME("resource_selected"), p_resource, p_path); } void EditorInspector::_node_removed(Node *p_node) { @@ -2479,18 +2474,18 @@ void EditorInspector::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { if (update_scroll_request >= 0) { - get_v_scrollbar()->call_deferred("set_value", update_scroll_request); + get_v_scrollbar()->call_deferred(SNAME("set_value"), update_scroll_request); update_scroll_request = -1; } if (refresh_countdown > 0) { refresh_countdown -= get_process_delta_time(); if (refresh_countdown <= 0) { for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - if (!E->get()->is_cache_valid()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : F->get()) { + if (!E->is_cache_valid()) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } } @@ -2509,10 +2504,10 @@ void EditorInspector::_notification(int p_what) { while (pending.size()) { StringName prop = pending.front()->get(); if (editor_property_map.has(prop)) { - for (List<EditorProperty *>::Element *E = editor_property_map[prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } pending.erase(pending.front()); @@ -2600,8 +2595,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li } Set<StringName> added; - for (List<Ref<Script>>::Element *E = classes.front(); E; E = E->next()) { - Ref<Script> s = E->get(); + for (const Ref<Script> &s : classes) { String path = s->get_path(); String name = EditorNode::get_editor_data().script_class_get_name(path); if (name.is_empty()) { |